Go Down

Topic: Delay question (Read 599 times) previous topic - next topic

PlayStationFarm

I'm a beginner so please excuse my ignorance.

If I want to program an 8 hr. delay do I program 480000ms or is there an "hour, minute, second" command in the programming language?  Also can someone recommend a method of energy conservation to minimize the electrical consumption during a lengthy delay?  Thanks.

wildbill

#1
Feb 10, 2013, 12:29 pm Last Edit: Feb 10, 2013, 12:33 pm by wildbill Reason: 1
As far as I know, millis is the only game in town unless you add hardware such as a real time clock. Don't forget to declare any variables you use to store millis as unsigned long and any constants you use will need a UL suffix e.g. 60000UL. For power consumption help, search the forum for watchdog timer.

Edit: BTW - 480000ms is eight minutes.

UKHeliBob

Have a look at the TimeAlarms library.
Set an alarm to go off in 8 hours and run a function that you specify.
Job done.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

PlayStationFarm

Thanks wildbill.  Oops, I meant 28800000ms - see what I mean?  Dealing with ms for lengthy timing gets somewhat unwieldy.


Have a look at the TimeAlarms library.  Set an alarm to go off in 8 hours and run a function that you specify.  Job done.

Where would you suggest I look for TimeAlarms library info?

wildbill


Have a look at the TimeAlarms library.
Set an alarm to go off in 8 hours and run a function that you specify.
Job done.


D'oh! of course!

MarkT

Which Arduino board?  There is no way to shutdown the USB chip on boards such as Uno and Mega AFAIK,
so putting the microcontroller into a sleep mode won't drastically reduce current consumption.  Usually you'd
need an real-time-clock chip if going that route as running the microcontroller's 16MHz clock is a large part
of the current consumption.

Its worth searching these forums carefully there have been several lengthy threads on this sort of thing.

[ I won't respond to messages, use the forum please ]

johncc


Where would you suggest I look for TimeAlarms library info?


Google?  :)

TimeAlarms is included in the Time library:
Code: [Select]
http://playground.arduino.cc/Code/time

Unfortunately the playground does not include documentation for it though.  But see the example sketch--and the readme file in the library folder that you install.

And google.  http://www.lmgtfy.com/?q=arduino+timealarms

Cheers,
John

AWOL

Quote
I meant 28800000ms - see what I mean?  Dealing with ms for lengthy timing gets somewhat unwieldy.
so, don't do it. Let the compiler take the strain
Code: [Select]
8UL * 60UL * 60UL * 1000UL.
Of course, you could also name the constants.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nick Gammon


  Also can someone recommend a method of energy conservation to minimize the electrical consumption during a lengthy delay? 


See this for tips on saving power:  http://www.gammon.com.au/power
http://www.gammon.com.au/electronics

Go Up