Heading off by up to 40° after two spins on yaw axis with my quadcopter

The problem:
I’m having this problem since the begining I’m using Navio2, when I’m spining on the yaw axis
after two turns at about 90°/sec the heading is completely off, up to 25° after the first spin
(EKF Compass turns orange in MP), and by up to 40° after the second spin (EKF Compass turns red in MP).

My configuration:
Tarot-650-Sport, DJI E800 propulsion system (3510-360KV/13"), Tattu 6S4500, RPi3/Navio2, AUW2400g
Copter V3.4-rc4, Mission Planner V1.3.41, Temp 15°, no wind
WiFi & BT disabled, CompassMot calibrated, tried enabled/disabled
External HMC5983 compass on 25cm mat, onboard calibration, manual declination (1°36’ for GVA/CH), offsets X-83/Y69/Z57
Internal compass #1 & #2 disabled, external compass #3 set as primary
Dataflash log: 2016-10-30 16-00-04.bin (1.9 MB)

For testing purpose I made many times the same flight pattern in PosHold at different locations and with different settings,
problem is always the same, here is the flight pattern same as in the above dataflash log:
(5 seconds pause at each steps unless specified)

  1. Heading to 310° and takeoff at alt.3m
  2. Forward 5m, climb to alt.10m, hover 30sec (hdg 310°)
  3. Yaw +90° (hdg 40°), yaw +90° (hdg 130°), yaw +90° (hdg 220°), yaw +90° (hdg 310°)
  4. Translation 10m right side, translation 10m left side (hdg stay at 310°)
  5. Translation 10m forward, translation 10m backward (hdg stay at 310°)
  6. Yaw 360° CW in 4sec
  7. Hover 5sec (hdg 310°)
  8. Yaw 360° CW in 4sec
  9. Hover 30sec (hdg 310°)
    10.Descent and landing at home point (hdg 310°)

At point-7 my quad is actually heading at 310° but MP and graph shows 290°
At point-9 my quad is actually heading again at 310° but MP and graph shows 280°
Sometimes I’ve got serious TBE after the second spin but not always.

In the dataflash log we see the yaw not coming back to 310° after the spins.
EKF4.SMX goes up to 0.8 (mag inconstency) and takes 20 seconds to come back below 0.2.
EKF3.IMX goes up to -130 (exceed recommended max of 50) and takes forever to come down.
During the 20 seconds following the spin (39000 to 43500) my copter is slowly rotating about 10°CCW but the graph shows it’s not rotating,
that’s why I have to bring it back to 310° (my yaw correction at 43500).

I can even reproduce the problem by spining the quad by hand, motors/props off (therefore no high current flowing),
the heading is lost same as in real flight.

I tried the same flight pattern with another quad and a Pixhack/CopterV3.3-rc3/M8N/InternalCompass as wll as with V3.4.1, no problem at all.

Any help or suggestion about this matter would be greatly appreciated, thank you.

Hello Patrick!

Thank you very much for your thorough research and elaborate report. Could you please sudo apt-get update && sudo apt-get upgrade in order to use a stable AC-3.4.0 and try to reproduce the problem?

Hello George,
Thank you for your fast reply, as you suggested I upgraded to latest 3.4 stable and made a flight
with the same pattern but there is still the same issue I’m afraid:
2016-11-18 15-50-25.bin (2.3 MB)

BTW I enable COMPASS_MOT this time and please note that sometimes it’s even worse. I also made some
auto flights with a few waypoints, one of them is a 3-circles 10m-radius with ROI at the center, after the third
circle EKF-Compass_Satus went to red and I had to switch to Stabilize mode to recover and bring it back.

Any idea what I can check or try further ?

Thank you and best regards.

Hello George,

BTW, for comparison here is the graph for the same flight pattern made with a Pixhack V3.3.3
on a similar frame:

As you can see, this one is perfect, yaw come back sharp at the same heading after 2 spins and SMX/IMX are ok.

Are you sure in compass rotation setting for HMC?
You can also try disabling all compasses except third (external). You’re being extremely thorough and we appreciate the effort digging into the problem. Thanks.

Hi George,

Actually the graph and log in my first post is with both internal compasses disabled, only external enabled
and set as default.
I tried almost any possible combinations, like with only second internal compass enabled and set as default,
(first internal and external disabled). In that case I choose the second because it had lower offsets than the
first one. And here is the log and graph (AC-3.4-rc4):

2016-10-30 16-13-00.bin (2.0 MB)

As you can see, always same behavior and same problem, in this case heading off by 25°, IMX and ErrYaw raised
up to 0.7 and took forever to come back down. Before the two spins my copter was heading at 300-305° and
after the two spins my copter was visually and obviously again at 300-305° but graph and log shows 280°.
Then my copter turns slowly to 280° but the graph shows that it’s not turning, and after 30 seconds I have
to bring it back to 305° as you can see at 43500.
Best regards.

I was wondering why you continue testing the AC-3.4-rc4?

I also wanted to get an answer about compass orientation one more time just to be sure that we’re on the same page.

Hi George,

I have upgraded both of my frames (RPi3/Navio2 & Pixhack) to the latest stable AC-3.4.0 therefore I do not
test anymore in older versions, the last graph is with AC-3.4-rc4 indeed because I already made a batch of
testings prior to post my problem here and it seems that having upgraded to the latest stable version do not
change anything. Further tests and flight will be with AC-3.4.0

About my compass orientation:

To check the external compass orientation I followed this procedure (found on another forum):

To be absolutely 100% certain of the compass orientation, do a live graph of xmag, ymag, and zmag, and verify:
   - Pointing the copter NORTH will result in positive X, near-zero Y
   - Pointing the copter WEST will result in positive Y, near-zero X
   - Point the copter NORTH, tilt it UP 90° so that FORWARD is UP, BOTTOM pointing to north,
     Z should go POSITIVE (Y will stay roughly zero)

Furthermore the mx my & mz life graphs of all three compasses are following closely each others accordingly.
When I’m rotating the frame slowly the heading is correct. I tried COMPASS_ORIENT3=4 (yaw180°)
and others, re-calibrated and rebooted, then the heading is completely off, therefore I assume my compass
orientation is correct.

BTW, the Navio2 I2C bus power voltage is 5V and it seems it’s not documented anywhere. Some users
installed HMC5883/5983 external boards (these chips should be powered with 3.3V) without voltage regulator
on them. I tried one of these myself and the behavior is erroneous with very high and unusable offsets when
powered with 5V. I believe a comment about this in the documentation would be welcome.

If you think I made a mistake please let me know, any comment would be appreciated.
Thank you.

There’s an inscription on the other side of the board, actually but a hint in the documentation is indeed needed. Thank you for the valuable input.

The setup with a Pixhawk is exactly the same with only one thing that is changed and that being a flight controller used, isn’t it?

Just to clear this one up. Navio2 I2C bus voltage is 3.3V, the power voltage in the connector is 5V. I would advise everyone not to use compass boards that are powered directly from 3.3v, without onboard LDO. This is against best practices in electronics and this might cause instability.

Hi George,

About the Navio2 5V I2C power voltage and 3.3V I2C bus signals, I know there is a marking on the back
side of the board but it is useless when it is installed on the Raspberry unless we think to make a picture
prior to the installation, anyway a nice drawing like the one you made for the older Navio would be welcome
as many users asked for it already. Please note also that somewhere else on the forum you gave a link
(actually I think it was from Mikhail) to an HMC5883 compass board without LDO
(SparkFun Triple Axis Magnetometer Breakout - HMC5883L - SEN-10530 - SparkFun Electronics) and this could have mislead some people to use an inappropriate
product, I saw some having compass problems and referred to the same link.

To come back to my setup, the frame are different but similar, carbon frame with 650mm wheelbase, same
motors, same propellers, same ESCs, same LiPo, different power module: on the Pixhack frame I have
a Mauch BEC and Hall current sensor, on the Navio2 frame I have a standard power module.
To make sure about this today I tried another power module, problem remains the same.

Please remember (see my first post) that even when I turn my frame by hand on the ground the heading
is 40° off after two spins. I tried this by powering only the Navio2 from the power port without powering
the ESCs to avoid any EMF from them.

Best regards.