LamaPLC: Simatic S7 SCL commands: Bit logic operations

positive/negative edge monitoring

Of course, there is an R_TRIG / F_TRIG function for edge monitoring, but do you really need to call an FB and an IDB for such a simple function?

Both positive and negative edge monitoring require an additional BOOL-type static, DB, or mark variable (temp is not suitable) in addition to the signal variable. This variable stores the signal state from the previous cycle, which is then compared to the current state. If the old state is FALSE and the current state is TRUE, it indicates a positive edge; if the reverse is true, the old state is TRUE, and the new state is FALSE.

The example below demonstrates the two options, with the variables being FB local “static” variables, but they can also be DB variables or markers. The signal can also be an input.

edge_monitor

// signal, old_signal is type BOOL
 
IF #signal AND NOT (#old_signal) THEN
    // positive flash block program
    // 
    ;
END_IF;
 
IF NOT(#signal) AND #old_signal THEN
    // negative flash block program
    // 
    ;
END_IF;
 
// update the storage BOOL
#old_signal := #signal;

>> Back to LamaPLC main menu (SCL commands)

R_TRIG

Detect positive signal edge, if the state changes from FALSE to TRUE at CLK. I have described above a similar but much simpler procedure for edge monitoring: positive/negative edge monitoring.

_FB_ R_TRIG (CLK := signal monitoring (BOOL), Q ⇒ result (BOOL);

parameter nameparameter typefunction
CLK inputIncoming signal
Q outputResult of edge evaluation

>> Back to LamaPLC main menu (SCL commands)

If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.

2026/01/06 15:16

F_TRIG

Detect a negative signal edge if the state transitions from TRUE to FALSE at the CLK. I have described above a similar but much simpler procedure for edge monitoring: positive/negative edge monitoring.

_FB_ F_TRIG (CLK := signal monitoring (BOOL), Q ⇒ result (BOOL);

parameter nameparameter typefunction
CLK inputIncoming signal
Q outputResult of edge evaluation

>> Back to LamaPLC main menu (SCL commands)

Automation! - S7 index

URL_nameNameDescriptionReadiness status
automation:s7_varSimatic Variables/TypesVariables, types, addressing, pointer90 %
automation:s7_hwSimatic HW basic / PLC TypesHW config, SW structure2 %
automation:s7_modbusSimatic and ModbusSimatic S7 and Modbus communication1 %
automation:s7_scl_commandsSimatic FunctionsStandard and system functions70 %
automation:s7_comSimatic CommunicationCommunication0 %
automation:s7_opcSimatic OPC UAUsing and operating OPC UA0 %
automation:s7_ardSimatic & ArduinoSimatic & Arduino1 %
automation:s7_iotSimatic IoTSimatic & Internet of Things0 %
2026/01/19 14:15



This page has been accessed for: Today: 3, Until now: 77