Altitude hold -- throttle reversed?

I got the Sonar Sensor today and tried it out. I first tested it. It shows 35 cm from 0 to 35cm and then onwards seems pretty accurate to within a couple of cm.

Altitude hold was a lot more precise than just Baro.

However, I then tried to increase altitude (while in ALT_HOLD) by moving the throttle stick up, but the quad went down! If I moved the throttle stick down, it went up. That led to a scary couple of seconds when I transitioned back to STABILIZE but luckily no harm done.

Has anyone else observed this?

I've mounted the sensor with the black cylinder pointing downwards which I believe is the correct orientation. There are no wires or any other obstructions below it.

I should also mention that I did this indoors (!). May be the sonar signal was bouncing off the ceiling? But then the initial test was pretty accurate.

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

Join diydrones

Email me when people reply –


  • I''m trying to understand the code when sonar is enabled ...


    In the function update_alt() there is a "spike filter". If, in any one 10Hz iteration (medium loop), the quad's altitude goes up by more than 50cm, then this function will ignore the sonar reading from then on till the quad drops to the original altitude.

    For example, if sonar_alt is 250. In the next iteration if the quad rises to 310, that reading will be ignored. If it continues to rise, no matter how high, as long as it stays above 310, update_alt() will report the altitude as 250.

    Have I misunderstood the code, or is the assumption that a quad can never go up by 50cm in 100ms?

  • I had the same in open air. Wanted to lower a bit and it went up.
This reply was deleted.