go away spammer

Author Topic: $50 Photocell Help!!  (Read 3880 times)

0 Members and 1 Guest are viewing this topic.

Offline kevinisnekkidTopic starter

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 0
    • Golden Bares
$50 Photocell Help!!
« 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
« Last Edit: October 09, 2008, 08:17:59 PM by kevinisnekkid »
Robots don't hide what they are.

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: $50 Photocell
« Reply #1 on: October 08, 2008, 11:54:34 PM »
make sure your battery is charged, and post your code

Offline kevinisnekkidTopic starter

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 0
    • Golden Bares
Re: $50 Photocell
« Reply #2 on: October 09, 2008, 01:26:25 AM »
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.
Code: [Select]
#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;
}
Robots don't hide what they are.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: $50 Photocell Help!!
« Reply #3 on: October 10, 2008, 04:53:13 AM »
Quote
I have modified the code to remove the threshold
Does it work without code modification?


Did you check the photocell voltages with a multimeter?

Offline kevinisnekkidTopic starter

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 0
    • Golden Bares
Re: $50 Photocell Help!!
« Reply #4 on: October 12, 2008, 02:25:39 AM »
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
« Last Edit: October 12, 2008, 03:09:33 PM by kevinisnekkid »
Robots don't hide what they are.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: $50 Photocell Help!!
« Reply #5 on: October 15, 2008, 06:40:22 AM »
and you will post a vid and pics too :P

Offline kevinisnekkidTopic starter

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 0
    • Golden Bares
Re: $50 Photocell Help!!
« Reply #6 on: October 17, 2008, 09:37:41 AM »
*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. :)
Robots don't hide what they are.

 


Get Your Ad Here

data_list