I'm operating a stock standard Arducopter 2 from jdrones with GPS, Magnetometer, MB1200 Sonar and a Turnigy 9x radio
Over the past couple of months I have seen the occasional odd behaviour with the Sonar when bench testing with the CLI Sonar test. Basically the Sonar sometimes fails to report the correct distance - sometimes it locks in a fixed and incorrect distance, sometimes it sticks at the minimum 34cm. At other times it appears rock steady and quite accurate.
Yesterday while out on a perfect flying day (a rare event in the middle of winter here in the land downunder) I struggled to get altitude hold to work when testing 2.0.35. I saw the pulsing or gunning behaviour others have seen in the latest Alt_Hold followed by either a steady climb or a gentle descent that brought the aircraft down to lawn mower level.
Looking at the logs in Mission Planner I notice that the sonar data is very spikey.
In the images below note the red trace is Sonar Alt, Blue is Baro Alt, Green is Throttle
The correlation between the sonar peaks and baro altitude is good at low altitudes which reassures me the Sonar is functioning correctly - some of the time
and the same again zoomed in near the start of the data.
Can anyone help explain what I am seeing with this 'noisy' sonar data.
Do I have a hardware problem?
Where might it be?
Looking in to the data further reveals that the 'pulsing' or 'gunning' behaviour in Alt_Hold can be clearly seen in the throttle trace in the image below at the point I enter Alt_Hold mode (about line 10500) and the peaks and troughs in the throttle correlate with troughs and peaks in the noisy sonar data. ie when the sonar drops out the motors throttle up. Note the pink line in this graph shows when flight mode is Alt_Hold
It appears a number of others users have seen this behaviour either sonar drop outs or Alt_Hold pulsing and lack of holding.
Do we have a systematic problem with sonar hardware or software, or could it be an obscure combination of the two?
Some reading and thinking has lead me to wonder if there is RF or electrical noise interference or if the battery connector may have been moving in and out of the filed of view of the sonar sensor.
I have extended the sonar mount legs by 15mm with additional plastic stand offs and ensured the battery connector is secured out of the way.
I've then run a test of the sonar with the Arducopter captive in my outstretched hand, with and without the motors running.
The step in early part of each peak is me carefully climbing up on a chair while holding a live Arducopter
The results are much better than before with only the odd 'spike' which could be explained by a stray leg or similar entering the sonar sensor field of view. There is more 'noise' in the second peak - with motors running - but nothing like before.
Time to test fly the new mounts. And see how Sonar and Alt_Hold performs. It's Sunday night here downunder so this will have to wait for another clear calm winters day.
One question I now have is about the scaling on the sonar data the values shown are 150% of what they should be. from the Maxbotics specs sheet the scaling factor changes by 150% depending on what voltage you supply the sonar module. Time to read the circuit diagram and code to check things out.
The sonar has a very large field of view. It must be mounted far from the frame, it can have about 180° filed of view at near distances !
You can verify this putting your fingers around it and checking it in the cli.
It must be mounted with a small plate around, so that it does have a more focused filed of view. A one inch (2.5 cm) plate is a minimum diameter for the plate.
Watch for the sonar datasheet, where you will find filed of view sensitivity according to plate diameter.
I think it does avoid two much sonic refraction around the sonar. So that reflected interferences does not enter from behind.
Could up upload a log so we can compare?
Looking at those values in the log. It seems impossible with the moving average filter that's in the Rangefinder class. Something must not be working right. I'm looking at it today.