Px4 compass problem

Just been paid tuning a large quad copter with pixhack v5 and have come across a strange problem that I only noticed after tuning and trying position mode.

The compass can switch 180 degrees. It’s only happened once in the air nearly causing a crash but I switched to stabilised.

Its happening all the time now though (I’m only flying in stabilised mode so I don’t lose control).

I take off yaw a complete circle and compass is fine. However once I land the onscreen compass drifts from good to 180 degrees wrong direction over about 30 seconds.

I’ve tried many 6 axis compass calibrations and the compass orientations are right in the parameters and physically on the machine.

Any ideas what I can do?

here is a log showing a takeoff a couple of intended yaws. The 180 degree drift from correct to wrong happened after landing and disarming: https://logs.px4.io/plot_app?log=47d839ad-487b-4337-86c3-d5d344136676

Hi,

You have extremely bad magnetometer data. Most likely due to interference from current. Try to place the magnetometer as far away as possible from any power cables and twist your power cables

1 Like

Hi
How can I check the magnetometer data is bad or good? Thanks

The first thing to look at is to make sure that the correlation between the norm of the measured magnetic field and the measured current is low, or preferably nonexistent.
The red line here should be horizontal