TrojanHorse
Active Member
Is there a known issue when using the Elk Counters as timers and decreasing the value every second?
There's an old post here (http://cocoontech.com/forums/topic/16687-counters-timers/?p=140463) where @wuench says "As mentioned above you don't want to use counters as timers, you want to use phantom outputs.", which I'm starting to agree with, although it conflicts with some Elk examples here (https://www.elkproducts.com/using_counters.html)
Oddly, I had a problem before when I was using counters to monitor whether a zone was violated for more than 45 seconds and speak a message over the speakers and repeat every 45 seconds. If I had the counter start at 0 and count to 45 I would get unusual results (triggering at not always 45 second increments). If I started at 45 and counted down to 0 it worked as expected (similar to the Elk examples linked above). Perhaps this should be a clue to me and others, although it seems it really shouldn't matter whether I count up or down to a certain value.
Anyway, I have a more important set of programs that open gates if a fire or CO alarm is active for more than 60 seconds (the 60 second delay is to allow us to turn off a false alarm if appropriate before gates open). Randomly in the middle of the night when we were away these programs triggered. These programs have been stable for more than 6 months since initially set up. I'm suspecting an issue with the counters. Any ideas?
I'm pasting the programs below, basically I'm setting a counter to 60 upon Fire or CO alarm, decreasing by 1 every second, then when the counter is 0 trigger an output and send me a message so I know the program ran. Bottom line seems to me that if there was no fire or CO alarm active (there wasn't and there are no other events in the log), then the outputs should never have triggered and I shouldn't have received the email messages from these programs. The counters are not used in any other programs.
Any thoughts? Why are some people here saying not to use counters this way when Elk suggests it's okay with examples. I can use a phantom output instead but wanted to better understand what's going on here. It certainly seems like there is an issue with using counters this way...
Relevant Elk Rules:
Count how long fire alarm has been active
WHENEVER ANY FIRE ALARM TURNS ON
THEN SET FireCOsec (Counter 1) TO 60
Count how long CO alarm has been active
WHENEVER ANY CARBON MONOXIDE ALARM, ANY AREA TURNS ON
THEN SET FireCOsec (Counter 1) TO 60
Subtract one from counter every second the fire alarm has been active
WHENEVER EVERY 1 SECONDS
AND ANY FIRE ALARM IS ACTIVE
THEN SUBTRACT 1 FROM FireCOsec (Counter 1)
Subtract one from counter every second the CO alarm has been active
WHENEVER EVERY 1 SECONDS
AND ANY CARBON MONOXIDE ALARM, ANY AREA IS ACTIVE
THEN SUBTRACT 1 FROM FireCOsec (Counter 1)
Open Both Gates if fire or CO alarm active for 60 seconds
WHENEVER FireCOsec (Counter 1) CHANGES TO 0
THEN TURN FIRE North Gate (Out 38) ON FOR 2 SECS
THEN TURN FIRE South Gate (Out 34) ON FOR 2 SECS
THEN SEND EMAIL MESSAGE 3 TO me (Email 3)
THEN SEND EMAIL MESSAGE 4 TO me (Email 4)
THEN SET FireCOsec (Counter 1) TO 60
Reset the counter once the fire alarm is turned off
WHENEVER ANY FIRE ALARM CUTS OFF
THEN SET FireCOsec (Counter 1) TO 60
Reset the counter once the CO alarm is turned off
WHENEVER ANY CARBON MONOXIDE ALARM, ANY AREA CUTS OFF
THEN SET FireCOsec (Counter 1) TO 60
There's an old post here (http://cocoontech.com/forums/topic/16687-counters-timers/?p=140463) where @wuench says "As mentioned above you don't want to use counters as timers, you want to use phantom outputs.", which I'm starting to agree with, although it conflicts with some Elk examples here (https://www.elkproducts.com/using_counters.html)
Oddly, I had a problem before when I was using counters to monitor whether a zone was violated for more than 45 seconds and speak a message over the speakers and repeat every 45 seconds. If I had the counter start at 0 and count to 45 I would get unusual results (triggering at not always 45 second increments). If I started at 45 and counted down to 0 it worked as expected (similar to the Elk examples linked above). Perhaps this should be a clue to me and others, although it seems it really shouldn't matter whether I count up or down to a certain value.
Anyway, I have a more important set of programs that open gates if a fire or CO alarm is active for more than 60 seconds (the 60 second delay is to allow us to turn off a false alarm if appropriate before gates open). Randomly in the middle of the night when we were away these programs triggered. These programs have been stable for more than 6 months since initially set up. I'm suspecting an issue with the counters. Any ideas?
I'm pasting the programs below, basically I'm setting a counter to 60 upon Fire or CO alarm, decreasing by 1 every second, then when the counter is 0 trigger an output and send me a message so I know the program ran. Bottom line seems to me that if there was no fire or CO alarm active (there wasn't and there are no other events in the log), then the outputs should never have triggered and I shouldn't have received the email messages from these programs. The counters are not used in any other programs.
Any thoughts? Why are some people here saying not to use counters this way when Elk suggests it's okay with examples. I can use a phantom output instead but wanted to better understand what's going on here. It certainly seems like there is an issue with using counters this way...
Relevant Elk Rules:
Count how long fire alarm has been active
WHENEVER ANY FIRE ALARM TURNS ON
THEN SET FireCOsec (Counter 1) TO 60
Count how long CO alarm has been active
WHENEVER ANY CARBON MONOXIDE ALARM, ANY AREA TURNS ON
THEN SET FireCOsec (Counter 1) TO 60
Subtract one from counter every second the fire alarm has been active
WHENEVER EVERY 1 SECONDS
AND ANY FIRE ALARM IS ACTIVE
THEN SUBTRACT 1 FROM FireCOsec (Counter 1)
Subtract one from counter every second the CO alarm has been active
WHENEVER EVERY 1 SECONDS
AND ANY CARBON MONOXIDE ALARM, ANY AREA IS ACTIVE
THEN SUBTRACT 1 FROM FireCOsec (Counter 1)
Open Both Gates if fire or CO alarm active for 60 seconds
WHENEVER FireCOsec (Counter 1) CHANGES TO 0
THEN TURN FIRE North Gate (Out 38) ON FOR 2 SECS
THEN TURN FIRE South Gate (Out 34) ON FOR 2 SECS
THEN SEND EMAIL MESSAGE 3 TO me (Email 3)
THEN SEND EMAIL MESSAGE 4 TO me (Email 4)
THEN SET FireCOsec (Counter 1) TO 60
Reset the counter once the fire alarm is turned off
WHENEVER ANY FIRE ALARM CUTS OFF
THEN SET FireCOsec (Counter 1) TO 60
Reset the counter once the CO alarm is turned off
WHENEVER ANY CARBON MONOXIDE ALARM, ANY AREA CUTS OFF
THEN SET FireCOsec (Counter 1) TO 60