Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Sequence Control Relay Program Control

Inputs/Outputs Operands Data Types


n S BOOL
Memory Ranges Errors Instruction Support for S7-200 CPUs SIMATIC/International Mnemonics
Data Ranges ENO Instruction Size in CPU Memory Addressing Memory

SCR instructions provide you with a simple yet powerful state control
programming technique that fits naturally into a LAD, FBD, or STL program.
Whenever your application consists of a sequence of operations that must be
performed repetitively, SCRs can be used to structure your program so that it
corresponds directly to your application. As a result, you can program and
debug your application more quickly and easily.
The Load Sequence Control Relay (LSCR) instruction loads the SCR and
logic stacks with the value of the S bit referenced by the instruction (N).
The SCR segment is energized or de-energized by the resulting value of the
SCR stack. The value of the SCR stack is copied to the top of the logic stack
so that boxes or output coils can be tied directly to the left power rail without
an intervening contact.
The Sequence Control Relay Transition (SCRT) instruction identifies the
SCR bit to be enabled (the next n bit to be set). When power flows to the coil
or FBD box, the referenced n bit is turned on and the n bit of the LSCR
instruction (that enabled this SCR segment) is turned off.

The Sequence Control Relay End (SCRE) instruction marks the end of an
SCR segment.

The Conditional Sequence Control Relay End (CSCRE) instruction marks


the end of an SCR segment once power is applied to the input. CSCRE is only
available in the STL editor.
Note: CSCRE is available only in 2nd generation (22x) CPUs beginning
with version 1.20.

The following is true of Sequence Control Relay instructions.


 The Load SCR instruction (LSCR) marks the beginning of an SCR segment, and the SCR End instruction (SCRE)
marks the end of an SCR segment. All logic between the Load SCR and the SCR End instructions are dependent
upon the value of the S stack for its execution. Logic between the SCR End and the next Load SCR instruction is not
dependent on the value of the S stack.
 The SCR Transition instruction (SCRT) provides the means to transfer control from an active SCR segment to another
SCR segment. Execution of the SCR Transition instruction when it has power flow will reset the S bit of the currently
active segment and will set the S bit of the referenced segment. Resetting the S bit of the active segment does not
affect the S stack at the time the SCR Transition instruction executes. Consequently, the SCR segment remains
energized until it is exited.
 The Conditional SCR End instruction (CSCRE) provides a means to exit an active SCR segment without executing
the instructions between the Conditional SCR End and the SCR End instructions. The Conditional SCR End
instruction does not affect any S bit nor does it affect the S stack.
Restrictions for using SCRs
 You cannot use the same S bit in more than one routine. For example, if you use S0.1 in the main program, do not
use it in the subroutine.
 You cannot use the JMP and LBL instructions in an SCR segment. This means that jumps into, within, or out of an
SCR segment are not allowed. You can use jump and label instructions to jump around SCR segments.
 You cannot use the END instruction in an SCR segment.

Controlling Program Flow with SCR Segments


The main program in an S7-200 PLC consists of instructions that are executed sequentially once per scan of the PLC. For
many applications it may be appropriate to logically divide the main program into a series of operational steps, that mirror
steps within a controlled process (for example, a series of machine operations).
One way to logically divide a program into multiple steps is to use SCR segments. By using SCR segments it is possible
to divide your program into a single stream of sequential steps, or into multiple streams that can be active simultaneously.
It is possible to have a single stream conditionally diverge into multiple streams, and to have multiple streams conditionally
re-converge into a single stream.

Example: Sequential Control with 2 SCR States


In the following sample program, the first scan bit SM0.1,is used to set S0.1, which will be the active State 1 on the first
scan. After a 2-second delay, T37 causes a transition to State 2. This transition deactivates the State 1 SCR (S0.1)
segment and activates the State 2 SCR (S0.2) segment.
STL

NETWORK 1
// On the first scan enable State 1
LD SM0.1
S S0.1 1
NETWORK 2
// Beginning of State 1 control region
LSCR S0.1
NETWORK 3
// Control the signals for Street 1
LD SM0.0
S Q0.4 1 // Set: Turn on the red light
R Q0.5 2 // Reset: Turn off the yellow and green lights
TON T37 +20 // Start a 2-second timer
NETWORK 4
// After a 2 second delay, transition to State 2
LD T37
SCRT S0.2
NETWORK 5
// End of SCR region for State 1
SCRE
NETWORK 6
// Beginning of State 2 control region
LSCR S0.2
NETWORK 7
// Control the signals for Street 2
LD SM0.0
S Q0.2 1 // Set: Turn on the green light
TON T38 +250 // Start a 25-second timer
NETWORK 8
// After a 25 second delay, transition to State 3
LD T38
SCRT S0.3
NETWORK 9
// End of SCR region for State 2
SCRE

LAD
Types of Logical Control Flow
Sequential Control
A process with a well-defined sequence of steps is easy to model with SCR segments. For example, consider a cyclical
process, with 3 steps, that should return to the first step when the third has completed.

State L

Transition Condition

State M

Transition Condition

State N

Transition Condition

Divergence Control
In many applications, a single stream of sequential states must be split into two or more different streams. When a stream
of control diverges into multiple streams, all outgoing streams must be activated simultaneously, as shown in the following
diagram:

State L

Transition Condition

State M State N

Example: Divergence of Control Streams


The divergence of control streams can be implemented in an SCR program by using multiple SCRT instructions enabled by
the same transition condition, as shown in the following example
STL
NETWORK 1
// Beginning of State L control region
LSCR S3.4
NETWORK 2
LD M2.3
A I2.1
SCRT S3.5 // Transition to State M
SCRT S6.5 // Transition to State N
NETWORK 3
// End of the State region for State L
SCRE

LAD

Convergence Control
A situation similar to divergence control arises when two or more streams of sequential states must be merged into a
single stream. When multiple streams merge into a single stream, they are said to converge. When streams converge, all
incoming streams must be complete before the next state is executed. The following diagram illustrates convergence:
State L State M

Transition Condition

State N

Example: Convergence of Control Streams


The convergence of control streams can be implemented in an SCR program by making the transition from state L to state L
’ and by making the transition from state M to state M’. When both SCR bits representingL’ and M’ are true, state N can be
enabled as shown in the following example.
STL

NETWORK 1
// Beginning of State L control region
LSCR S3.4
NETWORK 2
// Transition to State L'
LD V100.5
SCRT S3.5
NETWORK 3
// End of SCR region for State L
SCRE
NETWORK 4
// Beginning of State M control region
LSCR S6.4
NETWORK 5
// Transition to State M'
LD C50
SCRT S6.5
NETWORK 6
// End of SCR region for State M
SCRE
NETWORK 7
LD S3.5 // When both State L'
A S6.5 // and State M' are actived then:
S S5.0 1 // Enable State N
R S3.5 1 // Reset State L'
R S6.5 1 // Reset State M'

LAD
Divergence of a Control Stream, Depending on the Transition Condition
In other situations, a control stream may bre directed into one of several possible control streams, depending upon which
transition condition comes true first. Such a situation is shown below.

STL

NETWORK 1
// Beginning of State L control region
LSCR S3.4
NETWORK 2
// Transition to State M
LD M2.3
SCRT S3.5
NETWORK 3
// Transition to State N
LD I3.3
SCRT S6.5
NETWORK 4
// End of SCR region for State L
SCRE

LAD

You might also like