(image from http://www.ngdc.noaa.gov/geomag/WMM/image.shtml)
Hi folks!
I decided to implement an on-board declination calculator based on geographic location and I'd love to get some feedback. It takes up about 1400 flash bytes in total for a 3 degree declination error anywhere that people live (permanently - sorry Vostok!) and using a compass is reasonable. It's not going to be flight tested until it stops raining here, so use at your own risk! See the paper for more details :)
-John
Paper:
Lightweight%20Computation%20of%20the%20Earths%20Magnetic%20Field.pdf
APM Code - check under AP_GPS for AP_Declination_Lookup.*
LUT/IDW C# Calculator:
Footprint:
COMPASS_DECLINATION_LUT == DISABLED
113268 bytes, Free RAM: 1351, using 2061 bytes of memory
COMPASS_DECLINATION_LUT == ENABLED, COMPASS_DECLINATION_LUT_ACCURACY_LEVEL == 0
114692 bytes, Free RAM: 1351, using 2061 bytes of memory
Accuracy:
Scalable with table size
Table size: 89 entries (COMPASS_DECLINATION_LUT_ACCURACY_LEVEL == 0)
-------------------------------
Error 0 percentile: 0
Error 10 percentile: 0.1098926
Error 20 percentile: 0.2223369
Error 30 percentile: 0.3377705
Error 40 percentile: 0.4542923
Error 50 percentile: 0.5770731
Error 60 percentile: 0.7134132
Error 70 percentile: 0.8671622
Error 80 percentile: 1.072514
Error 90 percentile: 1.401104
Error 91 percentile: 1.447367
Error 92 percentile: 1.495352
Error 93 percentile: 1.551685
Error 94 percentile: 1.611044
Error 95 percentile: 1.676226
Error 96 percentile: 1.764013
Error 97 percentile: 1.864101
Error 98 percentile: 1.988347
Error 99 percentile: 2.208701
Error 100 percentile: 2.987068