T5

A Record of important things…

Compass Bug Killed!

FINALLY!!!   I had one last bug to track down that was annoying the hell out of me.  Very occasionally I would turn the digital compass on and it would be 20degrees off and stay that way until I had power cycled the unit a bunch of times.  I scrubbed the code for uninitialized variables.  Filtered the heck out of the power.  No change.

Experimentally I found that my lab supply was the problem.  The HMC5883L must go through some internal initialization at power up.   I have a big honking lab DC power supply.  Whenever I turn it off and on I get a relay click and a big hum - must be charging some caps or something.  Anyway, when that occurs the compass chip must latch onto some stray field being put out by the supply which screws up its internal power-up calibration routine.  Certain relationships and distances between the compass and the supply proved to be worse than others.

Using a different supply, or just a separate switch from the lab supply’s switch got rid of this behavior.  Nice to have it understood/killed.  My experience is that if you have a bug on the bench, even a  very rare one,  it will occur in the field - probably at the worst possible moment.