MMC3416 One Axis Reversed

Hi Ardupilot Forums,

I am trying to set up arduplane 4.1.6 with a MMC3416 magnetometer and one of the axes seems to be reversed. When doing the orientation test (dip nose, dip right wing, flip inverted), I can tell that the X signal increases when nose down, the Y signal increases right wing down, but the Z axis increases when the aircraft is flipped inverted (opposite of what it should be for norther hemisphere). This plane has another mag that reads properly, so this is only isolated to the MMC3416.

I tried manually changing the orientation and got these results:
Orientation 2 (Yaw90): X reversed, Y correct, Z reversed
Orientation 6 (Yaw270): X correct, Y reversed, Z correct
Orientation 10 (Roll180Yaw90): X correct, Y correct, Z reversed
Orientation 14 (Roll180Yaw270): X reversed, Y reversed, Z reversed

This tells me that the input coordinate system is left-handed rather than right-handed (one axis is backwards), making this mag unusable. The datasheet for the MMC3416 confirms this, but I would have thought the driver takes this into account. Is this a common issue, or is there a parameter I’m missing?

Thanks -Nathan

Compass calibration should resolve it correctly with COMPASS_AUTO_ROT which is enabled (check and fix) by default.

Hi Dave,

Thanks for your reply. However, COMPASS_AUTO_ROT was already set to ‘check and fix’ and kept setting roll180yaw270 (14). In that orientation all 3 axes are opposite of what they should be via the nose, wing, flip test.

It’s tricky to explain, but when all 3 axes are negative that means one or two of the axes must be flipped coming from the magnetometer. You cant rotate a right-handed 3-axis cartesian coordinate system and get X = -X, Y = -Y, and Z = -Z. It’s impossible via the math. Yes you can get all principle axes to be negative of eachother, but there’ll be a mismatch like X = -X, Y = -Z, Z = -Y. I tried all possible orientations this could be and got consistent results that one axis must be backwards. Even the data sheet shows it, which is why I’m confused the software seems to not be handling it.

Are there any other parameters or settings I can try?

Hmm. No other settings and the driver is definitely there:
MMC3416 driver

I tried making the mag scaling -1.0 but it seems the code is smarter than that. Was worth a try but didn’t change the results.

Additionally I tried the magnetometer on another identical board and a legacy pixhawk both running the same firmware and the issue was present on both.