Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: kevinisnekkid on October 08, 2008, 09:31:08 PM
-
Hi,
I am having a problem with my robot. I got everything built ok. 8) I'm not fully understanding the photocells. But I followed the directions. The robot just goes straight. I can re-program the robot just fine. I have modified the code to remove the threshold, but the best result I've gotten was a very brief pause (less than a second). I've tried turning the plug around. I don't have the proper sockets, so I modified a socket from a computer hard drive cable. Since photocells are usually used in pairs, there shouldn't be any reason this won't work. I've checked the continuity on the circuit board, everything checks ok. The photocells look like they are wired right. What else can I check? ???
Btw, I used 1k resistors instead of 1.5k resistors. Will that make it completely not work? I have an ISP cable, can I use that to get values from the board?
-Kevin
-
make sure your battery is charged, and post your code
-
It's a freshly charged 8.4v pack. I ran it around for over an hour after I tried the photocells. And it was still going strong.
I used stock code. I just set the threshold to 0 for maximum sensitivity.
#include "SoR_Utils.h" //includes all the technical stuff
int main(void) {
//declare variables here
int i=1000;//a 'whatever' variable
int sensor_left=0;//left photoresistor
int sensor_right=0;//right photoresistor
int threshold=0;//the larger this number, the more likely your robot will drive straight
/****************INITIALIZATIONS*******************/
configure_ports(); // configure which ports are analog, digital, etc.
a2dInit(); // initialize analog to digital converter (ADC)
a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage
/**************************************************/
/*********ADD YOUR CODE BELOW THIS LINE **********/
LED_off();//turn LED on
while(1) {
//store sensor data
sensor_left=a2dConvert8bit(5);
sensor_right=a2dConvert8bit(4);
//detects more light on left side of robot
if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold) {//go left
servo_left(44);
servo_right(44);
}
//detects more light on right side of robot
else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold) {//go right
servo_left(25);
servo_right(25);
}
//light is about equal on both sides
else {//go straight
servo_left(25);
servo_right(44);
}
delay_cycles(500);//a small delay to prevent crazy oscillations
}
/*********ADD YOUR CODE ABOVE THIS LINE **********/
return 0;
}
-
I have modified the code to remove the threshold
Does it work without code modification?
Did you check the photocell voltages with a multimeter?
-
Code modification didn't affect it.
I pulled out my breadboard, and checked. Only a tiny voltage would have gone to the chip, probably too small to read. I'm slightly puzzled why a 1.5k resistor was recommended. I went over the math and resistance readings. It seems that an 8k would be perfect. I tried a 15k, and the voltage tests good.
It's too late tonite (1:30am) to finish it, so I will continue tomorrow. I made a new set of "eyes" with 15k resistors. I'll put a plug on them later, and try it tomorrow.
-Kevin
Ok, it works!! :) My robot now chases my flashlight!! :) I will modify the code to have a smoother tracking, and change the wheels for better traction. Yay!! :)
Kevin
-
and you will post a vid and pics too :P
-
*sigh* my robot rolled over, and it's not working again... once I have it working good, I'll post pics & vid :) I'm going to change out the wheels to get better traction.
I'm also making a second board to help with diagnostics, so I can swap "eyes" and other sensors between them to help see if it's a board problem, or an "eye" problem. I ordered an rs232 adapter to have it talk to my computer, and I'll use it to read values. :)