RTC update
Posted by kll on June 12 2015 09:12:46
using a RTC with my own code ( and make a USB MENU version )
i now play with the new libs
* http://www.pjrc.com/teensy/td_libs_Time.html
* http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
* http://www.pjrc.com/teensy/td_libs_DS1307RTC.html
and found that somehow my code was 30 years wrong.
as i use the RTC seconds and add 1970 years ( that's what i understand from the datasheet )
i still not find my mistake.

but using the Alarm lib i tested a easy day timer,
lets say you need to do 2 times a day the same job ( for a certain time )
-- you need to specify start time 1 and start time 2 ( hour , minutes )
-- you need to say how long ( time between start job and end job )
-- and you need to add your user code what has to be executed at start and end of JOB.
( not a conti job thinking like in my USB MENU )

while i play RTC i had a good question:
i understand that the time library creates a variable set in arduino
/ day / month / year / hour / minutes / seconds /
and using the cpu millisecs to keep it running ( by a software interrupt in the lib ?)
( when i did it the first time ( without library ) and run it for month i see that my cpu time was wrong about 4 minutes per day! )

when you use a RTC ( with battery ) and set the RTC once it has a more accurate time
( again i think seconds after 1.1.1970 )
while arduino boot you need to read the RTC and store it to above time lib variables.

but again this cpu time now runs alone ? and possibly out of sync from RTC.

in the RTC lib i not see a automatic resync function.
so i try my own, every hour i compare RTC and arduino time, and if off 5 sec, i set arduino by RTC again. That is not fully checked until now / so diagnostic prints still ON.

code doc