- Interactive Q & A - Interactive Q & A (
-   LIVE PLC Questions And Answers (
-   -   Edge trigging in ST or SCL (

xzen January 12th, 2021 06:10 AM

Edge trigging in ST or SCL
What is your best practice for edge trigging in structured text language?


#condition := (Value1 > 0 OR NOT Tag1) AND Tag2;
IF #condition_positive_edge THEN

ojz0r January 12th, 2021 06:22 AM

Use the built in functions (IEC 61131-3):
- R_Trig: Rising edge
- F_Trig: Falling edge

AustralIan January 12th, 2021 07:19 AM

+1 R_Trig

Manglemender January 12th, 2021 07:55 AM

If you wish to code it yourself then:

IF Condition AND NOT Condition_Memory
Some Code
End IF

Condition_Memory = Condition

Lare January 12th, 2021 02:18 PM

Jesper's post 9 years ago, same as Manglemenders If condition on ST.


Originally Posted by JesperMP (Post 424585)
Dont think there is a one-shot block for SCL.
But it is trivial to code.

signal_oneshot_ON := signal_input AND NOT signal_mem ; // generate the ON oneshot
signal_oneshot_OFF := NOT signal_input AND signal_mem ; // generate the OFF oneshot
signal_mem := signal_input ; store the status of the input

ndzied1 January 13th, 2021 01:35 PM

1 Attachment(s)
Not sure if it's in all ST packages but in CoDeSys (at least in v3.5) you can set a bit for a positive or negative edge trigger. The 'P' indicates positive edge, for Negative edge it would be an 'N'

All times are GMT -5. The time now is 05:00 PM.