Sonar ALT_Hold Issue


Hello there,

Yesterday, i added a new senor onto my quad, MaxSonar MB1260 XL for better altitude hold. Before attaching and re-uploading the ArduCopter 2.7.3 onto the APM 2. I erased and reset the board. And then attached sonar as described in the wiki manual. And uploaded the code and followed all initial steps (Of course i enabled the sonar). Everything went smooth. 

Next step, time for test fly. It flew great in Stable mode. However, as soon as i toggled the ALT_Hold switch ON. Quad started acting strange. It kept climbing higher n higher and suddenly dropped out of nowhere. Luckily i managed to control by toggling the switch back to stable mode.

I have checked everything couple of times now. All connection looks good. Mission Planner looks ok. I don't know what the problem. Your help would be so much helpful. I have attached couple of videos below. Please take a look at them. If you need any other information let me know. Thank you.

Quad Setup:

  • DJI F450 Frame
  • HackerStyle 20-22L Motors
  • Turnigy TY-P1 25Amps ESC (Flashed with SimonK firmware)
  • ArduCopter 2.7.3
  • MB1260 XL - Sonar 
  • 4000mah 20C 3Cell Battery
  • DX7 with AR7000 
  • Using one of four ESCs to provide power to the APM 2. 








E-mail me when people leave their comments –

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

Join diydrones


  • Hello! This is Tom Bonar from MaxBotix Inc.

    @Thor Larsen


    1. Electrical noise & proper shielding and grounding.

    2. If you don't fix the noise problems or they aren't sure how. swith to the MB1220 Hardware gain of 1000 vrs hardware gain for 4000

    3. Propwash can occational noise. 


    I saw your forum post and I saw you were having issues with flying over grass.  When flying over grass, there are a lot of factors in play that will effect your ultrasonic ranging.  

    Electrical noise is one of the biggest contributing factors to unstable range readings with the MB1200 ultrasonic sensor.  If a noise filter ( and shielded cable ( are not being used in your system, and wired properly, electrical noise can effect range readings.  If your control unit is not supplying stable power, the sensor's reported range scaling will change, and your control module will record an inaccurate range.  Proper connection of the shielded cable and ground, are extremely important.  

    The ground on the shielded cable need to be connected to the ground on the control module, not on the sensor's ground.  Connecting the ground on the shielded cable to the sensor's ground will not make the supplied power to the sensor or the signals from the sensor better.  This will add the signal noise on the shielded cable to the sensor.  By connecting the ground on the shielded cable to the control module, electrical ground noise is brought away from the sensor.

    If correcting the ground, power, and shielding do not correct the unstable range readings, you may wish to consider using an MB1220.  The MB1220 has a hardware gain of 1000, verses the MB1200's hardware gain of 4000.  The high gain of the MB1200 makes it more sensitive to outside interference.  The lower the hardware gain is, the less likely it is to be effected by outside noise and interference.

    Acoustical noise from the prop wash of your multi-copter may be a contributing factor.  Prop wash can have ultrasonic noise that interferes with the range readings reported by the sensor.  The prop wash from your sensor is also causing the grass that you wish to range to, to move in different directions. This movement causes the grass to reflect sound away from the sensor.  When this happens, the sensor will report maximum range.

    You stated that you were trying to fly your multi-copter over carpet, or range your sensor over carpet. If your carpet is soft, such as the shag carpet from the 70's, the sensor may not be able to range to it. The reason being, is the carpet is a soft target that is absorbing the ultrasonic sound that is sent from the sensor.  If your carpet is dense and thick, your sensor may not be perpendicular to the carpet, the carpet is reflecting the ultrasonic sound away from the sensor.

    MaxBotix Inc., engineers have recently bench tested a quad-copter for use with our ultrasonic sensors.  They have found that the MB1240, MB1340, and MB1242 had the best performance with quad-copters.  The reason being, these are are least sensitive sensors to outside acoustic noise, such as prop wash and mechanical noise.  We hope to have this engineering test published to our website in the next several weeks.  If you wish to have the preliminary write up, please email us and we will supply it to you.  Being the evaluation write-up hasn't been finalized yet, I can not publish it on a public forum.

    Please let me know if you have any questions.

    Best regards,

    Tom Bonar
    Technical Support
    of MaxBotix Inc.
    Phone: (218) 454-0766
    Fax: (218) 454-0768

    Follow us on Facebook at:

    Technical support and sales are subject to
    the terms and conditions listed on our
    website at MaxBotix,
    MaxSonar,EZ0, EZ1, EZ2, EZ3, EZ4, AE0, AE1,
    AE2, AE3, AE4, WR1, WRA1, and WRLA1 are
    trademarks of MaxBotix Inc. 
  • Hi Thor,

    In my case I could reduce quite a lot the sonar alt measurements noise / spikes with the BEC from this shop:

    and placing the sonar sensor (MB 1200) on my Storm Drone ( like this:


    Hope this helps also in your case.

    jDrones custom low noise 5V/3Amp tested uBEC
    R/C UAV and ArduCopter manufacturer and one stop shop. We make your FPV come true.
  • Funny about flying over grass... I have yet to fly my 3DR quad, but I have been tuning a good deal in my office (with carpeted floors).  When sitting on my desk, motors running or not (no propellers attached), the ALT readings seemed to be very constant at .2m.  However, when I put the quad on the carpet, the readings would jump all over the place and the VSI would climb/fall like crazy and the ALT would (generally) start climbing slowly.  I moved it to a hardwood floor, and all those issues went away again (motors running or not).  Now, this is in no way scientific... but those readings and observations occurred before I read this thread (in fact, let me to this thread).  I have standard wiring, etc... will upgrade those soon.  seen here

  • Hi Randy, on Sept. 23 you showed two sonar signal graphs (before and after shots). Did you have only noise and spikes when you alter the throttle? In my case I have only noise and spikes when altering the throttle value. Otherwise the sonar values are "quiet" and stable. I wonder if my receiver and corresponding lines are too near placed to the MB 1200 sonar sensor.

  • Hi Kure, did you resolve the problem in the meantime. I have the same problem with the APM 2 on a Storm Drone from .  The best I can achieve with altitude PID tuning is a correct working of alt hold at low altitude for some seconds (10 - 20 s). Afterwards the drone climbs (sometimes after going nearly to ground) up as in your case. Interesting is that the measurenments of the sonar (MB 1200) on a testbench (see photo) are correctly with running motors (throtle approx hover condition). I used this testbench for attitude PID tuning.


    3692542721?profile=original - The Largest RC Helicopter Online Store - The Largest RC Helicopter Online Store online at the Lowest Price. HeliPal is the largest rc helicopter online store. HeliPal is famous…
  • Oh, I already had the capacitor soldered onto the sonar, so it's not in the pictures.

  • How I made my cable:

    I cut up Audio/Video cables I had laying around the house until I found one that was shielded. I cut the ends off and stripped back the insulation. 

    Then I twisted all the shields together at one end, and I choose the white conductor as my ground and twisted it in with the shields. Then I crimped on pins and soldered the shields since all that wire couldn't fit into the pin. 


    On the other end, I cut off the shields and put pins on each conductor, and put the resister on the 5v line (it's the RC filter). 

    Cheap and easy. I got my crimp tool and pin kit from Hansen Hobbies.


    Hansen Hobbies - Home
    Hansen Hobbies - Electronics for Radio Controlled Aircarft
  • AHA!!!!!

    Another flight, and I noticed something. As I flew over my driveway, the data got clean as whistle. Then when I flew over grass again, it went back to a mess of data spikes. Flying over cement doesn't give 100% clean data, but it's waaay better. Parts of the log are perfect. Soooooo it IS the Sonar that is putting out crap data. I bet each of those data spikes is a "no return" on it's echo. That would make sense. It pings and never hears back until the timer runs out. Pop! Spike in the data. I get it now.

    I think the shielded wires and RC filter are doing their job. But I'm not sure how to make the sonar work better. I mean, I usually fly over grass, who doesn't? 


  • Another extreme measure at getting good sonar data.

    Built my upteenth cable, this time each wire is individually shielded and grounded at the apm side. I extended the sonar way out about 6 inches (10cm), it has the power supply RC filter installed and as you can see it STILL is full of data spikes. It actually seems to work somewhat in flight..... But you can hear motor surges while it tries to track the data. 

    I still don't know if this is a sonar problem or a APM problem. I'm pretty sure at this point it's NOT interference or vibration. I've done everything under the sun to cure both those problems, and nothing has any effect what so ever. So either the sonar itself is a P.O.S. (likely) or the APM isn't reading the data correctly. 


  • Another commonality between my Xcopter and Kur's is that we both have J1 installed. 

    Do you guys that have Sonar working, have J1 installed as well?

    Maybe running the APM2 on separate power may be the answer?

This reply was deleted.