Go Down

Topic: Time Library added to Playground (Read 41314 times) previous topic - next topic

Glasshopper

Quote

? timerRepeat is only in seconds and not formatted like alarmRepeat ?
You should be able to set timers just like alarms, did you try something like :  Alarm.timerRepeat( 1,30,0, TimerTask);   // set timer to repeat every 1 hour and 30 minutes


I see..
 Alarm.timerRepeat(1, 0, Repeats);
does not work
but
 Alarm.timerRepeat( 0, 1, 0, Repeats);
does.

thank you :D

mem

I could add the overloaded versions if that functionality is what most people expect:

timerRepeat(Period, TimerFunction); // Period in seconds
timerRepeat(Minutes, Seconds, TimerFunction); // Period in Minutes & seconds
timerRepeat(Hours, Minutes, Seconds, TimerFunction); // Period in Hours, Minutes & seconds

then  Alarm.timerRepeat(1, 0, Repeats)  would do the same thing as Alarm.timerRepeat(0, 1, 0, Repeats);

Peeter123

#32
Jan 21, 2010, 03:35 pm Last Edit: Jan 21, 2010, 03:39 pm by Peeter123 Reason: 1
I think you should make overloaded functions in the library. It's more logical.

For example when I say I'm gonna do something in 5 minutes, I don't say I'm gonna do something in 0 hours and 5 minutes ;)

Btw I have uploaded the sourcecode of the timesync application:

http://www.megaupload.com/?d=YIEMNV9W

adambrum

I have being having a play with the 1307rtc and alarm code and it works great apart from one thing.

When i have used other 1307 codes the rtc keeps the time when the power is off ( i have a sparkfun rtc with battery ) with the new code it resets the time and i cant find a way to set the rtc time so when i disconect the power the rtc stores the time.

Any ideas around this because apart from that the codes great and a lot less fuss thatn other codes.

Thanks Adam

mem

#34
Jan 30, 2010, 02:01 pm Last Edit: Jan 30, 2010, 02:02 pm by mem Reason: 1
Quote
..with the new code it resets the time and i cant find a way to set the rtc time so when i disconect the power the rtc stores the time.

Adam, can you clarify the problem you are having.

Is it that you can't set the time on the rtc (using the TimeRTCSet.pde sketch in the download)?

Or that once the time is set it does not display correctly when you disconnect and reconnect power with the RTC board connected to the Arduino board?  If the latter, check that the battery in the RTC board is ok.

adambrum

Looks like a dodgy rtc module.

I have a spare and it works fine, im sure i will be back with some more questions later.

Thanks Adam

moriszen

Hi Guys ,
I am trying to complete my logger project where my Arduino runs on batteries in low power (<1uA) and wakes up every specified time , reads the temperature off a thermal resistor , logs the data in an external SPI SD Flash along with date and time and goes back to sleep .
The problem is that the init of the SD starts logging from the beginning of the file and doesn't append an the sleep libraries don't seems to work so well with it .
Does anyone know of any similar project that was done along this area .
I couldn't find anything in the playground yet it seems very likely other people have done similar projects . ::)

mem

#37
Jan 30, 2010, 11:22 pm Last Edit: Jan 30, 2010, 11:25 pm by mem Reason: 1
moriszen, as I posted in an earlier reply to a question on your project, I would like to keep this thread focused on issues relating to the Time library.

You are more likely to attract relavant replies if you start a new thread with a title relevant to your project.

moriszen


Eddie Schnell

Hi All,

I am trying to use the Time Library on an RFID door project. It's running on an Arduino MEGA. I have a GPS hooked up to it, but when I tried to run it using the GPS code it completely locked up and would not allow any input. Instead, I am manually getting the date and time using gps.crack_datetime() and inputting it into setTime(), then using adjustTime(-18000) for the eastern time zone. It will only run the GPS dump if it has been around an hour or more since the last time. At first turn on, it gets the correct time and displays it on the LCD, and updates the LCD every minute perfectly. But after the door is opened, it waits in an endless loop for the the door to close before re-locking. The time is then way off. The code for the loop is posted below.

Thanks for your help,
Eddie Schnell

Code: [Select]
if(digitalRead(intopen) == LOW) return;                              // manual lock
 while(digitalRead(trigger) == HIGH) {
   delay(5);                                                          // take a breath
   if(digitalRead(intopen) == LOW) return;                            // manual lock
   Serial.println("Close the Door");                                  // debug
 }
 Serial.println("First Test Door Closed");                            // debug
 delay(50);
 if(digitalRead(intopen) == LOW) return;                              // manual
 delay(50);
 if(digitalRead(intopen) == LOW) return;                              // manual
 delay(50);
 if(digitalRead(intopen) == LOW) return;                              // manual
 if(digitalRead(trigger) == HIGH) {
   Serial.println("Failed Second Test");                              // debug
   while(digitalRead(trigger) == HIGH) {
     delay(5);                                                        // take a breath
     if(digitalRead(intopen) == LOW) return;                          // manual
     Serial.println("Close the Door Again");                          // debug
   }
 }

mem

Lets see if we can find out why you had problems running the example GPS code, perhaps that may be related to the problem you are having in your current sketch.

Was the example code that locked up modified, and if so, can you post the code you ran.

Eddie Schnell

OK, I went back to the original GPS code and put it into my code. It does not lock up everything, but it's stuck in 1970. It does seem to be counting in the loops though.

The code is too long to post, it is viewable at http://www.schnellnetworks.com/code.html

Thanks,
Eddie

Eddie Schnell

Had a breakthrough. When I pressed some of the buttons on the door, it magically got the correct time on the screen. I changed the startup code to wait for serial data to be available by using the feedgps function, then called the gps.encode line for the Time library to read, and now it seems to be getting the correct time at startup.

Code: [Select]
Serial.println("Waiting for GPS Time...");                          // debug
 setSyncProvider(gpsTimeSync);
 while(feedgps() != true) {                                          // if feedgps is false
   delay(50);                                                        // take a breath
 }
 gps.encode(Serial3.read()); // process gps messages


Thanks,
Eddie Schnell

mem

Eddie, good to hear you have it working, it looks like an interesting project. Perhaps you could post some more details in the exhibition forum when you are ready.

For the benefit of others  that may want to test using the GPS example code in the download, did that work as expected with your GPS after you changed the serial port for the Mega, but before you added any logic for your application?

transfinite

In reply #4 Veronica pointed out:
Code: [Select]
#include <time.h>

in Time.cpp should have a capital T.

This is the case ( ;)) in the DS1307RTC.h file also.

It took me way too long to figure out this was the problem.

Otherwise, great library.  I've been using the old one since last June, and it's nice to have RTC support integrated.
Also I was _really_ glad to see the default TIME_HEADER changed to 'T' instead of 255.

-transfinite

Go Up