Sonar Problems in flight

Hello,

I have a MB1200 sonar from the DIYDrones store. While working with it recently I observed some very weird behavior. I was getting pretty bad altitude hold in Loiter and AUTO modes. When I would analyse the sonar_alt logs, it would have a few true values and everything else would be values between 27-35. This would happen even when the quad is atleast 2-3 meters in the air. I am flying over grass. However the strange thing is that when I am doing a simple table test and logging the sonar, it does perfectly. Also note that the max range is 750 and minimum is 20 cm. Therefore these 27-35 do not belong in either category. In order to solve this I have tried the following:

1) I poll the sonar in the 10 Hz loop in update_altitude() and commented out the sonar.read() in the 50Hz loop.

2) I perform a digital read of PWM on one of the other pins, rather than the current analog way that is in the code. This is done again in the 10Hz loop as it would be very slow to do at 50Hz.

Both the above methods yield most of the readings as 27-35 cm with only a few correct readings during flight. The table tests are perfect for both.

TLDR: Sonar performance is terrible in flight but great on a table test.

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

Join diydrones

Email me when people reply –

Activity