ActivityBot Bug
JessA
Posts: 2
I have an activitybot. I am using the qti line sensors to make it follow a line. My servos wont run at the same speed in this program only. While running the programs off parallax.com the servos behave correctly. This is a school project. I called the help line they said to post on the forums for help.
Here is my code:
/*
http://learn.parallax.com/activitybot
*/
#include "simpletools.h" // Include simpletools header
#include "abdrive.h" // Include abdrive header
int qr, l, r;
int main() // main function
{
while(1)
{
high(4); //sets outputs high so capacitors will discharge
high(5);
high(6);
high(7);
//set_direction(4,1);
set_directions(4,7,1111); //pin set to output
pause(10);
//set_direction(4,1);
input(4);
input(5);
input(6);
input(7);
pause(10);
qr=get_states(4,7);
//print("%d ",qr);
if(qr==0) // Centered
{drive_ramp(0,0);
pause(1);
}
else if(qr==1) // Turn Right
{drive_speed(10,20);
pause(1);
}
else if(qr==2) // Centered
{drive_ramp(20,20);
pause(1);
}
else if(qr==3) // Turn Slight Right
{drive_speed(21,20);
pause(1);
}
else if(qr==4) // Turn Slight Left
{drive_speed(20,25);
pause(1);
}
else if(qr==5) // Centered
{drive_ramp(20,20);
pause(1);
}
else if(qr==6) // Centered
{drive_ramp(20,20);
pause(1);
}
else if(qr==7) // Turn Slight Right
{drive_ramp(20,10);
pause(1);
}
else if(qr==8) // Turn Left
{drive_ramp(0,25);
pause(1);
}
else if(qr==9) // Centered
{drive_ramp(15,20);
pause(1);
}
else if(qr==10) // Centered
{drive_ramp(15,20);
pause(1);
}
else if(qr==11) // Centered
{drive_ramp(10,25);
pause(1);
}
else if(qr==12) // Turn Slight Left
{drive_speed(15,30);
pause(1);
}
else if(qr==13) // Centered
{drive_ramp(15,20);
pause(1);
}
else if(qr==14) // Turn Slight Left
{drive_speed(15,20);
pause(1);
}
else if(qr==15);
{drive_ramp(0,0); //Stop
pause(1);
}
print("%d ",qr);
}
}
Here is my code:
/*
http://learn.parallax.com/activitybot
*/
#include "simpletools.h" // Include simpletools header
#include "abdrive.h" // Include abdrive header
int qr, l, r;
int main() // main function
{
while(1)
{
high(4); //sets outputs high so capacitors will discharge
high(5);
high(6);
high(7);
//set_direction(4,1);
set_directions(4,7,1111); //pin set to output
pause(10);
//set_direction(4,1);
input(4);
input(5);
input(6);
input(7);
pause(10);
qr=get_states(4,7);
//print("%d ",qr);
if(qr==0) // Centered
{drive_ramp(0,0);
pause(1);
}
else if(qr==1) // Turn Right
{drive_speed(10,20);
pause(1);
}
else if(qr==2) // Centered
{drive_ramp(20,20);
pause(1);
}
else if(qr==3) // Turn Slight Right
{drive_speed(21,20);
pause(1);
}
else if(qr==4) // Turn Slight Left
{drive_speed(20,25);
pause(1);
}
else if(qr==5) // Centered
{drive_ramp(20,20);
pause(1);
}
else if(qr==6) // Centered
{drive_ramp(20,20);
pause(1);
}
else if(qr==7) // Turn Slight Right
{drive_ramp(20,10);
pause(1);
}
else if(qr==8) // Turn Left
{drive_ramp(0,25);
pause(1);
}
else if(qr==9) // Centered
{drive_ramp(15,20);
pause(1);
}
else if(qr==10) // Centered
{drive_ramp(15,20);
pause(1);
}
else if(qr==11) // Centered
{drive_ramp(10,25);
pause(1);
}
else if(qr==12) // Turn Slight Left
{drive_speed(15,30);
pause(1);
}
else if(qr==13) // Centered
{drive_ramp(15,20);
pause(1);
}
else if(qr==14) // Turn Slight Left
{drive_speed(15,20);
pause(1);
}
else if(qr==15);
{drive_ramp(0,0); //Stop
pause(1);
}
print("%d ",qr);
}
}
Comments
Mount all the QTIs so that they are edge-to-edge on the front of your ActivityBot, as shown in the product documentation: http://www.parallax.com/sites/default/files/downloads/28108-QTI-Line-Follower-Guide-v2.0.pdf.
Use this program with the black line on page 5 of the product documentation, (or with black vinyl electrical tape on white paper or poster board). Keep in mind that the far-left QTI connected to P7 should be the one closest to the wheel by the Activity Board's servo ports. The middle-left QTI should be connected to P6, and mounted next to the far-left QTI. Then the P5 QTI is middle-right, and the P4 QTI is far-right, closest to the other wheel.
* Click SimpleIDE's New Project button and save it as Test QTIs.
* Paste the code in the box below over the template code that comes with New Project.
* Use SimpleIDE's Run with Terminal button to run TestQTIs.
* Verify that you see these patterns for the QTIs when a given sensor is over the black stripe:
1000...Far-left only
1100...Far-left and middle-left
0110...Middle-left and middle-right
0011...Middle-right and far right
0001...Far-right only
Assuming you have followed the instructions in the ActivityBot Tutorial (http://learn.parallax.com/activitybot) up through Calibration (http://learn.parallax.com/activitybot/calibrate-your-activitybot), this code should do a nice job of following a black vinyl electrical tape stripe on a white background.
* Click SimpleIDE's Save Project As button, and set the File name to Line Follow with QTIs.
* Paste the code in the box below over all the code that's currently in SimpleIDE.
* Use SimpleIDE's Load EEPROM & Run button to load the program into the ActivityBot.
* You can now disconnect the programming cable, set the PWR switch to 2, and set it on your line course.
Once your application is running, try experimenting with higher speeds (up to 128).
Andy Lindsay is an amazing, creative, silled contributor and we are all thankful to have him assist us with our learning.
Thanks again, Andy!
Ken
Amen, Ken. Next day service by Brother Andy! Might have been same day service had JessA posted before 7 pm.