domingo, 20 de julio de 2014

CRIUS compass magnetic interference (compassmot)

The problem

I am using the CRIUS AIOP v2 flight controller, with MPNG 3.01 R3. I have been flying some months using auto modes without problems (loiter and auto missions). After a crash on a windy day I rebuilded the quad again using a H.A.L frame, as I am very pleased with the robustness and weight, and also price of it. This time I configured everything in the middle part to maintain the center of gravity as centered as possible, as my previous crash was produced messing around with different roll/pitch pid values trying to adapt to different weighted arms (camera and battery on one H.A.L arm).

With this new configuration, flying in auto missions some times at the time of changing from one waypoint to the next, in the momment of heading to face the next point the quad fails the angle and begin to fly in some random direction and I have to take manual control and bring it back home. This also happened in loiter, but just some times, it begins to lean one random angle and slowly fly away. I checked all the hardware parts without solving anything, in the end using compassmot I realized that I have a 65% of interference due to power cables, as this time the FC was about 1cm above the power cables, much closer than in any other configrations I did before.

Here a video of the effect at Loiter:

One solution

This was the original configuration, you can see the board  very close to the power cables (between thw two H.A.L. plater, near the orange plastic parts)

Hardware configuration with high magnetic interference

Detail of CRIUS FC position, 1cm above power cables
And the result of compassmot of 65%!!, using Attopilot current voltage and current sensor, properly configured in Mission Planner so in compassmot I was measuring current vs throttle:

65% Current vs Throttle interference

Here the new configuration, with the CRIUS FC 5cm above the power cables:

Hardware configuration with small magnetic interference

CRIUS FC board 5cm above power cables
The compassmot results shows a reduction to 10% interference, which results in a perfect loiter and auto mission performance. It is very important to do a new live compass calibration after moving the compass to other place, as offsets can vary significantly. I like also to do a live calibration periodically as recommended in the datasheet of the HMC5883L compass used in CRIUS, to take into account sensitivity drift due to temperature variations.

10% Current vs Throtle interference
If you cannot move away the FC then you can always use an external magnetometer I2C connected to the CRIUS board.

This is just one method to avoid magnetic interference, some others are described here, simple methods as twisting wires from battery to FC, and from FC to ESCs. For me this was the most effective as magnetic interference reduces with the cube of the distance to the source of the interference.

Magnetic interference

For a better understanding on how to solve one specific wiring ditribution on a quad it is good to understand a bit of the physics involved, simpliflying  the wire path from battery to flight board and then esc and return to battery as a circle (DC current, the one that produces most of the interference problem) :

The formula of magnetic field at a point at z axis, perpendicular to loop plane (Bz >> Bx, By, theoretically cancelled ina perfect loop), let us deduce some facts about how our wiring distribution would behave:

  •  the bigger the circcle the stronger the magnetic field (proportional to R)
  •  higher current implies higher interference (proportional to I)
  •  the field reduces as the cube of the distance to the source (1/z3 proportional)
  •  twisting the wires creates a sort of loop along the z plane (each twist one loop) that makes Bz somehow cancel itself along z axis, or at least been reduced.