Say I have button, physical or groov, doesn’t matter.
I want to sense the pressing of button as one event not continuous event, and trigger to do an action, only once per trigger.
The problem I encounter, when the button is press too long, the action will be done many times.
The problem with not having an edge trigger function:
When using Momentary Button - you need to press long enough to sync with your program read cycle.
Using Command Button - there’s no need to sync with read cycle, but you need to de-assert button in your code.
A physical button and a button in groov View are very different and need to be treated differently.
When it comes to physical buttons (in PAC or EPIC), use the built in latch function.
So your chart would look for an on-latch event.
Once it has read the on-latch, it can clear it ready for the next button press.
This way, the operator does not have to hold the button and your software can just read the on-latch when it needs to check the button.
You can also use the get-and-clear latch events to both read and reset the latch from your flow chart.
When it comes to groov buttons (which you seem to mention in the last part of this post - if I am reading it correctly), then you usually have a UI chart, a chart that just takes care of the user interface and it has a pretty good scan rate (say 100 msec).
groov View writes button events straight away, so there is very little delay in sending the button press from groov to the strategy. There is the usual 1 second scan rate for reading variables, but not in writing them.
So, best practice is to use latches for physical buttons and use a user interface chart that handles the groov View button presses.
For a physical button, there is the GetOnLatch and GetClearOnLatch commands.
For a software button, you would need to set a flag variable that you handled the press and clear the flag when you see the button is no longer pressed. (This would work with a physical button as well)