Pages: [1]   Go Down
Author Topic: 1 year timer with Leonardo  (Read 668 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using a Leonardo to create a replacement control board for an air conditioner.

The Leonardo is taking information from sensors, and controlling a bank of 8 relays.

Part of the system requires an alarm (an LED) to remind the user to clean the air filters every, say, 1 year. What hardware do I need to add to the Leonardo to acheive this? Do I need a second Leonardo? It really ought to be able to remember where it has got to, and be able to carry on from there, if there's a power cut.

Thanks for any suggestions.
Logged

Croatia
Offline Offline
Sr. Member
****
Karma: 11
Posts: 443
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A real time clock?
http://playground.arduino.cc/Main/DS1302
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might consider using a RealTime Clock with battery backup - e.g. http://www.sparkfun.com/datasheets/Components/DS1307.pdf  -
to restore time after a power failure.

For the rest depends on the sensors you read, maybe some libs and voltage convertors.

For the relays you need a separate power supply and possible optocouplers to decouple leonardo from relay.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3639
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could use the Leonardo's EEPROM and keep track of how many hours (or tens of hours) have passed and assume that the occasional power outage doesn't really matter for filter reminding purposes. Just be aware that the EEPROM has a limited number of write cycles before it goes bad (~100,000). Alternatively, you could add a RTC and just store the time you last changed the filters in EEPROM. You'll need a switch for the user to reset the time when the filters are changed too.
Logged

Lindenwold, NJ USA
Offline Offline
Jr. Member
**
Karma: 2
Posts: 58
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been working on just such long delays as part of my initial Arduino timer study. All you need to do is count rollovers or overflows of a timer.  Assuming a 16mhz clock, the max time of one 8 bit overflow, with a prescale of 1024 is 16.320 milliseconds.  There are 31.558 x 10^6 seconds in a year, and that divided by 16.320x10^-3 = 193.400 x 106 overflows.

If you use Timer 1, the overflow is 65536 x 64 usecs or 4.19 SECONDS.  So now we can divide the year of seconds by 4.19 seconds for an overflow count of 7.531 x 10^6.  It turns out a LONG variable (32 bits) can hold a 4.29x10^9 counts - so you just set up a long variable, set timer 1 to CRC mode, set OCRA to TOP or 0xFFFF, set up an ISR.  Each interrupt, increment your YEARCOUNT, and when it reaches 7.531 x 10^6 the year has ended!

My numbers (years and such) may be off a tad - I'm typing this in quickly.  But the basic idea is to turn any long interval ( longer than 1 second) into a a number of seconds, the count the overflows.  Naturally the final accuracy of this all depends on how much the Leonardo timer crystal drifts and other vague issues. But for a air conditioner filter-change alert, I suspect it will be fairly close and requires little technology to make it work.

=Alan R.

I am using a Leonardo to create a replacement control board for an air conditioner.

The Leonardo is taking information from sensors, and controlling a bank of 8 relays.

Part of the system requires an alarm (an LED) to remind the user to clean the air filters every, say, 1 year. What hardware do I need to add to the Leonardo to acheive this? Do I need a second Leonardo? It really ought to be able to remember where it has got to, and be able to carry on from there, if there's a power cut.

Thanks for any suggestions.
Logged

+++++++++++++++++++++++++++++++++++++
The completion date of a software project is 2 weeks from any given date.

Pages: [1]   Go Up
Jump to: