Isn't compass used in AltHold mode so what made the copter yaw?

Hi guys,

I hope you are doing well.
I am flying and tuning a new H frame quadcopter - big one with 32 props.
When doing manual tune in AltHold, I figured out some strange behaviours. The drone did yawing without my input in the yaw channel. When analysing log, I realize there was some “noisy” or “abnormal” mangetic intensity in x and y axis. Right after the magnetic changed, the yaw rate changed, so I had to correct it by yaw stick (my input)


According to this discussion, the compass input may be used for correcting the gyro drift Does Alt Hold require a compass? - #6 by Rob_Lefebvre

Is it the case for my situation?
If this is not the reason, how can I minize this yaw-auto-rotating problem in the AltHold mode?

This is the log in case you need to do additional analysing: https://drive.google.com/file/d/1YHCh7_DiTQccqknALtl7TLHwANnjtdaH/view?usp=sharing

Thanks,
Vu.

Let me explain a little more about the time stamp:
At 1:
I observed the drone yaw leff - but it did not shown here!!!

At 2:
I started correcting it by applying input to yaw channel making the drone yaw right

At 3:
The drone came back to my desired yaw angle

It looks like the compass is responsive to throttle (current) to me:

That’s correct!
The external compass is mounted close to power wires - I know I need to choose a better position in loiter or poshold mode later on.

Even with normal throttle, yaw rate is still there without pilot input, yaw rate changed right after taking off successfully.

Even in AltHold, the controller commanded copter to yaw

I am setting parameters of compass:
. COMPASS_LEARN : 2 - EKF Learning
. EK3_MAG_CAL : 0 - When flying

Hi guys, it would be much appreciated if someone can confirm where this yaw effect came from.
Thanks.

Set these back to default and try the Magfit utility in MAVExplorer to calibrate the compass and set the compass motor offsets. Page down to the MAVExplorer section.
Magfit

Thanks @dkemxr for introducing me this tool. I found it so helpful.
About the problem I faced here, I used RM3100 compass and Z-axis mag coil was soldered wrongly because it is polarity sensitive. After fixing everything, the problem of realigning automatically was solved.

However, I also did a test: I changed the compass Yaw axis off 180 degree on purpose and take off in AltHold Mode. Again, the copter tried to realign, it did yaw without any yaw input.
This test went back to my inital question: Is the compass used in AltHold mode?
The next question is: before taking off, why I did not receive the messaged “Error compass variance” or “Compass not healthy” instead?

Yes.