## Saturday, 4 June 2011

### Sharp Infra Red Sensor Calibration

After reading SOR forum and Robot room I have decided to use a 10uF capacitor across the sensor power supply rails. I taped some paper on to my table and marked the distance from the sensor at 1cm increments to 80cm. I used a white box as a target.

I then took readings at every centimetre from 10cm to 80cm from the sensor and added a trend line.

I think it is important to do this, since the trend line given in my datasheet was distance = 12343.85 * (reading ^ -1.15). My trend line from the graph was distance = 7883.10 * (reading ^ -1.08).  I plotted the datasheet equation and my new equation against the actual distance.

It show that the new equation has better agreement than the datasheet equation. I then changed the reference voltage from 5V to 3.3V to make it more accurate. I read this before changing the voltage, so I didn't break anything. I took the data in the same way as before.

This gave a new trend line, distance = 12214.16 * (reading ^ -1.08) and plotted against the actual distance.

I think I will use 3.3V as the reference voltage with the new equation and the 10uF across the sensor power rails. The program I used for the sensor calibration is...

void setup() {

analogReference(EXTERNAL);  // Set the ADC reference voltage to external (only use if using 3V, read
// first)

Serial.begin(115200);       // sets the speed of the serial connection to the computer

}

void loop() {

// 10 second countdown to start
for(int i=10;i>0;i--) {
Serial.println(i);         // print to the computer when the USB cable is connected
delay(1000);              // 1 second delay
}

int reading;                // used for taking the averages

for(int i=0;i<6;i++) {
delay(1);                 // wait one millisecond
}

Serial.println("Done");

}

Next is to check for timing errors in the sensor sweeps.

EDIT: I have just realised that the Arduino generates 3.3V not 3V, so I have changed all the references to 3V to 3.3V.