Loading...
Pages: [1]   Go Down
Author Topic: Delay question  (Read 199 times)
0 Members and 1 Guest are viewing this topic.
Midwest USA
Offline Offline
Newbie
*
Karma: 0
Posts: 19
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
Edison Member
*
Karma: 24
Posts: 2345
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)
Online Online
Edison Member
*
Karma: 47
Posts: 1398
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

Midwest USA
Offline Offline
Newbie
*
Karma: 0
Posts: 19
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
Edison Member
*
Karma: 24
Posts: 2345
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
Tesla Member
***
Karma: 71
Posts: 6603
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

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
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
Online Online
Brattain Member
*****
Karma: 137
Posts: 19015
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.

Global Moderator
Melbourne, Australia
Offline Offline
Shannon Member
*****
Karma: 218
Posts: 13896
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
Print
 
Jump to: