Timers/countdown and what Pots to use
Posted: Thu Jan 28, 2010 10:09 pm
I'm trying to come up with a way to implement two countdown timers and I have a hard time figuring out what the best way is to go about it.
The idea is to have 1 timer counting down from say max 90 minutes to min 5 minutes and then close a relay or switch on a transistor, the 2nd timer will countdown from say max 180 mins to min 5 mins. The user will have the option to switch between normal mode (90-5 mins range) and extended mode (180-5 mins range).
To set the number of minutes to countdown from the device will have 2 potentiometers (normal mode and extended).
What I struggle with is the code for this. How does one create a countdown for periods this long and what value should I use for my pots?
The countdown doesn't need to be extremely precise, +/- 30 seconds is acceptable.
If it's not too much to ask, what's the best way to display the countdown on an LCD? I'm not talking about using the LCD macros but showing 16 (minutes) instead of whatever the counter is at at that time (e.g. 23067).
The other requirement is to read the set time all the time, for example if the initial countdown was say 45 mins, the countdown is now at 30 mins but now the user changes the countdown to 10 mins, the 10 mins should become the new countdown from setting.
I know medelec35 has posted some timing code here: http://www.matrixmultimedia.com/mmforum ... 294#p16294 but I just can't wrap my head around it.
BTW, during the count down, the PIC should still be able to receive commands from buttons like Reset (not the PIC reset), turn on a alarm, etc. While I'm on this topic, any suggestion re. a CO sensor I can use with the 16F877A?
Thanks
D.
The idea is to have 1 timer counting down from say max 90 minutes to min 5 minutes and then close a relay or switch on a transistor, the 2nd timer will countdown from say max 180 mins to min 5 mins. The user will have the option to switch between normal mode (90-5 mins range) and extended mode (180-5 mins range).
To set the number of minutes to countdown from the device will have 2 potentiometers (normal mode and extended).
What I struggle with is the code for this. How does one create a countdown for periods this long and what value should I use for my pots?
The countdown doesn't need to be extremely precise, +/- 30 seconds is acceptable.
If it's not too much to ask, what's the best way to display the countdown on an LCD? I'm not talking about using the LCD macros but showing 16 (minutes) instead of whatever the counter is at at that time (e.g. 23067).
The other requirement is to read the set time all the time, for example if the initial countdown was say 45 mins, the countdown is now at 30 mins but now the user changes the countdown to 10 mins, the 10 mins should become the new countdown from setting.
I know medelec35 has posted some timing code here: http://www.matrixmultimedia.com/mmforum ... 294#p16294 but I just can't wrap my head around it.
BTW, during the count down, the PIC should still be able to receive commands from buttons like Reset (not the PIC reset), turn on a alarm, etc. While I'm on this topic, any suggestion re. a CO sensor I can use with the 16F877A?
Thanks
D.