Sonar Noise Reduction update

 I have read the arducopter manual and also reviewed some of the earlier forum posts and initially moved my sonar sensor (recommended Maxbotix) 3" away from the main electronics but still see too much noise for the sonar to work in Alt Hold properly,  So I did some more research and think the following may be of interest to the group. I certainly hope it allows me to keep the sonar closer to the centre of my copter rather than out on an extended arm and nearer to the motors and props.


I found a simple solution from Maxbotix, that should eliminate the effects of excessive supply noise which can impact the Sonar sensor operation.  Placing a 100 Ohm resistor in series with the V+ line along with a 100uF Electrolytic capacitor (6.3V +/- 20% tolerance) to ground, you create an effective filter for the sensor.  This ensures that almost any noise introduced onto the line is captured and only clean stable power is supplied to the sensor.  See the photo schematic below:




This combined with perhaps a shielded cable as described here may eliminate the need to place the sensor out on a long plastic arm as I have seen mentioned in another forum post and in the Arducopter manual.


The only concern I have is extending the ground plane to the sensor board and whether this may introduce other issues.   For example, normally the signal receiving end ground plane would  be tied to earth,  But in the arducopter this is not possible being a flying platform. 


Anyone care to discuss / comment  the possible side effects of a floating ground between the APM and sensor acting as an antenna of some sorts if both ends are connected? In other words would connecting the signal wire shield to the GND on both the APM and Sonar (As described in the Maxbotics article)  be ok? Note the postive, negative and Analogue signal would be inside the shield. 


I plan to do some experimenting over the next few days and report back my findings.


One other quick question.  How many people run with sensor filters enabled on the  IMU shield (3 in total)? What are the cons if you use the filters?  e.g some sensitivity loss in the detector / sensor?


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

Join diydrones

Email me when people reply –


  • It looks like there's a few I2C SRF's out there already:


    This should help minimize the noise on the signal when it's getting transferred from the sensor to the APM... provided that the EMI isn't large enough to throw off the I2C signals.


    As an after thought, one of my professors here at the college keeps mentioning the usage of differential circuitry to transmit and recieve the lines. The concept is, since the EMI is common to both transmission lines, a simple unity buffer could be used to filter out the EMI.


    The unity buffer would then essentially be an analog op-amp with both inputs connected to both transmission lines. In your case, you might be able to plug the cable shielding into one input (I'm thinking the - side) and your analog line into the other (the + side).

  • Over the weekend I switched to 2.0.49 which I note has a higher PWM output (400Hz) to better suit some cheaper ESC's according to Jason. The one thing I have noticed in my recent flight test logs is, the Sonar is noisy again. But to be fair I have changed some things which might account for this e.g added a better quality shielded cable and I am now usign a Turnigy UBEC with LPF power filter to supply the APM and receiver versus the on board ESc BEC.

    One thing that has been bothering me is, with shielding and the power filter, is there is still noise but the spikes have variable intensity and time base i.e they appear intermittent rather than a constant effect like a ripple on the power line.

    So what is the connection? One thing I have not touched on yet is the actual analogue output from the Sonar itself. Could these intermittent noise spikes be correlated with motor / ESC behaviour and the change in the electrical dynamics over time. One thing I have observed is when I see e motor pulsating breiflyin ALT hold as a result of this interference it tends to be less frequent as the the battery discahrges and the motors and ESC's heat up well into the flight. In other words in a given log I see the effects for about 60% of the flight but they are hardly noticable near say the last 5 minutes.

    I started wondering if the Sonar is some how either audibly or electrically sensing the ESC driven pops and clicks in the motors which you hear under lower throttle settings. For me I do not need much throttle to hover with 12 x 4.5 props and larger motors (880Kv from jdrones with their 30A ESCs) so I believe I have more of this aberrant noise at the moment than say someone with a standard arducopter running 850Kv motors). This could explain why some users report better results in ALT hold than others. Of course noting that lowering the ALT HOld P value might help in my case.

    Now if you are following my logic so far then I wondered if the newer code outputing the PWM at a higher rate is generating more pops and clicks from the ESC's and hence becuase I have not focused on the signal filtering my sonar is dirty again. Or I have some new problem in my quad and probably will go insane before finding it :-).

    This brings me to my next step with is two fold. First I am going to try Andrews I2C fix using the Arduino mini as a slave unit to process the Sonar digital output. It means I wont have to sacrfice the APM processing by blocking to read the Sonar digital output. The second approach is in fact trying to see if I can remove the intermittment interference from the signal using a low pass signal filter on the AD input using the following:

    By Placing a 0.1uF capacitor near/at the analog to digital pin directly to the APM ground plane and next placing a 10K ohm resistor in series with the analog voltage output from the Sonar to the 0.1uF capacitor this will create a signal LPF. The time constant for this circuit will be 1mS.  This will cause a 5mS delay to allow the voltage to settle.  For slower readings and slightly less noise the resistor could be increased to 100K ohms and this will cause a 50mS delay.

    This is where I am worried about the impact of the ALT Hold feedback. Would a 5 or even 50mS delay mean the Arducopter will not be able to compensate for altitude fluctions in realtime due to external influence as well as before placing a settling delay of 5mS on the sonar signal? Ultimately I want to determine if having an actual signal filter on the inout side will reject the other noise I have described earlier. Has anyone tried this already? I think I would need Jason to comment on the possible feedback loop effects in the code. I am no expeRt in this field hense my hesitation and questions.

    A fina, thought for the day is the way the shielding is set up. At the moment I follow the Maxbotics recommended approach and have the shield only grounded at the receiving end and my power and signal wiring to the sonar are inside the metal shield. This makes me speculate if I should just use a single wire shielded cable and run the power seperately (Outside of the sheild) and use the poer filter I already have? S many variables

    In closing I just want to pass on some new infromation I received froM Scott at Maxbotixs after their engineers looked into my questions. Firstly there is a recommendation that the Power filter should be contructed using a 10Ohm resister in series with the 100uF capacitor. Someone mentioned this earlier but I had Maxbotix confirm their diagram is wrong for the XL- Sonar EZ0. Second bit of information they oassed on is the recomended Sonar (XL-Sonar eZ0) is the most sensitive device they have in their range with a wider beam foot print. So is most prone to external noise.

    I may be taking the Sonar off the quad thia weekend and hooking it up to my laptop using the available range finder software this was I can move the sensor around the quad and see if I can detrmine what the real source of my persistent interference issues are. Sorry for the long post hoepfully some of my thinking aloud resonates with yiur expereinces as well debugging this very sensitive device.
  • Took the arducopter out for a fly today over a nice hard concrete surface below (good for sonar returns)

    Here is the plot of I2C Sonar (red) and baro (green) altitudes, also plotted is the throttle (white) and Next Waypoint Altitude (blue)

    This blue line shows when the aircraft is in altitude hold or loiter mode. Note the throttle response is a lot sharper in alt hode mode.

    I did fly over a couple of small bushes while in alt Hold - this obviously splits the sonar and baro as the sonar see this as a sudden drop in altitude but the baro doesn't - see around line number 10.5 and 11



  • Here's my latest flight with a MB1200 XL-MaxSonar-EZ0 with a filtered power supply and shielded cable, also with a haphazard but ungrounded attempt at shielding the module itself with a small box covered in aluminum tape:





    The most wiggly parts of the throttle out graph indicate either alt hold or loiter being used. For some reason the interference causes spikes in both directions (I used to see spikes only from current value to minimum before) and it is intermittent, sometimes disappearing altogether as can be seen between lines 8k - 11k, and for almost the entirety of the last flight from line 11k to 15k. The sonar is 12 cm from two ESCs which are situated on aluminum arms, with the sonar sticking out from the hub on a short puny arm (a piece of not-very-rigid plastic) between them. I don't know if this is due to the ESCs switching at a fortuitous frequency that causes less EMI or what.


  • Can't we just move to something like this for sonar and be done with all the black art and fidgeging with the analog signal?

    The cost for an Arduino Mini is peanuts in comparison to the total cost of an ardupilot system.

  • Today I finally had perfect windless conditions to do some final testing on the sonar noise reduction modifications I have described in this post.  I have also replaced the shielded cable with a better one from an unlikely source.  I was not happy with the thickness of the 4 core cable is was using.  I used of all things a relatively new Belkin ipod/iphone USB cable which has 3 cores and a nice shield with grounding wire.


    I have to admit at this point I am still seeing some interference in the sonar signal (intermittent spikes) and I am less than impressed with the baro performance even with the recommended gauze / cotton pad cover.  To make sure the interference was not from a bad IMU shield board I replaced this with a new spare and repeated the same tests.  However, I experienced the same Sonar spikes I am about to show you as well as baro error / fluctuations.  


    For the record I am still using 2.0.45 for testing consistency.  However since I am looking at the electrical signal properties I doubt there would be significant difference in my findings unless the sample loop was reduced to counter noise effects or something similar.


    The following plot is sonar versus throttle at around 3.5m which is well within the 7m range of the XL-Maxsonar-EZ0.

    3692288579?profile=originalI engaged ALT Hold just as you see the first matching sonar and throttle spike (Green). There is not many for this altitude test but notice the altitude is starting to drop slightly before I disengage the ALT hold and allow the arducopter to descend. As I mentioned I have no idea where these spikes are coming from or if this is just normal sonar behavior.  I have swapped the shielded cable but I had the same interference before and after even with the power low pass filter.  There is also good dampening in my arducopter and very well balanced props to keep mechanical vibration to a minimum.   I have also spent many hours perfecting the wiring and soldering everything to a high standard.  I just wonder under the circumstances if what I am seeing is limitation in the electronic sensor signals which will ultimately mean this effect cannot be countered by the software ?


    Another datapoint I should mention is I have tried the manual recommended Sonar mounting position off one of the frame arms, with the same signal results.


    The next plot is Sonar versus Throttle at ~ 7m (the limit of the sonar)  There is more noise and looking at other DIY member feedback this would appear to be expected.  Of course what happens at this point is the baro kicks in but this device lacks any real precision so the arducopter height fluctuates considerably making the current project not very suitable for stable photography or filming. Well that is unless I am really unlucky to get two bad IMU shield boards.  Both mine are (Hotel) version -H and purchased from the DIY store.


    3692288519?profile=originalHere you can see the sonar spikes are more frequent and in observing my standard build arducopter quad at 7 meters in the air, the throttle is pulsing more regularly than the occasional spike within the sonar "sweet" spot.  The wiring of my quad is strictly by the manual (power of one ESC) and I have previously given reference to the finished product. I use the 30A ESC's from jDrones, and the 880Kv motors with 12 x 4.5.  Radio gear is high end JR PCM 10 with Spectrum 2.4Ghz module and AR9000 receiver.


    I will say the height was maintained at 7 metres from the above plot but shortly after this once the baro started to dominate the quad started to climb and then fall again. I was not game to go beyond 12m in this test flight today.


    The final poly below is to show the same data points (7 m test) with Sonar versus baro.


    3692288137?profile=originalI note here that the baro on both my IMU shield boards (sensor pads enabled and using baro pad cover) always reads less than the sonar until the upper limit of the sonar.  There is quite a lot of fluctuation in the baro and the error looks to be anywhere from 1-2metres, which is significant.


    I wish there was something more I could do but I think I just have to accept the arducopter sonar and baro has limits which means there is still more development to go, but I am sure as a group we will get there.  If I sound somewhat flat on this matter I really have run out of ideas at the moment on how to improve on the issues I have described.  I will do some more research on the sensors and see if there are alternatives which can be attached to the APM with the inbuilt sensors like baro disabled.   Has anyone had much success using a laser range finder sensor or some other optical sensors less prone to interference?

  • I´ve tried all kind of shielding, board filtering, and sonar distancing from ESC. All of this staff improves the pulsing problem but not eliminated completely.


    Using the Maxbotix recomended resistor-condenser solution solved definetively the problem. I have now a perfect sonar behaviour without any aparent drawback (I´m using this solution quite long time ago).

  • I completed some testing over the past few days looking at both vibrational and electrical interference impact on the sonar signal with some interesting results.  I have also made a few modifications including putting heat shrink on the landing gear mount screws which previously could vibrate against the metal frame as a possible RF interference source.  Here are some results with log plots of sonar versus throttle with and without cable shielding and combining shielding with power filters:

    3692284578?profile=originalHere we see a noisy sonar signal (Red) versus Throttle before shielding the sonar analogue signal or using a first order passive filter on the sonar power supply.  I should note at this point my sonar is mounted around 3" vertically below the Arducopter center frame hub where my ESC's are attached (Note this mounting is the same for all tests)



    In this test I used a 3 core shielded cable between the sonar sensor and APM.  The V+ GND and Analogue wires are inside the shield with the shield itself tied to the IMU / Oil PAN ground only. i.e the shield is not grounded at both ends.  You can see here there is little difference from the previous unshielded sonar signal test.  In this flight (using 2.0.45)  I engaged ALT Hold towards the end (you can see a distinct change in the throttle pattern). at this point the motors where pulsating so I did not achieve a stable ALT Hold.

    3692284591?profile=originalAfter seeing the shielded cable did not effectively reduce the sonar signal interference and I had a regular pulsing motor effect in Alt Hold, I added a passive power filter as described in the start of my forum post.  I also wrote to Maxbotix and received a nice email confirmation on the recommended shield GND configuraiton and values for the passive filter which is 100 Ohm resistor in series with V+ and 100uF electrolytic capacitor across the +5 to GND power for the  XL-Maxsonar-EZ0 I am using.  Maxbotix recommended to ground the shield on the receiving end (APM side).

    In this plot you can see I started with no motors running, but I had armed the quad to start the sonar logging on the ground.  I basically wanted to see the sonar reading with and without the motors running.  The intervals of each test in this plot is approx 1 minute.  At the 1 minute mark I raised the quad (no motors running) to 2 metres and held it there until the 2 minute mark.  At this point I placed the quad on the ground again and started the motors but not enough for lift off.  Notice now the sonar signal is nice and clean.  In the next phase on the test I lifted the copter to 2 metres again increasing the throttle and holding this for another minute. I repeated this again with more throttle and note in both cases appearance with what looks to be some interference.

    However I note the following.  I was holding the quad by hand and was not that stable so this can account for some of the peaks.  But it is clear there was still sonar interference which I attribute to vibration harmonics not so much electrical sources.  For example there is less noise at a higher throttle.  Although I cannot explain the two sharp transient peaks unless some sort of momentary spike from the ESC's.  Mainly because I see this in the throttle and sonar traces.


    My final test below is to see the difference in the sonar output with the quad sitting on a hard surface (in this case tile floor) versus on flat carpet while the motors are running at speed.  No props installed of course.


    3692284677?profile=originalThis log plot is showing sonar readings just above ground level with increasing throttle at 1 minute intervals.  In the last run I moved the quad on to a flat / hard carpet square and used a high throttle setting.  Note the Sonar trace is no longer noisy.  So I believe the remaining noise I have, comes from a frame harmonic perhaps as the motors transition through a throttle up point.  I notice for example the frame vibrate a little and smooths out again once the motors are past ~ 50%.  So I could improve on the sonar by altering the motor mounts.


    From this I found the following in my case:

    1. Using a passive power filter as described has the most impact by cleaning up the sonar power which would otherwise negatively impact the analogue signal going to the IMU board. Note I retained the shielded cable as there is still some improvement over just using an unshielded alternative.


    2. I did not have to have the sonar halfway out on the frame.  But in honesty my sensor is an equivalent distance away from the ESC's i.e is mounted directly below rather than out in front.  I guess I did not like the idea of the sonar being closer to the propeller wash.


    3. Both electrical and mechanical (vibrational harmonic effects) would appear to effect the sonar sensor.  But my testing is limited.  So from a scientific standpoint, the results are inconclusive.


    4.  I had a lot of fun and learnt more about this vital sensor in the process.


    In closing, do my current sonar signals look clean enough with just using the cabling and passive power filter combined with keeping the sensor away from the ESC's??

  • If you have a MB1200 XL-MaxSonar-EZ0, a 10 Ohm resistor was recommended to me by Maxbotix. For me a shielded cable and a power filter didn't fully solve the problem, I still get intermittent interference. My sonar is 12 cm from two ESCs (situated between them, ESCs are on the arms). My next addition, for which I haven't yet found a suitable light-weight foil for, is to enclose the module itself and connect that without any gaps to the cable shield, which is only connected at the APM end. A fully enclosing conductive shield ought to help by reflecting and/or absorbing the effects of the magnetic and/or electric field (which one it predominantly is, depends... basically we want to create an impedance mismatch between the source of the interference and the sonar and its cabling. A light-weight highly conductive shield should work well if the interference is high frequency... we shall see. Low frequency interference would require a shield with high permeability.

    Here's a useful resource:

  • The filter looks to be a 100Hz LPF first-order passive. A bit curious why the electrolytic is used versus a standard ceramic?


    You may be able to use the copter's metal support arms in place of an Earth ground, but I'm not sure how much that will help.


    And as far as passive filters goes, they're not ideal, so if you use them you'll loose a bit of sensitivity in your pass band (in this case from 0 to 100Hz) as your target frequency gets closer to the cutoff frequency. So a 99Hz signal's power is reduced by a little less than half and a 101Hz signal power is reduced by a little over.


    Active filters can give you a more ideal response and flat pass-band, but they increase circuit complexity and power consumption...

This reply was deleted.


Hiroki Tanaka liked Hiroki Tanaka's profile
Oct 13
Derrick Davies liked lisa TDrones's profile
Sep 23