Compass drifting issue

Hi,

I have an ArduPilot Mega 2.6 (although I think it’s probably a 2.5.2, as I needed to cut the compass SDA line?)

My GPS module is the uBlox NEO-6M.

My two symptoms / configurations;

Setup 1:
With the uBlox GPS/Compass disconnected, the ‘current heading’ seems accurate & stable, and moves accurately with rotation of the plane - which doesnt make any sense, because I have cut the onboard compass circuit?

  • perhaps I havent cut deeply enough?
  • I dont know if this is just some clever estimation of heading by use of PC link & gryo sensor?
  • When in this configuration, I cannot run the compass calibration, no data points are seen.

Setup 2:
With the uBlox GPS/Compass connected, it is then possible to run the Compass calibration, I get a good GPS 3D fix, the calibration goes smoothly, with 900+ datapoints in all axis, but when returning to the ‘Flight data’ screen, the ‘Current heading’ sometimes seems to be in line, but very quickly starts to disappear off on it’s own journey to pretty much any compass point - although it seems to favour 90deg to plane.

Is there something I’m missing?

I do have a magnetic door latch about 3-4 inches away from the uBlox, which feels like a pretty strong magnet… could this be related?

I also have a volage regulator nearby (5v for APM), which has a ferrite ring with the wire wrapped around it… can this cause magnetic interference?

Otherwise there isnt much else nearby, other than Rx & APM - both a good 3 inches away.

Hope you can help!

Thanks,

Andrew

Hi, sorry forgot to include;

I am currently using ArduPilot 3.0.3.

It is also my initial setup, I have only flown this setup once, I did not try any navigational modes - I only tried Stabilise (As this appears to work fine on the ground).

Thanks again,

Andrew

Perfectly normal.
You are seeing the angle from the accelerometers. You may have noticed that “North” is always the heading where the APM booted, since there is no compensation from the magnetometer.

Yes.

[quote=“bbwonder”]
I also have a volage regulator nearby (5v for APM), which has a ferrite ring with the wire wrapped around it… can this cause magnetic interference?
[/quote]Yes.

If you can, move the door latch and the ferrite ring around a bit and observe your heading.
I’m fairly certain you will see it change.

@JNJO01

Thank you very much for your suggestion!

I will try this tonight!

[quote=“bbwonder”]Hi,
Setup 2:
I do have a magnetic door latch about 3-4 inches away from the uBlox, which feels like a pretty strong magnet… could this be related?

I also have a volage regulator nearby (5v for APM), which has a ferrite ring with the wire wrapped around it… can this cause magnetic interference?
Andrew[/quote]

Magnets, including those in the motor, really affect the magnetometer. Keep your compass as far away as possible and get rid of all magnets, except, of course, the ones on the motor. :slight_smile:
Did you do the wire wrapped around nail experiment when you were a kid? Current in a wire generates a magnetic field. The battery, main wire harness to the battery and the power to the ESC are the main culprits.

Any Ferrous material can affect the compass but my personal experience is that magnets are worst and the rest can be compensated for during compass cal. I enable compass learn so that I am constantly getting cal info.

Lastly, I assume you flying a plane or you wouldn’t need magnets. On a plane, the compass is far less critical as the GPS will give actual track. Your true heading if you use telemetry will be a little bizarre if you compass is not calibrated. The compass sets the gyros every so often so they can provide instant heading changes. My theory, just mine, is if you have the compass learn on, you will be okay cuz the gyros will know North good enuf. Like in a real plane, you set the Gyro Compass based on the magnetic compass and reset every so often while flying.

After you do a “hand” compass cal, in a flight config, check the offsets in MP. Anything over -400 or +400 is out of whack. It should actually be way less than that.

[quote=“Icarus”]
Magnets, including those in the motor, really affect the magnetometer. Keep your compass as far away as possible and get rid of all magnets, except, of course, the ones on the motor. :slight_smile:
Did you do the wire wrapped around nail experiment when you were a kid? Current in a wire generates a magnetic field. The battery, main wire harness to the battery and the power to the ESC are the main culprits.

Any Ferrous material can affect the compass but my personal experience is that magnets are worst and the rest can be compensated for during compass cal. I enable compass learn so that I am constantly getting cal info.

Lastly, I assume you flying a plane or you wouldn’t need magnets. On a plane, the compass is far less critical as the GPS will give actual track. Your true heading if you use telemetry will be a little bizarre if you compass is not calibrated. The compass sets the gyros every so often so they can provide instant heading changes. My theory, just mine, is if you have the compass learn on, you will be okay cuz the gyros will know North good enuf. Like in a real plane, you set the Gyro Compass based on the magnetic compass and reset every so often while flying.

After you do a “hand” compass cal, in a flight config, check the offsets in MP. Anything over -400 or +400 is out of whack. It should actually be way less than that.[/quote]

Fantastic! Thanks for your comments! It’s such a relief to hear real world troubleshooting experience… This autopilot malarkey is a steep learning curve!

Yes I’m flying a .40 size electric trainer, lots of space for electronic equipment & big batteries :smiley:

I’ll remove the hatch magnet completely and relocate my regulator right to the front.

It should be pretty easy to temporarily relocate things , process of elimination…

I’ll post back my result! Thanks again.

Heading to the workshop now!

Andrew

[quote=“JNJO01”]
I’m fairly certain you will see it change.[/quote]

Awesome I hope so! It’s the only thing I’m not happy about, everything else has gone surprisingly well!

Really appreciate the advice :smiley:

one last question…

Should the compass direction be locked-on, or is it typical to have a bit of wandering - like 5 deg either side of actual?

Just trying to gauge my expectations!

[quote=“bbwonder”]…
Should the compass direction be locked-on, or is it typical to have a bit of wandering - like 5 deg either side of actual?..[/quote]
Hopefully a developer can chime in, if I’m wrong.

If seen the same wandering during ground tests.
I believe it comes from using the GPS-position for attitude correction. (AHRS_GPS_GAIN)
If I set AHRS_GPS_GAIN to 0, the heading stays locked on true heading.

Note that AHRS_GPS_GAIN should be set to 1.0 in APM:Plane.

In the air, with a speed over ground, I have no problems with heading.
I only see this when ground speed is close to zero.

[quote=“JNJO01”][quote=“bbwonder”]…
Should the compass direction be locked-on, or is it typical to have a bit of wandering - like 5 deg either side of actual?..[/quote]
If seen the same wandering during ground tests.
I believe it comes from using the GPS-position for attitude correction. (AHRS_GPS_GAIN)
If I set AHRS_GPS_GAIN to 0, the heading stays locked on true heading.
[/quote]

Ahh this could make sense - I’ve just come back inside from garden, and only got the same result - even after removing magnets & regulator from near compass. The compass direction in Flight data just wanders all over the place.

I logged into the APM terminal, and run the compass test - it ran flawlessly, giving stable heading data, although North/South were flipped… but East/West were correct. (Is this something to do with compass ROTATION_ROLL_180 ?)

I was cheered that I saw such a stable heading, looks much more like I was expecting.

Maybe I should just fly this and see what happens! :slight_smile:

(I’ll try GPS GAIN on ZERO to see if I get same result!)

Thanks again

Hi JNJO01,

I’ve tried setting my Gain to 0, but I’m afraid the compass still did not settle down in Mission Planner / on Ground…

Since it seems stable in the Terminal tests, I’m going to try flying it this weekend - I’ve ordered the 3DR telemetry kit today, so I should be able to monitor it in-flight now, and see what’s going on.

Thanks for your help, I’ll report back here with my results!

Run my first full auto mission today! (5 waypoints, ending in unlimited loiter)

Flew perfectly (although desperately need to run through auto tune… Very soft turning angles)

Sadly all my previous tinkering filled the log file memory and didn’t record my first momentous flight :frowning:
So I can’t see whether the compass is giving good readings.

At least I have learnt plenty anyway. (And recorded the whole flight in HD from underside of wing - Möbius action cam)

Thanks again for help, looking forward to my next flight.