PLCS.net - Interactive Q & A

PLCS.net - Interactive Q & A (http://www.plctalk.net/qanda/index.php)
-   LIVE PLC Questions And Answers (http://www.plctalk.net/qanda/forumdisplay.php?f=2)
-   -   Edge trigging in ST or SCL (http://www.plctalk.net/qanda/showthread.php?t=127835)

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?

Code:

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


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.


Quote:

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'

http://www.plctalk.net/qanda/attachm...1&d=1610562946


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

.