Let's Make Robots!

IR compound eye


AttachmentSize
Mr._General_4.bas17.21 KB
Vendor's Description: 


I have posted some tip/walkthroughs on home made IR sensors for obstacle detection and later for motion tracking. Now DAGU proudly presents the IR compound eye. Designed to fit LMR's universal sensor bracket, this sensor works by shinning IR light onto an object and then tracking the reflected IR. This sensor does not work in bright daylight as sunlight has a lot of IR and blinds the sensor.The IR LEDs can be controlled by a digital output so that ambiant light as well as reflected light can be measured. Your microcontroller needs 4 analog inputs available to use this sensor. See a video of it working here: http://www.youtube.com/watch?v=iKYCob7getU

Note: calibration is not normally required, heatshrink is provided fo those who wish to fine tune their eye. A black permanent marker can also be used. Incorrect application can reduce the range of the eye.

This product is now sold at Robot Shop.

Click on the schematic for a bigger image.

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I admit, getting Mr. General to smoothly track an object was difficult and took many hours of experimenting. By subtracting ambient light readings from the readings with the LEDs on to get the reflected light from the object you will get more accurate tracking data from your eye but you will loose some sensitivity and thus range when ambiant light levels are high.

At China's Hi-Tech Fair our stand recieved a lot of indirect sunlight from overhead windows that reduced Mr. Generals detection range down to as little as 10cm. 

without attempting to control servos, no heatshrink and just measuring the analog inputs you should be able to detect a white buisness card from about 20cm. If you can't then there is something wrong with the eye or your setup.

Since heatshrink does not need much to shrink it I just very quickly run the flame of a cigarette lighter over it. If you want you can also use a black permanent marker. If the heat shrink or pen is not setup properly then it can also reduce the range. Normally no calibration is required. The heatshrink is just for fine tuning.

Hi guys,

 

I got the compound eye working on the Arduino you can find the code I used below. I'm not a programmer nor a robotics expert (working on my first robot based on a mr basic kit/pan tilt/compound eye). Basicly I just tried to understand what Oddbot did in his original code and replicated it in a similar way on the Arduino.

The setup is using a pan and tilt kit mounted with the compound eye. It's working but it's range is currently only about 5 cm. I did not add the heatshrink yet or the ambient light optimization yet. I was kind of wondering how you guys shrink the heatshrink without damaging the LED's.

I did also make the mistake initially to think the J1 indication on the PCB meant PIN1 was located next to it. After measuring I actually found it was reverse and then I noticed someone already talked about it in the thread Dohh

 

If you guys think the code listing polutes the thread I'll try to remove it.

 

There's a lot of serial communication in there as well but that's mostly for debugging and is commented out by default.

 

Just copy paste the code in a sketch and it should work

 

 // Library inclusions
 #include <Servo.h>

 
//VAR Declaration

//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 2;
int Pos_P = 0;  // Variable to store Pan servo position
int Pos_T = 0;  // Variable to store Tilt servo position
int Servo_Pan_Centre = 70;
int Servo_Tilt_Centre = 70;
int Servo_Min_Pos = 10;
int Servo_Max_Pos = 170;
int Pan_Scale = 0;
int Tilt_Scale = 0;
int Max_Dist=185; // Maximum distance to check against. This value was determined from sensor reading averages
int Best_Dist=400; // Best distance to check against. This value was determined from sensor reading averages
//VAR pin selection
int sensorPin_Top = 0;    // select the Arduino input pin for the CompoundEye PCB IR pin 2
int sensorPin_Right = 3;    // select the Arduino input pin for the CompoundEye PCB IR pin 3
int sensorPin_Bottom = 2;    // select the Arduino input pin for the CompoundEye PCB IR pin 4
int sensorPin_Left = 1;    // select the Arduino input pin for the CompoundEye PCB IR pin 5
int ledPin = 13;      // select the Arduino output pin for turning on the compound eye PCB IR LED
//VAR sensorvalues
int sensorValue_Top = 0;  // variable to store the value coming from the Compound Eye sensor(Top)
int sensorValue_Right = 0;  // variable to store the value coming from the Compound Eye sensor(Right)
int sensorValue_Bottom = 0;  // variable to store the value coming from the Compound Eye sensor(Bottom)
int sensorValue_Left = 0;  // variable to store the value coming from the Compound Eye sensor(Left)
int sensorValue_Average = 0;
//VAR servo object creation
Servo Servo_Pan;
Servo Servo_Tilt;

void setup() {
//  Serial.begin(9600);
  Servo_Pan.attach(5);  // assign pin for the Pan Servo
  Servo_Tilt.attach(6);  // assign pin for the Tilt Servo
  pinMode(ledPin, OUTPUT);    // declare the ledPin as an OUTPUT:
  digitalWrite(ledPin, HIGH);   // turn the ledPin on

// Center the servos
  Pos_T=Servo_Tilt_Centre;
  Pos_P=Servo_Pan_Centre;
  Servo_Pan.write(Pos_P);
  Servo_Tilt.write(Pos_T);
//  Serial.print("calibrating sensor ");
//  for(int i = 0; i < calibrationTime; i++){
//      Serial.print(".");
//      delay(1000);
      }
//    Serial.println(" done");
//    Serial.println("SENSOR ACTIVE");
//    delay(50);

 
//}

void loop() {
  // read the value from the sensor and determine if the object is in range if not return the Pan/Tilt servos to the center:
  sensorValue_Top = analogRead(sensorPin_Top);   
  sensorValue_Right = analogRead(sensorPin_Right);   
  sensorValue_Bottom = analogRead(sensorPin_Bottom);   
  sensorValue_Left = analogRead(sensorPin_Left);
  sensorValue_Average = (sensorValue_Top+sensorValue_Right+sensorValue_Bottom+sensorValue_Left)/4;
//  Serial.print ("sensorValue_Average="); // debugging code
//  Serial.println (sensorValue_Average);  // debugging code
  if (sensorValue_Average < Max_Dist) {
    if (Pos_T > Servo_Tilt_Centre) {
      Pos_T = Pos_T - 1;
      Servo_Tilt.write(Pos_T);
    }
    if (Pos_T < Servo_Tilt_Centre) {
      Pos_T = Pos_T + 1;
      Servo_Tilt.write(Pos_T);
    }
    if (Pos_P > Servo_Pan_Centre) {
      Pos_P = Pos_P - 1;
      Servo_Pan.write(Pos_P);
    }
    if (Pos_P < Servo_Pan_Centre) {
      Pos_P = Pos_P + 1;
      Servo_Pan.write(Pos_P);
    }
  }
// if the object is in range we need to start tracking it
   if (sensorValue_Average > Max_Dist) {
     Pan_Scale = (sensorValue_Left + sensorValue_Right) / 10;
     Tilt_Scale = (sensorValue_Top + sensorValue_Bottom) / 10;
     if (sensorValue_Left > sensorValue_Right) {
       Pos_P = Pos_P -((sensorValue_Left - sensorValue_Right) / Pan_Scale);
       if (Pos_P < Servo_Min_Pos) {
         Pos_P = Servo_Min_Pos;
       }
//     Serial.print ("Going Left"); // debugging code
     Servo_Pan.write(Pos_P);
     }
     if (sensorValue_Left < sensorValue_Right) {
       Pos_P = Pos_P +((sensorValue_Right - sensorValue_Left) / Pan_Scale);
       if (Pos_P > Servo_Max_Pos) {
         Pos_P = Servo_Max_Pos;
       }
//     Serial.print ("Going Right"); // debugging code
     Servo_Pan.write(Pos_P);
     }
     if (sensorValue_Top > sensorValue_Bottom) {
       Pos_T = Pos_T -((sensorValue_Top - sensorValue_Bottom) / Tilt_Scale);
       if (Pos_T < Servo_Min_Pos) {
         Pos_T = Servo_Min_Pos;
       }
//     Serial.print ("Going Up"); // debugging code
     Servo_Tilt.write(Pos_T);
     }
     if (sensorValue_Top < sensorValue_Bottom) {
       Pos_T = Pos_T +((sensorValue_Bottom - sensorValue_Top) / Tilt_Scale);
       if (Pos_T > Servo_Max_Pos) {
         Pos_T = Servo_Max_Pos;
       }
//     Serial.print ("Going Down"); // debugging code
     Servo_Tilt.write(Pos_T);
     }
   }



/* below is part of the experimentation code used to get a feel for the bestdist and maxdist values I hope it is self explanatory
of course you need the do the analog read in order to be able to display these values
  Serial.print("Top Value=");
  Serial.print(sensorValue_Top);
  Serial.print("- Right Value=");
  Serial.print(sensorValue_Right);
  Serial.print("- Bottom Value=");
  Serial.print(sensorValue_Bottom);
  Serial.print("- Left Value=");
  Serial.print(sensorValue_Left);
  Serial.print("- Average value=");
  Serial.println((sensorValue_Top+sensorValue_Right+sensorValue_Bottom+sensorValue_Left)/4);
  delay(500);  
  */
   delay(30);
}

Hi, i just got my eye and am testing it, something odd is happening though, one of the analog outputs gives me a lot of noise. it does respond to proximity of objects but its values are just noisy, while the other 3 are quite noise free...

any tip, or guess about what could be wrong? (everything came already soldered) 

It sounds like a bad or missing solder joint. Check all the solder joints, particularly around the 4K7 resistors and the 7 pin jumper. I am changing the way we do things here so that in future all prefabricated eyes will be tested thoroughly.

If the solder joints on the PCB look good then I would check your connections from the PCB to your processor.

you were right :) thanks

it was the R6 resistor that had a bad joint.

i'm going to buy a solder sucker to desolder it and then sodler it again. 

it seems that afterall the problem is in the pin itself (pin1 or J2) can someone show me how to desolder these pins? i'm having a hard time trying to do so...

well i removed the pins now...

i'm testing with a multimeter and i get signal between all pins and any component that is connected to them in the diagram.. except on the first output pin (the pin hole now...) :p

is the pcb defective? 

Please post a photo of the PCB front and rear with the suspect pin highlighted.

I doubt if the PCB is faulty as we have not had a bad one yet and they are all visually inspected and electronically tested at the factory. The only way the PCB would be faulty is if you have damaged it when de-soldering a component.

here they are...

 CIMG2028_.jpg

CIMG2027_.jpg 

Yes i might of course have damaged it. I'm just asking for help to find out whats wrong, so that i can learn and try to fix it.

thanks 

G'day mate, glad to see you got your package. It is strange, the first 15-20 robots we made had no problems but recently we have had similar problems. I am suspecting a bad batch of IR phototransistors as this problem has only occured in the last week or 2. As soon as I know for certain I will let you know. If it does turn out to be faulty components I will send you a new pre-tested eye.

Don't worry about the heatshrink too much. The eye will work fine without it. For those who wish to tweak the eye then the heatshrink when properly fitted can increase the sensitivity and range slightly.