Gadget, Strike and Dip

WMM code ported to STM32! I think!

In my quest to get the Strike and Dipper up to snuff, I found a program to automatically determine the magnetic declination from any location on Earth, the World Magnetic Model from NOAA.  It is really lightweight, if you’re working on a PC or SoC, but the geoid information alone is 4 MB.  So I dumped the geoid stuff.  I’m pretty sure it is only used to correct for the Earth not being a perfect sphere, so it shouldn’t have too large of an effect.  The main thing that I did was to move the coefficients from a file to a function.  It’s kind of ugly, but it should do the job of loading them up into RAM.  The files can be found at GitHub.

Unfortunately, I’ve only verified that it compiles without error since it is almost 1KB larger than the STM32F030R8 can handle.  I need to either port it over to the STM32L476RG that I have kicking around, or pick up an STM32F4 since that will be cheaper for manufacture.  I really don’t want to move to the STM32F7, but given the current size of the code and all it does is the WMM algorithm, it may need some more horse power.

In other Strike and Dipper news, I’ve determined that the shoddy readings reported earlier are a result of really bad mag/accelerometer integration.  I’ve tried a few different schemes that I’ve found online, but none of them have been particularly helpful.  I’ve even thrown in an automatic calibration algorithm to no avail.  I’m thinking that I may need to try a higher quality IMU, but I’d really like to get it going with the LSM303.