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: >> >> 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. >> > Hi! > > Can you check the real frequency of the oscillator? If it is too far from > 16MHz, there are two options: trim the capacitors that are in the crystal > oscillator circuit (I'm not familiarized with the Arduino... but I suppose > they will be there), or... software trim changing the counter reload value as > you suggest :) 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. > Does the counter needs reloading every overflow or it is automatically > reloaded? depending on how you are done this, it can also provide some delays > that apparently slows the clock. It's manually reloaded with the 3036 value every time the routine is called. If I load it with a bigger value I will make a faster second. If with a small value the second will be longer. Thanks for your help! Cheers, Miguel > > Regards, > > Javier > > > > > _______________________________________________ > time-nuts mailing list -- time-nuts@febo.com > To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts > and follow the instructions there. _______________________________________________ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.