More on triggers… (I finally got to this project, delayed since April, and am trying to make it work…)
I am troubleshooting some intermittent issues and decided to log some data whenever a change occurred to learn about using triggers.
While the loop in PAC Control is operating every 250ms, I did not want to check that often with PAC Display, so it checks every 500ms for the trigger.
I wanted at least 2 periods, so when a change is detected, the trigger is set to 1. On following loops, if the trigger is > 0, it increments. If it is >4. it resets to 0.
When I executed this code, I sometimes got more than 1 log of a data set. (There is a unique counter logged, so if the counter doesn’t increment, the same data is saved twice.)
I didn’t expect this. I changed the code to set the trigger to 1 and start an UpTimer. I then check the Uptimer and if >1, reset the trigger and stop the Uptimer.
I now get 1 and only one log of each captured data set. (Some data is not logged, if more than one change is detected while the trigger is already True, bu this was expected by the method).
I didn’t expect this to change the behavior. The Trigger went true when it went from 0 to 1. There should not have been any change when it went to 2, 3 and then 4. So why did I get multiple log entries with the original method?
I would like to try using a DownTimer set to 1 second as the trigger. This would then automatically reset, saving the checking. But if a changing value triggers a log event, this would result in multiple logging. Still open loop, but less code…