1. Sequential control instruction STL\STLE\ST\SET\RST

1. Sequential control instruction STL\STLE\ST\SET\RST

1.1. Instruction description

  1. STL and STLE must be paired one by one, with STL representing the beginning of a state and STLE representing the end of a state;

  2. Each state is independent and cannot be nested with each other. During the execution of a scanning cycle, do not reuse STL segments with the same number;

  3. The initial state can be arbitrarily specified according to requirements, and does not necessarily have to be executed in the order of S0, S1, S2, etc;

  4. After executing the SET Sx K1 instruction, the Sx state is turned on, and the corresponding STL Sx ladder segment will be executed;

  5. After executing the RST Sx K1 instruction, the Sx state is turned off and the corresponding STL Sx ladder segment will be reset;

  6. When the state changes from ON to OFF, the output commands such as OUT, timer, pulse, etc. in the state will be reset, while the original state will be maintained for commands such as SET and turn on delay memory timer;

  7. SET and ST are both state transition instructions, but it should be noted that the difference between the two state transition instructions is:

(1) When the SET instruction is used and the state transition condition is met, the next state to be transitioned is set to ON. During the state transition process, both states will be turned on simultaneously only within one scanning cycle. The state in the current STL segment is reset to OFF in the next scanning cycle after the transition;

(2) When the state transition condition is met using the ST instruction, the next state to be transitioned is set to ON, but the state in the current STL segment is not reset to OFF. The ST instruction is generally used when the program needs to run multiple state programs simultaneously;

1.2. Example 1: The difference between SET and ST

NETWORK 000
LD M8150
SET S0 K1 // Initialization state S0 is ON
POP
NETWORK 001
STL S0
LD M8160
OUT Y000
POP
LD M0
SET S1 K1 // When condition M0 is conductive, state S1 is set to ON, and the S0 state is reset in the next scanning cycle.
POP
LD M1
ST S2 // When condition M1 is turned on, state S2 is set to ON, but it does not reset the current S0 state, meaning that the program will execute both S0 and S2 state programs simultaneously.
POP
STLE
NETWORK 002
STL S1
LD M8160
OUT Y001
POP
STLE
NETWORK 003
STL S2
LD M8160
OUT Y002
POP
STLE

1.3. Example 2: selectable branches and connections

In practical production, process selection or branch selection is necessary for jobs with multiple processes, that is, a control flow may be transferred to one of multiple possible control flows, but multiple branches are not allowed to be executed simultaneously; Which branch to enter depends on which of the transfer conditions before the control flow is true.

NETWORK 000
LD M8150
SET S0 K1
POP
NETWORK 001
STL S0
LD M8151
OUT Y000
POP
LD X000
SET S1 K1
POP
LD X003
SET S3 K1
POP
STLE
NETWORK 002
STL S1
LD M8151
OUT Y001
POP
LD X001
SET S2 K1
POP
STLE
NETWORK 003
STL S2
LD M8151
OUT Y002
POP
LD X002
SET S5 K1
POP
STLE
NETWORK 004
STL S3
LD M8151
OUT Y003
POP
LD X004
SET S4 K1
POP
STLE
NETWORK 005
STL S4
LD M8151
OUT Y004
POP
LD X005
SET S5 K1
POP
STLE
NETWORK 006
STL S5
LD M8151
OUT Y005
POP
LD X006
SET S6 K1
POP
STLE

1.4. Example 3: Parallel Branches and Connections

In many instances, a sequential control state flow must be divided into two or more different branches to control the state flow, which are parallel branches or concurrent branches. When a control state flow is divided into multiple branches, all branch control state flows must be activated simultaneously. When multiple control flows produce the same result, they can be merged into one control flow, which is the connection of parallel branches. When merging control flows, all branch control flows must be completed. In this way, the transition to the next state can only occur when the transition conditions are met.

The following example needs to be specifically noted: When parallel branches are connected, all containing states must be simultaneously transitioned to the new state to complete the startup of the new state. In addition, in the STL program segments of states S2 and S4, since the SET instruction is not used, the reset of S2 and S4 cannot be automatically performed, and they need to be reset using the reset instruction in the end. This processing method is often used in parallel branch connection merging, and the last state before parallel branch connection merging is often a "waiting" transition state, where they have to wait for all parallel branches to be in the "active state" before transitioning to the new state together. These 'waiting' states cannot be automatically reset, and their reset must be completed using reset instructions.

NETWORK 000
LD M8150
SET S0 K1
POP
NETWORK 001
STL S0
LD M8151
OUT Y000
POP
LD X000
SET S1 K1
SET S3 K1
POP
STLE
NETWORK 002
STL S1
LD M8151
OUT Y001
POP
LD X001
SET S2 K1
POP
STLE
NETWORK 003
STL S2
LD M8151
OUT Y002
POP
STLE
NETWORK 004
STL S3
LD M8151
OUT Y003
POP
LD X002
SET S4 K1
POP
STLE
NETWORK 005
STL S4
LD M8151
OUT Y004
POP
STLE
NETWORK 006
LD S2
AND S4
AND X003
SET S5 K1
RST S2 K1
RST S4 K1
POP
NETWORK 007
STL S5
LD M8151
OUT Y005
POP
LD X004
SET S6 K1
POP
STLE