Wednesday, February 16, 2011

Day 19: The End?

Today was our last day of class.. a sad day for all of us who really enjoyed this class. I personally would like to thank professor mason for taking part in this class and teaching it for the first time! I especially appreciate all the things he did for us that were actually not part of the class (directly), but instead was just him going out of his way being the great professor he is~ Thanks mason!

Anyways, TC and I presented today and we received a B grade on our presentation due to lacking enough detail on conclusion and lack of sufficient testing on our robot.


Also, while the other groups were presenting everyone packed up their stuff and got their toolboxes sorted. We all packed everything up nicely how we received it and waited for mason to come around and check off our stuff.



It was kind of sad putting everything away, knowing that we weren't going to be using it anymore, but we (or at least I ) were (was) glad that we (I) took this class because it taught us so much and really was fun. Even though it was a hectic schedule which i do not recommend and there was a lot of rushing on several days, it was a good experience and I am glad i had the opportunity to take this class.

Day 18: (Tuesday of the last week of class)

We were given a presentation on giving presentations & asked to start planning our presentations for presenting wednesday.

We split our PowerPoint slides between each other & got 2 work!



Tuesday, February 15, 2011

Day 16 & 17: COMPETITION

Friday we had extra time to work on some things. We spent most of the time programming again and spent a little bit of the time working on our final build.

Saturday was the competition and TC and I were worried because our design had been working about 80% as much as we wanted it to and saturday morning it was about 70%.
We decided to go to the competition earlier-arriving at 11am.
We started working on it as soon as we got to Cal State Fullerton. We eventually decided to go with the less complex code from the day before because all of the new changes that came into our build only slowed us down and reduced the robot's total performance.
We decided to go with a name chosen by one of our classmates with respect to the robot's appearance.
Name: BABY SCORPION.

SUCCESS (LOL by luck!)
We placed 2nd in the championship being 1 of the 2 only robots to succesfully get a can to the end. Our robot was, at this point, working to 85% efficiency, but it still had some grave bugs to be worked out.


here is the video:



This is the latest code I have.. which is 95% similar to the code we used on the day of the competition... Minor changes were made by my partner TC and I did not get a chance to get that from him.


#pragma config(Sensor, in1, linesensor, sensorLineFollower)
#pragma config(Sensor, in2, colorsensor, sensorReflection)
#pragma config(Sensor, in3, encoder, sensorRotation)
#pragma config(Sensor, in4, sonar, sensorSONAR, int1)
#pragma config(Motor, port2, leftmotor, tmotorNormal, openLoop)
#pragma config(Motor, port3, rightmotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port4, rightarm, tmotorServoStandard, openLoop)
#pragma config(Motor, port5, leftarm, tmotorServoStandard, openLoop)
#pragma config(Motor, port8, platform, tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

void checkline()
{
if (SensorValue[linesensor] > 450)
{
motor[leftmotor]=-40;
motor[rightmotor]=-40;
wait1Msec(1000);
motor[leftmotor]=40;
motor[rightmotor]=-40;
wait1Msec(1000);
motor[leftmotor]=0;
motor[rightmotor]=0;
wait1Msec(50);
}
}
void goforward(int gotime) //go forward function
{
motor[rightmotor]=45;
motor[leftmotor]=45;
checkline();
wait1Msec(gotime);
checkline();
motor[rightmotor]=0;
motor[leftmotor]=0;
checkline();
}
void pause(int gotime) //pause function
{
motor[rightmotor]=0;
motor[leftmotor]=0;
checkline();
wait1Msec(gotime);
}
void goback(int gotime)
{
motor[rightmotor]=-40;
motor[leftmotor]=-40;
checkline();
wait10Msec(gotime);
pause(100);
}
void turn(int gotime) //turn function
{
motor[rightmotor]=35;
motor[leftmotor]=-35;
checkline();
wait1Msec(gotime);
checkline();
motor[leftmotor]=0;
motor[rightmotor]=0;
}
void tilt(int gotime) //tilt color sensor function
{
motor[platform]=35;
wait10Msec(gotime);
motor[platform]=0;
wait10Msec(20);
motor[platform]=-25;
wait10Msec(gotime);
motor[platform]=0;
}

short given1=0; //variable for first given color
short given2=0; //variable for second given color
short mission=0; //variable for defining what mission robot is on
int count=0; //counter for loop assigning colors to givens
short carry=0;
bool go;
bool finish;


void closeclaw()
{
motor[leftarm]=10;
motor[rightarm]=10;
wait10Msec(200);
}

void openclaw()
{
motor[leftarm]=160;
motor[rightarm]=160;
wait10Msec(20);
}

void check(int gotime1,int gotime2,int gotime3)
{
pause(gotime1);
tilt(gotime2);//tilt color sensor
pause(gotime3);
count ++;
}

void rightcolor()
{
//Move to color zone that matches color of can
finish=true;
carry=1;
}

void wrongcolor()
{
//Get rid of can
openclaw();
goback(200);
turn(100);
finish=false;
}

void checkcolor()
{
closeclaw();
wait10Msec(200);
int color1 = SensorValue[colorsensor];
if (color1 <> 18) //Is it red
{
if (given1==8) //red is the target color?
{
rightcolor();
}
else
{
wrongcolor();
}

}//check to see if color is green
if (color1 <> 328) //Is it green and is green the target color?
{
if (given1==6) //green is the target color?
{
rightcolor();
}
else
{
wrongcolor();
}

}//check to see if color is blue
if (color1 <> 628) //Is it blue and the target color is blue?
{
if (given1==7) //blue is the target color?
{
rightcolor();
}
else
{
wrongcolor();
}
}
if (color1 > 1000) //Not one of the above Maybe we should sense again
{
openclaw();
}
}

void search()
{
while(go==true)//search for can
{
openclaw();
if (SensorValue[sonar] <=-1 || SensorValue[sonar] >=20)
{
goforward(200);
pause(50);
checkline();
goforward(100);
pause(50);
checkline();
turn(100);
checkline();
pause(150);
}
if (SensorValue[sonar]>=3 && SensorValue[sonar]<20)>
{
goforward(150);
pause(50);
}
if (SensorValue[sonar] <3>=1) //if something is in close range
{
goforward(40);
pause(100);
go=false;
checkcolor();//closeclaw();

}
}
}

void end()
{
pause(200000);
}

void searchfloor()
{
if (SensorValue[colorsensor] >1000)
{
pause(1000);
goforward(20);
checkline();
pause(150);
int color2=SensorValue[colorsensor];
if (color2 <> 18) //Is it red
{
if (given1==8) //red is the target color?
{
openclaw();
end();
}
else
{
goforward(50);
}

}//check to see if color is green
if (color2 <> 328) //Is it green and is green the target color?
{
if (given1==6) //green is the target color?
{
openclaw();
end();
}
else
{
goforward(50);
}

}//check to see if color is blue
if (color2 <> 628) //Is it blue and the target color is blue?
{
if (given1==7) //blue is the target color?
{
openclaw();
end();
}
else
{
goforward(50);
}
}
pause(250);
}
}

void goforever()
{
while(true)
{
checkline();
motor[rightmotor]=40;
motor[leftmotor]=40;
wait1Msec(50);
checkline();
searchfloor();
}
}

task main()
{
bMotorReflected[leftarm]=1;
while(true)
{
if (carry==0)
{
openclaw();
}

do
{ //look forward for first color given1
//check to see if color is red
if (SensorValue[colorsensor] <> 18)
{
if (given1==0) //if given1 has not been set, set to red
{
given1=8;//red
check(500,30,750); //pause,tilt,pause,count++
}
else //else set given2 to red
{
given2=8;//red
check(500,0,0); //pause,no tilt, no 2nd pause, count++
}

}//check to see if color is green
if (SensorValue[colorsensor] <> 328)
{
if (given1==0) //if given1 has not been set, set to green
{
given1=6;//green
check(500,30,750); //pause,tilt,pause,count++
}
else //else set given2 to green
{
given2=6;
check(500,0,0);
}
}//check to see if color is blue
if (SensorValue[colorsensor] <> 628)
{
if (given1==0) //if given1 has not been set, set to blue
{
given1=7;//blue
check(500,30,750);
}
else //else set given2 to blue
{
given2=7;//blue
check(500,0,0);
}
}//end color sense
} while(count<=2);

pause(100);
motor[leftmotor]=40;
motor[rightmotor]=40;
wait10Msec(50);
pause(20);

if(count>=2 && count <=4)
{
go=true; //allow for next loop
count++;
}

search(); //search for can

if (finish==true)
{
motor[platform]=30;
wait10Msec(25);
motor[platform]=0;
wait10Msec(10);
pause(100);
goforever();
checkline();
}
if (finish==false)
{
search();
}
}
}

Friday, February 11, 2011

Day 15: Final Day before Competition

We got all of our building done and most of our testing done as well as a lot of the programming. We spent all day fine tuning our code and making sure we weren't leaving anything out. We kept having problems with running something infinitely and not running at all, but we got mostly everything sorted out. We did not completely finish, but we have something going on and that's what counts!

This is our robot being programmed:


Thursday, February 10, 2011

Day 14: Problems, Bugs, and Fixes

We finally got some work done. We successfully tested all of our sensors and got started on the final programming tasks and refining some code. Then, it all fell apart... the color sensor was not reading the right color thinking everything was green. Then, the light sensor completely failed on us, it was not working at all except for whenever it wanted to. Eventually we got some better code written and we jiggled the light sensor in the right way ( i guess) because it started to work.

We finally started testing on the arena and ran 1/5 successfully.

This is our robot during testing:

Wednesday, February 9, 2011

Day 13: Applying Ideas & Installing Sensors

We began implementing TC's idea of a claw and while he was installing it and modifying it, I was designing the platform for the color sensor & installing it on the robot.

This is what we started with:






We decided to use an encoder to more efficiently maneuver the Color sensor. And we had to do some modifications to the location of the sonar to make room for other parts.

These are the results of the claw modifications & the color sensor installation:

Monday, February 7, 2011

Day 12: Planning and Brainstorming

Since we were no longer going to receive a packet with instructions to follow per daily basis, we now have just one thing to do: work on our robots for the competition.

I am still having problems with my color sensor, but i decided that it would have to wait for further testing dates as my teammate and I have planned for later this week.

So far we modified the vehicle and started working on a manipulator.

My color sensor looks a lot better than before, but it still needs some work.

This is my color sensor's current state:
This coming week we have to start building the manipulator and testing it, which, thanks to saturday, we are already ahead on.

Thursday, February 3, 2011

Day 11: Finishing Up Sensors

I finally got my color sensor working but I had a lot of problems putting it together.
I first finished it early, but I realized I did not put in some extension cables and my sensor would have been very inefficient.

This is what I had:



When I finally fixed this problem, I noticed that the socket I soldered onto my board had 8 pins while my micro controller chip had only 7. I had to re solder some of my connections again.
After that, I had to solder a capacitor onto my board ( this was not part of the original diagram ) and then finally, I soldered the wires onto the board.
Finally I finished the color sensor, though, I feel I am very behind.

This is my soldering work:

Tuesday, February 1, 2011

Day 10: Light and Color Sensors

Today we worked on our sensors that we will use for our robots. Since we are now in teams and we have to build 2 sensors, each person built one.
My partner TC got the easier one, the light sensor, which sends out an infrared beam and then reads the amount of light that was reflected by the surface.
I got the color sensor, which has a lot of bugs and even with debugging and using the oscilloscope, I had a hard time finishing it. I will have to finish it another time because i did not get the chance to finish. I did not feel bad though, because not everyone who had the color sensor even got down to soldering.

This is what i have so far:
When this sensor is done, it will have the ability to detect the difference between green, red, and blue light. This will be helpful in our robotics challenge as it seems we are to have our robots distinguish colors and collect the right colored can while in autonomous mode.

Day 9: Programming, Timing & Sensors

On this day we spent all of our time working on our robots. We had 2 competitions to perform; they were the same - both were to travel through a black tape labyrinth. The hard part of this was that we could not control the robot, instead, it had to be autonomous: by itself.

The first time we had to do it using just timing; figuring out how many tiles the robot moved with a given amount of power for a given amount of time. Also, we had to figure out how to run the motors to find a proper way of turning the robot. We programmed the labyrinth dimensions into the robot based on our measurements. It was tough to be able to predict the friction, battery drainage, and other mechanical discrepancies in the robot.
Then we were placed in teams of 2 for the next part & the rest of the class.
Next, we had to do it with sensors. The sensor we used was similar to a tachometer & it helped a lot! My robot did a whole lot better. This shows the efficiency and importance of sensors, even something as simple as a tachometer, in an autonomous to robot program.


This is my robot:

Wednesday, January 26, 2011

Day 8: 555 chip, Oscilloscopes and Potentiometers

Today we worked with the infamous 555 chip and used it to light an LED. The 555 pulses power through the circuit and the LED flashes on and off.
After that I connected it to a potentiometer and the frequency of the flashing either sped up until it seemed to be on 100% of the time or it slowed down until it was 0.
Then I worked on a packet on Oscilloscopes. These things show how pulses of electricity are transfered between the different parts of a circuit. I got it working off of the potentiometer which increased or decreased the frequency by increasing and decreasing the resistance of the circuit.This is my final set up for that packet which includes using the oscilloscope tool called a BNC plug.

Project # 1: Toy Hacking

PROJECT 1
For our first project the objective was to learn various electronics skills and apply them all together in a final test of our skills.
First, I had to find a toy and take it apart to find the motor wires- this would allow us to connect our own wires and pull them out of the toy to be able to control it from our microcontroller.
This is my Toy:
Second, I soldered our wires onto the toy and put the toy back together.
Next, after having worked on several handouts that instructed me on microcontroller, transistor, capacitor and motor control, I set up a circuit on my breadboard that would allow me to fulfill the requirements for the project.
My motors ran forward and backwards, and the board I had originally built for this case would not work because the power would only run one way. Professor mason told me about a thing called an H-bridge, which was pretty much a bunch of transistors and diodes used to be able to allow current to flow forward or backwards into the motor, which in turn allowed my claw to move forwards and backwards from the same connections.

Unfortunately, this would have take a long time to complete and luckily, Mason gave me a Motor Driver Chip, which was exactly the same thing but in a smaller package.
This is my board:
Finally, i had to program my toy to be able to work with input from a sensor, in this case an LDR (Light Dependent Resistor). I programmed my toy to run the motor forwards when the input value from light was above 120 and to go backwards when the input was less than 70. This way, there was a gap in the middle and i could just leave it off if i let only the right amount of light to get in.
This is my toy working under microcontroller command:
Here is a working video of my final project:

Day 7: Catch up

Today I spent all of my time working on the last packet that had to do with communicating between microcontroller and PC and finishing my first project. I finally got my toy claw to work off of my programming and got all the things on the rubric finished and ready to turn in.

Thursday, January 20, 2011

Day 6: Microcontrollers and Darlingtons

Today i caught up on dismantling my toy. I unscrewed the top and bottom and figure out that the wires from the motor run from the control unit on the bottom to the claw motors on the top.
After this I went into a packet titled 'Interfacing a Microcontroller,' which pretty much shows us how to mess with transistors including: TIP41, and TIP102 and of course our 2N-3904 transistor from before. One of the activities had us wiring up and programming a christmas light to flash every 1 second. Here is mine:
We also learned about darlingtons, which is the name for the configuration in which two transistors are connected in such a way that they multiply the total gain. This in actuality means that for the same little 5v supply we can create much higher currents.
We then switched to a stronger transistor, but there was no more TIP102's left. =(
Fortunately, Mason had a TIP120 for me, which is better! (According to Mason).
In the end i was able to use my previous breadboard configuration and connect it to the motor on my toy. My picture does not show it all, but the claw was moving up and down depending which way i wired the motor onto the breadboard.
This is my toy:
However, I could not get the claw to move up AND down by itself or with the programming. Mason told me i would have to build an H-bridge or buy another part that does it on its own, both of these use the same idea behind the darlington to amplify power output.

Day 5: Serial Connectors and Microcontrollers

On day 5 we finished up soldering our DB9 connector for use in our next project.
We were introduced to micro controllers and the many possibilities that they bring us. One of the activities on this packet was to get our LED to light up several times using the microcontroller and then shut off after a certain number of blinks:
We also had to program our board to be able to use sensors that would allow or restrict the flow of power from one LED to another, depending on the amount of light it received.

Next we started reading on hacking toys and figuring out how we were going to handle this.

Tuesday, January 18, 2011

Day 4: Transistors and the Logic Probe

Today in class i finished up what i hadn't from my robot.
After a few parts from the professor and some time and elbow grease, i finally got it running.
This is the finished product:




After that i got to familiarize myself with transistors and the many things they can do. They are similar to relays, but a lot more versatile. This activity had me connecting it to an LED and having two exposed wires. When i touched my fingers (from the same hand) to these wires the LED turned on because my fingers were used as a filler between the connections.
After that was done, i got to work on another of our tools that, according to professor mason, we will be using a lot throughout the class. This was our Logic Probe, which worked similarly to our multimeter, but was a faster way of getting the job done in some cases. This activity had us putting together almost everything we had learned so far to build a simple piece of genius.
This was my finished project.
I did not get around to soldering the last piece for today, but I heard it only took a couple of minutes so hopefully i could have it done tomorrow early.

Thursday, January 13, 2011

Day 3: Switches, Relays, and Robots

After finishing my inventory sheet from yesterday, which was missing too many pieces to count...
I started with todays tasks.
We learned about switches and how they allow or deny the flow of current.
I connected 2 switches to an LED and some power, then i flipped one switch and then the other and each time the light turn on or off; this showed they were connected together and they interrupted the flow of power between the power supply and the LED.
We also learned about relays and their ability to switch power output to one LED or the other.
Once we got the LEDs lighting up back and forth and we got the "miniature noisemaker" integrated,
we moved on the the next part.
We started on our robots!
Since a lot of parts were missing from my toolbox, i did not get to finish everything and I had a hard time putting things together.
Eventually time ran out as it always does and i did not get to finish my robot, but i did get the main parts built.

Wednesday, January 12, 2011

Day 2: Multimeters, Breadboards and Resistors

Today we learned about voltage, current and resistance.
We learned how to use a multimeter and how to properly verify the capacity of resistors through the use of resistor color codes.
We then learned how to properly power an LED and together with our new found knowledge of resistors, we put all these components together on a breadboard.
We learned how to use breadboards and how they are important to the everyday geek- i mean electrician/electronics person.
Breadboards.
No, they are not edible... they are plastic boards with many holes for plugging in electrical components.
We put together a resistor, an LED, and the power supply on the breadboard and tried to get the brightest we could get our LEDs without burning them out.
In the end we were supposed to fill out an inventory sheet on our vex robotics parts for our robot that will be built soon, but I did not have enough time to finish all the way there.
This is my finished breadboard system with a proper capacitor and working LED bulb.


Tuesday, January 11, 2011

Day 1: Stripping Wires & Soldering

Today in Electronics 10.

Today we learned how to solder and how to work safely in laboratory situations.

We went over an extensive safety manual and took a safety test!

We then watched a clip on introductory soldering.

-A good solder joint is one where the solder looks shiny and covers all of the copper on the opposite side of the board.

-A bad solder joint could be one that is lumpy or big or does not cover the whole copper part. Also it could be one that does not fully cover the lead and/or does not attach itself well to the board.

We were supposed to solder at least 20 leads, i did a bit more just for practice.

Here is my finished product.





Next we practiced stripping wires and welding them to eachother end to end.

This practice was useful for cutting up an old power supply and welding new wires to the power supply.

After this I put some shrink wrap on it and secured the wires to prevent stress.

This is my finished product.