Close
0%
0%

Terabalance

Abusing a fast time of flight sensor to balance a ball in real time

Similar projects worth following
A couple of us got hold of a new TOF sensor developed at 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. This sensor claims 1000 readings per second, with a straightforward zero calibration TTL serial interface that could (but had not yet) be used with microcontrollers like the Arduino. Let's see.

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.

  • 1 × TeraRanger One sensor
  • 1 × Teensy 2.0 board
  • 1 × 12v PSU 1A
  • 1 × Servo from the hackerspace box
  • 1 × Small Breadboard (typical Arduino proto)

View all 7 components

View all 2 project logs

Enjoy this project?

Share

Discussions

CarlEnglish wrote 07/17/2018 at 19:45 point

Hi awesome work, could it be modified to maintain a laser beam like this: https://youtu.be/nBmeqCOW5P8, if you could please contact me

  Are you sure? yes | no

Rocketburns wrote 02/16/2015 at 23:21 point

is there a github repository or somewhere where I could view the code for this?

  Are you sure? yes | no

makegeneve wrote 02/16/2015 at 17:23 point

Hmm, we'll see if we have any lying around the lab...

  Are you sure? yes | no

Adam Fabio wrote 02/16/2015 at 07:04 point

Awesome work! While the servo works, I'd love to see how that balance would perform with something a bit smoother - maybe a brushless DC motor (similar to the gimbals used on many quadcopters)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates