Mag P controller

From MultiWii
Jump to: navigation, search

Requirements

For magnetic heading hold to work, you must have a flight controller with a magnetometer. It is important to protect the magnetometer from stray magnetic fields, eg those from high current motor, battery and ESC wiring, or permanent magnets.

You must check and set your magnetic declination every few months to ensure the best performance of the mag mode and GPS modes.

Test your setup by tethering your multirotor or removing all the props, arm and give at least 50% throttle while checking the reported heading doesn't deviate. If the heading deviates more than a few degrees you need to increase the distance between the mag and the wiring.

Calibrate your mag sensor regularly, outdoors and test your heading over a full rotation of yaw (holding the copter, while it is not armed). The heading should smoothly update as you rotate it. If the heading doesn't look correct during any part of the rotation, repeat the calibration procedure until you are satisfied with the result. Stray magnetic fields can upset this process so do it far from buildings and power lines etc.

Mag P controller tuning

Since the magnetic heading hold is controlled only by a proportional (P) controller, there is only one value to adjust. The larger the P value, the more forcefully the flight controller will react to deviations from it's desired heading. If your multirotor yaws by itself and isn't able to hold heading in mag mode increase the P value gradually until performance improves. Higher values of P will likely cause oscillations around the correct heading.