Last question!! I swear!! Can I have 2 instances running at once? 1 counting the on time, and the other counting the off time?
Last question!! I swear!! Can I have 2 instances running at once? 1 counting the on time, and the other counting the off time?
No, the Elapsed Timer Demo can only have one timer at a time.
The same concept can be used to create multiple timers, but this demo doesn't do that.
Since the ON and OFF periods can't happen at the same time...
When one period is finished, Reset the timer and measure the next period.
You only need one timer.
You don't have to stop and start the timer, just GOSUB ResetTime, and the time will revert to 0d-00:00:00.0 and keep counting.
Use it like a Stopwatch.
The interactive LCD on this page shows how it works. (Click on the "GOSUBs")
http://www.darreltaylor.com/DT_INTS-14/elapsed.html
But that page is for the DT_INTS version of the Elapsed Timer.
DT
Well I've had an implementation of this working great for months now. Its counts down 20 minutes, turns off the output, flashes an LED using the pause command, then sits there waiting for the input to start again.
I need to add a feature now though. As the time reaches 15 minutes, I need it to flash an LED at 2Hz while still counting down and turning off at 20 minutes.
Currently the code is like this:
If I change it to this will it do what I need it to do? Second thing is if it will, how do I flash an LED while still running the main program? I am using HPWM already.Code:IF MinutesChanged THEN MinutesChanged = 0 IF Minutes = 20 THEN HPWM 1, 0 , 30000 POWER = 0 LEDS = 0 CURRENT = 0
Code:IF MinutesChanged THEN MinutesChanged = 0 IF Minutes = 15 THEN GOSUB Flashyflashy ENDIF IF MinutesChanged THEN MinutesChanged = 0 IF Minutes = 20 THEN HPWM 1, 0 , 30000 POWER = 0 LEDS = 0 CURRENT = 0 ENDIF
Hi,
I'm not that familiar with the code but the way you suggest will only call FlashyFlashy when minutes is 15 - not more, not less. If you want FlashyFlashy to keep executing all the way to 0 you need IF MINUTES <= 15 THEN You could also streamline it a bit, there's no real need to check and reset MinutesChanged twice, perhaps something likeCode:IF MinutesChanged THEN MinutesChanged = 0 IF Minutes <= 15 THEN GOSUB Flashyflashy IF Minutes = 20 THEN HPWM 1, 0 , 30000 POWER = 0 LEDS = 0 CURRENT = 0 ENDIF
Jim,
I think that'll just flash it once at the 15 minute point.
This should work.
Code:Flashing VAR BIT IF MinutesChanged THEN MinutesChanged = 0 IF Minutes = 15 THEN Flashing = 1 IF Minutes = 20 THEN Flashing = 0 HPWM 1, 0 , 30000 POWER = 0 LEDS = 0 CURRENT = 0 ENDIF ENDIF IF Flashing THEN SELECT CASE Ticks CASE IS <25 : HIGH LED CASE IS <50 : LOW LED CASE IS <75 : HIGH LED CASE ELSE : LOW LED END SELECT ENDIF
Last edited by Darrel Taylor; - 26th April 2012 at 23:08.
DT
Darrel, can this be used as a countdown timer with the time left updated each second and displayed on a LCD?
Thanks.
It Can ...
But you would need to create the count down routine.
The demo only counts up.
DT
Bookmarks