Chapter 9: PLC Programming
language – STL/SFC Instructions
1
Introduction
Sequence control using the SFC (Sequential Function Chart)
or STL (STep Ladder) is available in FX PLCs.
In SFC programs, the role of each process and the overall
control flow can be expressed easily based on machine
operations design a sequence easily.
As a result, the same contents can be handled in relay ladder
charts which are familiar and easy to understand.
2
Introduction
Parallel branch
process process
process process
Selective branch
process
3
Operation
Output coils can be used again in different state relays.
4
Operation example
5
Operation example
The process drawing
6
Operation example
Assign devices of a PLC in the created process drawing.
Assign a state relay to a rectangle indicating a process. At this time, assign a state
relay (S0 to S9) to the initial process.
After the first process, arbitrarily assign state relay numbers (S20 to S899) except
the initial state relays. There are latched (battery backed) type state relays(S500
to S899) whose ON/OFF status is stored against power failure.
The state relays S10 to S19 are used for special purposes when the IST (Initial
State - FNC 60) instruction is used.
Assign a device to each transfer condition. NO contact and NC contact are
available for a transfer condition. If there are two or more transfer conditions,
AND circuit or OR circuit is available.
Assign a device (output terminal number connected to external equipment, timer
number, etc.) used for an operation performed in each process. Many devices
such as timers, counters and auxiliary relays are provided in a PLC, and can be
used arbitrarily.
If there are two or more loads such as timers and counters which are driven at
the same time, two or more circuits can be assigned to one state relay.
When performing repeated operations or skipping some processes (jump
operation), use “” and specify the jump destination state relay number.
7
Operation example
A circuit for setting the initial state relay to ON is required to execute the
SFC program
After that, write the SFC program to an SFC block.
8
Operation example
9
Notes
10
Notes
11
Notes
Operations of “ ” and “”
Use “ “ to express transfer to a state relay in an upper position
(repeat), transfer to a state relay in a lower position (jump), or
transfer to a state relay in another separate flow.
“•” is automatically
displayed in the transfer
destination state relay.
12
Notes
Use “” to express reset of a state relay.
13
Notes
Jump
14
Notes
Jump to another flow
15
Notes
Repeat
16
Notes
17
Example
Clock signal generator by SFC
18
Example
Fountain control
1) Cyclic operation (X001 = OFF, X002 = OFF)
When the start button X000 is pressed, the outputs turn ON in the
order “Y000 (wait indication) → Y001(center lamp) → Y002 (center
fountain) → Y003 (loop line lamp) → Y007 (loop line fountain) →
Y000(wait indication)”, and then the outputs return to the wait
status. Each output is switched in turn every 2 seconds by a timer.
2) Continuous operation (X001 = ON)
Y001 to Y007 turn ON in turn repeatedly.
3) Stepping operation (X002 = ON)
Every time the start button is pressed, each output turns ON in turn.
19
Example
20
STep Ladder (STL)
21
STep Ladder (STL)
22
STep Ladder (STL)
Replacement “ ” and “” in SFC to STL
23
24
Selective branch
25
Selective recombination
26
Parallel branch
27
Parallel recombination
28
Importance Note
Limitation in the number of branch circuits:
In one parallel branch or selective branch, up to 8 circuits can
be provided.
29
Appendix: Advanced Functions
30
Introduction
Program Flow functions
Move and Compare functions
Arithmetic and Logical Operation functions
Rotation and Shift Operation functions
Data Operation functions
High Speed Processing functions
Handy functions
Read the reference: FX3G_FX3U-Programming manual_Basic
and applied [Link]
These instructions call Function (FNC) with number from 00 to
69.
31
Summary
32
Summary
33
Note
The functions with “P” character at last position, such as:
CMPP, ZCPP, INCP, ADDP, MULP, … execute only once based
on rising edge of input signal.
34
CMP (Compare) function
Operand
Mnemonic Description Step
S1 S2 D
CMP, CMPP
Compare two Y, M, S
K, H 7 steps.
values. Results: Note: Using 3
CMP KnX; KnY; KnM; KnS DCMP;
smaller; equal or bits
T, C, D, V, Z DCMPP
larger. consecutively
13 steps
CMP: the comparison value (S1) and the comparison source (S2) are compared
each other.
[S1] [S2] [D]
X0
CMP K50 C25 M1 S2 < S1 ((value in counter C25 is smaller than K
= 50), bit D (M1) is ON.
M1
C 25 < K 50; M 1 ON
S2 = S1 ((value in counter C25 is equal K = 50),
M2 bit D+1 (M2) is ON.
C 25 = K 50; M2 ON S2 > S1 ((value in counter C25 is larger than K =
M3 50), bit D+2 (M3) is ON.
C 25 > K 50; M3 ON
35
ZCP (Zone compare) function
ZCP (Zone Compare): compares two values (S1 & S2) with the
comparison source (S3).
Operand
Mnemonic Description Step
S1 S2 S3 D
Compare a K, H ZCP, ZCPP:
Y, M, S
zone with KnX; KnY; KnM; KnS 9 steps.
Note: Using 3
ZCP source. Result: T, C, D, V, Z DZCP,
bits
smaller; equal Note: S1 is always less than DZCPP:
consecutively.
or larger. S2. 17 steps.
[S1] [S2] [S3] [D]
X0 S3 < S1 < S2; (value in counter C30 is smaller than
ZCP K50 K70 C30 M3
50), bit D (M3) is ON.
M3 S1 <= S3 <= S2; ((value in counter C30 is in range
C 30 < K 50 < K 70; M3 ON
M4
[50, 70]), bit D+1 (M4) is ON.
K 50 < C 30 < K 70; M 4
K50<=C30<=K70 ON S3 > S2 > S1; (value in counter C30 is larger than
M5 70), bit D+2 (M5) is ON.
K 50 < K 70 < C 30 ; M 5 ON
36
MOV (Move) function
MOV (Move): transfers (copies) the contents of a device to
another device.
Operand
Mnemonic Description Steps
S D
K, H
MOV, MOVP
Transfer the KnX; KnY; KnM; KnY; KnM; KnS
5 steps.
MOV source data to KnS T, C, D, V, Z
DMOV ; DMOVP
destination device T, C, D, V, Z
9 steps
X0 [S] [D]
MOV H0050 D10
37
BCD (Binary Coded Decimal) function
BCD (Binary Coded Decimal) : converts binary data to
Convert binary data (BIN) to Binary Coded Decimal data.
Display numeric values on the seven-segment display unit equipped
with BCD decoder.
Operand
Mnemonic Description Step
S D
BCD, BCDP
Convert binary data of
5 steps.
[S] to BCD data and KnX; KnY; KnM; KnS KnY; KnM; KnS
BCD DBCD ;
transfer the converted T, C, D, V, Z T, C, D, V, Z
DBCDP
BCD data to [D]
9 steps
X0 [S] [D]
BCD D20 K2Y0 K2Y0: 2x4bit = Y000 ÷ Y007
38
BCD (Binary Coded Decimal) function
A program shows the time on the 7-segment LED with C000 for
second; C001 for minute; and C002 for hour. I/O of PLC is shown
in the following figure.
X003
BCD C000 K2Y000
BCD C001 K2Y010
BCD C002 K2Y020
39
BIN (Binary) function
BIN (Binary):
Convert BCD data into binary data.
Use this function to convert a BCD value set by a digital switch
(Thumbwheel switch) into binary value and to receive the converted
binary data.
Operand
Mnemonic Description Step
S D
BIN, BINP:
5 steps.
Convert BCD data into KnX; KnY; KnM; KnS KnY; KnM; KnS
BIN DBIN,
binary data T, C, D, V, Z T, C, D, V, Z
DBINP:
9 steps
X0 [S] [D]
BIN K2X0 D13
40
Arithmetic and Logical Operation functions
ADD (Addition)
SUB (Subtraction)
MUL (Multiply)
DIV (Division)
INC (Increment)
DEC (Decrement)
41
INC (Increment) function
Operand
Mnemonic Description Step
D
Increment the data of KnY; KnM; KnS INC, INCP: 3 step.
INC
specified device by “1” T, C, D, V, Z DINC; DINCP: 5 step
X0 [D]
INC D10
42
DEC (Decrement) function
Operand
Mnemonic Description Step
D
Decrement the data of
KnY; KnM; KnS DEC, DECP : 3 steps.
DEC the specified device by
T, C, D, V, Z DDEC; DDECP : 5 steps
“1”
X1 [D]
DEC D10
43
ADD (Addition) function
Mnemo Operand
Description Step
nic S1 S2 D
Add two values KnY; KnM;
K, H, KnX; KnY; ADD, ADDP : 7 steps
(S1 + S2) and KnS
ADD KnM; KnS DADD; DADDP : 13
save the result T, C, D, V,
T, C, D, V, Z steps
to D Z
44
SUB (Subtraction) function
Mnemo Operand
Description Step
nic S1 S2 D
Subtract two KnY; KnM;
K, H, KnX; KnY; SUB, SUBP : 7 steps
values (S1 – KnS
SUB KnM; KnS DSUB; DSUBP : 13
S2) and save T, C, D, V,
T, C, D, V, Z steps
the result to D Z
[S1] [S2] [D]
X0
SUB D10 D12 D14
45
MUL (Multiplication) function
Mnemo Operand
Description Step
nic S1 S2 D
Multiply two KnY; KnM;
K, H, KnX; KnY; MUL, MULP : 7 steps
values (S1 * KnS
MUL KnM; KnS DMUL; DMULP : 13
S2) and save T, C, D, V,
T, C, D, V, Z steps
the result to D Z(V)
Note: If S1 and S2 are 16-bit data registers, the multiplication result is
transferred to 32-bit data register.
46
DIV (Division) function
Mnemoni Operand
Description Step
c S1 S2 D
Divide two values KnY; KnM;
K, H, KnX; KnY; DIV, DIVP: 7 steps
(S1 / S2) and KnS
DIV KnM; KnS DDIV; DDIVP: 13
save the result to T, C, D, V,
T, C, D, V, Z steps
D Z(V)
Note: If S1 and S2 are 16-bit data registers, the quotient is transferred to D
(16-bit data register), the reminder is transferred to D+1.
47