It appears teensy also has a clock compensation setting: Teensy3Clock.compensate(int). I would double check your soldering and whatnot.
Is the 250ms delay causing it to read accurate times, or is that just correcting the time? I wonder if refreshing the clock too quickly causes errors. Indeed I’m in over my head here, I hope others have some insight
It appears to be to do with the way it keeps time — if I set setSyncInterval to 1 then I get an accurate time but the second hand pauses every so often as it resynchronises itself.
If I set setSyncInterval to 10 then the thing is constantly moving the second hand backwards every ten seconds to correct itself.
Thanks for the idea. I was going to add a RTC to my Ardunio so I could turn my lightshows on/off automatically by time of day. I’ll play around with your code examples to see if I can get it to work for me. Of course, I will need to set the clock to some virtual time first.
The Teensy is very convenient as it has an RTC built in — for the cost and if it’s accurate enough for you it’s a neat solution. All you need is a coin battery holder.
The example code that comes with the Teensyduino software will set the time for you to your PC/Mac clock — super easy.
Update: I sorted this issue by doing this at the beginning of every loop:
time_t time = Teensy3Clock.get();
and then using the usual hours, minutes seconds etc
minute(time)
I also wanted to get an accurate millisecond so I am reseting an elapsedMillis every time a new second happens — this still won’t get you an accurate millisecond because it’s still using the Teensy crystal for timing which is approx 1.5x too fast on mine (overclocked 96Mhz). So I time the whole loop and then apply a compensation something like:
Bob— depends if you’re using any odd libraries— most of the key ones are ported to Teensy. The Teensy is really great — it’s so much quicker and bigger and gives huge overheads for speed and memory.
It’s a no brainer to go for a Teensy over an Arduino.