Sonar behavior


I have been reading with interest the sonar usage (right sensor, etc.) because I had already purchased the previously recommended sensor (EZ0) but had yet to add it to my quad. After reading the posts by Maxbotix and others, I went ahead and took the plunge. I added a 100uF capacitor directly to the board (photo above) as recommended and put a 100ohm resistor on the +5V line.

I created a cable and hand-braided it in an attempt to eliminate as much noise as possible.  I know Maxbotix recommends a shielded cable but I didn't have any.  The cable is also a little too long.  I also temporarily mounted it to a paint stir and put it on the opposite side of the air-frame from the receiver.  But as you can see from this photo, it is darn close to one of the prop tips too.  But enough of that - how did it perform?

Here is the result of a test flight in pretty high wind.


3689508645?profile=originalThe red is the sonar height, the green is the barometer height.  At no time did the actual height get above 10m during my test.

First, I am continually surprised at how accurate the barometric height is.  Second, the sonar trace has some decent readings for much of the flight, but sometimes is has crazy readings.  I can't tell exactly what is going on here yet, but I'm going to track it down.  I know the sonar I have is ultimately too sensitive and is probably picking up things like the mailbox (which was certainly nearby).  Additionally, I wonder how likely it is to be hindered by heavy winds?

I'm going to do some more testing soon.  I want to shorten the boom to get it further from the prop.  If anybody has any testing methods they think are good for sonar units, please let me know.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • @Scott: We only saw these kinds of errors at higher altitude so you would need a pretty large stand (or maybe a balcony or something like that). Take care when powering up the motors because the I-part of the controllers can start accumulating and then bad things happen ;)

  • @Christian - agreed, that's what I'm thinking as well.  Algorithms can only take you so far and of course can result in bad behavior if your algorithm distorts reality far enough.  Hitting the mailbox because you disbelieve the sensor won't help.

    I'm thinking of setting up the sensor with a test bed and trying out things until I figure out what is going on.  Here is what I have thought of so far.

    Test setup - Quad on a stand (attached so it can't fly) and a measured distance from the ground.  

    First, I'm going to power up the quad but not arm the motors and watch the track, ensuring that the sensor measures right that way.  If it doesn't, then I can focus on what electrical interference are getting in there from the components powered up at that time (receiver, APM, GPS, etc.)

    Second, I'm going to arm the motors and spool them up, watching to see if it changes based on speed of motor, airflow from the props, EMI from the ESC/motors, etc.

    I'm looking for noise - either acoustical or electrical.  

    I note that @Gary mentions that trying to isolate the sensor acoustically from the quad around it was attempted but failed because the medicine bottle amplified the sound.  I wonder if that could be eliminated somehow.

  • We already tried a median filter with three values, which works to some extent and filters out single wrong values but a lasting error as at 14.4k lines in the log cannot be filtered that way. We are now trying to fuse the sonar with IMU values with a Kalman filter but it's not finished yet. But as Georacer said, this is the best (and EKF etc.) you can do. Nevertheless, it would be interesting to see where the error actually originates additionally to trying to cope with it.

  • @Georacer - thanks, that's exactly the type of thing I was thinking of - and I like the idea of tuning it based on how much delay you are willing to insert.

  • You could try a simple 1D Kalman filter, as described in this link:

    It introduces a small time delay, proportional to the "smoothing" you want to achieve.

    In general, the better you can describe your model dynamics in a Kalman filter, the better the noise rejection you can achieve.

  • I wonder if some hysteresis code could be written which helps smooth out really aberrant values.  I know we want real-time behavior because we're trying to avoid obstacles, but there is probably time to react.

    I'm thinking of storing a memory of about 3 values and dropping the middle one if it appears too far away from its neighbors.  This lets us ignore noisy samples.

  • We see the same behavior with an EZ0, too. We also added the RC filter but additionally, we use a shielded cable and even double-shielded it with aluminium foil. Especially the behavior at about 14.4k lines in your log, where the sonar suddenly jumps from about 400cm to about 130cm for several samples, is well reproduced. We did several measurements over plan ground (grass and concrete) but we don't really know what causes this behavior.

  • I am using the EZ0 successfully with the recommended RC filter and positioned away from ESC's (although I still had to shield the 2 closest ESCs with aluminum tape for satisfactory performance.

    And I still get periodic (excursions) on the SONAR graph although SONAR flight maintenance seems to be solid.

    The fact of the matter is that all of the Maxbotics sensors are sensitive to every possible type of noise,.

    Acoustic (Prop noise and turbulent prop wash), EMF from the ESCs or motors, electrical on the power lines and vibration in the air frame.

    That said, Robert LeFevre confirmed that the least noisy and most workable sensor is one of the EZ4 series which is limited to 7 meters and has the narrowest beam pattern of any of the non-horn type sensors.

    Using a shielded cable, the recommended R/C filter and mounting it under the center of the copter to avoid prop wash he achieved spike free results with the EZ4 and only the EZ4.

    It must be mounted well away from any ESC's and you may need to shield it with aluminum to minimize EMF from the ESC's.

    The shielded cable will help, braiding or twisting, not so much, both wires can pick up EMF.

    Finally, mounting it on double sided foam tape can minimize acoustic coup[ling of frame vibration.

    Also do not put a little thin plastic cup (medicine cup) around the sensor, the cup itself will pick up outside vibration and sound and amplify it to the sensor (you can guess how I know).

    SONAR can be made to work fine, but if there is any "noise" of any kind it will find it and read it instead of your altitude.

  • The recommended module changes daily.  Sometimes it's the HRLV-EZ, sometimes the XL-EZ, sometimes the XL-AE, sometimes the EZ0, sometimes the EZ4 sometimes the AE4.  It's not even clear if Maxbotix knows what all their products are or if the recommendations are just whatever is over stocked.

This reply was deleted.