MaxSonar-EZ1
Frequently Asked Questions (FAQ)
Index
1) What
motivated Maxbotix to design, build, and market the MaxSonar-EZ1?
2) The MaxSonar-EZ1 range repeatability seems better than competing
sensors. How is this possible?
3) The beam width is much narrower than competing sensors. How is
this possible?
4) How can a single sensor detect all the way to the front face?
5) How does the the signal system in the MaxSonar-EZ1 work?
6) How can I use more than one MaxSonar-EZ1 in the same system?
7) What is the beam width of the MaxSonar-EZ1 in degrees?
8) How can I get the best possible accuracy from the analog output?
9) Tell me how serial, pulse width, and analog voltage outputs
compare.
10) Tell me more about the repeatability and accuracy of the
MaxSonar-EZ1.
11) How far away does the MaxSonar-EZ1 detect people?
12) Code example for BasicX, BX24p.
13) Code example for the Basic Micro, Atom.
14) Code example using Wright Hobbies, DevBoard-M32 (AVR using
Bascom).
15) Code example using Parallax,
Basic Stamp BS2.
16) Where is the "User Manual"?
17) More to come...
ˇ@
|
| ˇ@ |
1) What
motivated Maxbotix to design, build, and market the MaxSonar-EZ1?
One of the reasons this sensor was completed was because my
daughters robot was stuck on a wall (it was too close) during a
contest. The sensor that was on the robot was one of most popular
two sensor models, but when too close, it was blind. (In all
fairness, this sensor, was not that bad... just wanted something
better!)
One of all the (other) popular robot
ultrasonic sensors were then evaluated. The goal was to find a
solution to the range sensing that didn't cost much and wasn't
big. Purchasing and evaluating a sample of each, below are some
of the things we discovered.
The dual-sensor models beam-widths were much too wide. The
(worlds smallest?) dual sensor model has a beam width so wide that
it detects a wall, a full 180 degrees, one meter away. It seemed
unusable, without a great deal of effort.
The other dual sensor high end range sensor with I2C readings,
vary so much, during the first one meter, that it was not uncommon
to have its readings vary more than 6 cm and sometimes 15 cm. It
also had a beam width that was over two meters wide just one meter
out. Again the beam width seemed too wide to be useful in a home,
or to "look" down a hall, or to use at a long distance.
Another recent dual sensor model has a narrow beam width, but
seems to have trouble with small objects and the sensor has a
comparatively short range.
The expensive (about $100) two-inch round models had a high
current draw, and were larger, especially if using on a small
robot. (These round ones actually worked though, but the audible
click can be annoying.)
I found I could not purchase a low-cost, small, low-power sensor,
that actually provided narrow long-range detection, with a stable
range output.
The MaxSonar-EZ1 is an original design, designed to overcome the
above mentioned problems and more. The MaxSonar-EZ1 is very easy
to use and works well.
2) The MaxSonar-EZ1 range
repeatability seems better than competing sensors. How is this
possible?
It is true that the MaxSonar-EZ1
range repeatability is very good. The complete signal system in
the MaxSonar-EZ1 was designed from the ground up to perform the
task of extracting the proper distance within a narrow detection
cone.
3) The beam width is much narrower
than competing sensors. How is this possible?
It is true that the MaxSonar-EZ1 beam width is very narrow, yet
the MaxSonar-EZ1 is still able to detect small objects. Competing
sensors either suffer from a short detection range, or the sensor
detection pattern is very wide. The complete signal system in the
MaxSonar-EZ1 was designed from the ground up to perform the task
of extracting the proper distance within a narrow detection cone.
4) How can a single sensor detect
all the way to the front sensor face?
The MaxSonar-EZ1 can detect even small objects up to and touching
the front sensor face. The complete signal system in the
MaxSonar-EZ1 was designed from the ground up, and one of the goals
was to be able to detect objects in the so-called ˇ§dead zoneˇ¨.
The MaxSonar-EZ1 does not have a dead zone. The signal system
can detect up close objects by detecting changes in the ring down
pattern and thereby know that an object is within the field of
view. Additionally, the back of the MaxSonar-EZ1 transducer is
potted to reduce the effects of the ring down.
5) How does the signal system in
the MaxSonar-EZ1 work?
The signal from the transducer is amplified by a bandpass-filter/amplifier,
followed by another bandpass filter/log-amplifier, followed by an
integrator with integrated gain, followed by an analog to digital
converter integrated in a microcontroller. This system yields
continuously variable gain from less one to over 1000. The
microcontroller continuously performs signal processing techniques
to extract the distance. Some users have asked for finer
resolution, but the time between readings is used by the software
to evaluate the signal. This type of circuit performs much better
than simple comparator thresholds, single gain, or switched gain
type circuits.
6) How can I use more than one
MaxSonar-EZ1 in the same system?
When using just one sensor you can just let it range
continuously in free run mode.
This is very easy and works very well.
6a) Free run all Sensors
(not recommended)
Continuous free run operation will generally not work when using
more than one sensor in the same system. Let's discuss what
happens. If you leave the RX pins unconnected on both devices so
that they range continuously, at start-up they will range at
exactly the same time, however they aren't synchronized and will
range with slightly different intervals. Slowly but surely the
devices will stop ranging at the same time. These frequency
drifts will likely cause interference between sensors for most
applications. If looking at the analog voltage output from the
MaxSonar-EZ1, this will appear as voltage noise that occurs at
some regularly occurring rate. Additionally, the digital outputs
will have phantom readings at some regularly occurring rate.
6b) Tie RX lines so Sensors Range
Together (works for most instances)
Start all MaxSonar-EZ1 sensors at the same time by pulling high a
single line connected to all RX lines will work for most
applications. The MaxSonar-EZ1 has continuously variable gain and
this will allow this method to ignore (in most instances) adjacent
sensors. This method is especially convenient when using the
analog voltage, as the analog can be read at any time (i.e. the
user does not have to wait for the output).
6c) Sequentially Read each
MaxSonar-EZ1 (always works)
Only start one device every 50mS. This allows each device to
range only after the previous has finished. This method will
always work. There will not be any interference between sensors,
but ranging frequency drops by the factor of "the number of
sensors used".
7) What is the beam width of the
MaxSonar-EZ1 in degrees?
Many users have asked for the beam width of the the MaxSonar-EZ1.
For any ultrasonic range finder, the beam width is a function of
the sensor used and the system gain following the sensor. System
gain for the MaxSonar-EZ1 gain is actively and continuously
adjusted by the MaxSonar-EZ1 system software to yield a long
comparatively narrow beam.
The figure below shows the target detection angle of the
MaxSonar-EZ1. Most objects are detected in the central 36 degree
zone. The actual detection zone, is a cone that, extends from the
front of the detector face.

The actual gain was tuned during the engineering design phase to
yield long narrow detection of a 1" pole, yet still be able to
detect soft targets (such as an open hand) up close, and a person
for a considerable distance. Side lobes would generally be
apparent, but were removed by software during this phase of
development.
8) How can I get the best possible
accuracy from the analog voltage output?
First, many users have reported that this is the interface of
choice for them. In addition, from these users we have heard that
the analog voltage output agrees with the other outputs. This is
true for most users because the MaxSonar-EZ1 sets this voltage to
within 5 mV, twice the accuracy required.
But if in your application the MaxSonar-EZ1 analog voltage output
has noise, there is an easy way to remove the noise on the analog
voltage output. Place a 0.1uF capacitor near/at your analog to
digital pin directly to your ground. Next place a 10K ohm
resistor in series with the analog voltage output from the
MaxSonar-EZ1 to the 0.1uF capacitor. The time constant for this
circuit will be 1mS. This will cause a 5mS delay to allow the
voltage to settle. For slower readings and slightly less noise
the resistor can be increased to 100K ohms and this will cause a
50mS delay. (If you are technical please read the sections
following this answer for the reasons why this might be needed.)
9) Tell me how the serial, pulse
width, and analog voltage outputs compare.
The serial digital output and the pulse width outputs are taken
directly from the time of flight measurement. They will have no
additional noise present on them and will be the most accurate.
Concerning the analog output, most users have reported that the
analog output agrees exactly with the other two outputs.
This said, it is possible for the analog output to have additional
noise coupled onto the output. Letˇ¦s describe how the analog
output section of the circuit works. The analog voltage is set by
the microcontroller on the MaxSonar-EZ1 to within 5 mV as measured
by the analog to digital converter integrated in the
microcontroller. The voltage is held in a 1uF capacitor and very
little drift occurs between measurements. (In addition, if the
range measurements are stopped, the microcontroller maintains the
last analog voltage at the correct level.) Next, the voltage is
buffered by an opamp. The opamp is a very low cost amplifier and
does have some inherent offset and non-linearity. This offset
and non-linearity is repeatable, but it will introduce some error
in the readings, but will not cause the non-repeatability
mentioned above. So the analog voltage is ready to be read by an
outside circuit. Below is plot of the analog voltage for a few
range measurements captured on a digital oscilloscope. The
voltage on the output was multiplied by 100 (i.e. divided by 0.01
volts per inch) to yield inches.

Back to our question, if the outside circuit is a handheld
multimeter, the voltage will, in general, appear very stable
because most meters of this type integrate the voltage for 0.1
seconds and virtually all noise will be eliminated. So a
multimeter will function very well to display the analog voltage
and the corresponding range, except for rapidly changing ranges.
If the voltage is read by an analog to digital converter then the
readings may appear to jump around, but the reason is not because
the correct voltage is not present at the output of the
MaxSonar-EZ1. Instead the problem is that noise is added to the
readings. If the voltage is read deferentially at the connection
pins to the MaxSonar-EZ1, then the reading will also be fairly
stable. The filter mentioned above in answer for question 5 would
not help if placed on the MaxSonar-EZ1. The filter needs to be
placed near the analog to digital converter that is doing the
measurement.
10) Tell me more about the
repeatability and accuracy of the MaxSonar-EZ1.
As an object is moved away or towards the sensor, in
general, the MaxSonar-EZ1 will only switch between two values, and
this occurs as it is going though the transition from one inch to
the next.
Making a sensor as small as the MaxSonar-EZ1 involves some
compromises. Instead of a crystal oscillator, the PIC
microcontroller internal RC oscillator is used. Although the PIC
clock is accurate, we have found that it is better to calibrate
the microcontroller clock at the Maxbotix factory to within 1%.
Even after calibration, the internal RC clock may drift from this
calibration value by another 1%. Other factors affect accuracy,
like temperature, the size of the object detected, and the texture
of the object detected.
11) How far away does the
MaxSonar-EZ1 detect people?
The MaxSonar-EZ1 will detect a person (an acoustically soft
target) to 10-feet or more.
12) Code Example for the BasicX, BX24p.
www.basicx.com
'BX24
'MaxSonar-EZ1 Code Example
'By Chris Harriman
'01/09/2006
'The program below continues to read the MaxSonar-EZ1
'It uses the AD to read, and debug to output the data.
Const RX As Byte = 10
Const AN As Byte = 13
Dim AnalogOutPut As Byte
Dim SerialOutPut As Byte
Dim PWOutPut As Byte
''**********************************************************************************************
Sub Main()
Do
AnalogOutPut = RangeA
' Get the Range
Debug.Print "Analog " &
CStr(AnalogOutPut) ' Print the Range
Call SLeep(512)
Loop
End Sub
'**********************************************************************************************
Function RangeA() As Byte
' Reads the Analog output of the MAXSonar EZ1 (AN Pin) and
returns the target range as a Byte
Dim AValue As Integer
Call PutPin (RX, 0)
' Turn off the EZ1 just in case we started
with it on
Call PutPin (RX, 1)
' Turn on the EZ1
Call Sleep(40)
' Wait about 50 ms
AValue = GetADC(AN)
' Read the ADC
RangeA = Cbyte(AValue \ 2)
' Convert value to Byte and return
End Function
'**********************************************************************************************
13)
Code Example for the Basic Micro Atom.
www.basicmicro.com
'BasicAtom
Code
'Reads MaxSonar-EZ1
'Bob Gross
'01/14/2005
'5V connect to +5V
'GND connect to common
'TX, connect to Atom P7
'RX, connect to Atom P5
'The RS232 data will be sent when the reading is complete,
'This is very fast when an object is close.
'Only four lines of code required
RS232Data var byte
'Set up variable to
hold the data
High P5
'Hold high to
start the reading
SerIn P7, n9600, [WAIT("R"),
dec RS232Range ] 'wait for "R" and get the data
Low P5
'Set low when
complete
14) Code example using DevBoard-M32 (AVR using Bascom)
www.wrighthobbies.com
'Using the
MaxSonar-EZ1 with the DevBoard-M32
'By Eddy Wright, Wright Hobbies Robotics, 2006
'http://www.wrighthobbies.net
'We will read both the analog and serial outputs of the MaxSonar
'The M32 A/D converter has an internal voltage
'Reference of 2.56v which is perfect for output
'of the MaxSonar - 2.55v
'The analog output (AN)of the MaxSonar is connected to
'Port A.0, the ADC Channel 0
'The serial output (TX) is connected to to Port D.7
'Each loop, we read the analog and serial values
'This code can be used with any AVR with ADC that is supported by
Bascom
Dim
Dist As Word , Strdist As String * 8 , Serdist As Byte
'Config the softare UART,
we need to use the INVERTED option with the MaxSonar
Open
"comd.7:9600,8,n,1,INVERTED" For Input As #1
'Configure ADC
Config Adc = Single , Prescaler = Auto , Reference = Internal
Start Adc
Do
Dist = Getadc(0)
Shift Dist , Right , 2
'The M32 has 10bit ADC, shifting
it twice makes it 8bit
Input #1 , Strdist Strdist = Right(strdist , 3)
'Strip off the
letter R
Serdist = Val(strdist)
'Convert
to a number
Print "Analog Distance = " ; Dist ; " Inches"
Print "Serial Distance = " ; Serdist ; " Inches"
Loop
15) Code Example using Parallax Basic Stamp BS2
www.parallax.com
'Reads both the PW and serial outputs
' {$STAMP
BS2}
' {$PBASIC 2.5}
' www.danderrick.com/maxsonar
' permission for unlimited use granted to all
' First test of the MaxSonar-EZ1
' micro µ
' ------- P PINs -----------------------------
pMaxRecv PIN 15
pMaxClock PIN 14
pMaxPWM PIN 0
' --------------- X Variables -----------------
xDist VAR Word
xPulse VAR Word
xX VAR Byte
' ============ Main loop ================
DO GOSUB sPWM
GOSUB sSerial
DEBUG CR, CR
PAUSE 50
LOOP
END ' never
reached
' ------------- Subs ------------------------
sPWM: 'Max sends 147 µs
per inch
'BS2 reads for 2 µs
FOR xX = 1 TO 5
HIGH pMaxClock
PULSIN pMaxPWM, 0, xPulse
LOW pMaxClock
DEBUG DEC5 xPulse, " "
PAUSE 50
NEXT
DEBUG CR
RETURN
sSerial:
FOR xX = 1 TO 5
SERIN pMaxRecv\pMaxClock,
16468, [WAIT ("R"), DEC xDist]
DEBUG DEC5 xDist, " "
PAUSE 50
NEXT
DEBUG CR
RETURN
' -------- Physical end of file ------------
16) Where is the "User Manual"?
The user manual was
mentioned in the frist data sheets when Maxbotix believed that
additional information would be placed in a user manual. Maxbotix
can respond to the users much more quickly by using this
Frequently Asked Questions (FAQ) format and has decided to use
this format indefinitely. We apologize that it is not as concise
as a user manual would be, but it is current, and as questions
come in, it is updated.
ˇ@
|
ˇ@ |