IR-Ranger

Up

This is a project that is all about learning what the Sharp GD2D02 sensor is good for. I have always been perplexed at the amount of data that one can get out of tech data sheets and still be left sort of in the dark about what the gizmo actually does or how it behaves. In this case, the GD2D02 is proclaimed to be an IR sensor that can determine the distance between it an an object. It's usable range is stated to be between 8 and 120cm or 3" to almost 4' (3' 11.24"). As the distance falls away, so too the accuracy. My ultimate plan for the sensor was a scanning device that could localize the nearest object. To test that in as controlled of an environment as I could muster, I built a little test jig. The setup is a BiPOM 8051 series microcontroller with an Optrex 16x2 LCD display and a HiTec miniature servo for motion. The controller does everything including the PWM for the servo. It has four buttons, two of which do something - they control the  'speed' of the sweep. This is actually the size of the change from one position to the next. The position changes as soon as the 'last' data conversion is finished. After I got it working I found the display numbers to be a nice trouble shooting aid but largely useless for understanding the actual data so I also wrote some VB.NET code to 'see' the results on a radar type display. This was most enlightening. In the movie you can see glimpses of the radar display.

Ultimately I was also curious to know more about how the thing actually worked but without being able to see the light I couldn't grasp the operation. So, I set it up in the corner of my cubicle and took some videos of the operation in the camera in the IR or night mode. You can se the projected IR light pulse. You can also hear the clicking of the servo. This gives you a great idea just how fast this little can move.

Check out the movie it's very telling!

The Whole Enchelada

OK, so it's not as pretty from behind.

ANother behind the scenes.

Note the battery replacement clips.

Upside down

showing the LCD sandwich

From the Top

Showing the LCD sandwich

The whole deal

Servo and sensor

The LCD

RS-232 outlet

 

Here is what I found out:

UNKNOWNS:

  1. One thing that is not apparent in the GD2D02 documentation is exactly where in the timing sequence the IR pulse is actually being read. This means that in a polled situation like I set up, servo movement time is wasted on the internal processor doing it's GD2D02 conversion.
  2. I don't know the settling time on the sensor pod so the results are a little suspect in that regard.

DATA CONVERSION: Since the sensor provides a non-linear output, the first thing I had to do was fit the curve to interpret the data. I broke the curve down into 10 straight lines and using the endpoints of each segment and applying y=mx+b, I got the following line constants and curve below.

X1 Y1 X cm Y bit m-slope b-offset Resolution
- - 8 230 - - 0.03 cm/bit
8 230 14 160 -11.67 323.33 0.09 cm/bit
14 160 19 140 -4.00 216.00 0.14 cm/bit
19 140 25 120 -3.33 203.33 0.21 cm/bit
25 120 28 110 -3.33 203.33 0.25 cm/bit
28 110 35 100 -1.43 150.00 0.35 cm/bit
35 100 45 90 -1.00 135.00 0.50 cm/bit
45 90 60 80 -0.67 120.00 0.75 cm/bit
60 80 70 77 -0.30 98.00 0.91 cm/bit
70 77 100 70 -0.23 93.33 1.43 cm/bit
100 70 120 67 -0.15 85.00 1.79 cm/bit

It matches Sharps curve pretty well which is:

ELECTRONIC:

No real surprises here. I did learn that if your driving this with 9v batteries you'll have to separate the servo power from the rest of the system. The servo power surges tend to generate random resets on the microcontroller and at best really corrupt the sensor output. I also found out from the vendor that the case of the sensor is conductive plastic and not well connected to the ground pin so an extra ground wire to the sensor is helpful for stability. (In the movie you'll see the extra alligator clip I added to ground the sensor carrier.)

CODE:

As usual, the published code drivers for this device, don't 'quite' work. It took a long time to figure out that in the serial data train there was a bit missing if you strobe the line per the design guidelines. So, two really useful code segments came out of this project. One is the internal interrupt driven PWM code for the 8051 and the other is the data acquisition routine for the GD2D02.

SUMMARY:

The IR project is not finished yet. It got put on hold due to some animatronics work I was doing over Halloween than came the on rush of holidays and I have not gotten a chance to do some more serious data interpretations on different surfaces and in varying environments. I do plan to finish this sometime in the near future.

In the mean time if you want to motivate me to finish or have any questions or want the code segments, fire me an email: jim@cannibalrobotocs.com.


Last updated: 01/05/09.