Range Finders

Download this tutorial's presentation PDF

Range finders are sensors that are designed to find the distance between the sensor and an object obstructing the sensor's beam. The beam may be composed of infrared or sonar signals. Sensors return either an analog signal that must be interpreted or a digital signal. Range finder sensors are critical to robotics movement and control algorithms. It is important to note that all sensors must be "configured" to read real-world distances: a function must convert from analog to a real-world distance.

Analog Reading
The Arduino supports six built-in analog input pins. In our below example, we have the red cable to the 5V pin, the black cable on the Gnd pin, and the yellow signal pin on Analog In pin 0.

To read an analog signal on the Arduino, we will be using the int analogRead(pin) function.

Source(s): Source Code solutions

From here you are able to save sample range values and, using the methods listed below, configure your sensor.

Sonar Sensors


Sonar sensors use ultra-sonic sound pulses to find an object. Based on the time it takes for the pulse to return, it returns the distance of the obstructing object in an analog signal.

The benefits of sonar sensors is that they are indifferent to light and color, and have a large field of view. Sonars are perfect for avoiding general obstacles. Sonars are sensitive, but are less sensitive to picking up interference to sound relative to environmental effects.

With most sonar sensors there are certain conditions in which you should be aware of. Some sonars have a large cone, which means that it's angle of field of view is large and can receive false-positives from obstructions such as the robot it-self or even the ground the robot is on. In our case, the sonar has a narrow cone and long field of view which is still efficient enough for general use but limits any possible errors.

Sonars, similar to IR, are interfaced with the same three basic cables: Power (red), ground (black), and the signal (yellow). The club is currently using the LV-MaxSonar-EZ1. Some advanced sonars interface through other protocols, such as IIC. This specific sonar sensor provides a multiple methods of interfacing with extra functionally and different calibrations, but are not covered in this article.

Conversion Function
The sonar sensors are easy to implement in hardware as well as in code since they follow the exact same instructions are the above mentioned IR sensors. The except is that these sonar sensors have a linear relationship between distance and voltage. This means that for every 10 mV returned by the sonar, it is about 1 inch in distance.

IR Sensors
IR sensors, well documented on Acroname's page, are infra-red devices that calculate distance based on the angle of the returned IR beam. IR sensors are more sensitive, have faster response time (speed of light is faster than sound) and are more accurate (due to a narrow field of view) than sonar. The negative aspects are the that they have a narrow field of view, can receive interference from other IR sources (sun, incandescent light bulbs, etc..), as well as return erroneous values for certain textures/colors (such as black). Other factors to consider in the usage of IR sensors is that they return an analog signal that is not linear to distance. An interpolation, documented below, must be done to obtain accurate data.

Most IR sensors have three interface cables: Power (5V), Ground, and Signal. The standard IR device used in the club is Sharp's GP2D12. See the data sheet here.

Three cables come from the sensor: Source (Red), ground (Black), and signal (Yellow). Connect the source (red) cable to Vdd (Positive supply, typically +5V) and connect the ground (black) cable to Vss (Negative supply, 0V). Please note that this device typically pulls 33 to 50 mA. The signal cable (yellow) is connected to in different ways for each Microcontroller.

Conversion Function


As mentioned above, the given signal is non-linear. To correct this, you should manually calibrate each IR sensor. To do this, we will setup an experiment to collect multiple data points in excel, graphing the actual distance measured by hand versus the returned analog value. By doing this, we will be able to find an equation that takes the analog and returns the distance. Certain close-range distances will return erroneous values, such as any distance smaller than 10 cm. Certain distances beyond 80 cm can also be considered erroneous.

Once the graph is built, use the solve function in Excel to generate a exponential best-fit line. Remember to remove erroneous points as mentioned above. In the sample image to our right, we generated an equation for our best-fit line, and solved it as an equation used in our calibration function code below:

Other Sensors
Many other sensors exist such as laser-range finders, Light Detection sensors, sound (microphones), Line Detectors, etc. Even simple devices, such as Bump Sensor, are types of sensors. Read more about these sensors throughout the RoboWiki.

= Building Schedule =

If you or your team are building for a specific robotics competition during a semester format, make sure you follow our Tabletop Design Schedule. Contact any club executive to learn more about differences in the schedule for your respective semester.

= Links =


 * Acroname's overview of IR sensor technology
 * Arduino Home Page
 * Arduino Programming Language Overview
 * MaxBotix sonar sensor web page
 * UV Tron Detector Package
 * ITP Sensor Workshop UV Tron Overview