Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #135 on: January 27, 2013, 01:34:39 pm » |
Hey all, I have a question regarding the function time_t now() inside the time library: Inside this function the Arduino built-in timer ( millis() ) is compared to a last update time of the library. I wonder what will happen after approx. 50 days of operation when the number returned by millis() has an overflow. As far as I understood the code, the time will stay at its last update time and will not run anymore. Did anyone observe such a behaviour or is there a certain function which takes care about such an overflow which I did not recognize? Thanks, Thomas time_t now(){ while( millis() - prevMillis >= 1000){ sysTime++; prevMillis += 1000; #ifdef TIME_DRIFT_INFO sysUnsyncedTime++; // this can be compared to the synced time to measure long term drift #endif }
...
return sysTime; }
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14091
Lua rocks!
|
 |
« Reply #136 on: January 27, 2013, 04:15:55 pm » |
millis will wrap around after 50-odd days. It doesn't stop, or not run. If you do subtraction that wrap-around won't matter. eg. if (millis () - startTime >= wantedInterval) { // do something }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #137 on: January 29, 2013, 05:01:16 pm » |
What will happen if you have the following: Alarm.alarmRepeat(8,30,0, AlarmA); Alarm.alarmRepeat(8,30,0, AlarmB); Alarm.alarmRepeat(8,30,0, AlarmC); Will AlarmA get executed 1st, and then AlarmB and then AlarmC? Does the accuracy of the time, depends on other program running, or it has to be idle? In another words, Do I need to add delay(1) or something like that in my loop? Does the time accuracy changes when used with other libraries like PulsePattern? http://playground.arduino.cc//Main/PulsePatternThank you. Sia
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #138 on: January 29, 2013, 05:29:52 pm » |
Alarms for the same time will be called in the order the were scheduled.
The scheduler calls the alarm handler in the Alarm.delay function so this should be called regularly in the sketch. There is a readme file in the download with some more details. When there are more than one alarm ready to be triggered, the first scheduled alarm is serviced on the next call to Alarm.delay, the next scheduled alarm is serviced on the next call to Alarm.delay and so on. The accuracy of the servicing depends on how often the Alarm.delay function is called.
I have not used PulsePattern, but if time the code is in the interrupt handler is short, the timing accuracy should not be significantly affected. Why not give it a try. If you print the millis value in the alarm handler you should be able to see if that library is affecting the servicing of the alarms.
I hope that helps.
Have fun!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #139 on: January 29, 2013, 06:42:28 pm » |
Thank you Mem. It was very helpful.
I have been successfully use Alarm.timerRepeat(1, DisplayTime) and it seems to work correctly. Showing "millies" is a great idea, thank you. I will add that to my code.
Within my routine, it fetches something from the network, Reading some huge file, and parse and filter what it receives. I have this done every one minute with Alarm.timerRepeat(60, ReadData). The problem is when the data is being read, the DisplayClock does not seem to be executed (Clock stops), for 10~20 seconds. When its done with the ReadData code, it goes back and show the clock every second and the time seems to be correct.
With in ReadData code, I am using Alarm.delay, client.connect and some other functions from Ethernet library.
The PulsePattern works on Timer1. I will give that a try.
Thanks again.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #140 on: February 01, 2013, 11:05:19 am » |
I am a beginner with arduino. I have a funcioning lcd 20x4 with rtc module after a long time getting the correct libraries to work with arduino1.0.3. this display the time & date ect but I now need to add alarm functions etc. the working DS1307library i am using is called DS1307new and my code based on the below that came with library
Scriptname : DS1307_Test.pde // # Author : Peter Schmelzer, Oliver Kraus // # Date : 2011-04-08 // # Version : 1.21
I would like to use the alarmtime library and have downloaded the time library from arduino playground but all the programs give compile errors. I have removed all other libraries to check incase there was any conflicting ones but still does not work.
The above code and library is more complex than the code in the time library and would prefer to use that if possible.
Any help would be appreciated
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #141 on: February 01, 2013, 11:08:21 am » |
Once you downloaded the code, it became yours. You need to post YOUR code and YOUR error messages.
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #142 on: February 01, 2013, 11:24:34 am » |
Keith, there is code for connecting to a DS1307 RTC provided with the Time library download, its called TimeRTC. Why not use that?
Michael
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #143 on: February 01, 2013, 12:17:29 pm » |
Keith, there is code for connecting to a DS1307 RTC provided with the Time library download, its called TimeRTC. Why not use that?
Michael
Well, well. Look who's back. Been a while. Life treating you well, I hope.
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #144 on: February 01, 2013, 12:53:52 pm » |
Well, well. Look who's back. Been a while. Life treating you well, I hope.
Hi Paul, its good to be back. I have been busy with all kinds of interesting projects. Still am, but will try to hang out here as much as possible. Michael
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #145 on: February 03, 2013, 04:11:46 pm » |
Keith, there is code for connecting to a DS1307 RTC provided with the Time library download, its called TimeRTC. Why not use that?
Michael
Yes I have tried that but I can´t get any of the code to work of the official time library download, any ideas
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #146 on: February 03, 2013, 04:20:28 pm » |
just to illustrate I have just opened TimeRTC from examples/time/time/examples and tried to compile it. I have not touched this code. I just gave the other code so you were aware of what was working, I can post the whole code but becomes rather long. I'm sure the solution if something simple but can't get it. It seems to me it is not picking up the library but yet it is in the right place and in shown in examples.. thanks for any help. the errors in compiling shown below.
TimeRTC.pde: In function 'void setup()': TimeRTC:13: error: 'RTC' was not declared in this scope TimeRTC:13: error: 'setSyncProvider' was not declared in this scope TimeRTC:14: error: 'timeStatus' was not declared in this scope TimeRTC:14: error: 'timeSet' was not declared in this scope TimeRTC.pde: In function 'void digitalClockDisplay()': TimeRTC:28: error: 'hour' was not declared in this scope TimeRTC:29: error: 'minute' was not declared in this scope TimeRTC:30: error: 'second' was not declared in this scope TimeRTC:32: error: 'day' was not declared in this scope TimeRTC:34: error: 'month' was not declared in this scope TimeRTC:36: error: 'year' was not declared in this scope
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #147 on: February 03, 2013, 05:13:09 pm » |
It looks like the libraries are not being found. Make sure you have installed DS1307RTC in the Arduino libraries folder.
The Time.zip file is structured so you can copy the three folders (Time, TimeAlarms, and DS130RTC) into the Arduino Libraries folder.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #148 on: February 04, 2013, 04:41:20 am » |
Yes that what it seems like to me yet all the folders were unzipped correctly in the library folder. I've taken the screen shot to show
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #149 on: February 04, 2013, 09:13:58 am » |
The Time, TimeAlarms, and DS1307RTC folders all go at the same level. DS1307RTC does not go in the Time folder.
|
|
|
|
|
Logged
|
|
|
|
|
|