[time-nuts] Clock Correction Algorithm

Miguel Gonçalves mail at miguelgoncalves.com
Thu Nov 24 14:21:37 UTC 2011


Hi Javier!

Thanks for your help. 

On 24/11/2011, at 13:16, Javier Herrero <jherrero at hvsistemas.es> wrote:

> El 24/11/2011 13:56, Miguel Gonçalves escribió:
>> 
>> 
>> Right! That is what I am doing.
>> 
>> The problem is the drift between adjustments. Arduino's clock is slow 25 ms every minute and if temperature changes it will surely be different.
>> 
>> 
> That is more than 400ppm error, that sounds quite high. Is the clock frequency of the Arduino so drifted? I would try first to check (and correct a bit) the source of that error. If the crystal frequency is ok, perhaps there is an error in the programming of the timer that generates the timing interrupt.

I am using an Arduino Uno that presumably is running at 16 MHz. 

I am using a 16 bit timer with a 256 pre-scaler:

16000000 / 256 = 62500 Hz

1 / 62500 = 16 us

65536 - 62500 = 3036

I am setting the counter to 3036 and let it overflow after 65535.

If I check the error every second I see the clock getting behind correct time and after 60 seconds it's 25 ms apart from UTC. 

Perhaps I should increase the initial value from 3036 to 3036+25E6/(60/16). I will make the second shorter this way. 

What do you think?

Cheers,
Miguel


> 
> Regards,
> 
> Javier
> 
> 
> _______________________________________________
> time-nuts mailing list -- time-nuts at febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.



More information about the time-nuts mailing list