I have an Arduino EtherMega R3 from Freetronics. If i was to use NTP to sync the time to the net without a RTC module (Ds1307 etc) - how much drift would i expect to see over say an hour ? And What is it (i.e. any functions that i perform) that would cause this to increase ?
This would be a stock standard board - no messing with bootloaders, fuses, crystals etc.
I have tried loading the NTP sketch and running that and then checking an hour later and it seems to have less than a 1 second drift - however this is in a test environment and the board is doing little else. My production system would be interfacing to a couple of SSRs and a goodly number of DS18B20 temp sensors as well as a LCD
There would be a certain amount of drift based on how accurate the resonator/crystal is. I think temperature would affect that to an extent. I seem to recall 10 to 30 ppm being a possible drift amount.
You could conceivably work out if it is running fast or slow by comparing what the next NTP reading is to what the internal reading is and then compensate.
Mind you, the NTP access won't be to the microsecond because of network latency, etc.
Thanks Nick - thats the answer i wanted - and just to clarify - there is nothing in basic code that would effect this and cause a greater drift ? i.e. i am not doing any weird power downs, or sleep cycles or anything else
If you implement a full NTP client then it would compensate for long term clock drift and skew. However, what you'll probably implement on an Arduino is an SNTP client that just steers the clock back towards the consensus time - as long as you provide a mechanism for correcting via skew adjustments then you should still be able to have a free-running clock that see-saws around the consensus time.
PeterH:
If you implement a full NTP client then it would compensate for long term clock drift and skew. However, what you'll probably implement on an Arduino is an SNTP client that just steers the clock back towards the consensus time - as long as you provide a mechanism for correcting via skew adjustments then you should still be able to have a free-running clock that see-saws around the consensus time.
Thanks Peter - i was planning on using the full example NTP client (with mods to return appropriate time for my Tz)