Well 2-5 days passed quickly :P... ok, ok, I'm ahead of schedule here. I grabbed a copy of the library and made some tiny changes (so I didn't have the baggage of AP).
Specifically I changed AP_Declination.h
#ifndef AP_Declination_h
#define AP_Declination_h
#include <Arduino.h> // added this
#include <avr/pgmspace.h>
#include <math.h>
AP_Declination.cpp
//#include <FastSerial.h> // removed this
//#include <AP_Common.h> // removed this
#include <Arduino.h> // added this
#include <AP_Declination.h>
#include <avr/pgmspace.h>
#include <math.h>
Then I changed prinf to print in AP_Declination_test and removed "FastSerialPort(Serial, 0);". All compiles well and runs flawlessly in my Arduino Mega. Passed all of their self-tests and for the few points I tried was within 1 degree of magnetic-declination.com. Yay!
mmcp42:
me again!
+12 degrees in Northern Finland
Botswana -11 degrees
trouble is magnetic substrata can have a massive local effect
I recall seeing aeronautical isocline charts for Scandinavia with loops and whorls like a fingerprint
Super job! Thanks for finding outliers for me to check. Just compared them against the library and it agrees with magnetic-declination.com to within a degree for all the places I checked. Happy :).
PeterH:
I don't understand why you're trying to deal with magnetic declination and so on. It seems that the objective is to predict the position of the sun so you can point a solar collector at it. To do that you need to know the lat/log, time and direction of North. But just how accurately do you need to know which way is North? Or put another way, just how directional is your solar collector? If it's a flat PV panel, it's not very directional at all. Surely, a GPS position and time fix plus a bog standard uncorrected magnetic compass is going to get you better accuracy than you need. If you don't think it is, then what sort of accuracy are you aiming for, and why?
You are right that a PV panel isn't that directional at all. The energy collected will probably fall off roughly as the cosine of the angle between the panel normal and the direction of the sun. I suppose 10 degrees off (due to declination) wouldn't be the end of the project and it would be very reasonable to just neglect it.
I am a bit of a perfectionist, however, and I am hoping some of what I learn/cobble together can be used in other projects such as heliostats where precision could be more important. I have been working with Gabriel over at cerebralmeltdown.com and he has managed to create a library that can track the sun with better than degree accuracy at a rate of one calculation per second. I have built/adapted a machine that can move a panel to better than 1 degree of accuracy. It seemed natural to me to just try to maintain this accuracy provided it didn't take up all my time. I wondered how easy it would be and thanks to this thread I think I'm there now in just 1 day! Yay!