A picture of the first stages of the square bot.
A picture of the middle stages of the square bot.
A picture of the square bot near the final stages, looking for the flame.
A picture of the final build of the square bot. Our team name for the competition is, "Kitty Kat".
Here is the link to the video of "Kitty Kat" in action:
http://www.youtube.com/watch?v=paTmTizYf1I&feature=player_embedded
Our team was able to put of the flame, however, it was due to luck and not the code. Kitty Kat did carry out code correctly. More testing would have avoided the robot from crashing into the candle.
Here is the code for "Kitty Kat":
#pragma config(Sensor, in1, flameSensor, sensorAnalog)
#pragma config(Sensor, in2, leftEncoder, sensorRotation)
#pragma config(Sensor, in3, rightEncoder, sensorRotation)
#pragma config(Sensor, in4, sonarSensor, sensorSONAR, int1)
#pragma config(Sensor, in5, lineSensor, sensorReflection)
#pragma config(Sensor, in6, startButton, sensorReflection)
#pragma config(Sensor, in10, fan, sensorDigitalOut)
#pragma config(Motor, port2, rightMotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void stoprobot()
{
motor[leftMotor]=0;
motor[rightMotor]=0;
SensorValue[rightEncoder]=0;
SensorValue[leftEncoder]=0;
}
void goforward(int counts)
{
SensorValue [leftEncoder] = 0;
SensorValue [rightEncoder] = 0;
int normalspeed;
int slowspeed;
normalspeed = 60;
slowspeed =45 ;
//while (SensorValue [rightEncoder]<counts && SensorValue [leftEncoder]<counts)
while(SensorValue[leftEncoder] < counts)
{
if(SensorValue[leftEncoder]>SensorValue[rightEncoder])
{
motor[rightMotor]=normalspeed;
motor[leftMotor]=slowspeed;
}
if(SensorValue[rightEncoder]>SensorValue[leftEncoder])
{
motor[rightMotor]=slowspeed;
motor[leftMotor]=normalspeed;
}
if(SensorValue[rightEncoder] == SensorValue[leftEncoder])
{
motor[rightMotor]=normalspeed;
motor[leftMotor]=normalspeed;
}
}
}
void gotowall(int distance)
{
while (SensorValue [sonarSensor] >= distance || SensorValue [sonarSensor] < 2)
{
goforward(1);
}
}
void fanOn ()
{
SensorValue[fan]=1;
wait10Msec(100);
SensorValue[fan]=0;
}
void killFlame (int flameValue)
{
fanOn();
wait10Msec(100);
while (SensorValue[flameSensor]> flameValue)
{
goforward(5);
fanOn();
stoprobot();
wait10Msec(500);
}
}
void searchRight(int fire, int searchTime)
{
int counter=0;
SensorValue [flameSensor] = 0;
SensorValue [leftEncoder] = 0;
while(SensorValue[flameSensor]<fire && counter<searchTime)
{
counter=counter+1;
wait1Msec(1);
motor[rightMotor] = -50;
motor[leftMotor] = 50;
}
killFlame(600);
}
void fw2 ()
{
while (SensorValue[flameSensor]> 100 && SensorValue[flameSensor] <900)
{
goforward(5);
stoprobot();
}
int fire;
int searchTime;
searchRight(fire+300,searchTime);
}
void goleft(int langle)
{
SensorValue [leftEncoder] = 0;
SensorValue [rightEncoder] = 0;
while (SensorValue [rightEncoder]<langle)
{
motor[rightMotor] = 60;
motor[leftMotor] = -60;
}
}
void goright(int rangle)
{
SensorValue [leftEncoder] = 0;
SensorValue [rightEncoder] = 0;
while (SensorValue [leftEncoder]<rangle)
{
motor[rightMotor] = -60;
motor[leftMotor] = 60;
}
}
void rfindTape(int rblack)
{
while (SensorValue [lineSensor] <= rblack)
{
goforward(10);
}
}
void findTape(int black)
{
while (SensorValue [lineSensor] >= black)
{
goforward(10);
}
}
void back(int bb)
{
SensorValue[rightEncoder]=0;
SensorValue[leftEncoder]=0;
motor[rightMotor]= 0;
motor[leftMotor]=0;
motor[rightMotor]=-60;
motor[leftMotor]=-60;
wait1Msec(1000);
motor[rightMotor]=0;
motor[leftMotor]=0;
}
void sr1()
{
goright(90);
back(50);
gotowall(10);
goright(90);
back(50);
gotowall(15);
searchRight(600,2900);
stoprobot();
wait10Msec(100);
goright(90);
stoprobot();
back(200);
stoprobot();
goright(95);
back(200);
gotowall(10);
goleft(90);
back(150);
gotowall(10);
stoprobot();
goleft(90);
stoprobot();
back(60);
stoprobot();
}
void sr2()
{
goforward(200);
// gotowall(35);
stoprobot();
goright(90);
stoprobot();
back(60);
stoprobot();
gotowall(35);
stoprobot();
searchRight(400,3400);
stoprobot();
wait10Msec(100);
goright(75);
stoprobot();
back(100);
stoprobot();
goright(90);
stoprobot();
back(250);
gotowall(10);
stoprobot();
}
void sr3()
{
goright(90);
//stoprobot();
//back(210);
//stoprobot();
goforward(100);
stoprobot();
goright(90);
stoprobot();
gotowall(40);
goleft(90);
stoprobot();
back(50);
gotowall(10);
searchRight(600,3400);
stoprobot();
goright(90);
back(60);
goright(90);
back(60);
gotowall(10);
stoprobot();
}
void sr4()
{
goright(90);
goforward(90);
goright(90);
gotowall(40);
goleft(90);
gotowall(10);
goright(90);
back(60);
gotowall(20);
searchRight(600,3000);
gotowall(10);
searchRight(600,3000);
stoprobot();
}
void SearchRoom1()
{
wait1Msec(2000);
back(80);
stoprobot();
gotowall(10);
sr1();
}
void t2 ()
{
// gotowall(10);
// stoprobot();
goforward(80);
// searchRight(400,2900);
stoprobot();
}
task main()
{
wait1Msec(1500);
SearchRoom1();
stoprobot();
sr2();
stoprobot();
sr3();
stoprobot();
sr4();
stoprobot();
}
The task main code basically tells "Kitty Kat" what navigation path the take. "Kitty Kat" will go straight to room 1, call functions that search for the flame and turn the fan on if a value of greater than 500 is present. If there is no flame, it would then proceed to sr2,(room2) and do the same. It would keep doing this in till it has found a flame or explored all 4 rooms.
Testing and reconfigure values was a must. Depending on battery life, and surface texture "Kitty Kat" would behave differently. In order to minimize errors, few function were made and many were called a lot. This made debugging easier. One governing rule that was absolutely necessary was "Kitty Kat" ability to go straight for long distances and turn 90 degrees perfectly. Having this insured that the robot would not crash on throw itself off course.
Overall this project was extremely fun and taught me a lot about programming, planning, and testing a unit. I think the next time I enter a robot competition I will be very confident in being able to win. I would not relay on luck but on hard work.
Wednesday, February 13, 2013
Day 14, Final build of Square Bot
Picture of final build of the square bot.
Square bot has fan, external power supply, sonar sensor, flame sensor, line sensor, and encodes on the wheels. Code has been written to allow the square bot to move forward by both encoder counts, and sonar values, turn right and left, power on the fan, and find the flame.
More testing was done on the maze. Problems with going straight and turning were wrinkled out.
Square bot has fan, external power supply, sonar sensor, flame sensor, line sensor, and encodes on the wheels. Code has been written to allow the square bot to move forward by both encoder counts, and sonar values, turn right and left, power on the fan, and find the flame.
More testing was done on the maze. Problems with going straight and turning were wrinkled out.
Tuesday, February 12, 2013
Day 13, Powering The Fan
The fan that we are using to extinguish the fan is rated at 12V but the power supply of the square bot only outputted 7.2V. So a MPS A 14 transistor was used with two 9V batteries in series to give the fan the needed power. The fan is controlled by the signal output of the Vex.
Day 12, Traveling The Maze
Picture of the maze with the square bot searching for the flame.
On this class day, our time was spent on having the square bot traverse through the maze and find the flame and stop once it found the fire. Our search strategy was to go top right, top left, bottom left and finally bottom right. Each time in would enter a room it would initiate the search for the flame and if not found would go to the next room. Going straight and turning 90 degrees was mandatory for a successful run.
Thursday, January 31, 2013
Day Eleven, Adding Sensors and Programming
Picture of the square bot with added sensors. Sonic, flame, and light sensor added. Writing code is fun and hard. Adjusting right values to initiate commands can be frustrating but rewarding once it works.
Wednesday, January 30, 2013
Day Project, Bird
Picture of the gutted bird. I think I broke the connection that control the movement of the wings. Or lost the piece. I will take better note and care when disassemble a toy.
Picture of bird put back together. The goal of my project was to have to movement be controlled by the press of the tongue but was unable to do so. The movement is now controlled by the micro controller in set time intervals. The motor runs clockwise, stops, and then counter clockwise.
Video of the Bird in action. Movement is controlled by micro controller. It moves in time intervals that can be change with the PC. The wings are suppose to move with the movement of the head but they do not. More debugging and more attention to detail when taking the bird apart would of safeguarded against breaking the wing movement. But the motor at least does controll the head movement. The project was fun and rewarding.
Code for Bird project:
void setup ()
{
pinMode (6,OUTPUT); // input for relayswitch
pinMode (7,OUTPUT); // input for relayswitch
}
void loop ()
{
digitalWrite (6, HIGH); // inputs high to motor
digitalWrite (7,HIGH); // inputs high to motor
delay (5000); // duration of movement
digitalWrite (7,LOW); // inputs low to motor
delay (1000); // stops movement for 1 second
digitalWrite (6,LOW); // reverse movement for motor
delay (2000); // duration of movement
}
Day Ten, Building Sensors for Robot
Picture of the square bot pointing towards the candle light. The picture shows the encoders on the back wheels. The flame sensor is in front. The goal for the day was to write code that would tell the square bot to turn clockwise in till the flame sensor finds the flame then tells the square bot to move forward a given amount controlled by the encoder. It was very rewarding to have the square bot function as attended.
Day Nine, Vex Programming
This day we input code and encoder wheels onto the square bot to navigate a maze. No video or picture were taken this day. The first trial was done using time as a variable and it was very hard to adjust code to small changes that were needed. The second trial was done using the encoder on the wheels as a variable. Using the encoder as a variable made applying changes much easier than the time variable.
Day Eight, Bi-directional Motor Control
Picture of motor of my toy being controlled with a relay switch setup. The motor turns clockwise and counter clockwise.
Picture of the motor being powered by a darlington transistor.
Wednesday, January 23, 2013
Day Seven, Cont. LDR and Driving Motor's
Picture of
LDR controlling the LED's. 4 States were programmed, bright light,
medium light, low light, and no light. Finding the right value that the
LDR operated was time consuming even though programming logic was correct.
Picture of the microcontroller controlling the signal lamp. A transistor was used to pull up the current needed to turn up the lamp. Changing the resistance in the base of the transistor changes he brightness of the lamp.
Video of the signal lamp turning off and on.
Day Six, Micro Controller LED
Picture of a switch that controls the digital input of the micro controller that turns on the LED.
Picture of Light Depended Resistor (LDR) controlling the micro controller analog input to turn on the LED's.
Picture of Light Depended Resistor (LDR) controlling the micro controller analog input to turn on the LED's.
Thursday, January 17, 2013
Day Five, Micro Controllers
Picture of LEDs connect to the Micro Controller.
Video of Yellow LED blinking on and off by simple code uploaded from a computer. One second intervals between each blink.
Video of a LEDs turning on and off. They blink from right to left then left to right. Writing of code was longer harder than the single blinking LED.
Day Four, Square Bot and Transistor
Picture of a Square Bot half finished. A trick to know while building the Square Bot is to use gravity to aid the construction of it, not impede it.
Picture of a completed Square Bot. Wired up and ready to go.
Video of Square Bot in motion.
Video of transistor circuit. Pressing my fingers on the wires makes the circuit complete and lights up the LED.
Picture of a completed Square Bot. Wired up and ready to go.
Day Three, Switches and Relays
Picture of switches that I soldered wires onto to connect to the breadboard.
Picture of a circuit using a relay to alternate the green and yellow LED with the push of a button.
Tuesday, January 15, 2013
Day Two, 5 V Power supply
A ring of wires composed of alternating colors that are soldered together and then wrapped with heat shrink.
Picture of a 5 V power supply of a phone that has been modified to have 2 pin plugs. They were soldered on and then wrapped with heat shrink to protect them from shorting each other out.
Picture of a 5 V power supply of a phone that has been modified to have 2 pin plugs. They were soldered on and then wrapped with heat shrink to protect them from shorting each other out.
Thursday, January 10, 2013
Day one, Elec 10 - 5 V power supply.
1st assignment was to place and solder parts onto PCB. Getting perfect cones and correct amount of solder was important. After a couple of tries it became easier.
Top picture of PCB. It was important to get the component as close and flush with the PCB.
Top picture of PCB. It was important to get the component as close and flush with the PCB.
Subscribe to:
Posts (Atom)