LSM303AH - Mag field on Z ax doubt
Hi, I have implemented a tilt and heading calculation using the simplified heading calculation that only works when the device is horizontal, and was until now ignoring the magnetic field value on the Z ax. Now I'm trying to implement a tilt compensated heading to be able to calculate heading when the device is not horizontal, and I was starting by trying to obtain the Z ax max and min magnetic field value to compensate its offset as I did before on the X and Y axes, and noticed that the minimum is with the board lying horizontally on the table, components facing up, and the maximum is with the board lying horizontally on the table with the components facing down, I never get close to these max/min values rotating the board in any other direction. I was rotating the board vertically and the Z value varies but its max/min value when it is in a vertical position is less than half of the value when it is lying horizontally on the table. Does it makes sense? For the Z ax It seems that the stronger magnetic field is below the table, but that doesn't agree with the measurements I get on the other axes, the X and Y axes need some offset compensation but their value varies with their relative orientation with the North so their maximum values point to North and not 'down'. Any help / clarification will be appreciated, I think I might be missing something here.
For the tilt compensated heading, is there any reference code that could be used? I have already implemented but having a reference code to compare will be great, the code is running on a STM32L4xx.
Thank you in advance!
Fernando
