Got hold of a new TOF sensor developed in cooperation with CERN. Official launch is only in a few weeks, but as we live the area someone had mercy on us to give it a try in advance. They claimed fast, accurate, low cost distance measurement and we wanted to put it to the test. Ultra sound is common, but does have some limitations for example surface structure, wide "field of view" and cross talk. We chose this project to see if the TeraRanger could handle a situation that ultra sound could not do. We chose balancing a polystyrene ball. The sensor measures the position of the ball on a balance. Depending on the relative position of the ball on the arm, a servo moves the arm up or down to bring the ball back into a central position.
Building a "Balance" out of wood is easy. A baseplate, two "towers" and the arm are quickly made out of scrap wood. The only complication was the groove on the arm so that the ball could run smoothly back and forth. The Post Tenebras Lab Hackerspace in Geneva is fortunately equipped with a CNC, so the challenge was easy to tackle.
The electronics are also simple. The sensor can easily be connected to an Arduino through a bread board. Connectors are small crimps but the wiring is documented in the user guide. We only needed to connect +12v, GND, and TTL Tx and Rx to the serial port.
There is a converter cable available to connect the sensor via Micro USB directly to a computer which we used to verify that the sensor was working. It outputs TTL serial directly at 115200 baud in either binary or text mode, as you choose. We opted for a direct link to the Arduino-compatible board (Teensy 2.0), as it has a hardware serial port available for connecting to the sensor. You really need to use a hardware serial port as we found problems with SoftwareSerial at speeds over 57600 – at least on the Arduino Uno that we started with.
A "faulty" power supply here at the hacker space caused a bit of grief, as the sensor had "jumpy" readings, which actually turned out to be a reset restarting the communications routines on the sensor. With the help of the forum, the root cause was eliminated.
On the programing I started with the servo driver from the Arduino library. Reading the sensor works well. Key challenge was to synchronize the output of the sensor with the reading speed of the Arduino. We did this through switching to binary output mode to make the reading speed more predictable and eliminating the delay from the example code on the servo output.
In addition, the balancing of the system took a bit of tweaking. In the initial attempts, the servo was too responsive causing the ball to bounce and causing damage on the linkage. I played with averaging the reading and reducing the leverage of the linkage on the arm. After a few iterations, it worked like magic. And we have already a few ideas what to try next.
Key Take Aways
The sensor works well in conditions where ultra sound does not work.
At 120 EUR it is not the cheapest solution but also not the most expensive.
The interfacing of the sensor to the Arduino is straightforward. It just needed care to ensure we keep reading the data fast enough to correctly fit into our specific project.
Hi awesome work, could it be modified to maintain a laser beam like this: https://youtu.be/nBmeqCOW5P8, if you could please contact me