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


  • The only downside of this is that it's more prone to get mechanically damaged during a hard landing.

  • Thanks!  I like your idea of putting the sensor like that - I bet many will be able to put the sensor near the landing gear (even a little off-center would be OK I suspect.)

  • Here you go:

    3692659460?profile=original3692659228?profile=originalThe Raspberry Pi controls the Ardupilot and does the sensor fusion. The ESC only supplies power for the Raspberry, so it's not a Raspberry Pi-based ESC.

  • @Christian - great to hear and very encouraging!  Any chance you might have a picture of the new sensor placement?

    And is there a link to the details about a Raspberry PI-based ESC that you've built?

  • We did some further experiments regarding cabeling and sensor placement. We found that the shielded cable itself work pretty well, only minor disturbances werte introduced by nearby electronics. What we totally underestimated was the fact that the sensor itself is prone to interference because it is not shielded. The placement of the MB1240 as shown in the pictures was the worst possible because it is located next to two ESC, one of which supplies a Raspberry Pi with 700mA from its 5V internal regulator. Putting the sensor far away from electronics cured most of our problems. We build a new set of landing gear which enables us to put the sensor about 3cm under the battery and the cable as far away from other cables and electronics as possible. Now we have a very nice signal.

  • We now implemented the Kalman filter (credit for the implementation goes to We used the OpenCV Kalman filter implementation and fused IMU and sonar. This gets rid of a lot of noise and some of the strange problems. But as discussed it only cures symptoms and doesn't solve problems. For sonar values above 6m we see the expected measurement errors when the sonar detects the pulse sent one measurement earlier but for hights above 6m, baro takes over anyways.

    boehmdav - Overview
    boehmdav has 4 repositories available. Follow their code on GitHub.
  • @Christian - thanks for the pics.  You have better placement than me, better vibration damping, and better cable shielding.  Oh and of course you're using the better sensor.  Maybe Tom @ Maxbotix will be able to help.

  • The problem is not the noise in the sensor readings, this doesn't affect alt_hold too much as Gary said. The problem are the longer segments of wrong sensor readings from 4m to 1m etc. because then the copter does a pretty big jump in altitude (about 3-4m or something like that) and when the sensor then gets correct values again it drops hard and if you are unlucky, the copter ends up getting stuck in a big oscillation which can easily see it crashing hard. I already damaged several copters badly this way. And it's a big problem indoors, obviously..

  • @Gary: Here's the copter I did the two flights with:


    3692650422?profile=originalOn these pictures, both MB1200 and MB1240 are mounted but only MB1240 is connected. It is a rather tight fit with ESCs close, but both use shielded cables with wire mesh and aluminum foil. Vibration damping is not that good because there is not enough space but we could change the feet to get more ground clearance.

  • MR60
    Thx for the lonk Gary. Indeed model ae/xl MB1240 seems best,although the 1260 i got has a longer range , but less noise tolerance. I guess that it would not make a big difference. I am very sarisfied with the way my quad holds alt, rock solid.
This reply was deleted.