The second revision of my board incorporates a 10uF tantalum bypass capacitor on the ranger supply, a 4.7uF tantalum on the ADC supply, and has an anti-alias RC filter feeding the ADC and features improved PCB layout.
ADC Measured NoiseFirst, I looked at the noise read by the ADC for each of the two board revisions to see if I'd made any improvements.
Apparently not. Both the Rev 0.1 and 0.2 boards have a similarly high level of noise. Disappointing.
Before looking at board design and ADC noise further, I decided to look at the ranger itself.
For my tests I used a 150cm GP2Y0A02YK (datasheet pdf). The board is hooked up to the ranger via 1.5cm lengths of wire. The board is powered through 5cm long supply wires connected to a breadboard. The breadboard is in turn powered from USB (eeZee Power) with 100uF tantalum bypass capacitor.
Sharp IR NoiseDespite a 10uF tantalum bypass capacitor very close to the ranger's supply connector, the oscilloscope shows supply voltage dips on the order of 0.1V at 200Hz measured at the ranger connctor.
These dips almost certainly correspond to current draw from the ranger's infrared LED.
Why 200Hz? So the ranger can bandwidth filter on that frequency to eliminate interference from other sources, most likely. Much as an IR remote typically runs around 40kHz. These rangers do work outside in sunlight, after all.
Pulses of 20mV occur on the signal line at the same times as the power supply dips suggesting that whatever internally generates the analog voltage is affected by the power supply.
Next I tried adding a 10 ohm resistor in series with a 10uF capacitor in parallel. This should isolate the ranger noise from any upstream circuitry.
The power supply waveform changed to a typical RC charge/discharge curve and the maximum swing increased to 1.2Vp-p.
Or rather, the lowest voltage was lower than before as you can see by looking at the scope grid. That makes sense with the series resistor in play. I would expect to see (but didn't check) that the other side of the resistor shows attenuated noise.
Something I didn't notice at first was the intermittent nature of the 200Hz pulsetrain. Here I'm using a 10uF bypass cap across the signal and a 100uF bypass across the supply. No series resistor.
The datasheet indicates the sensor samples at approximately 40ms intervals which matches my scope measurements of 8 divisions at 5ms/div. The ranger runs the LED for a period, then stops and generates a new output voltage.
You can see the output voltage changing in sync with the LED off period, below. (Sorry for the blurriness; I was handholding the camera with a slow shutter to capture the whole trace).
The top trace is the supply voltage (with a slightly different filtering configuration) while the bottom trace, the output voltage, shows the voltage jumps in the LED off periods.
Both channels are set to AC coupling so I could see small noise on top of big DC signal. In that mode, as you might expect with a large capacitor inserted in series with the signal, you still see abrupt (high frequency) changes in DC voltage, but the trace deflection decays over time, as in the left side of the bottom trace.
Good Enough?I'm still working out the noise problem, just how much is tolerable, and eventually how to get good performance out of the ADC.
I've gotten the signal noise down to 5mV with a 10uF electrolytic bypass capacitor, and a 10 ohm / 100uF RC on the supply. But I'm just messing around at this point to get a feel for things.
Is 5mV of noise too much? By my calculations, the required voltage sensitivity of the GP2Y0A02YK at 140-150cm is about 2.6-3.0mV / cm.
To calculate the required sensitivity, I estimated data points from the datasheet and did a curve fit in Libre Calc.
So 5mV could be too much. Additional filtering could be done in software, with the ADC running at least 2 times the noise frequency per the Nyquist-Shannon sampling theorem.
Software filtering should be able to reduce the noise further. Whether through simple averaging, or by implementing a digital notch filter.