Arducopter's Sonar-based Altitude hold works great

I have installed the recommended sonar sensor (XL-Maxsonar EZ4) on my custom-framed Arducopter. Using the ArudPirateNG code, I've been flying with the Altitude hold and it works great. I love it! It allows me to put the quad at the altitude I want, say five feet off the ground, flip the Altitude hold switch on my Tx, and then fly around at will at that altitude. This allows me to practice my yawing, pitching, and rolling without having to worry about crashing into the ground. (Still have to watch out for trees and buildings!). It's very cool. Thank you to the team!


I'm really looking forward to automatic take off and landing in the future, and also obstacle avoidance (using yet to be installed side-firing sensors obviously). I have included some pictures of how I mounted the sonar sensor underneath my quad. I have also included some pictures of the tiny EyeCam camera (made by DraganFly Innovations) that I installed on my arducopter. It transmits video in real-time back to a 9" portable screen and a small video receiver that I rigged up with a battery.













Views: 6008

Comment by Andrew Bailey on February 20, 2011 at 10:40am
OK, well it looks like I can stop it climbing like a homesick angel by reducing the PID's. Problem is that it is next to useless at actually holding altitude. Ho hum..  Unless anyone has a brainwave I think I will give up on the sonar for the time being. Thanks anyway for trying so hard Randy and for your help too Robert.
Comment by Rana on February 20, 2011 at 3:57pm
Robert, Great efforts in setting up such a wonderful quad frame, did you record some video ?
Comment by Robert Beatty on February 20, 2011 at 4:16pm

Thank you. I appreciate it. There are some more pictures of the frame in this earlier post:

Since those earlier pics were taken I've changed the motors and props, added the magnetometer, mini camera, sonar, and landing gear. Unfortunately, I don't have any video yet. I'll need to get an assistant for that. :)


Comment by Randy on February 20, 2011 at 8:08pm


     the only last thing that I can suggest is that either you have your throttle slightly too high when you engage the altitude control or your quad needs more throttle changes than the altitude control PID is set-up to handle.  If you look in Navigation.pde you'll see these two lines around line 185:


This controls the maximum amount that the PIDs will modify the throttle up or down from the point the throttle was at when you engaged the autopilot.  You could increase both numbers (maybe double them) to see if it helps.


I actually don't think this will work because you've already said your barometer altitude hold works and it has similar (actually slightly smaller) ranges.

Comment by John Hanson on February 24, 2011 at 11:28am
I have had good luck testing with the EZ-4. I have hade it maintain arelatively stable altitudes +- about 6" over grass, pavement, and surprisingly a pool cover that is a woven mateial you can see light thru. It is fun to go over rolling terrain as it will follow it. It seems much more stable than the baro hold. I occasionally have had it decide my height is about 6", just land and go up again to reset height.
Comment by MaxBotix Inc on October 19, 2011 at 1:17pm

Hello everyone,

MaxBotix Inc., saw your post so we decided to do some testing to help everyone see the difference in our ultrasonic sensors noise immunity.  


First I want to address some of the above information.  The text quoted below.  

I have the Maxbotix LZ EZ-4, the one with the widest beam.

Only afterwards i noticed a smaller beam was advised.

Any ideas how the wide beam would negatively affect altitude hold in our application?

Would it be usable ? Can the beam be tuned ?

I'm sorry, should be LZ EZ-0 of course


The narrow beam sensors are the more immune to noise.  The narrow beam sensor is the LV-EZ4 and the widest beam sensor is the LV-EZ0.  The wide beam sensors have a higher sensitivity and as such are more likely to detect noise when noise is present in the operation frequency of the sensor.  The LV-EZ4 sensor is a narrow beam sensor and as such is less sensitive to noise.


In some applications, users have been able to make any of our sensors work while others, only the narrow beam pattern like the LV-EZ4 would work.  


The reason we recommend the XL series of sensors is because of the noise immunity. Demonstrated in the test below, you will see they are significantly more  immune to noise than the LV series of sensors.  


MaxSonar Acoustic Noise Tolerance Test

MaxBotix Inc., felt it would be good to do a test of the sensor's ability to reject acoustic noise sources, because of the interest to use the MaxSonar product line for use in the presence of acoustic noise.


Below are the LV-MaxSonar-EZ sensor thresholds, where the noise began to affect the sensor, (ie. the noise caused one incorrect reading, out of 100 range readings). The LV-MaxSonar sensors provide decent noise tolerance. (Range to 9cm dowel provided for reference.)


Below, the extra acoustic noise tolerance of the XL series is readily apparent. Users needing the noise suppression along with the extra sensitivity are encouraged to use the XL-MaxSonar sensor line.


Here are the XL-MaxSonar-EZ/AE sensor thresholds, where noise the began to affect the sensor, (ie. the noise caused one incorrect reading, out of 100 range readings). (Range to 9cm dowel provided for reference.)


The test was setup to evaluate the real world use of the sensors, to allow comparison between MaxBotix Inc., sensors. A noise source was used that produced a pulsating acoustic source of 30KHz to 50KHz with a sweep at a 60Hz rate. This caused large spikes of noise within the sensor frequency band. The acoustic noise source was placed about 50cm to the side of the sensor under test, with an output up to 120dB. This acoustic noise source was setup to direct the energy towards a large flat target, (which would then be reflected back t

Comment by MaxBotix Inc on October 19, 2011 at 1:19pm

to the sensor under test). A large flat target was placed 1.5 meters from the sensor. This target at 1.5 meters allowed the sensor to report 1.5 meters as a valid target. The noise source output was increased until the noise just began to change the sensor output; the noise level was then decreased until no incorrect readings occurred, and this was recorded as the threshold.



Note: *Decibels (dB) are reported on a log scale. A passing train at 30 meters is ~90dB, and a passing train at 1 meter is ~105dB.
*Our sensors are sensitive to noise above the human range of hearing so this is provided for reference only.


Please let me know if you have any questions by email me at


Scott Wielenberg
Technical Support & Sales
of MaxBotix Inc.

Phone: (218) 454-0766
Fax: (218) 454-0768


Comment by Randy on October 20, 2011 at 4:49am

This is a great piece of information!   Nice testing as I guess would be expected from a professional organisation.

I hope people can find it hidden away on this old post (of course I found it so maybe they will) and I guess you might add this to your product PDF some day in any case.

Thanks again!

Comment by srinath reddy on December 27, 2011 at 10:36am

hello every one..

1.i have got the same problem as andrew. as soon as i switch the quad to alt hold mode it climbs up very fast.i have tested the sensor in the cli mode. i got pretty decent distance values. ihave also tested the sensor using arduino and got the same distance values. i have used a lv ez4 and apm with 2560. i have been trying to solve the problem but i am not able to understand where the problem is comming from. i used ardupilotplanner.

2. i want to try the ardupirates code.but i donot know whether ardupirates code supports 2560.

thank you

Comment by MaxBotix Inc on January 4, 2012 at 12:02pm

Thanks for the comment.  I did some searching on the forum here, here is a link to that talks about the reading the distanstance.  I hope this helps you.  Please let me know if you have any questions.  

Best regards,

Scott Wielenberg
Technical Support & Sales
of MaxBotix Inc.
Phone: (218) 454-0766
Fax: (218) 454-0768


You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service