Rolling timer
Franklin
Posts: 4,747
I'm looking for a way to initiate a response when I get three inputs (on same pin) within five seconds. The problem is the timing has to roll with the inputs such that if the span from input 1 to 3 is six seconds the inputs 2 and 3 are still in play if a fourth input would make three in five seconds. Any thoughts or code examples?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Comments
-Tom
Post Edited (cica) : 6/2/2006 4:53:03 PM GMT
So if the events happen as, event1...4 seconds later event2...2 seconds event3...2 seconds event4
Time between event1 and event3 is more than 5 seconds so no output but time between event2 and event4 is 4 seconds so OUTPUT!
Hope this makes it more clear. I would have included a flowchart but I don't have software for that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
1) How accurate does it have to be?
2) Do you have an external real time clock or timer that you want to use as the reference, or do you want to do it all in PBASIC?
3) Does the program have to be doing other things while waiting for the three clicks, or can it be modal, just sitting there waiting for the button as its only task?
That is a modal snipppet devoted to monitoring the button with a granualarity of 0.1 second. You can see the problem if the stuff2do takes a long or indeterminate amount of time. While it is off doing the stuff, it is not timing of the button. If the stuff takes a definite amount of time, you can adjust the timer or the PAUSE to compensate. Similarly, if other stuff has to be done by the program while waiting for the buttons, it can be stuffed in as part of the PAUSE in each timing loop, and the PAUSE adjusted. It all depends on precision required and the other stuff. The situation and programming is diffferent if you have an external reference clock source.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Just for the record, many PIR detectors have built-in false alarm detection. Even beyond that, some are dual-sensing, in that they sense BOTH I/R _and_ movement, and won't fire off unless BOTH are present.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
I used to install alarm systems for a living. There are PIR detectors that require 3 events in order to trigger. I'd lose the stamp and buy one of these $20 detectors.
-Tom