Friday, February 22, 2013

AVC 2013, Sharp IR I2C

My AVC 2013 preparations have begun.

I have a list of improvements planned for my rover Data Bus to make it faster, more precise and accurate. I'll soon add the convenience of telemetry and FPV.

Some changes are small but quite helpful. One such improvement is to I2C-ify my Sharp IR Rangers.

Last year, Data Bus used a Sharp IR ranger as a last-minute, last-resort device to curtail violent curb encounters during testing.

My beautiful electronics layout, ruined by...this.
Lacking free ADC ports on the mbed required the addition of a butt-ugly protoboard Arduino to translate analog ranger signals to I2C. I will be replacing it with something like this. Prettier, no?

Early prototype for my Sharp IR Ranger I2C Adapter
It's a tiny, general purpose board that will adapt any Sharp ranger to digital I2C. Or any analog sensor, in fact, with the performance advantages of a dedicated, 188.9kSPS ADC near the analog sensor. The board includes the recommended 10uF decoupling capacitor for the ranger. A single I2C bus can host 9 of the devices, each with a unique address.

It's built around the Texas Instruments ADCxx1C021 single supply I2C ADC where xx is the bit resolution, 08, 10, and 12. The chip costs under $4 in single quantities. (More info: ADC081C021ADC101C021ADC121C021)

Resolution

Resolution is a challenge. The Sharp GP2D12 analog signal range is about 2V with supply voltage of 5V according to the datasheet (pdf). A single supply, single-ended ADC running at the same 5V as the ranger, therefore, loses more than 1 bit of resolution.  So, how many bits of ADC resolution is needed?
This plot shows the non-linear Range (cm) vs LSB
relationship for the big 5m sensor
In the GP2D12 datasheet, there's a plot of voltage versus distance. ADC resolution is more important for longer distances as you can kind of tell from the plot above. Close in, 10-30cm, the sensor sensitivity is 110mV/cm and at long range, 50-80cm, it is 6.67mV/cm.

A 5V 8-bit ADC has a resolution of 19.5mv/LSB, almost 3cm/LSB at long range. Better is a 10-bit ADC with a 4.88mV/LSB or 0.73cm minimum resolution. Best is a 12-bit with 1.22mV/LSB or 0.18cm resolution. I'll probably be able to get away with a 10-bit ADC.

I don't know what the Sharp sensors' resolution is in mV. I've looked at sensor output on an oscilloscope and it is not purely analog because it changes in small steps.

Layout

As a part of this project, I spent some time learning about mixed signal PCB layout and ground planes. One of the best resources I read was this Maxim paper, Successful PCB Grounding with Mixed-Signal Chips - Follow the Path of Least Impedance. The ADC's datasheet also provides good information about layout and PCB design.

The gist is that low frequency signals follow the shortest path on their return to ground, while high frequency signals (say around 100kHz and up) return to ground under the corresponding signal trace because the signal current reduces impedance on the adjacent ground plane. In short, signals follow the path of least impedance. Shocking, I know.

My next set of prototype boards implement the Maxim paper's suggestions. I'll test noise performance and also attempt to answer some questions I have about the best way to use a ratiometric ADC on a noisy digital sensor like the Sharp. If you have a 10uF bypass capacitor on the Sharp supply, should the ADC also feed off that point? I think so but we'll see how much it matters.

Incidentally, I don't need to go to all this trouble for a curb sensor. I plan to make this board available to other hobbyists and I want it to work well.

Here are some more papers:
  • Analog Devices AN-202 (pdf)
  • Elmac paper, "The ground plane: Lord of the Board", (pdf)

4 comments:

  1. By the way, I2C-IT from Solarbotics is a GP2D12 with an I2C backpack costing only a little more than the analog ranger alone. Great if you don't have a sensor yet and want the 80cm version.

    I wanted to convert my already-purchased batch of GP2D12s, GP2Y0A02YKs (150cm), and GP2Y0A710YKs (5.5m), Maxbotics ultrasonic sensors, and whatever else comes along.

    ReplyDelete
  2. Thanks for sharing those papers. I love finding documents that clearly explain principles that should have been taught in the EE class but were obfuscated by academic method and lingo.

    BTW, did you see that the mbed libs went open source?

    !!Dean

    ReplyDelete
  3. @!!Dean - I did hear that and am very excited about it, too!

    I was actually going to post that on the blog after I had a chance to dig into it a little more.

    I was thinking for awhile about migrating to an STM32F4 but this provides one more good reason to stick with what I've got.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete