Pages: [1]   Go Down
Author Topic: Delay question  (Read 563 times)
0 Members and 1 Guest are viewing this topic.
Midwest USA
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 10, 2013, 06:33:45 am by wildbill » Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4267
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Midwest USA
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12205
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

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

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 361
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where would you suggest I look for TimeAlarms library info?

Google?  smiley

TimeAlarms is included in the Time library:
Code:
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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 303
Posts: 26354
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
8UL * 60UL * 60UL * 1000UL
.
Of course, you could also name the constants.
Logged

"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.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18819
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

  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
Logged


Pages: [1]   Go Up
Jump to: