Mag current compensation

Post Reply
mopedcrosser
Posts: 52
Joined: Sat Feb 23, 2013 12:35 pm

Mag current compensation

Post by mopedcrosser »

Hi all,

according to the issue that some of us have problems with magetic fields from their wiring interfering with the
mag sensor I might have an idea how to compensate for it. This is the problem I am refering to...

http://www.multiwii.com/forum/viewtopic.php?f=17&t=3178

I know that this is not the "proper" solution since such a problem should be solved by a proper wiring causing
no interference. However, due to the copter designin many cases it might be almost impossible to get rid of all
interference.

So here is what I am thinking.. I figured out that the mag deviation always changes by the same amount, depending
on the throttle position. This should be always like this unless the wiring has been changed. So if there is always the
same deviation at the same throttle position, it should be relatively easy to compensate for this.

Could it be possible to add a calibration function where the copter is fixed on the floor while the engines are speeded up
once to full throttle ? Since the copter would be fixed, the mag should not change its direction. Because of this, all deviation
measured during this process should be caused by the mag fields from your wiring and could be added / subtracted from the
original value. The only problem I see, is that the currents in a fixed state vary from the currents in the air, since there is more
"load". Predefining a correction courve might also be an option. But it might be worth a try.. What do you think ?

Sebastian

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Mag current compensation

Post by Hamburger »

attempting an imperfect software fix to overcome a wrong hardware layout is not really cool. You could try coding it yourself but I would prefer to not see that become part of the official code - it sounds just plain wrong. Fix your hardware layout and be done for good.

mopedcrosser
Posts: 52
Joined: Sat Feb 23, 2013 12:35 pm

Re: Mag current compensation

Post by mopedcrosser »

Thats what I meant with not proper fix. However it´s just an idea which might be useful

subaru4wd
Posts: 316
Joined: Sat Dec 08, 2012 2:16 am

Re: Mag current compensation

Post by subaru4wd »

The new ArduCopter 3.0 has this feature in it and it does a great job of overcoming magnetic interference.

zwiebacksaege
Posts: 27
Joined: Thu Mar 07, 2013 10:14 am

Re: Mag current compensation

Post by zwiebacksaege »

I fully agree to this nice idea. Although I think it might just be too much effort to really calibrate it over GUI or so ... I just wish some factor to set maybe via config.h which compensates this problem. I also agree that workarounds like this are not the way of proper engineering but for some of the frames its really hard to eliminate the mag field as I just found out when testing different shieldings... the warthox frame with integrated eletric distributor for example seems to be a magnetic desaster...

Now we are in some kind of dilemma as we want to place the FC as close as possible in the COG and then coming deeper inside thos mag fields. I am pretty sure that I'm not the only one who is not willing to waste the mag sensor on some AllinOne board as the crius to build some additional external mag somewhere else. In this case I would really appreciate some kind of software damping for this problem.

maybe someone could just tell me how the variables for the mag value and the throttle-output are called in the MW code then I would just try it on my own and make a review about the results here.

User avatar
Crashpilot1000
Posts: 631
Joined: Tue Apr 03, 2012 7:38 pm

Re: Mag current compensation

Post by Crashpilot1000 »

Hi!
Basically the idea is not new and has been done in other project years ago (arm-o-copter 2010 or 2011) - the need of a good hardwaresetup is still needed. Why might that be? Hamburger is completely right, it can not overcome a poor hardwarelayout in the first place. An external mag is the best way to do that. But it can help increasing accuracy and suppressing slight mag deviations. Looking at the arducopter approach it seems they are boiling the deviation down (for each axis) relatively simple to one parameter for each axis. Furthermore (i think) they mainly tested it with amperesensor input. The code however allows the usage of pwm values when amperesensor is not present. Perhaps Hamburgers extensive work in that area might come in handy there. On the other hand I don't think the mag-deviation is really linear over the throttle/ampere range (even the randy video seems to show that ) and you will find a different distribution of the mag disturbance during different independent motor usage (yaw/leveling etc.). So disturbance from nearby motors are still a different story than the distubance from the powerdistribution. To make it more correct, you will have to create different correction parameter sets over the whole throttlerange (every 5 or 10% throttle?). You could also take each motor individually for that and than all together and produce some correction matrix ..... Another thing that can be done about the mag (aside from power/motor stuff) is based on Bill Premerlanis' ("gentlenav/matrixpilot") work depicted here: http://gentlenav.googlecode.com/files/M ... isited.pdf. Arducopter and at least openpilot have that code as well. Openpilot has an alternative at play but much yawing still seems problematic as documented in the source. Both approaches seem to be more suitable for airplanes than for copters.
Dji and even 3dr are selling external gps/mag combos - and that's probably because the softwarecompensation is inferior and can not substitute a good hardwaresetup in the first place. Complicated mathematical models might come close to that but the compassmot shown in arducopter seems like something to try out but not expect too much.
Cheers Rob

Post Reply