Almost everyone here is aware of the advantages of modulated IREDs for rejection of background IR fluctuations and line-frequency noise from artificial lighting. Typically, the IRED modulation occurs at 38 kHz, to which the integrated detectors are tuned and respond with a digital output. But what if you wanted to respond to more than one IRED at a time and, moreover, know the intensity level of the response from each? Such a question is the theme of this thread.
First, we need to delve into Walsh functions
. Walsh functions are the digital equivalent of the Fourier sine and cosine basis functions for decomposing waveforms into constituent parts. Unlike their sine and cosine counterparts, Walsh functions can take on only two values: -1 and +1. Like the Fourier sine and cosine basis functions
, the Walsh basis functions are mutually orthogonal. This means that, over one full cycle, the product of any pair of these functions integrates to zero. Also, as with sine and cosine functions, the average duty cycle of Walsh functions (except for W(1, 1)) is 50%, a desirable characteristic for modulating IREDs with them.
By modulating a set of IREDs, each with a different Walsh function, and using a single analog IR detector, it should be possible to sort out which IREDs the return signal came from, along with how much each one contributed to the response. To this end, I purchased six IREDs from RadioShack and mounted them on a QuickStart board, as shown below:
I replaced the 100K resistor packs in series with the touchpads with 100-ohm resistor packs, in order to drive the IREDs from the Propeller's P2-P7 pins.
For a sensor, I initially thought an IR phototransistor would work well with a sigma-delta input. Although phototransistors are notoriously slow, in the sigma-delta circuit VCE
would be held constant at about Vdd / 2, thus eliminating any slowness due to its Miller capacitance. Unfortunately, even in this circuit, the phototransistor was too slow for detecting modulated signals accurately.
In the end, I purchased an AMS (TAOS) TSL262R-LF
, which converts incoming IR to a voltage output and has a very fast response (at the expense of sensitivity). I mounted the sensor to the bottom of the board so as to avoid direct illumination form the rear of the IREDs:
The output of the sensor (powered from 3.3V) is fed into a DC-coupled sigma-delta ADC, populated on the QuickStart board using SMD resistors and caps. Here's a block diagram:
Each IRED is modulated with a different Walsh function, as shown above. With strong reflections coming from all six Walsh-modulated IREDs, here's what the output from the sensor looks like:
Now for some Propeller counter magic! The feedback output from the sigma-delta counter is combined XOR fashion with the outputs to the IREDs in six different counters, spanning three cogs. Remember that the feedback is a pulse train whose duty cycle is inversely proportional
to the signal coming into the input pin. So when the input pin is predominantly high (i.e. the output duty cycle is low) and an IRED pin is high, the XOR counter will add to phs
x. The same happens when both the input and IRED output are predominantly low. In other words, the XOR counter for any particular IRED is correlating the input signal from the sensor with the Walsh function driving the associated IRED to tell how much that IRED is contributing to it. Because the Walsh functions are orthogonal, the contributions from the other five signals will, ideally, sum to zero. The result is that each counter demodulates the signal only from its associated IRED.
In the attached program, the IREDs are modulated at 950 Hz (i.e. 1.053 ms for each of the 16 increments in a full Walsh waveform cycle). Each counter is sampled every eight full cycles, with the result of each sample poked into an array. These results can be displayed via the serial output, and they are also used to drive the blue LEDs on the QuickStart board with intensity proportional to the log of the response from each IRED. Here's a video that shows the result:
Some practical applications of this technique might include crude robotic "vision", where obstacles can be roughly located in the field of view and their distances approximated via the return signal strength. Another app might be a light curtain that uses Walsh modulation instead of physical baffling to isolate the different channels. In any event, it scratched an itch for me, wondering if it would actually work. Apparently, it does!