How to detect edge trigger in PAC

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.

What is the best practice?

1 Like

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.

@philip said it better in less words!

1 Like

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)

@Beno is a ninja

1 Like

Let me try.

Thank you.

Using Momemtary Button with 100 msec loop did not register for 1 momentary click.
But thank you for tips I found a way:

Using Command Button
imageimage

UI Chart
image image

Action Chart
image image

It probably could be simpler but so far it works.

Good job, it even accounts for those chronic double clickers!

:+1:

This is the simple button logic:
image

:smile:

Since you are using a command button wouldn’t the following work:

if(button == 10) then
  nzWipState = nzWipState + 1;
  button = 30;
endif

That is a good one! I can use the button in any part of the code.