Go Down

Topic: Time and TimeAlarms Libraries – Ask here for help or suggestions (Read 78 times) previous topic - next topic

ninja2

#65
Feb 02, 2012, 09:09 pm Last Edit: Feb 02, 2012, 09:23 pm by ninja2 Reason: 1
The time inaccuracy is due to the Arduino hardware, the library itself will not fix that.

You can improve accuracy by adding a Real Time Clock (RTC) breakout such as the DS1307. I'm finding the inaccuracy of a DS1307 Real Time Clock is typically to loose around 5 to 8 second every day. It can be more or less than this but it gives you an idea. At 5 secs/day that would be about 15 minutes lost in six months. If this áccuracy is not good enough for your project, there are two possible solutions:

1) buy a more accurate RTC, such as the DS3231. See this thread http://arduino.cc/forum/index.php/topic,87846.0.html

2) run the clock for a few days and work out how much it gains/looses per day, then write software to compensate.

Your compiling problem is because you are using an old version of the time library . In the release notes for Arduino 1.0  it explains "wprogram.h" is now replaced by "arduino.h". You need to change the code to fix this. But it's your lucky day, to save you time I've attached a revised version of the Time library which has this update in Time.cpp:

#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

schrockstudio

#66
Feb 02, 2012, 10:20 pm Last Edit: Feb 02, 2012, 10:28 pm by schrockstudio Reason: 1
Thanks ninja!

upon reading more it seems that you cannot use millisecond delays with the timealarm lib.
At 9pm every sunday I want to set the array to do a simple choreographed sweep through the LEDs back and forth 60 times and that requires the LEDs to High/Low with 100 milliseconds delays.
-Is that not possible using TimeAlarm Lib?
-If I simply calculate Milliseconds 604,800,000(once a week) and use the Arduino's clock, what is the typical drift? I can live with a little change. if that change is consistant. ie, it looses/gains 26.44 seconds a day. I can plan my events accordingly to that.

The 6months/deadline starts in 4 days. so I cannot order any of those shields.

Also a concern I have is, what if there is a power surge? does the Arduino reset the program completely or start where it left off?

Thanks! Thanks thanks!!!



*edit. PaulS I just read your post, thanks for letting me know about the Lib update!
-So as it sounds the hardware timing inconsistency isn't solved by software/code. so that means it is an A)inconsistant time change?
or
B)just inconsistant between different Arduinos, so I could calculate my specific hardwares drift and adjust?

Thank you for helping!

Brian Brumfield

Just a passing suggestion.

It seems like what you're describing is a set of modes. One mode for a period of time, and then another, and so on.

One thing you could do is use the Arduino's EEPROM (non-volatile RAM) to write the current mode, so that on power-cycle it can restart in the last mode, where it left off. You could likewise do something like tick off the number of hours in that mode, so your recovery to the last mode could also be a little more granular than just a restart from the beginning.

EEPROM tips here: http://arduino.cc/it/Tutorial/EEPROMWrite

phantom89

hi,
I need to include a clock in my project, that syncs with NTP. But im using an enc28j60 based ethernet controller(Using Ethercard library). so how can i modify the TimeNTP example to use it with my Ethernet controller.
(I have already established the internet connection)

miker

I've downloaded and installed the subject library. The sketch (RealTimeClockDS1307_Test)
complies and loads without error but when I run it and view the Serial Monitor I just get
a sequence hex chars that do not appear to be incrementing... the output on
the Serial Monitor looks like this:

Code: [Select]

1: FF-1F-3F 1F:7F:7FP
2: FF-1F-3F 1F:7F:7FP
3: FF-1F-3F 1F:7F:7FP
4: FF-1F-3F 1F:7F:7FP
5: FF-1F-3F 1F:7F:7FP
6: FF-1F-3F 1F:7F:7FP
7: FF-1F-3F 1F:7F:7FP
8: FF-1F-3F 1F:7F:7FP
9: FF-1F-3F 1F:7F:7FP
10: FF-1F-3F 1F:7F:7FP
11: FF-1F-3F 1F:7F:7FP
12: FF-1F-3F 1F:7F:7FP
13: FF-1F-3F 1F:7F:7FP
14: FF-1F-3F 1F:7F:7FP
15: FF-1F-3F 1F:7F:7FP
16: FF-1F-3F 1F:7F:7FP
17: FF-1F-3F 1F:7F:7FP
18: FF-1F-3F 1F:7F:7FP
19: FF-1F-3F 1F:7F:7FP
20: FF-1F-3F 1F:7F:7FP
21: FF-1F-3F 1F:7F:7FP
22: FF-1F-3F 1F:7F:7FP
23: FF-1F-3F 1F:7F:7FP
24: FF-1F-3F 1F:7F:7FP
25: FF-1F-3F 1F:7F:7FP
Send ? for a list of commands.
26: FF-1F-3F 1F:7F:7FP
27: FF-1F-3F 1F:7F:7FP
28: FF-1F-3F 1F:7F:7FP


Looking at the DS1307 datasheet the default/power on  date/time should be  01/01/00 00:00:00 but I can't
get to this from FF-1F-3F 1F:7F:7FP ??

Go Up