When you wanted to measure a distance at a precise location, there wasn't, up to now, any middle range between very expensive laser telemeters (of the Baumer type) and cheap sensors (of the Sharp type). These cheap sensors don't provide a real measured value and are very limited distance-wise. Therefore, we were particularly interested in the LIDAR-Lite project which announced a distance measure of several meters for under $100. Nine months later, the baby is here at last and we can test the final version of the product to try out this new technology.
The most complete way to exploit this laser distance sensor is to use a I2C interface. But as we don't have a generic Yocto-I2C available yet, we used the alternative interface of the LIDAR-Lite, based on a PWM signal.
Connecting for PWM
The LIDAR-Lite requires a 5V power source: we connect the red wire to the 5V source, and the black wire at the opposite end to the ground. Now if you link the 3rd wire towards ground going through a resistance, the sensor will perform continuous measurements and advertise the measures using square pulses on that wire. The duration of the pulses in milliseconds corresponds to the distance in meters.
Connecting a LIDAR-Lite to a Yocto-PWM-Rx
The test: an invisible harp
Have you heard of the laser harp? It's an electronic instrument. You play it by interrupting its laser rays with your hands. On the same principle, we are going to try to build an invisible laser harp with the help of 10 LIDAR-Lite telemeters which sound a note depending on the measured distance. By splitting the space into ranges, we can even multiply the number of available "keys" for playing notes.
Yoctopuce laser harp took no more than a few hours to build
The 10 telemeters are connected to 5 Yocto-PWM-Rx controlled through the network thanks to a YoctoHub-Ethernet powered by Power-over-Ethernet. To transform the measures into sounds, we programmed a few lines of code linking the Yoctopuce library, able to read the sensor over the network, with the fluidsynth library, able to play notes.
Technically, this test is a success. Except for compiling fluidsynth under Mac OS X, which was a bit of a pain, the making and the coding of this project are very simple and the instrument works out of the box. The LIDAR-Lite sensors provide indeed usable distance measures, much more reactive and pin-pointed than what you would get from a sonar. The ten sensors side-by-side at 10cm from each other work without mutual interference, and are perfectly able to discriminate the hand that moves in front of them at 1m50.
The only problem we have met once or twice with the sensors: when we had by accident an obstacle very near to the sensor (in PWM mode), it did sometime switches into a mode where measures were no more reported. In this case, a power cycle would make it work normally again. Most probably, that issue would not have happened in I2C mode, but this will have to be verified.
From a musical perspective, the result of the test is more so-so. As we are ambitious, we have designed the instrument so that the "lower keyboard" on the left hand selects the harmony (in the Bontempi 70's style), while the "upper keyboard" on the right hand plays the melody. In the real life, this instrument is awfully hard to play because there is no mark to help placing the hands in the right spot. After half a day of training, and several attempted homicide from my colleagues, here is what we finally managed to get:
If you want to have a look at the source code of our laser organ, it is available here.