I am trying to get heading information of a forklift. I've designed a small PCB for this purpose. This PCB has a 3 axis magnetometer and a 6 axis gyroscope-accelerometer (Z- axis looking towards the ground). I've used Madgwick's sensor fusion algorithm to combine 9 axis' informations. There are 3 choices for the sensor fusion implementation;

  • Choice 1: It uses all 9 axis information and returns roll, pitch, yaw values (Affected by magnetic interference)
  • Choice 2: It uses only gyroscope and accelerometer readings and returns relative roll, pitch, yaw values (Does not get affected by magnetic interference however value drifts over time)
  • Choice 3: It uses only magnetometer and accelerometer readings returns tilt compansated heading (Affected by magnetic interference)

Which one would be more suitable in metal heavy environment? Are there any other methods that you can suggest?

Also due to dynamic magnetic interference of the forklift's moving parts, I've mounted the device at the rear top side of the forklift. Should I do hard and soft iron calibrations when the device is mounted on the forklift or should I do calibrations before mounting? If I try to calibrate when the device is mounted, I won't be able to rotate device around the Z axis.

  • \$\begingroup\$ You do them after mounting. Why wouldn't you be able to rotate? The forklift turns, does it not? Do you understand what soft and hard calibrations actually are? Turning the sensor with the forklift is the entire point point of the calibrations. \$\endgroup\$
    – DKNguyen
    Commented Oct 7, 2021 at 14:07
  • \$\begingroup\$ @DKNguyen Perhaps OP means that they cannot rotate around the horizontal axis without placing the forklift in a rather large CNC lathe? \$\endgroup\$ Commented Oct 7, 2021 at 14:45
  • \$\begingroup\$ @ChrisKnudsen Z-axis is the spindle axis on a lathe but if you're talking about a forklift then z-axis is a very strange label for a horizontal axis. \$\endgroup\$
    – DKNguyen
    Commented Oct 7, 2021 at 14:55
  • \$\begingroup\$ Have you ever asked yourself how a vessel compass is calibrated? You can read some old book, several decades ago it was a serious procedure, also the compass was the main instrument. \$\endgroup\$ Commented Oct 7, 2021 at 15:12
  • \$\begingroup\$ @ChrisKnudsen Yes, I meant horizantal axis. I can only rotate the forklift around yaw (can't do roll and pitch rotations). \$\endgroup\$ Commented Oct 7, 2021 at 15:38

1 Answer 1


I did not understand well the use case. Nevertheless, I would recommend to use your mobile phone ( if not done yet) attached to your machine and install Sensor List or similar to check which one is more suitable. As I recall, there are some real sensors and virtual sensors listed there ...

On the other hand, I would avoid Choice 3 in that library. Usually magnetic compensation is performed to compensate earth magnetic field fluctuation ( Not all points on earth have same magnetic field)...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.