Thursday, February 17, 2011

DAY 18

Today we clean up.

Thank you Professor Mason for your guidance and inspiration.

Furthermore, we would like to thank John Davis for all his help on our series of projects.

Cheers Everyone!!!

Wednesday, February 16, 2011

DAY 17

Check out our presentation!!!

We all had a terrific time!!!

...well we try posting it but not sure how to post a powerpoint presentation.

Tuesday, February 15, 2011

DAY 16

The days after the competition was a huge relief but at the same a huge revelation of sort.

Testing is never ending.

Reprogramming is never ending.

Tweaking is never ending.

Now we start work on our presentation for the project and tell our story and lessons learn.

Thursday, February 10, 2011

DAY 15

Programming we found is the most complex aspect of all our task.

Our mechanics and sensors can work 100%, but without competent programming codes; nothing works.

As I have mentioned before. The robot can seek out and find the can. What about the rest?

It turns out the rest is a lot more work than we have time for.

The scan for can finds the can but we still need an approach the can routine. The robot can't just rush to the can and hope to hold it in upright. The robot needs to cautiously creep up to the can so it maybe able to capture or contain it in the upright position for color reading.

Even if it was able to approach the can close enough for containment, the arm needs to capture or secure the can gently so it doesn't knock over. A lower the arm subroutine was needed to actuate a competent secure the can routine that will always capture the can upright and not knock it over. Once the color is read, the robot needs to make decision base on the result of the reading. If it is not the correct color of choice, the can needs to be rejected and kept out of the robot's way. The ferris wheel will flip the other way and knock the top of the can from behind and push it out and knocking it down at the same time. If it is the correct color of choice, the robot keeps the can and work the subroutine for placing the can in its proper color region. We have a subroutine that does a random 90 degree turns when it lines up with any black lines. When ever we hit the black line, we use the ground color scan routine to check for the correct color over the black line--our arm is made to do such scan at convenience. No matter what can or what can color spot, we will find the place the can.

We did not have the arena to test this until the competition. ( we hadn't tweek and finish this part of the program in class ) but here's what we got the day before the competition along with post dated competition video.

We must admit that though we have much help from our professor concerning programming, we still have lots of work to do.


#pragma config(Sensor, in1, LeftLineSensor, sensorLineFollower)
#pragma config(Sensor, in2, RightLineSensor, sensorLineFollower)
#pragma config(Sensor, in3, Range, sensorReflection)
#pragma config(Sensor, in4, Color, sensorReflection)
#pragma config(Sensor, in5, Switch, sensorTouch)
#pragma config(Sensor, in6, LeftWheel, sensorRotation)
#pragma config(Sensor, in7, RightWheel, sensorRotation)
#pragma config(Motor, port1, LeftMotor, tmotorNormal, openLoop)
#pragma config(Motor, port2, RightMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port3, Servo, tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

int can_color = 3; //1 = RED,2 = Green, 3 = Blue
int foundcolor = 0; //This is the color found by the color sensor

void goforward(int time)
{
motor[port2] = 50;
motor[port1] = 50;
wait1Msec(time);
}

void gobackward(int time)
{
motor[port2] = -50;
motor[port1] = -50;
wait1Msec(time);
}

void TurnLeft(int time)
{
motor[port2] = 55;
motor[port1] = -53;
wait10Msec(time);
}

void TurnRight(int time)
{
motor[port2] = -55;
motor[port1] = 55;
wait10Msec(time);
}

void StopBot(int time)
{
motor[port2] = 0;
motor[port1] = 0;
wait10Msec(time);
}

void SlowArmDown ()
{
motor[port3] = -60;
wait10Msec(50);
motor[port3] = -40;
wait10Msec(50);
motor[port3] = -30;
wait10Msec(50);
motor[port3] = -20;
wait10Msec(50);
motor[port3] = -10;
wait10Msec(50);
motor[port3] = -0;
wait10Msec(50);
motor[port3] = -10;
wait10Msec(50);
motor[port3] = -20;
wait10Msec(50);
motor[port3] = -30;
wait10Msec(50);
motor[port3] = -40;
wait10Msec(50);
motor[port3] = -50;
wait10Msec(50);
motor[port3] = -60;
wait10Msec(50);
motor[port3] = -70;
wait10Msec(50);
motor[port3] = -80;
wait10Msec(50);

}

void gotocolor(int destcolor) //1 is red, 2 is blue, 3 is green
{ //Go to a line
while ((SensorValue[RightLineSensor] <>
{
goforward(1);
}
//Now we are on a line
if (SensorValue[RightLineSensor]>800)
{
StopBot(100);
while(SensorValue[LeftLineSensor] <>
{

TurnLeft(1);
}
StopBot(1000);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);

//Now the other sensor is over the line so the cart is straight on the line
// Now turn 90 degrees
TurnLeft(150);
StopBot(100);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);
}
else if (SensorValue[LeftLineSensor]>800)
StopBot(100);

{ while(SensorValue[RightLineSensor] <>
{
TurnRight(1);
}
StopBot(100);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);
//Now the other sensor is over the line so the cart is straight on the line
// Now turn 90 degrees
TurnRight(150);
StopBot(100);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = 0;
wait10Msec(20);
}

}

//Check the color of the can. Right now there is just signalling IE pecking to indicate the color found
//for debugging purposes.
void colorscan()
{
foundcolor = SensorValue[Color];
if (foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
gotocolor(1);
}
if (foundcolor > 500 && foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(100);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(50);
gotocolor(2);
}

if (foundcolor <> 100) //Green Peck 1 times
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
gotocolor(3);
}
}




//Check the color of the GROUND. Right now there is just signalling IE pecking to indicate the color found
//for debugging purposes.
void Groundcolorscan()
{
foundcolor = SensorValue[Color];
if (foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);

}
if (foundcolor > 500 && foundcolor <>
{
StopBot(10);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(100);
motor[port3] = -60;
wait10Msec(100);
motor[port3] = -50;
wait10Msec(50);

}

if (foundcolor <> 100) //Green Peck 1 times
{
StopBot(10);
motor[port3] = -60;
wait10Msec(20);
motor[port3] = -50;
wait10Msec(20);

}
}


void approachCan()
{
while (SensorValue[Range]>50 && SensorValue[Range]<200)
{
//CheckLine();
goforward(10);
StopBot(1);
//colorscan();
}
while (SensorValue[Range]>200 && SensorValue[Range]<400)
{
//CheckLine();
goforward(10);
StopBot(1);
//colorscan();

}
if (SensorValue[Range]>400) //If the can is close bring it all the way in.
{ //Bring the can all the way in

SlowArmDown ();
}
//colorscan();
gotocolor(1);

}


// First stop the robot, then move the sensor arm up and down to indicate that a can is found.
//Next call approach can to move toward the can
void grabcan()
{
StopBot(100);
motor[port3] = -50;
wait10Msec(100);
motor[port3] = -60;
wait10Msec(100);
approachCan();
}




//Approach the can until it is close, continually checking the color of the can.
//Once the can is close, move the sensor arm to bring the can into the robot.
void ScanforCanDelay(int times)
{
for (int i=0;i <>
{
wait10Msec(1);
if (SensorValue(Range) > 100)
{
grabcan();
}
}
}


void ScanforCan()
{
if (SensorValue(Range) > 100)
{
grabcan();
}
}



void CheckLine()
{
if (SensorValue[RightLineSensor] > 800) //If we see the line on the right then go back turn and scan
{
gobackward(1000);
TurnLeft(1);
ScanforCanDelay(150);

}

else if (SensorValue[LeftLineSensor] > 800) //If we see the line on the left then go back turn and scan
{
gobackward(1000);
TurnRight(1);
ScanforCanDelay(150);
}
}







/*
void candetection //
{
motor[port3] = 50;
if ((abs((sensorvalue(ColorSensor)-FloorColor))) > 100)
{
do
{
motor[port2] = 30;
motor[port1] = 30;
while (sensorvalue(Switch)=0)
stopbot(100);
motor[port2] = 50;
motor[port1] = 50;

if (SensorValue(Rightv
do
{
motor[port1] = 40;
motor[port2] = 0;
while (SensorValue(LefttLineSensor) <>
motor(port3) = 50
motor[port1] = -40;
motor[port2] = -40;
wait10Msec(150)
goto maingoal;
}

else if (SensorValue(LefttLineSensor) > 800)
{
stopbot(100);
do
{
motor[port1] = 0;
motor[port2] = 40;
while (SensorValue(RighttLineSensor) <>
motor(port3) = 50
motor[port1] = -40;
motor[port2] = -40;
wait10Msec(150)
goto maingoal;
}
else if ((abs((sensorvalue(ColorSensor)-FloorColor))) <>
}

}

void CanMission
{
motor[port3] = 30; //Close the arm
do
{
goforward(10);
while ((sensorvalue(LeftLineSensor) <>
}
if (sensorvalue(LeftLineSensor) > 800)
{
do
{motor[port2] = 30;
motor[port1] = 00;
while (sensorvalue(RightLineSensor) <>
}
stopbot(100);
goforward(50);
if sensorvalue
if
}
}

*/

task main()
{
motor[port3] = 10;

int FloorColor = SensorValue(Color); //First find the color of the floor
wait1Msec(3000);
Groundcolorscan();

// TurnRight(1000);
// StopBot(100);;

goforward(800); //ON startup move forward to get out of gate

//In the main loop, the robot moves forward 1 cm, checks to see if it hit the black line.(CheckLine)
//If it hit the line, it moves backward and turns.
//The the robot scans for the can. If it finds the can, it runs grab can
//If it doesn't find the can it repeats this process of moving forward, checking for the line and scanning for the can.


while (true)
{
//Maneuver Code
goforward(1);
CheckLine(); //If the the bot does not hit a black line
ScanforCan(); //This scans for the can one time
}

Wednesday, February 9, 2011

DAY 14

Today is furthering what we need to do to make the robot competition ready.

Here are the list of accomplishments:

Sensor Integrations:

2 IRs at front edge of robot
long range sensors
switch sensors
optical encoders
ground sensor readings

Mechanicals:

drive train change to rear wheel drive only
strengthen U-channel docking port with H-bridge and side bracing.
change rear wheel to larger wheel for tilt effect, allowing the sensor arm to dip closer to ground.
add rubber bands to secure wirings
add zip-tie whiskers to fan out and cover sensor blind spots

Programming:

modularize and tested the following:

forward
reverse
stop
left turn 90 degrees
right turn 90 degrees
line detection
scan for can


Needs further work:

RGB can color sensor readings: too erratic for blue and green, often reading are 330 and above.
Needed to work on angles and placements.

All mechanicals functionings--no further tweaking required

More in depth programming:
once can is found, what do you do?




Tuesday, February 8, 2011

DAY 13

As we work on modularizing our algorithm, we worked on modularizing our testing.


Here we worked on subroutine on can capture and secure containment


Here are side views of the robot chassis--battery, cables, and microcontroller unit are place specifically to accomodate the U-channel can containment. The gears has been reduced to a rear wheel drive simplicity of straight drive control.




Here's the frontal and perspective view of the robot:


Now, we have a up close of view of all the senor integerations:




From left to right: arm down to scan for can color, a close look of the long range sensor, and then the switch.



Top view of the robot and it's ground color scan module--set at motor servo value of 10.



Further testing of ground color scan and can color scan--servo module value of 90.


Finally, we solve the troublesome problem of the sensor and servo connections by hot gluing the pin units temporarily. It worked great!!!



Thursday, February 3, 2011

DAY 12

I neglected to mention but we started work on our GANNT Chart and PERT chart. Previously, we completed our RGB LED/sensor and our 2 IR sensors. Now we begin our work of design and planning on the works of our competition robot. The name of the game is color can grabber competition. The robot will autonomously, using sensors, locate the correct color can and place it in its corresponding color area.

We know of 2 possible design-grab a can or contain a can. Majority of the design uses a arm to grab the can. We decided that containment is th best. Less moving parts and that leaves us more motors to play with. The can is light so grabbing it increase the potential of knocking it over, i.e. in order to grab the can, the robot would have to be well align with the can for grabbing, if off by any degrees, the potentialities of knocking or rolling the cans over would increase as well.

Our design is based on the docking port or rather a moving docking port. We figure that if the robot can dock and secure the can, then reading the color would be considerably easier. The U shape docking came to mind. Just driving the robot up slowly to it would cause the can to place near point of reading. We added the ferris wheel arm to securely contain the can or reject the can if the sensor finds it to be the incorrect color. An added feature of the ferris wheel is the RGB col0r sensor. We had the intention of securing it near the docking point, near the base of our long range sensor, that tracks or detects the direction and distance of the cans. Since we discover that the RGB combo ferris wheel can detect cans at a arms distance, we thought that might be a fine pre-scan options for the robot. The IR sensors are place at the Left and Right leading edge of the front wheels. This will better the robot detection of initial left and right lines and help the robot line itself up for 90 degrees left or right turns. We had decided to remove the front gearing for the front wheels to add structural improvements as well as redesigning our manueverability. We also added a switch near the docking area as a checker for color scan.

We found that the GANNT chart helped us organize or manage what we do as a team timeline wise. I was initially in charge of mechanics and building of the robot and Bardia was focus on working out the programming algorithms. The IR, infrared subroutines, long range sensors, and the switch work well. Each functional subroutines from movements to sensors was rechecked and recalibrated for can seeking. Getting the robot to the can has been fairly successful, no matter what, the robot eventually finds the can. Reading the correct can color and securing the can needed more work.

The PERT chart helped us see the flow of our task. We were able to hit each point of our task.

Now it's up to figuring out how consistently work the RGB sensors to read the can color and the ground color accurately.



Wednesday, February 2, 2011

DAY 11

Ah the day of Senorship!!! Spend pretty much the whole time integrating the sensors--RGB LED and LDR onto the proto-board. Without the proper value for the LED-RGB at 220 ohms and the LDR at 10K ohm, the RGB sensor unit wouldn't work properly, especially the blue and green reflections. Thus tweaking those 2 resistor units was of utmost importance. It took over a day to finish this proto-boarding. Red wire is power; Black is ground. Orange(for red), Blue, and Green wires are for the color leads, respectively.



Input pin 0 for LDR sensor, ie readadc or read the value from the LDR into the Pic14M. Input 1,2,3 are the Red, Green, and Blue. b0, b1, and b2 respectively, are the possible stored read-value from the LDR. w3 is the combined value of b0, b1, and b2. Color determinations are done comparetively, i.e. if b0>b1 and b0>b2 then red--this means the largest reflective color is red; thought green or blue reflection may store some values, but red would be the predominant color reflected into the LDR sensor as compare with the blue and green colors, which may still exist but comparatively is not the dominant valued color. To account for range of colors beyond red, blue, and green, w3 is created to deal with color values beyond the RGBs, i.e. any color value intensity lower than 250 or greater than 510. Please see below for the actual program for reference.




'Color Sensor LEDs RGB on outputs 1,2,3 USING PWM
'Read the CDs cell on ADC 4

Low 0,1,2,3,4,5 'Set all outputs to low to turn off RGB
pause 1000

main:

w3 = 0 'This is the sum of all channels
high 1 'Set the RED channel high turns it on
low 2,3
pause 50 'Give time for the LED to turn on
readadc 0,b0 'Read the value from the LDR
high 3 'Set the BLUE Channel ON
low 1,2
pause 50
readadc 0,b2 'Read the value from the LDR into a different variable
'Apply any necessary offset for the sensitivity of the LDR
high 2 'Repeat for the GREEN Channel
low 1,3
pause 50
readadc 0,b1
b1 = b1 - 30
debug
w3 = b0 + b1 + b2 'Find the sum of the 3 color channels
'sertxd ("w3 reading ",#w3,13,10)
if w3 > 510 then nocolor 'Cut on total intensity
if w3 < class="Apple-tab-span" style="white-space: pre;"> 'Cut on total intensity
if b0>b1 and b0>b2 then red
if b1>b0 and b1>b2 then green
if b2>b0 and b2>b1 then blue

goto main

nocolor:
sertxd ("nocolor",13,10)
pwmout 2,99,400 ;SET THE OUTPUT TO 5V
low 4,5
goto main

red:
sertxd ("red",13,10)
pwmout 2,99,0 ;SET THE OUTPUT TO 0V
high 4
low 5
goto main

green:
sertxd ("green",13,10)
pwmout 2,99,125 ;SET THE OUTPUT TO 1.5V
low 4
high 5
goto main

blue:
sertxd ("blue",13,10)
pwmout 2,99,250 ;SET THE OUTPUT TO 3V
high 4,5
goto main



Tuesday, February 1, 2011

DAY 10

This was a tough assignment creating the color sensor code and the color sensor circuit. Bardia had the pleasure of working on the infrared sensors ( it was really awesome that he made 2 IR sensors; that was very helpful for the competition). With the right resistors, around 10K on the LDR and 220 or the RGB LEDs, the circuit board flashes accordingly with different colored cards.


Making the board was another tough solderinng job.

Here the RGB sensor is processed by a Pic-14M. I will describe the programming in details once the proto-board soldering is done. Here's how the initial testing works. If the color sensor detect a large red reflection of the red card, then the indicator red LED flashes. When sensor picks up large green reflected surface, like th green card below, the green indicator LED flashes. Lastly, a blue reflecting surface will reflect a largely blue wavelength, that in turn will turn on both red and green indicator LEDs.









Thursday, January 27, 2011

DAY 9

Today I started the VEX programming. In a very short time, I was able do simple robotics manuever code. Most importantly, I got to do functions. I was able to measure and modularize my algorithm and program the bot to manuever through the maze, roughly without the encoder. Then using the encoder, the robot move more accurately and got into the box, the very first time!!! But no one was around to see it. Then everyone shows up to see it the second time but the battery was low so it didn't perform as well. I believe Shawn or Brian has the video.













'Color Sensor LeDs RGB on outputs 1,2,3 USING PWM
'Read the CDs cell on ADC 4
Low 0,1,2,3,4,5 'Set all outputs to low to turn off RGB
pause 1000

main:

w3 = 0 'This is the sum of all channels
high 1 'Set the RED channel high turns it on
low 2,3
pause 50 'Give time for the LED to turn on
readadc 0,b0 'Read the value from the LDR
high 3 'Set the BLUE Channel ON
low 1,2
pause 50
readadc 0,b2 'Read the value from the LDR into a different variable
'Apply any necessary offset for the sensitivity of the LDR
high 2 'Repeat for the GREEN Channel
low 1,3
pause 50
readadc 0,b1
b1 = b1 - 30
debug
w3 = b0 + b1 + b2 'Find the sum of the 3 color channels
'sertxd ("w3 reading ",#w3,13,10)
if w3 > 510 then nocolor 'Cut on total intensity
if w3 < class="Apple-tab-span" style="white-space:pre"> 'Cut on total intensity
if b0>b1 and b0>b2 then red
if b1>b0 and b1>b2 then green
if b2>b0 and b2>b1 then blue

goto main

nocolor:
sertxd ("nocolor",13,10)
pwmout 2,99,400 ;SET THE OUTPUT TO 5V
low 4,5
goto main

red:
sertxd ("red",13,10)
pwmout 2,99,0 ;SET THE OUTPUT TO 0V
high 4
low 5
goto main

green:
sertxd ("green",13,10)
pwmout 2,99,125 ;SET THE OUTPUT TO 1.5V
low 4
high 5
goto main

blue:
sertxd ("blue",13,10)
pwmout 2,99,250 ;SET THE OUTPUT TO 3V
high 4,5
goto main



Wednesday, January 26, 2011

DAY 8


Today I meet the "most successful chip ever". The 555 timer. The circuit took awhile to set up due to lack of parts. Finding that darn capacitor was difficult. Mainly, the I used the logic probe to check if all the connections flashed accordingly. This is was a side exercise to get us ready for the servos and signal conditioning. I had a little time to work on the oscilloscope project but the servos worked fine.




In additions, there were the motors and relay switches push button switch that needed to be look over.





Tuesday, January 25, 2011

DAY 7

Finalize Toy Hack:


Franken Chicken LIVES!!!!

Here's my initial program attempt:

main:

serout 0, N2400, (10,13)
serout 0,N2400, ("Press a key...")
serin 4,N2400,b1
serout 0,N2400,(b1)
if b1="a" then hot

goto main
hot:
serout 0, N2400, (10,13,"A is the Hot Key!")

high 1
pause 2000
low 1
pause 500
play 0,0
sound 2,(50,100)
sound 2,(100,100)
sound 2,(120,100)
pause 1000
goto main

Thursday, January 20, 2011

DAY 6

Interfacing Micro to Transistors:

Having already programmed the picaxe-08m using LEDs, switches, and LDR, it's not all that much different to programmed the toy-hacked. It turns out the Frank Chicken has only one large motor that controls all aspect of its geared movements of the beak and wings and legs. I was able to located the motor positive and negative connection and cut and re-solder a much longer wire set that runs up and to the back and down. I burned a side-hole so the wires can easily slip between the casing and I glue the wire down using hot glue.


Though it seems as simple as plugging those motor wires into the picaxe output pins. There is one more criteria for this to work. The pic only put out about few mA, not enough to run the motor. We can use a relay switch but that would be a over-kill. Relay switch is a robust circuitry for 2Amps and above. For my motor, I just need to increase my gain, so here the fabulous TIP102, darlington transistor works wonders. With this configuration I could achieve gains of 750 to a 1000, depending on the resistors. Now, I may begin programming the Franken Chicken.

......GRRRRRRRR

Music/Advance Motor Control:

I've also started playing with music and more advance motor controls. Instead of using switches or LDR as input to turn on the Franken Chicken, I use the serout Pic command that will command me to push a keyboard button and start up Franken Chicken. I simply added input, output devices to the darlington configuration.


Wednesday, January 19, 2011

DAY 5

Serial Bus:

Ah, at last, we make serial bus connectors for programming, a rare find these days because everything is going USB? A serial connection will give you a serial signal connection TX or RX versus parallel connection which will have far more communication pins used. To build this crucial programming device, we used 3 color wires solder the point of female 5, 3,2 sockets, i.e., ground, TX, and RX, respectively. This can be confusing especially if you are seeing either from the front side or the back side, do specify. So our serial connector is a RS-232 standard, i.e., logic 0 = 2.5-15V and logic 1 = -2.5 to -15V. This suggest that RS-232 voltages are inverted with respect to logic, so here logic 1 is low and logic 0 is high. Furthermore, the RS-232 bit rate is 9600.


Micro-Controller:

Now the fun begins! I was given a microcontroller PiC 12F683 or PicAxe 08m. It's got 4in, 4outs, 3ADC, and one infrared pin connections. Using breadboard and a couple of LEDs, I started making circuits for Picaxe programming. I programmed a series of LED flashes on and off at 1 second intervals.


I also implemented a switch to control the flashes. Lastly, I installed a LDR, analogue, sensor and control the LED flashes by covering/uncovering the LDR--it acts like a light switch of sort.I also implemented a switch to control the flashes. Lastly, I installed a LDR, analogue, sensor and control the LED flashes by covering/uncovering the LDR--it acts like a light switch of sort.



Dissect Toy:

Ah the real fun begins. I commence the dissection of the "Franken Chicken" The "violation" of the toy went smoothly. Removing the fur is perhaps the toughest part. Opening up the plastic casing for circuitry was a matter of 5 screws.