I had a chance to sit down a play around with the Maxbotics LV-EZ3 ultrasonic range finder. The EZ3 is a low cost, reasonably high quality range finder capable of measuring distances from around 6″ all the way up to 254″. The device is fairly straightforward and can output analog voltage, PWM, or serial data (although strangely, RS-232 not TTL). The analog output is the obvious choice, as I will be using my arduino board to interact with the device.

When I initially connected the device I was mildly discouraged. The values returned on the analog pin seemed slightly erratic. Too much so to even process a data sample. The MaxSonar-EZ1 FAQ recommended implementing a low pass RC filter using a .1uF capacitor and 1k resistor, which stabilized the output nicely.
The next step was to convert the data into inches so that it will be more useful to Terry. Analog voltages on the arduino range between 0 and 1023 and are scaled based on the analog reference input. The default analog reference is 5V. This means that 5V applied to the arduino’s analog input pin is interpretted by the arduino as 1023. The arduino also has the ability to use an internal analog reference of 1.1V on the ATMega168 microcontroller (2.56V on ATMega8) or an external reference that can be specified by applying voltage to the arduino’s AREF pin. Information on the arduino analog reference configuration can be found here. The Maxbotics EZ3 outputs a maximum of 5V, therefore I was able to use the default reference.
With the low pass filter functioning properly and the analog reference properly set, I was ready to convert the output into inches. The arduino analogRead reference page indicates that each unit (0-1023) represents 0.0049V, and the Maxbotics LV-EZ3 datasheet specifies that an inch is represented by 9.8mV (0.0098V). From there it was simple to translate the arduino’s analog input into inches: ((units * 0.0049)/0.0098).
The code seems to work flawlessly. The data doesn’t seem to vary
beyond an inch in either direction even without data sampling and when the unit is jostled around. I will, however, likely sample the data using a mode average that will return the most frequently occurring value in a given dataset. Tomorrow I will try to uncover an effecient algorithm for this, even though it’s completely usable as-is.




