[time-nuts] Clock Correction Algorithm

2011-11-24 Thread Miguel Gonçalves
Hi! I am building a clock that fetches its time from a local NTP server (GPS synched machine). I am using a timer based on a 16 bit interrupt on an Arduino (ATmega328 clocked at 16 MHz). I am implementing an algorithm to steer the this clock (nothing as complicated as the NTP algorithms) and

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Attila Kinali
On Thu, 24 Nov 2011 10:14:17 + Miguel Gonçalves m...@miguelgoncalves.com wrote: The clock is set by sending an NTP packet and setting the clock with the replied timestamp plus half of the round trip time. In a local LAN this seems a good solution. I am not after micro-second accuracy as

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Miguel Gonçalves
On 24/11/2011, at 11:42, Attila Kinali att...@kinali.ch wrote: On Thu, 24 Nov 2011 10:14:17 + Miguel Gonçalves m...@miguelgoncalves.com wrote: The clock is set by sending an NTP packet and setting the clock with the replied timestamp plus half of the round trip time. In a local LAN this

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Javier Herrero
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

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Attila Kinali
On Thu, 24 Nov 2011 12:56:31 + Miguel Gonçalves m...@miguelgoncalves.com wrote: 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. The proposed algorithm

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Miguel Gonçalves
Hi Javier! Thanks for your help. On 24/11/2011, at 13:16, Javier Herrero jherr...@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

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Miguel Gonçalves
Hi!! On 24/11/2011, at 13:48, Attila Kinali att...@kinali.ch wrote: On Thu, 24 Nov 2011 12:56:31 + Miguel Gonçalves m...@miguelgoncalves.com wrote: 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

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Attila Kinali
On Thu, 24 Nov 2011 14:21:37 + Miguel Gonçalves m...@miguelgoncalves.com wrote: 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: 1600 / 256 = 62500 Hz 1 / 62500 = 16 us 65536 - 62500 = 3036 I am setting the

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Javier Herrero
El 24/11/2011 15:21, Miguel Gonçalves escribió: 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: 1600 / 256 = 62500 Hz 1 / 62500 = 16 us 65536 - 62500 = 3036 I am setting the counter to 3036 and let it overflow after

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Bob Camp
Hi How about simply adding 1 ms every other second? You could then fine tune it by picking a small number of seconds to not add a ms to. Bob On Nov 24, 2011, at 7:16 AM, Javier Herrero jherr...@hvsistemas.es wrote: El 24/11/2011 13:56, Miguel Gonçalves escribió: Right! That is what I

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Miguel Gonçalves
Hi Atilla! On 24/11/2011, at 14:42, Attila Kinali att...@kinali.ch wrote: On Thu, 24 Nov 2011 14:21:37 + Miguel Gonçalves m...@miguelgoncalves.com wrote: 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: 1600 /

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Miguel Gonçalves
Hi Javier! On 24/11/2011, at 15:15, Javier Herrero jherr...@hvsistemas.es wrote: El 24/11/2011 15:21, Miguel Gonçalves escribió: 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: 1600 / 256 = 62500 Hz 1 / 62500 =

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Miguel Gonçalves
Hi! On 24/11/2011, at 15:16, Bob Camp li...@rtty.us wrote: Hi How about simply adding 1 ms every other second? You could then fine tune it by picking a small number of seconds to not add a ms to. An idea but I am searching for a more global and elegant solution. In fact, after reading

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Kevin Rosenberg
On Nov 24, 2011, at 9:35 AM, Miguel Gonçalves wrote: The software way is probably the best idea as it would account for small differences in different oscillators. I have 3 Arduino boards and will make 3 time displays. For precision timing with a microcontroller, I've been using the 10 MHz

Re: [time-nuts] Clock Correction Algorithm

2011-11-24 Thread Attila Kinali
On Thu, 24 Nov 2011 16:32:04 + Miguel Gonçalves m...@miguelgoncalves.com wrote: Hi Atilla! On 24/11/2011, at 14:42, Attila Kinali att...@kinali.ch wrote: I'm not quite sure i understood you correctly, and i dont know anything about the arduino and the avr32. But usually, you set a