Fx5U Programming Documentsjy997d55701m
Fx5U Programming Documentsjy997d55701m
INTRODUCTION
This manual describes the instructions and functions required for programming of the FX5. Please read this manual and the
relevant manuals and understood the functions and performance of the FX5 PLCs before attempting to use the unit.
It should be read and understood before attempting to install or use the unit. Store this manual in a safe place so that you can
take it out and read it whenever necessary. Always forward it to the end user.
When utilizing the program examples introduced in this manual to the actual system, always confirm that it poses no problem
for control of the target system.
Note
• If in doubt at any stage during the installation of the product, always consult a professional electrical engineer who is
qualified and trained to the local and national standards. If in doubt about the operation or use, please consult the nearest
Mitsubishi Electric representative.
• Since the examples indicated by this manual, technical bulletin, catalog, etc. are used as a reference, please use it after
confirming the function and safety of the equipment and system. Mitsubishi Electric will accept no responsibility for actual
use of the product based on these illustrative examples.
• This manual content, specification etc. may be changed without a notice for improvement.
• The information in this manual has been carefully checked and is believed to be accurate; however, if you have noticed a
doubtful point, a doubtful error, etc., please contact the nearest Mitsubishi Electric representative. When doing so, please
provide the manual number given at the end of this manual.
1
CONTENTS
SAFETY PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
RELEVANT MANUALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
TERMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
GENERIC TERMS AND ABBREVIATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
CHAPTER 1 OUTLINE 5
CHAPTER 4 LABELS 31
4.1 Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2 Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.3 Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.4 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.5 Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.6 Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.7 Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
CHAPTER 6 ST LANGUAGE 47
6.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Delimiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Label and device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
2
7.2 Inline ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.3 Program Execution Order. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
The order of executions of program units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
CONTENTS
Action. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
8.3 SFC Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.4 SFC Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
CPU parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
SFC block setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.5 SFC Program Execution Order. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Whole program processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
SFC program processing sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
8.6 SFC Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Starting and stopping the SFC program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Starting and ending a block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Activating and deactivating a step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Behavior when an active step is activated. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Operation when a program is modified . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Checking SFC program operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
APPENDICES 121
Appendix 1 Operations of when the MC/MCR instructions are used to control EN . . . . . . . . . . . . . . . . . . . . . . 121
Appendix 2 Added and Changed Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
INDEX 128
REVISIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
WARRANTY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
TRADEMARKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
3
RELEVANT MANUALS
Manual name <manual number> Description
MELSEC iQ-F FX5 Programming Manual (Program Design) Describes the specifications of ladder, ST, FBD/LD, and SFC programs, and labels.
<JY997D55701> (This manual)
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Describes the specifications of instructions and functions that can be used in
Functions/Function Blocks) programs.
<JY997D55801>
GX Works3 Operating Manual Describes the system configuration, parameter settings, and online operations of GX
<SH-081215ENG> Works3.
TERMS
Unless otherwise specified, this manual uses the following terms.
Terms Description
Buffer memory A memory in an intelligent function module, where data (such as setting values and monitoring values) are
stored
Device A device (X, Y, M, D, or others) in a CPU module
Engineering tool The product name of the software package for the MELSEC programmable controllers
POU Defined unit of a program. Use of POUs enables a program to be divided into units according to process or
function, and each unit to be programmed individually.
Signal flow The execution status that the last time an operation of a program or an FB is executed in each step
4
1 OUTLINE
1
This manual describes program configurations, content, and method for creating programs.
For how to create, edit, or monitor programs using the engineering tool, refer to the following.
GX Works3 Operating Manual
■Ladder diagram
■ST language
1 OUTLINE
5
■FBD/LD language
■SFC program
• Ladder diagram and FBD/LD language are for customers who have knowledge or experience of sequence
control and logic circuits.
• ST language is for customers who have knowledge or experience of the C language programming.
• SFC program is suitable for creating program blocks for each actual control of machines and controlling the
transition of each operation.
• By using labels in a program, the readability of the program is improved, and activating a program for the
system with a different module configuration is easy.
1 OUTLINE
6
2 PROGRAM CONFIGURATION
Using the engineering tool, multiple programs and program organization units (POUs) can be created.
Programs and POUs can be divided according to processing.
This chapter describes the program configuration. 2
Project
·
Program file 1 Program file 2 FB file FUN file
POU POU POU POU
Program block Program block Function block Function
Program block
Project
A project is a group of data (such as programs and parameters) to be executed in a CPU module.
Only one project can be written to a single CPU module.
At least one program file needs to be created in a project.
Program file
A program file is a group of programs and POUs.
A program file consists of at least one program block. ( Page 10 Program Blocks)
The following operations are performed in units of program file: changing the program execution type from the fixed scan
execution type to the standby type and writing data to the CPU module.
2 PROGRAM CONFIGURATION
7
MEMO
2 PROGRAM CONFIGURATION
8
3 PROGRAM ORGANIZATION UNITS
There are three types of program organization units (POUs).
• Program block
• Function
• Function block
Processing can be described in the programming language that suits the control performed in each POU. Processing can be
described in the ladder diagram, structured text language, or FBD/LD in a function or a function block. 3
Functions and function blocks are called and executed by program blocks.
Project
Program file
Used
POU
Program block
POU folder
POU
Function block
POU
Function
Up to 32 worksheets can be created in one POU in the structured text language and FBD/LD.
Set the execution order of multiple worksheets on the "Worksheet Execution Order Setting" window of the
engineering tool. ( GX Works3 Operating Manual)
Program block 1
Program file
Program block 2
P0 I0
Main routine program Subroutine program Interrupt program
Execute the program according to the order of the execution of program file setting. 3
Program file setting
Actual program
Main routine program
ProgPou1
FEND
END (1) Main routine program
FEND
P0 P0
Subroutine program Subroutine program
ProgPou2
RET RET
END (1) I0
Interrupt program
I0 IRET
Interrupt program END
ProgPou3
IRET
END
(1) The END instruction in the middle of the program file is ignored.
• Create a subroutine program and interrupt program after the FEND instruction of the main routine program.
Any program after the FEND instruction is not executed as a main routine program. For example, when the
FEND instruction is used at the end of the second program block, the third program block or later runs as a
subroutine program or interrupt program. (Page 27 When a subroutine program or an interrupt program
is used)
• To create an easy-to-understand program, use a pair of instructions, such as the FOR and NEXT
instructions or the MC and MCR instructions, within a single program block.
• A simple program can be executed in the CPU module simply by writing the main routine in one program
block.
For details on the subroutine program and interrupt program, refer to the following.
MELSEC iQ-F FX5 User's Manual (Application)
Program
Function block
FUN
Function block
or Program
function block
FUN FB or FUN
Operation overview
The program of a function is stored in the FUN file and called by the calling source program when executed.
Ex.
When calling FUN1 and FUN2 from the main program, and calling FUN3 by FUN1 (Nested two times)
to indicate the execution flow (order).
(Program file) (FUN file)
Main program FUN1 program (FUN file)
FUN3 program
Ò Ó
Ô
FUN3
FUN1
Ö Õ
(FUN file)
FUN2 program
FUN2
×
Up to 32 subroutine type function blocks, macro type function blocks, and functions in total can be nested.
Input variables are set in the VAR_INPUT class and output variables are set in the VAR_OUTPUT class.
Variables defined in the function are overwritten every time the function is called.
To hold the data in the variables, create a program by using function blocks or so that the data in the output
variable is saved in another variable.
EN and ENO
EN (enable input) and ENO (enable output) can be appended to a function to control execution processing.
• Set a boolean variable used as an execution condition of a function to EN.
• A function with EN is executed only when the execution condition of EN is TRUE.
• Set a boolean variable used to output a function execution result to ENO.
The following table lists the ENO states and operation results according to the EN states.
EN ENO Operation result
TRUE (executed) TRUE Operation result output value
FALSE (not executed) FALSE Undefined value
• Setting an output label to ENO is not always required for the program written in ladder or FBD/LD.
• When EN/ENO is used in a standard function, the function with EN is represented by "function-name_E".
Program a function name as a label in a function to set a return value of the function. Setting function names
as labels is not necessary. The data type set in "Result Type" in the properties of the function can be used.
Ex.
When calling FUN1 and FUN2 from the main program, and calling FUN3 by FUN1
( to indicate the execution flow (order).)
(Program file) (FUN file)
Main program FUN1 program (FUN file)
FUN3 program
3
Ò Ó
Ô
FUN3
FUN1
Ö Õ
(FUN file)
FUN2 program
FUN2
×
The following figure shows the label assignments while the above functions are being executed.
Ò Ó Ô Õ
Main program being executed FUN1 being executed FUN3 being executed FUN1 being executed
(before FUN3 is called) (after FUN3 is executed)
Temporary area
Ö × Ø
Main program being executed FUN2 being executed Main program being executed
The class of labels that can be defined in the function are VAR, VAR_CONSTANT, VAR_INPUT, and VAR_OUTPUT.
The label to be defined by a function must be initialized by a program before the first access because the label
value will be undefined.
■Program
The number of steps required for a function program is the total number of instruction steps plus a minimum of additional 13
steps occupied by the system. For the number of steps required for each instruction, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
■Calling source
When calling a function, the calling source generates the processing that passes the argument and return value before and
after the call processing.
Program block 1 (1) Passing the argument
(displayed) Program file (2) Calling the FUN1 program
(3) Passing the return value
3
3.3 Function Blocks (FB)
A function block is a POU called and executed by program blocks and other function blocks.
Function Program
block block
FB
Function Program
block block
FB FB
(3) (3)
(4)
(4)
Ex.
When calling FB1_a and FB2_a from the main program, calling FB3_a by FB1_a, and calling FB3_b by FB2_a
Execution
(Program file) flow Actual structure of
Main program main program
FB1_a
FB1 FB1 program (1)
FB3 program
(2)
FB2_a
FB2 FB2 program (3)
FB3 program
(4)
(1) The FB1 program is loaded into the main program and executed.
(2) The FB3 program called by FB1 is loaded into the FB1 program.
(3) The FB2 program is loaded into the main program and executed in the same way as the FB1 program.
(4) The FB3 program called by FB2 is loaded into the FB2 program.
Ex.
When calling FB1_a and FB2_a from the main program, calling FB3_a by FB1_a, and calling FB3_b by FB2_a (Nested three
times)
to indicate the execution flow (order).
(Program file) (FB file)
Main program FB1 program (FB file) Program memory
FB3 program
Ò FB3_a Ó
FB1_a Ô Ø
FB3 Main program
FB1
Õ
Ö FB1 program
(FB file)
FB2_a
FB2 program
FB2 FB2 program
FB3_b ×
FB3
Ú
FB3 program
Ù
Up to 32 subroutine type function blocks, macro type function blocks, and functions in total can be nested.
RESET iTim
(1)
lCnt
(2)
3
Instance
CTD
CD Q
LOAD CV
PV
Input variables are set in the VAR_INPUT class, output variables are set in the VAR_OUTPUT class and
VAR_OUTPUT_RETAIN class, and input/output variables are set in the VAR_IN_OUT class.
Internal variables
Function blocks use internal variables. For each instance of a function block, labels are assigned to the different areas. Even
though the same label names are used, different states are held for each instance.
Ex.
Instance A Instance B
cdLabel11 cdLabel11
Current value Current value
The above function block starts counting when the input variables turn on and turns on the output variable when the current
value held in the internal variable reaches the set value. Even though the same function block is used, the output timings differ
because the instances A and B hold different states.
Internal variables are set in the VAR, VAR_CONSTANT and VAR_RETAIN class.
Ex.
Structure of instance (Example of subroutine type function block)
9 words
Reserved area 8 words
Creating another
instance based on
FB1 definition Another instance of FB1
(same area size)
Local label area
For the local label area and local latch label area, since the label area is secured in units of four words, three-words (padding
size) are secured in the above example.
Each area occupies a reserved area. The reserved area is used to add or change the local label, instructions, or instances of
the function block while keeping the label assignment by conversion or online change. If the area of the target data type to be
added cannot be secured, all programs are required to be converted (reassigned).
FB2 area
bLabel1 Reserved area 16 words FB1 area
16 words
MOVP wLabel0 wLabel1 36 words
The instance of FB2 declared as a local label is secured in the local label area, local latch label area, and signal flow for FB of
FB1 which is the declared source.
When an FB type local label to FB1 is added in the above example, since the capacity of the reserved area is 48 words for
local label area, 16 words for local latch label area, and 8 words for signal flow for FB, all programs are required to be
converted (reassigned) to add a function block with an area exceeding the capacity.
*1 Local labels can be declared as the local labels of a program block or function block. Local labels cannot be declared in a function.
Same function blocks can be instantiated with different names in a single POU.
Instance A
Function block
wLabel5
wLabel1 Input variable 1 wLabel8
wLabel6 Output variable wLabel4
wLabel2 Input variable 2
wLabel7 wLabel9
wLabel3 Input variable 3 Local variable
(1) (2)
Instance A Instance B
wLabel5 wLabel5
wLabel1 Input variable 1 wLabel8 wLabel10 Input variable 1 wLabel8
wLabel6 Output variable wLabel4 wLabel6 Output variable wLabel13
wLabel2 Input variable 2 wLabel11 Input variable 1
wLabel7 wLabel9 wLabel7 wLabel9
wLabel3 Input variable 3 Local variable wLabel12 Input variable 1 Local variable
If the reserved area capacity cannot be allocated to the data to be added by online change, the online change
cannot be executed and all programs are required to be converted (reassigned).
Creating programs
The program of a function block can be created by using the engineering tool.
[Navigation window] [FB/FUN] Right-click [Add New Data]
Select "Function Block" for "Data Type" in "Basic Setting".
The created program is stored in the FB file.
[CPU Parameter] [Program Setting] [FB/FUN File Setting]
Up to 64 created programs can be stored in one FB file.
For details on program creation, refer to the following.
Item Reference
How to create function blocks GX Works3 Operating Manual
Number of FB/FUN files that can be written to a CPU module MELSEC iQ-F FX5S/FX5UJ/FX5U/FX5UC User's Manual (Hardware)
■Types of program
There are two types of function blocks and the program of each function block type is stored in different ways.
• Macro type function block
• Subroutine type function block
For details, refer to the following.
Page 18 Operation overview
The above cannot be selected for module function blocks, standard functions, and standard function blocks.
*1 To select this item, select "Yes" for "Use EN/ENO". However, the item cannot be used depending on the versions of the CPU module
and GX Works3 used when "Subroutine Type" is selected for "FB Type". For the versions of the CPU module and the GX Works3, refer
to the following.
MELSEC iQ-F FX5 User's Manual (Application)
FB1_a
FB1 program
FB1
(FB1_a)
FB1_b
FB1
FB1 program
(FB1_b)
(1)
■Program
The number of steps required for a function block program is the total number of instruction steps, like usual programs.
For the number of steps required for each instruction, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
FB1_b
FBCall FB1_a (2)
M10 FB1 Y40
D10
Y20 (3)
The call-target program is
replaced with the instruction ·
for calling a function block. Calling the
FB file function block
FB1 program
• EN/ENO
The following table lists the number of steps required for EN/ENO.
Item Number of steps
EN 4 to 7
(The number of steps differs depending on the details of the program such as the type and number of the device specified as the
input source of EN.)
ENO 6 to 10
(The number of steps differs depending on the details of the program such as the type and number of the device specified as the
output destination of ENO.)
■Program
The number of steps required for a function block program is the total number of instruction steps, like usual programs.
For the number of steps required for each instruction, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
FEND
I0
Interrupt program
IRET
END
• Only one FEND instruction can be used for a program file. When multiple FEND instructions are used, an error occurs.
Program file
Execution
order
Because there are two
Main routine program
FEND instructions are in
the program file, an error
occurs.
FEND
FEND
I0
Interrupt program
IRET
END
Ex.
A program that saves the values in the index register Z1 and Z2 before the program execution and returns the saved values
after the program execution
MOV K0 Z2
Program execution
Ex.
Device used for passing the argument
MacroFbPou_1 (EN := M0, ENO => M1);
M2 := M1;
An unintended value may be generated if the argument of the macro type function block is used in other than the program of
the macro type function block.
Ex.
Unintended value
MacroFbPou_1 (EN := M0, ENO => M1);
M2 := MacroFbPou_1.ENO;
Ex.
A conversion error (1) occurs in VAR_OUTPUT in the macro type function block (FbPou)
3
(1)
If no error was found in (1), check the inputs and outputs (2) of the corresponding function block in the program block that is
the calling source.
(2)
Since the output variables of the function block have been passed to the write-protected label/device, a conversion error has
occurred in the above example.
4.1 Type
This manual describes the following types of label. 4
• Global labels
• Local labels
Global labels
Global labels are labels that can be shared by programs in a project. Global labels can be used in all the programs in a
project.
Global labels can be used in program blocks and function blocks.
When setting a global label, set the label name, class and data type, and assign a device.
■Device assignment
Devices can be assigned to global labels.
Item Description
Label to which no device is assigned • Programming without concern to devices is possible.
• Defined labels are allocated to the label area or latch label area in the device/label memory.
Label to which a device is assigned • If a device is to be programmed as a label referring to a device that is being used for input or output, the device can
be assigned directly.
• Defined labels are allocated to the device area in the device/label memory.
Local labels
Local labels are labels that can be used in each POU only. Local labels that are not included in POUs cannot be used.
When setting a local label, set the label name, class, and data type.
There are other types of labels available in addition to global labels and local labels.
System labels
System labels can be shared among iQ Works-compatible products and are managed by MELSOFT
Navigator. Global labels registered as system labels can be monitored or accessed using the system labels on
GOT.
For details, refer to the following.
iQ Works Beginner's Manual
Module labels
Module labels are labels defined uniquely by each module. Module labels are automatically generated by the
engineering tool from the module used, and can be used as a global label.
For details, refer to the following.
MELSEC iQ-F FX5 CPU Module Function Block Reference
For registration of module labels, refer to the following.
GX Works3 Operating Manual
4 LABELS
4.1 Type 31
4.2 Class
The label class indicates how each label can be used from which POU.
The selectable class varies depending on the POU.
Global label
Class Description Applicable POU
Program Function Function
block block
VAR_GLOBAL Common label that can be used in program blocks and function blocks
VAR_GLOBAL_CONSTANT Common constant that can be used in program blocks and function blocks
VAR_GLOBAL_RETAIN Latch type label that can be used in program blocks and function blocks
Local label
Class Description Applicable POU
Program Function Function
block block
VAR Label that can be used within the range of declared POUs
This label cannot be used in other POUs.
VAR_CONSTANT Constant that can be used within the range of declared POUs
This label cannot be used in other POUs.
VAR_RETAIN Latch type label that can be used within the range of declared POUs This label
cannot be used in other POUs.
VAR_INPUT Label that inputs to a function or a function block.
This label receives a value, and cannot be changed in POUs.
VAR_OUTPUT Label that outputs a value from a function or a function block
VAR_OUTPUT_RETAIN Latch type label that outputs a value from a function or a function block
VAR_IN_OUT Local label which receives a value, outputs it from a POU, and can be changed
in POUs
VAR_PUBLIC Label that can be accessed from other POUs
VAR_PUBLIC_RETAIN Latch type label that can be accessed from other POUs
4 LABELS
32 4.2 Class
Data type Description Value range Bit
length
Time*1 TIME Handles values as d (day), h (hour), m T#-24d20h31m23s648 ms to 32-bit
(minute), s (second), or ms (millisecond) T#24d20h31m23s647 ms*2
String(32) STRING Handles a character string (ASCII, Shift Up to 255 letters (half-width Variable
JIS) character)
String [Unicode](32) WSTRING Handles a Unicode character string Up to 255 letters Variable
Timer TIMER Structure that corresponds to a timer (T) of Page 33 Data types of timers and counters
a device
Retentive Timer RETENTIVETIMER Structure that corresponds to a retentive
timer (ST) of a device
Counter COUNTER Structure that corresponds to a counter (C)
of a device
Long Counter LCOUNTER Structure that corresponds to a long
counter (LC) of a device
4
Pointer POINTER Type that corresponds to a pointer (P) of a device (MELSEC iQ-F FX5 User's Manual
(Application))
*1 The time data is used in the time data type function of standard functions. For the standard function, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
*2 When using a constant for a label of the time data, prefix "T#" to the label.
4 LABELS
4.3 Data Type 33
Generic data type (ANY)
The generic data type indicates data type of a label which combines several primitive data types. The data type name begins
with "ANY".
The generic data type is used when multiple data types are available in arguments or return values etc. of a function of a
function block.
Labels defined as generic data types can be used for any sub-level data type.
For the types of generic data types and the primitive data types, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
4 LABELS
34 4.3 Data Type
4.4 Arrays
An array represents a consecutive accumulation of the same data type labels, under the same name.
Arrays can be defined by the primitive data types or structures.
The maximum number of arrays differs depending on the data types.
One-dimensional array Two-dimensional array
Label name Indexes Label name Indexes
[1,0] [1,1]
…
…
4
…
[m,0] … …
[m,n]
Definition of arrays
■Array elements
When an array is defined, the number of elements, or the length of array, must be determined. For the range of the number of
elements, refer to the following.
Page 36 Maximum number of array elements
■Definition format
The following table lists definition format examples up to three dimensions.
The range from the array start value to the array end value is the number of elements.
Number of array Format Remarks
dimensions
One dimension Array of primitive data type/structure name (array start value .. array end value) • For primitive data types:
(Definition example) Bit (0..2) Page 32 Primitive data type
• For structured data types:
Two dimensions Array of primitive data type/structure name (array start value .. array end value, array start Page 37 Structures
value .. array end value)
(Definition example) Bit (0..2, 0..1)
Three dimensions Array of primitive data type/structure name (array start value .. array end value, array start
value .. array end value, array start value .. array end value)
(Definition example) Bit (0..2, 0..1, 0..3)
4 LABELS
4.4 Arrays 35
Precautions
When a bit of a device/label (example: D0.0) is assigned to bit array in global label, labels and devices can not be used for
the array index in programming (example: bLabel1[D0] cannot be programmed).
• The data storage location becomes dynamic by specifying a label for the array index. This enables arrays to
be used in a program that executes loop processing. The following is a program example that consecutively
stores "1234" in the "uLabel4" array.
bLabel1
INC wLabel3
bLabel2
MOV K1234 uLabel4[wLabel3]
• In the case of the ladder diagram, arrays can be used with element numbers omitted. When the element
number is omitted, it is converted to the starting number of the array element. For example, when the label
name you define is "boolAry" and the data type is "bit (0..2,0..2)", then "boolAry[0,0]" and "boolAry" are
treated in the same way.
• A multidimensional array can be specified as setting data of an instruction, function, or function block using
arrays. In that case, the rightmost element in the multidimensional array is treated as the first dimension.
Precautions
■When an interrupt program is used
When a label or device is specified for the array index, the operation is performed with a combination of multiple instructions.
For this reason, if an interrupt occurs during operation of the label defined as an array, data inconsistency may occur
producing an unintended operation result.
To prevent data inconsistency, create a program using the DI/EI instructions that disables/enables interrupt programs as
shown below.
DI
EI
For the DI/EI instructions, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
4 LABELS
36 4.4 Arrays
■Array elements
When accessing the element defined in an array, access it within the range of the number of elements.
If a constant out of the range defined for the array index is specified, a compile error will occur.
If the array index is specified with data other than a constant, a compile error will not occur. The processing will be performed
by accessing another label area or latch label area.
4.5 Structures
A structure is a data type that includes different labels. Structures can be used in all POUs.
Each member (label) included in a structure can be defined even when the data types are different.
Creating structures 4
To create a structure, first create the configuration of the structure, and define members for the created structure.
Structure
Member (Label 1)
Member (Label 2)
Member (Label 3)
Member (Label 4)
Ex.
When using the member of a structure
stLabel1 . bLabel1
Member name
Structure label name
• When labels are registered by defining multiple data types in a structure and used in a program, the order
the data is stored after converted is not the order the data types were defined. When programs are
converted using the engineering tool, labels are classified into type and data type, and then assigned to the
memory (memory assignment by packing blocks).
GX Works3 Operating Manual
• If a member of a structure is specified in an instruction operand that uses control data (series of consecutive
devices from the operand used by the instruction), the control data is assigned to members of the structure
by the order they are stored in memory, not the order the members are defined.
4 LABELS
4.5 Structures 37
Arrays of structures
Structures can also be used as arrays.
Structure label [1] Structure label [2] Structure label [3] Structure label [4]
When a structure is declared as an array, append an index enclosed by "[ ]" after the structure label name.
The array of structure can be specified as arguments of functions and function blocks.
Ex.
When using an element of the structured array
stLabel [0] . bLabel1
Member name
Indexes
Structure label name
Structure types
The following data types are defined as a structure beforehand.
Type Reference
Timer type Page 32 Data Type
Retentive Timer type
Counter type
Long Counter type
4 LABELS
38 4.5 Structures
4.6 Constant
Types of constants
The following table shows the expressions for setting a constant to a label.
Applicable data type Type Expression Example
Bit Boolean data Input "TRUE" or "FALSE". TRUE, FALSE
Binary Append "2#" in front of a binary number. 2#0, 2#1
Octal Append "8#" in front of an octal number. 8#0, 8#1
Decimal Directly input a decimal number, or append "K" in front of a 0, 1, K0, K1
decimal number.
Hexadecimal Append "16#" or "H" in front of a hexadecimal number. 16#0, 16#1, H0, H1 4
• Word [Unsigned]/Bit String [16-bit] Binary*1 Append "2#" in front of a binary number. 2#0010, 2#01101010,
• Double Word [Unsigned]/Bit String [32- 2#1111_1111
bit]
Octal*1 Append "8#" in front of an octal number. 8#0, 8#337, 8#1_1
• Word [Signed]
*1
• Double Word [Signed] Decimal Directly input a decimal number or append "K" in front of a 123, K123, K-123,
decimal number. 12_3
Hexadecimal*1 Append "16#" in front of a hexadecimal number. 16#FF, HFF, 16#1_1
Or append "H" in front of a value.
FLOAT [Single Precision] Real number*1 Directly input a real number, or append "E" in front of a real 2.34, E2.34, E-2.34,
number. 3.14_15
Real number Append "E" in front of an exponent expression or a real number. 1.0E6, E1.001+5
(exponent Append "+" in front of exponent part.
expression)
String(32) Character string Enclose a character string (ASCII, Shift JIS) with single 'ABC'
quotations (').
String [Unicode](32) Unicode character Enclose a Unicode character string in double quotation marks ("). "ABC"
string
Time Time Append "T#" in front. T#1h,
T#1d2h3m4s5ms
*1 In the binary notation, the octal notation, the decimal notation, the hexadecimal notation, and the real number notation, values can be
delimited by an underscore (_) to make programs easy to read. (In the program processing, underscores are ignored.)
4 LABELS
4.6 Constant 39
4.7 Precautions
3. Use the label defined in step 2 for the functions having no restrictions on the use of labels. Use the device assigned to
the label for the function having restrictions on the use of labels.
2. Create a program using the label. The following is the program example for copying the data. (The data logging function
uses the data in udLabel1.)
SM400
DMOV udLabel1 D0
3. Use the device where the data has been transferred in step 2 for the function having restrictions on the use of labels. (In
the program example in step 2, use D0.)
When copying a value of a label to another device by a transfer instruction, note that the number of program
steps increases. In addition, when adding a transfer instruction on a program, consider execution timing of the
function to be used.
4 LABELS
40 4.7 Precautions
Precautions for creating programs
When specifying a label as an operand used in instructions, match the data type of the label with that of the operand. In
addition, when specifying a label as an operand used in instructions that control continuous data, specify the data range used
in instructions within the data range of the label.
Ex.
SFT(P) instruction
SFT bLabel[0]
To shift the bits correctly, specify the array of a bit type label.
SFTP bLabel[1]
or 4
SFT wLabel1.0
Specify the bit number of a word type label.
SFTP wLabel1.1
Ex.
SFR(P) instruction
Start device number of search range
wLabel1[0] 10
Data matched
wLabel1[1] 500
20
123
wLabel1[n]
Specify a label which has a larger data range than the search range (n) points.
4 LABELS
4.7 Precautions 41
5 LADDER DIAGRAM
Ladder diagram is a language that describes the sequence control by indicating logical operations consisting of "AND" or
"OR" with combinations of series connections and parallel connections in a ladder consisting of contacts and coils.
5.1 Configuration
With the ladder diagram, the following ladder can be created.
(1)
(2)
(3)
(4)
(5)
Ladder symbols
This section shows ladder symbols that can be used for programming in the ladder diagram.
Element Symbol Description
NO contact Turns on when a specified device or label is ON.
Rising edge Turns on at the rising edge (OFF to ON) of a specified device or label.
Falling edge Turns on at the falling edge (ON to OFF) of a specified device or label.
Negated rising edge Turns on when a specified device or label is OFF or ON, or at the falling edge (ON to OFF) of a
specified device or label.
Negated falling edge Turns on when a specified device or label is OFF or ON, or at the rising edge (OFF to ON) of a
specified device or label.
Conversion of operation result Turns on at the rising edge (OFF to ON) of an operation result. Turns off when the operation result
to leading edge pulse is other than the rising edge.
Conversion of operation result Turns on at the falling edge (ON to OFF) of an operation result. Turns off when the operation result
to trailing edge pulse is other than the falling edge.
Inverting the operation result Inverts the operation just before this instruction.
Turn-back Turns back a circuit by creating a turn source symbol and a turn destination symbol when the
number of contacts exceeds the number of contacts that can be created in one line.
5 LADDER DIAGRAM
42 5.1 Configuration
Element Symbol Description
Function Executes a function.
• How to create functions (GX Works3 Operating Manual)
• Standard function (MELSEC iQ-F FX5 Programming Manual (Instructions, Standard
Functions/Function Blocks))
Function block Executes a function block.
• How to create function blocks (GX Works3 Operating Manual)
• Standard function blocks (MELSEC iQ-F FX5 Programming Manual (Instructions, Standard
Functions/Function Blocks))
• Module function blocks (MELSEC iQ-F FX5 CPU Module Function Block Reference)
X1 1 X3 3 Y1 4
5
X2 2 X4 5 Y2 6
When executing the program above, Y1 and Y2 turn on corresponding to turning ON or OFF of X1 to X4 as shown below.
ON
X1 OFF
ON
X2 OFF
ON
X3
OFF
ON
X4
OFF
ON
Y1
OFF
ON
Y2
OFF
5 LADDER DIAGRAM
5.1 Configuration 43
Precautions for using a function block in ladder diagram
(1)
To change the on/off states of EN and the input variables (bit type), use a contact or an instruction equivalent to the contact.
(2): Contact
(3): Instruction equivalent to a contact
(2)
(3)
5 LADDER DIAGRAM
44 5.1 Configuration
5.2 Inline ST
Inline ST is a function that creates, edits and monitors inline ST box that displays an ST program in a cell of an instruction that
is equivalent to a coil in the ladder editor.
Numerical operations or character string operations can be created easily in a ladder program.
• Program with the inline ST
X0
1 W0:=K0;
2 W0:=(D0+D1+D2+D3+D4+D5+D6+D7+D8+D9+D10+D11)/K12;
+ D0 W0
+ D1 W0
5
+ D2 W0
+ D3 W0
+ D4 W0
+ D5 W0
+ D6 W0
+ D7 W0
+ D8 W0
+ D9 W0
+ D10 W0
+ D11 W0
/ W0 K12 W0
Specifications
For the specifications of the inline ST, refer to the ST language specifications.
Page 47 ST LANGUAGE
Precautions
• Only one inline ST can be created in one line of a ladder program.
• Creating both a function block and an inline ST box in one line of a ladder program is impossible.
• Creating an inline ST box in a position of an instruction that is equivalent to a contact creates an inline ST box in a position
of an instruction that is equivalent to a coil.
• The maximum number of characters that can be input in an inline ST is 2048. (A newline is counted as two characters.)
• In inline ST, do not use rising execution instructions, falling execution instructions, special timer instructions, OUT
instruction, positioning instructions, or standard function blocks (edge detection function blocks and counter function
blocks) as they may not work property.
• When the RETURN syntax is used in an inline ST, the processing inside the inline ST box ends, and the processing inside
the program block does not end.
5 LADDER DIAGRAM
5.2 Inline ST 45
5.3 Statements and Notes
In a ladder program, statements and notes can be displayed.
Statements
By using statements, users can append comments to circuit blocks. Appending statements makes the processing flow easy to
understand.
Statements include line statements, P statements, and I statements.
A line statement can be displayed on a tree view of the Navigation window.
■Line statement
A comment is appended to a ladder block as a whole.
■P statement
A comment is appended to a pointer number.
■I statement
A comment is appended to an interrupt pointer number.
Notes
By using notes, users can append comments to coils and instructions in a program.
Appending notes makes the details of coils and application instructions easy to understand.
5 LADDER DIAGRAM
46 5.3 Statements and Notes
6 ST LANGUAGE
The ST language is one of the languages supported by IEC 61131-3, the international standard that defines the description
methods for logic. ST language is a text programming language with a grammatical structure similar to C language. ST
language is suitable for programming some complicated processing that cannot be easily described using ladder diagram.
ST language supports control syntaxes, operational expressions, function blocks (FBs), and functions (FUNs). Therefore, the
following description can be made.
Ex.
Control syntaxes using selective branches with conditional statements and repetition by iteration statements
(* Control conveyors of Line A to C. *)
CASE Line OF
1: Start_switch := TRUE; (* The conveyor starts. *)
2: Start_switch := FALSE; (* The conveyor stops. *)
3: Start_switch := TRUE; (* The conveyor stops with an alarm. *)
ELSE Alarm_lamp := TRUE;
END_CASE;
IF Start_switch = TRUE THEN (* The conveyor starts and performs processing 100 times. *)
6
FOR Count := 0
TO 100
BY 1 DO
Count_No := Count_No +1;
END_FOR;
END_IF;
Ex.
Expressions using operators (such as *, /, +, -, <, >, and =)
D0 := D1* D2 + D3 / D4 -D5;
IF D0 > D10 THEN
D0 := D10;
END_IF;
Ex.
Calling a defined function block
//FB data name : LINE1_FB
//Input variable : I_Test
//Output variable : O_Test
//Input/output variable : IO_Test
//FB label name : FB1
FB1(I_Test :=D0,O_Test => D1,IO_Test := D100);
Ex.
Calling a standard function
(* Convert BOOL data type to INT/DINT data type. *)
wLabel2 := BOOL_TO_INT (bLabel1);
6 ST LANGUAGE
47
6.1 Configuration
Operators and syntaxes are used for programing in ST language.
IF M1 THEN
btn01 := TRUE;
ELSE Conditional statement
btn01 := FALSE;
END_IF;
intV1 := 0 ;
End of the statement
intV2 := 2 ;
Spaces, tabs, and line feeds can be inserted anywhere between an operator and data.
Space
intV1 := 0 ;
intV2 := Tab
2;
Line feed
intV1 := 0;
(* Substitution *) Comment
intV2 := 2;
6 ST LANGUAGE
48 6.1 Configuration
Delimiter
The following delimiters are provided in ST language for clarifying the program structure.
Symbol Description
() Parenthesized
[] Specification of an array element
. (period) Specification of members of the structure or function block
, (comma) Separation of arguments
: (colon) Device type specifier
; (semicolon) End of a sentence
' (single quotation mark) Description of a character string (ASCII, Shift JIS)
" (double quotation mark) Description of a Unicode character string
.. (two periods) Specification of an integer range
Operator
The following shows the operators used in an ST program and the target data types and operation result data types for each
operator.
Operator Target data type Operation result type 6
*, /, +, - ANY_NUM ANY_NUM
<, >, <=, >=, =, <> ANY_ELEMENTARY*1 Bit
MOD ANY_INT ANY_INT
AND, &, XOR, OR, NOT ANY_BIT ANY_BIT
** ANY_REAL (Base) ANY_REAL
ANY_NUM (Exponent)
• If an expression includes multiple operators with the same priority, the operation is performed from the leftmost operator.
• Up to 1024 operators can be used in one statement.
6 ST LANGUAGE
6.1 Configuration 49
Syntax
The following table shows the types of statements that can be used in an ST program.
Item Description Reference
Assignment statement Assignment statement Page 50 Assignment statement
Sub-program control statement Function block call statement, function call statement Page 51 Sub-program control statement
RETURN statement
Conditional statement IF statement (IF, IF...ELSE, IF...ELSIF) Page 52 Conditional statement
CASE statement
Iteration statement FOR statement Page 53 Iteration statement
WHILE statement
REPEAT statement
EXIT statement
Assignment statement
Format Description Example
<Left side> := <Right side> ; The assignment statement assigns the result of the right side expression to the label or device of
intV1 := 0;
the left side.
intV2 := 2;
The result of the right side expression and the data type of the left side need to be the same data
type.
When an array type label or a structure label is used, check the data types of the left side and right side of the assignment
statement.
When an array type label is used, the data type and the number of elements need to be the same for the left side and right
side. Do not specify elements.
Ex.
intAry1 := intAry2;
When a structure label is used, the data type needs to be the same for the left side and right side.
Ex.
dutVar1 := dutVar2;
Ex.
Example of automatic conversion
dintLabel1 := intLabel1;
// Assignment statement : Automatically convert the INT type variable (intLabel1) to a DINT type variable,
and assign it the DINT type variable (dintLabel1).
6 ST LANGUAGE
50 6.1 Configuration
To avoid the deletion of the data during type conversion, only conversion from smaller type to larger type is performed. Of the
primitive data types, type conversion is performed only for the following data types among primitive data types are the targets
of a type conversion.
Data type Description
Word [Signed] In the case of a double word [signed] after conversion, the conversion is automatically made into a value
with a sign extension.
In the case of a single-precision real, an automatic conversion is made into the same value as the integer
before the conversion.*1
Word [Unsigned]/Bit String [16-bit] In the case of a double word [unsigned]/bit string [32 bits] or a double word [signed] after conversion, an
automatic conversion is made into to a value with a zero extension.*2
In the case of a single-precision real, an automatic conversion is made into the same value as the integer
before the conversion.*1
*1 When the data of 16 bits (a word [signed] or a word [unsigned]/bit string [16 bits]) is transferred to an input argument of the data type
ANY_REAL, an automatic conversion is made into a single- precision real.
*2 When the data of a word [unsigned]/bit string [16 bits] is transferred to an input argument of ANY32, an automatic conversion is made
into a double word [unsigned]/bit string [32 bits].
For data types that are not described above, use the type conversion function.
Since type conversion is not performed in the following cases, use the type conversion function.
• Type conversion between integer-data types with different signs
• Type conversion between the data types by which the data is deleted
For the precautions for assigning the result of an arithmetic operation, refer to the following.
6
Page 54 When an assigned arithmetic operation is used
The following table shows the symbols used for arguments in a function block call statement and available formats.
Type Description Attribute Symbol Available formats
VAR_INPUT Input variable N/A, or RETAIN := All formats
VAR_OUTPUT Output variable N/A, or RETAIN => Variable only
VAR_IN_OUT Input/Output variable N/A := Variable only
The execution result of the function block is stored by assigning the output variable that is specified by adding "." (period) after
the instance name to the variable.
Function block FB definition Example
Calling a function block with one input variable and one FB name: FBADD
FBADD1(IN1:= Input1);
output variable FB instance name: FBADD1
Input variable1: IN1
Output1 := FBADD1.OUT1;
Output variable1: OUT1
Calling a function block with three input variables and two FB name: FBADD
FBADD1(IN1:=Input1, IN2:=Input2, IN3:=Input3);
output variables FB instance name: FBADD1
Input variable1: IN1
Output1 := FBADD1.OUT1;
Input variable2: IN2 Output2 := FBADD1.OUT2;
Input variable3: IN3
Output variable1: OUT1
Output variable2: OUT2
6 ST LANGUAGE
6.1 Configuration 51
■Function call statement
Format Description
Function name(Variable1, Variable2, ...); Enclose an argument by "()" after the function name.
When using multiple arguments, delimit them by "," (comma).
A user-defined function that does not return a value and a function that includes a VAR_OUTPUT variable in the argument of
a call statement can be executed as a statement by adding a semicolon (;) at the end.
■RETURN statement
Syntax Format Description Example
■RETURN RETURN; The RETURN statement is used to end a program, function
IF bool1 THEN
block, or function in the middle of processing.
RETURN;
When the RETURN statement is used in a program, the
END_IF;
processing jumps to the next step after the last line of the
program.
When the RETURN statement is used in a function block, the
processing is returned from the function block.
When the RETURN statement is used in a function, the
processing is returned from the function.
One pointer type label is used by the system for one RETURN
statement.
A user-defined function that does not return a value and a function that includes a VAR_OUTPUT variable in the parameter of
a call statement can be executed as a statement by adding a semicolon (;) at the end.
Conditional statement
Syntax Format Description Example
■IF IF <Boolean expression> THEN The statement is executed when the value of Boolean
IF bool1 THEN
<Statement> ; expression (conditional expression) is TRUE. The statement is
intV1:=intV1+1;
END_IF; not executed if the value of Boolean expression is FALSE.
END_IF;
Any expression that returns TRUE or FALSE as the result of the
Boolean operation with a single bit type variable status, or a
complicated expression that includes many variables can be
used for the Boolean expression.
■IF...ELSE IF <Boolean expression> THEN Statement 1 is executed when the value of Boolean expression
IF bool1 THEN
<Statement 1> ; (conditional expression) is TRUE.
intV3:=intV3+1;
ELSE Statement 2 is executed when the value of Boolean expression
ELSE
<Statement 2> ; is FALSE.
END_IF;
intV4:=intv4+1;
END_IF;
■IF...ELSIF IF <Boolean expression 1> THEN Statement 1 is executed when the value of Boolean expression
IF bool1 THEN
<Statement 1> ; (conditional expression) 1 is TRUE. Statement 2 is executed
intV1:=intV1+1;
ELSIF <Boolean expression 2> THEN when the value of Boolean expression 1 is FALSE and the
ELSIF bool2 THEN
<Statement 2> ; value of Boolean expression 2 is TRUE.
ELSIF <Boolean expression 3> THEN Statement 3 is executed when the value of Boolean expression
intv2:=intV2+2;
<Statement 3> ; 1 and 2 are FALSE and the value of Boolean expression 3 is ELSIF bool3 THEN
END_IF; TRUE. intV3:=intV3+3;
END_IF;
6 ST LANGUAGE
52 6.1 Configuration
Syntax Format Description Example
■CASE CASE <Integer expression> OF When the statement that has the integer selection value that
CASE intV1 OF
<Integer selection 1> : matches with the value of the integer expression (conditional
1:
<Statement 1> ; expression) is executed, and if no integer selection value
bool1:=TRUE;
<Integer selection 2> : matches with the expression value, the statement that follows
<Statement 2> ; the ELSE statement is executed. 2:
The CASE statement is used to execute a conditional statement bool2:=TRUE;
<Integer selection n> : based on a single integer value or an integer value as the result ELSE
<Statement n> ; of a complicated expression. intV1:=intV1+1;
ELSE END_CASE;
<Statement n+1> ;
END_CASE;
Iteration statement
Syntax Format Description Example
■FOR FOR <Repeat variable initialization> The FOR...DO statement first initializes the data used as a
FOR intV1:=0
TO <Last value> repeat variable.
TO 30
BY <Incremental expression> DO An addition or subtraction is made to the initialized repeat
BY 1 DO
<Statement> ; variable according to the incremental expression. One or more
END_FOR; statements from DO to END_FOR are repeatedly executed until
intV3:=intV1+1;
the final value is exceeded. END_FOR;
The repeat variable at the end of the FOR...DO syntax is the
value at end of the execution. 6
■WHILE WHILE <Boolean expression> DO The WHILE...DO statement executes one or more statements
WHILE intV1=30 DO
<Statement> ; while the value of Boolean expression (conditional expression)
intV1:=intV1+1;
END_WHILE; is TRUE.
END_WHILE;
The Boolean expression is evaluated before the execution of
the statement. If the value of Boolean expression is FALSE, the
statement in the WHILE...DO statement is not executed. Since
a return result of the Boolean expression in the WHILE
statement requires only TRUE or FALSE, any Boolean
expression that can be specified in the IF conditional statement
can be used.
■REPEAT REPEAT The REPEAT...UNTIL statement executes one or more
REPEAT
<Statement> ; statements while the value of Boolean expression (conditional
intV1:=intV1+1;
UNTIL <Boolean expression> expression) is FALSE.
UNTIL intV1=30
END_REPEAT; The Boolean expression is evaluated after the execution of the
statement. If the value of Boolean expression is TRUE, the
END_REPEAT;
statement in the REPEAT...UNTIL statement are not executed.
Since a return result of the Boolean expression in the REPEAT
statement requires only TRUE or FALSE, any Boolean
expression that can be specified in the IF conditional statement
can be used.
■EXIT EXIT; The EXIT statement is used only in an iteration statement to
FOR intV1:=0
end the iteration statement in the middle of processing.
TO 10
When the EXIT statement is reached during execution of the
BY 1 DO
iteration loop, the iteration loop processing after the EXIT
statement is not executed. The processing continues from the
IF intV1>10 THEN
line after the one where the iteration statement is ended. EXIT;
END_IF;
END_FOR;
6 ST LANGUAGE
6.1 Configuration 53
Precautions
■When an assignment statement is used
• The maximum number of character strings that can be assigned is 255. If 256 or more character strings are assigned, a
conversion error occurs.
• Contacts and coils of the timer type or counter type cannot be used for the left side of an assignment statement.
• The instance of a function block cannot be used for the left side of an assignment statement. Use input variables, input/
output variables, and external variables of the instance for the left side of an assignment statement.
■When the step relay (S) or SFC block device (BL) is used
If the step relay (S) or SFC block device (BL) is used at the right-hand of an assignment statement or as an input argument of
a function or function block, a conversion error may occur. If an error occurs, change the assignment statement.
Ex.
The following is the example of rewriting.
Before change After change
M0 := S0; IF S0 THEN
M0 := TRUE;
ELSE
M0 := FALSE;
END_IF;
In addition, to use the digit-specified step relay (S) or the step relay with block specification (BL\S), the data size must be
specified correctly. Since the step relay (S) and the step relay with block specification (BL\S) are not targeted for
automatic conversion of data type, a conversion error may occur if the data size is not the same.
Ex.
The following is the example of rewriting.
Before change After change
(*Conversion error because K4S0 is 16 bits and D0:UD is 32 bits*) (*Assign data to the 16-bit device.*)
D0:UD := K4S0; D0 := K4S0;
(*Conversion error because BL1\K4S10 is 16 bits and the second (*Specify 32-bit data for DMOV.*)
argument of DMOV is 32 bits*) DMOV(TRUE, BL1\K8S10, D100:UD);
DMOV(TRUE,BL1\K4S10,D100);
Ex.
When an arithmetic operation result of 16-bit data (INT type) is assigned to 32-bit data (DINT type)
varDint1 := varInt1 * 10; // VarInt1 is a INT type variable, and varDint1 is a DINT type variable.
The arithmetic operation result is the same data type as that of the input operand. Thus, in the case of the above program,
when the operation result of varInt1 * 10 exceeds the range of the INT type (-32768 to +32767), an overflow or underflow
result is assigned to varDint1.
In this case, convert the operand of the operational expression to the data type of the left side in advance and execute the
operation.
varDint2 := INT_TO_DINT(varInt1); // INT type variable is converted to DINT type variable.
varDint2 := varDint2 * 10; // DINT type multiplication is performed, and the operation result is assigned.
6 ST LANGUAGE
54 6.1 Configuration
■Using the operator "-" for sign inversion in an arithmetic operation
When the operator "-" is used to invert the sign of the minimum value of a data type, the minimum value evaluates to the same
value.
For example, -(-32768), where the operator "-" is used with the minimum value of INT type, evaluates to -32768. Thus, an
unintended result may be produced if the operator "-" is used to invert the sign of a variable whose data type will be
automatically converted.
Ex.
When the value of varInt1 (INT type) is -32768, and the value of varDint1 (DINT type) is 0.
varDint2 := -varInt1 + varDint1;
In the example above, the value of (-varInt1) evaluates to -32768 and -32768 is assigned to varDint2.
When using the operator "-" to invert the sign of a variable in an arithmetic operation, perform automatic conversion of the
data type of the variable before the arithmetic operation. Alternatively, avoid using the operator "-" for sign inversion in the
program.
Ex.
Performing automatic conversion of the data type before an arithmetic operation
varDint3 := varInt;
varDint2 := -varDint3 + varDint1; 6
Ex.
Avoiding the use of the operator "-" for sign inversion
varDint2 := varDint1 - varInt1;
■When a bit type label is used
Once the Boolean expression (conditional expression) is satisfied in a conditional statement or an iteration statement, the bit
type label that is turned ON in <Statement> is always set to ON.
Ex.
Program whose bit type label is always set to on
ST program Ladder program equivalent to ST program
To avoid the bit device to be always set to ON, add a program to turn OFF the bit type label as shown below.
Ex.
Program to avoid the bit type label to be always set to ON
ST program*1 Ladder program equivalent to ST program
6 ST LANGUAGE
6.1 Configuration 55
■When a timer function block or counter function block is used
Boolean expression (conditional expression) in a conditional statement differs for the execution conditions of the timer
function block or counter function block.
Ex.
When a timer function block is used
Program before change
IF bLabel1 THEN
TIMER_100_FB_M_1(Coil:=bLabel2,Preset:=wLabel3,ValueIn:=wLabel4,ValueOut=>wLabel5,Status=>bLabel6);
END_IF;
(* When bLabel1 = on and bLabel2 = on, counting starts. *)
(* When bLabel1 = on and bLabel2 = off, the counted value is cleared. *)
(* When bLabel1 = off and bLabel2 = on, counting stops. The counted value is not cleared. *)
(* When bLabel1 = off and bLabel2 = off, counting stops. The counted value is not cleared. *)
Program after change
TIMER_100_FB_M_1(Coil:=(bLabel1&bLabel2),Preset:=wLabel3,ValueIn:=wLabel4,ValueOut=>wLabel5,Status=>bLabel6);
When a counter function block is used
Program before change
IF bLabel1 THEN
COUNTER_FB_M_1(Coil:=bLabel2,Preset:=wLabel3,ValueIn:=wLabel4,ValueOut=>wLabel5,Status=>bLabel6);
END_IF;
(* When bLabel1 = on and bLabel2 = on/off, the value is incremented by 1. *)
(* When bLabel1 = off and bLabel2 = on/off, the value is not counted. *)
(* The counting operation does not depend on the on/off status of bLabel1. *)
Program after change
COUNTER_FB_M_1(Coil:=(bLabel1&bLabel2),Preset:=wLabel3,ValueIn:=wLabel4,ValueOut=>wLabel5,Status=>bLabel6);
An error occurs when the program before change is used since the statement related to the timer or counter is not executed
when the selection statement is not satisfied.
When the timer or counter is operated according to the AND condition of bLabel1 and bLabel2, do not use any control
statement, just use a function block only.
Using the program after change operates the timer and counter.
6 ST LANGUAGE
56 6.1 Configuration
■When a rising execution instruction or a falling execution instruction is used
Shown here is the operation when a rising execution instruction or a fall execution instruction is used in an IF statement or a
CASE statement.
Condition Result of operation
Conditional Condition to Result of the ON/ Result of the ON/ Rising execution Falling execution
expression of an IF execute an OFF judgment of OFF judgment of instruction instruction
statement or a instruction (EN) the instruction at the instruction
CASE statement the time of the
previous scan
Agreement of TRUE or TRUE ON ON Not executed Not executed
CASE
OFF ON Executed Not executed
FALSE ON OFF Not executed Executed
OFF OFF Not executed Not executed
Disagreement of FALSE TRUE ON OFF Not executed Not executed*1
or CASE
OFF OFF Not executed Not executed
FALSE ON OFF Not executed Not executed*1
OFF OFF Not executed Not executed
*1 This is a fall (ON to OFF), but the instruction is not executed because the condition in the IF statement or the CASE statement is not
satisfied. 6
Ex.
When the PLS instruction (rising execution instruction) is used in an IF statement
IF bLabel0 THEN
PLS(bLabel1,bLabel10);
END_IF;
(1) If bLabel0 = OFF (the condition expression in the IF statement is
ON
FALSE), the ON/OFF judgment result is OFF. The PLS
bLabel0 OFF instruction is not executed. (bLabel10 = OFF does not change.)
(2) If bLabel0 = ON (the condition expression in the IF statement is
ON ON
TRUE) and bLabel1 = OFF (the condition for executing the
bLabel1 OFF instruction is OFF), the ON/OFF judgment result is OFF. The PLS
instruction is not executed. (bLabel10 = OFF does not change.)
ON
ON/OFF (3) If bLabel0 = ON (the condition expression in the IF statement is
judgment OFF TRUE) and bLabel1 = ON (the condition for executing the
result instruction is ON), the ON/OFF judgment result is OFF to ON (the
(3) condition for a rise is satisfied). The PLS instruction is executed.
(1) (2) ON (bLabel10 turns ON for once scan only.)
bLabel10 OFF
1 scan
6 ST LANGUAGE
6.1 Configuration 57
■When a master control instruction is used
Shown here is the operation when the master control is OFF.
• The statement in a selection statement (an IF statement or a CASE statement) or in an iteration statement (a FOR
statement, a WHILE statement, or a REPEAT statement) is not processed.
• Outside of a selection statement or an iteration statement, assignment statement is not processed and statement other
than assignment statement is not executed.
Ex.
A statement in a selection statement (IF statement)
MC(M0,N1,M1); //Master control OFF
IF M2 THEN
M3:=M4; //No processing is executed when the master control is OFF. So, M3 maintains the value at the time of a previous scan.
END_IF;
M20:=MCR(M0,N1);
Ex.
A statement out of a selection statement or an iteration statement (in the case of a bit assignment statement)
MC(M0,N1,M1); //Master control OFF
M3:=M4; //No processing is executed when the master control is OFF. So, M3 maintains the value at the time of a previous scan.
M20:=MCR(M0,N1);
Ex.
A statement out of a selection statement or an iteration statement (in the case of an OUT instruction)
MC(M0,N1,M1); //Master control OFF
OUT(M2,M3); //No execution is made when the master control is OFF.
M20:=MCR(M0,N1);
Constant
For the expression methods other than the one described the above, refer to the following.
Page 39 Constant
6 ST LANGUAGE
58 6.1 Configuration
Label and device
Specification method
Labels and devices can be directly described in the ST program. Labels and devices can be used for the left or right side of an
expression or as an argument or return value of a standard function/function block.
For available labels, refer to the following.
Page 31 LABELS
For available devices, refer to the following.
MELSEC iQ-F FX5 User's Manual (Application)
The following shows the devices to which device type specifiers can be added.
• Data register (D)
• Link register (W)
• Module access device (U\G)
• File register (R)
6 ST LANGUAGE
6.1 Configuration 59
Precautions
• The pointer type can be used for ST programs.
• When a value is assigned using nibble specification, use the same data type for the left side and right side of an operation.
Ex.
D0 := K5X0;
In the above case, since K5X0 is the double word type and D0 is the word type, an error occurs in the program.
• When a value is assigned using nibble specification and the data size of the right side is larger than that of the left side,
data is transmitted within the range of the target points of the left side.
Ex.
K5X0 := 2#1011_1101_1111_0111_0011_0001;
In the above case, since the target points of K5X0 is 20, 1101_1111_0111_0011_0001 (20 bits) are assigned to K5X0.
• When the current value (such as TNn) of a counter (C), timer (T), or retentive timer (ST) is used with a type other than Word
[unsigned]/Bit string [16-bit], or when the current value (such as LCNn) of a long counter (LC) is used with a type other than
Double word [unsigned]/Bit string [32-bit], use the type conversion function.
Ex.
varInt := WORD_TO_INT(TN0); (*Use the type conversion function*)
Comment
The following table shows the comment formats that can be used in an ST program.
Comment format Comment Description Example
symbol
Single line comment // The character strings between the start symbol "//" and the end of the // Comment
line are used as a comment.
Multiple-line comment (* *) The character strings between the start symbol "(*" and the end symbol ■Without newline
"*)" are used as a comment. (* Comment *)
Newlines can be inserted in the comment. ■With newline
(* Comment in the first line
Comment in the second line *)
/* */ The character strings between the start symbol "/*" and the end symbol ■Without newline
"*/" are used as a comment. /* Comment */
Newlines can be inserted in the comment. ■With newline
/* Comment in the first line
Comment in the second line */
When the multiple-line comment format is used, do not use end symbols inside comments.
6 ST LANGUAGE
60 6.1 Configuration
7 FBD/LD LANGUAGE
This is a language that creates a program by wiring blocks for specific processing, variables, and constants along with the
flows of data and signals.
7.1 Configuration
With the FBD/LD language, the following program can be created.
(1) FBD unit
(2) LD unit
(6) (3) Common unit
(4) Connecting wire
(2) (5) (5) Connecting point
(6) Worksheet
(1) (4)
7
(3)
In a program of the FBD/LD language, data flows from the output point of a function block (FB), a function (FUN), a variable
unit (label or device), and constant unit to the input point of another function block, variable unit, and so forth.
7 FBD/LD LANGUAGE
7.1 Configuration 61
Program unit
FBD unit
Units constituting FBD/LD program are shown below.
Unit Symbol Description
Variable A variable is used to store each value (data). The data type of a variable should be a certain type.
Only the value (data) of the data type is stored.
You can specify a label or a device to a variable.
Constant The constant specified is output.
Ex.
When 1 is input as a constant value
The data type can be a BOOL type, a WORD type, a DWORD type, an INT type, a DINT type, or a REAL type. So, the data
type is not determined. When the constant unit and an FBD unit are connected over a connecting wire, the data type becomes
the data type at the input point of the unit at the destination of the connection.
(1) The data type is not determined.
1 (2) INT type
(3) INT type
(1)
INT_TO_REAL
1 IN
(2)
(3)
7 FBD/LD LANGUAGE
62 7.1 Configuration
■The input/output point of a function
• It is necessary that all the input points of a function should be connected to other FBD units over connecting wires.
• The data types of the input variables and output variables of a function should be of certain types. It is necessary that the
FBD units to be connected to the input point or output point should be of the same data types.
• Connect a variable element between an output variable (except for ENO) of a CPU module instruction or module dedicated
instruction and an input variable of another function (or function block).
• In a program that connects a function with EN to another function over a connecting wire, the other function must be a
function with EN and the program must connect ENO and EN over a connecting wire, in order to prevent the function from
using an indefinite value.
AND_E AND_E
(1)
BOOL_EN_DATA EN ENO EN ENO
Ex.
The following is the example of rewriting.
Before change After change
S0
S0 M0 M0
In addition, to use the digit-specified step relay (S) or the step relay with block specification (BL\S), the data size must be
specified correctly. Since the step relay (S) and the step relay with block specification (BL\S) are not targeted for auto data
type conversion, a conversion error may occur if the data size are not the same.
Ex.
The following is the example of rewriting.
Before change After change
DMOV DMOV
16 bit EN ENO 32 bit EN ENO
7 FBD/LD LANGUAGE
7.1 Configuration 63
LD unit
Units of ladder diagram that can be used in a program of the FBD/LD language are shown below.
Unit Symbol Description
Left bus This is an unit to represent a bus. This is the starting point to create a ladder circuit.
Rising edge Turns on at the rising edge (OFF to ON) of a specified device or label.
Falling edge Turns on at the falling edge (ON to OFF) of a specified device or label.
Negated rising edge Turns on when a specified device or label is OFF or ON, or at the falling edge (ON to OFF) of a
specified device or label.
Negated falling edge Turns on when a specified device or label is OFF or ON, or at the rising edge (OFF to ON) of a
specified device or label.
Coil Outputs an operation result to a specified device or a label.
Complementing coil When the operation result turns OFF, the specified device or label turns ON.
Set When the operation result turns ON, the specified device or label turns ON.
The device or the label that turns ON remains ON even if the operation result turns OFF.
Reset When the operation result turns ON, the specified device or label turns OFF.
When the operation result is OFF, the status of the device or the label does not change.
7 FBD/LD LANGUAGE
64 7.1 Configuration
Common unit
This represents a common unit placed on the FBD/LD editor.
Unit Symbol Description
Jump*1 The execution processing is jumped over from a jump unit to a jump label. The portion that is
jumped over is not executed.
Whether a jump is made or not is controlled depending on the ON/OFF information to the jump unit.
ON: The execution processing is jumped over up to a jump label.
OFF: The execution processing is not jumped over but is executed.
Jump label*1 This is the destination of a jump from a jump instruction in the same program. The processing is
executed from a program in the execution order after the jump label.
Connector This is used as a substitute of a connecting wire.
The processing moves on to the corresponding connector unit.
You can use one input connector or multiple input connectors for one output connector.
Return*1 The processing after a return unit in the program is aborted. Use this when you want to prohibit the
execution of the processing of a program, function, or a function block after the return unit.
Whether the return processing is executed or not is controlled depending on the ON/OFF
information to the return unit.
ON: The return processing is executed.
OFF: The return processing is not executed, but the ordinary execution processing is executed.
Comment Use this to describe a comment.
7 FBD/LD LANGUAGE
7.1 Configuration 65
■The operation of a return unit
A return unit operates differently depending on whether a program, function, and/or function block used there.
Program unit to use Description
Program The execution of the program unit is terminated.
Function The function is terminated, and the step goes back to the one next to the instruction that has called the function.
Function block The function block is terminated, and the step goes back to the one next to the instruction that has called the function
block.
■Connector unit
Use a connector element to place the program within the display area or print area of the FBD/LD editor.
Var1 Var2 Var3 Var4 Var5
CONNECTOR
Connecting wire
This is the wire to connect the connecting points between FBD unit, LD unit, and common unit.
After units are connected, the data is transferred from the left end to the right end. The data types of the connected units need
to be the same.
Connecting point
This is a terminal point to use a connecting wire to connect FBD unit, LD unit, and common unit.
The point on the left side of each unit is the input side, while the point on the right side represents the output side.
Unit Input connecting Output connecting Unit Input connecting Output connecting
point point point point
Contact Coil
Variable Constant
7 FBD/LD LANGUAGE
66 7.1 Configuration
Worksheet
A worksheet is a work area for inserting program units and for connecting them with wires.
Constant
For the expression methods other than the one described the above, refer to the following.
Page 39 Constant
Specification method
You can directly describe and use labels and devices in an FBD/LD program. You can use labels and devices for inputs and
7
output points of units, for arguments of standard functions/function blocks, return values, and so forth.
For available labels, refer to the following.
Page 31 LABELS
For available devices, refer to the following.
MELSEC iQ-F FX5 User's Manual (Application)
7 FBD/LD LANGUAGE
7.1 Configuration 67
Caution
■When using label
• Labels whose name ends with "_" cannot be used as an array index. To use such a device or label as an array index,
assign it to another device or label and specify that device or label as an index.
• Members of labels (structures or function blocks) whose name ends with "_" cannot be specified.
• Indexes cannot be specified to labels (arrays) whose name ends with "_".
7 FBD/LD LANGUAGE
68 7.1 Configuration
7.2 Inline ST
The inline ST is the function used to create an inline ST unit that displays an ST program in the FBD/LD editor, and edit and
monitor it.
This function enables to create numerical operations and character string processing easily in FBD/LD programs.
• Program that uses the inline ST
Specifications
For the specifications of the inline ST, refer to the ST language specifications.
Page 47 ST LANGUAGE
Precautions
• Up to 64 inline ST elements can be inserted into a single POU of an FBD/LD program.
• When the RETURN syntax is used in an inline ST, the processing inside the inline ST unit ends, and the processing inside
the program block does not end.
• Since inline ST units have no connection points, an inline ST element inserted into an FBD/LD program is executed every
scan.
7 FBD/LD LANGUAGE
7.2 Inline ST 69
7.3 Program Execution Order
The order of executions of program units
The order of executions of the units in the FBD/LD editor is determined depending on the positional relation of the units and
on the status of connecting wires.
Executed from
the left side to
the right side
M0 Y0
1 2
CTD_E_1
CTD_E
SM400
EN ENO
3
Var_CU CD Q Var_Q
4 8
Var_R LD CV Var_CV
5 9
Var_PV PV
6
7
SM400
RETURN
Executed from 10 11
the top to the
bottom
The number of the order of the execution is shown on each unit placed on the FBD/LD editor.
ADD
7 FBD/LD LANGUAGE
70 7.3 Program Execution Order
8 SFC PROGRAM
SFC is a program description format in which a sequence of control operations is split into a series of steps and the execution
sequence and execution conditions of each program can be clearly expressed.
• It is compatible with the SFC program of FX3, and the configuration of FX3 can be replaced with that of
FX5. (Page 103 FX3 compatible transition operation mode setting)
• This chapter describes the operations and specifications of SFC programs. For details on the information
not described in this chapter, refer to the following.
GX Works3 Operating Manual
MELSEC iQ-F FX5 User's Manual (Application)
Transition from MELSEC FX3G, FX3U, FX3UC Series to MELSEC iQ-F Series Handbook
Check the versions of the CPU module and the engineering tool before using the SFC program. For the
versions of the CPU module and engineering tool, refer to Page 126 Added and Changed Functions.
8 SFC PROGRAM
71
The SFC program consists of steps that represent units of operations in a series of machine operations.
In each step, the actual detailed control is programmed.
Machining
operation flowchart SFC diagram Ladder diagram of the action or transition of each step
Start Workpiece Conveyer
switch detection start
X0 X1 Y20
Start processing 1 operation unit
Pallet
detection
X2
TRAN
Pallet
Always ON clamping
Pallet check and SM400 Y21
clamping operation 1 operation unit
Clamp
confirmation
X3
TRAN
Y22
PLS M0
M0 Drill down
SET Y23
Hole making
1 operation unit X4 Drill down endpoint
operation RST Y23
OUT T0 K20
T0 Drill up
SET Y24
Drill up
endpoint
X5
TRAN
Pallet
Always ON unclamping
SM400 Y25
Y25
PLS M1
Unclamping operation M1
and workpiece unloading 1 operation unit SET Y24
Conveyer start
X6 Unclamp confirmation Y20
Workpiece unloading
confirmation
X7
End processing 1 operation unit TRAN
An SFC program starts at an initial step, executes an action of the next step in due order every time the relevant transition
becomes TRUE, and ends a series of operations at an end step.
8 SFC PROGRAM
72
It is possible to assign the actual controls of the entire facility, mechanical devices of each station, and all machines to the
steps in the blocks of the SFC program.
Step transition control unit for overall process Station 1 control unit
(Block 0) (Block 1)
Transfer machine start Start
(Initial step) (Initial step)
End
(End step)
(End step)
Pallet clamping
(Step 1)
Tapping
(Step 2)
8
Pallet unclamping
(Step 3)
(End step)
Pallet clamping
(Step 1)
Workpiece unloading
(Step 2)
Pallet unclamping
(Step 3)
(End step)
8 SFC PROGRAM
73
8.1 Specifications
This section lists the performance specifications related to SFC Programs.
Item Specifications
Number of device points (SFC) Step relay (S) 4096 points
SFC block device (BL) 32 points
SFC transition device (TR) 0 points
Number of executable SFC programs 1
Number of blocks 32 blocks
Number of SFC steps Up to 4096 steps in all blocks, up to 512 steps in 1 block
Step No. 0 to 511 per block
Number of branches 32 branches maximum
Number of simultaneously active steps Up to 128 steps in all blocks and in 1 block
Number of initial steps 1 step maximum per block
Number of actions 4 actions maximum per step
Number of sequential steps Action No limit
Transition Only one per ladder block
Number of online change (SFC block) target blocks 1*1
For the processing time of the SFC program, refer to the following.
MELSEC iQ-F FX5 User's Manual (Application)
8 SFC PROGRAM
74 8.1 Specifications
8.2 Structure
(4)
(5)
(6)
1. When starting a block, the initial step (1) is activated first and then the action (2) is executed. After execution of the action
(2), the program checks whether the next transition (3) has become TRUE.
8
2. The program executes only the action (2) until the transition (3) becomes TRUE. When the transition (3) becomes TRUE,
the program ends the action (2), deactivates the initial step (1), and activates the next normal step (4).
3. After execution of the action of the normal step (4), the program checks whether the next transition has become TRUE. If
the next transition does not become TRUE, the program repeats the execution of the action of the normal step (4).
4. When the transition becomes TRUE, the program ends the action, deactivates the step (4), and activates the next step
(5).
5. Every time the transition becomes TRUE, the program activates the next step and ends the block when it finally activates
the end step (6).
• Up to 4 actions can be created in one step. When multiple actions are created, they will be executed in
order from the top. (Page 87 Action)
• The operation of the initial step and normal step can be changed by adding the attribute. (Page 77 Step
types)
8 SFC PROGRAM
8.2 Structure 75
Block
A block is a unit showing a series of operation consisting of steps and transitions.
For the maximum number of blocks that can be created in an SFC program, refer to the following.
Page 74 Specifications
A block begins with an initial step, a step and a transition are connected alternately, and ends with an end step or jump
sequence.
A block is in the active or inactive state.
• Active: The block has an active step.
• Inactive: All steps in the block are inactive.
When the block state changes from inactive to active, the initial step becomes active to start sequential processing. (Page
106 Block execution sequence)
• Depending on the CPU parameter setting, only the block 0 can be started automatically when the SFC
program starts. In this case, when the end step is activated and the block 0 is finished, the block 0 will be
automatically restarted and executed again from the initial step. (Page 101 Start Conditions Setting)
• If a start request is issued to a step in an inactive block by using the SFC control instruction (activating a
step), the block is activated to execute processing from the specified step.
8 SFC PROGRAM
76 8.2 Structure
Step
A step is the basic unit for comprising a block.
(1) Step name
(1) (2) (2) Step No.
(3) Attribute
(4) Attribute target
Step0 S1
BS BL1
(3) (4)
For the maximum number of steps that can be created per block, refer to the following.
Page 74 Specifications
Steps have the following characteristics.
• When the step becomes active, the associated action is executed.
• A step No. is assigned to each step. The step No. is used to monitor the running step or forcibly start or stop the step by
using the SFC control instruction. (Page 86 Assigning the step relay (S) areas to steps)
• Each step name and No. are unique within each block. (Each cannot be a blank.)
The step name, step No., attribute and attribute target can be changed in the Step Properties window.
Select a step, and select [Edit] [Properties] on the menu. Then, the Step Properties window will appear.
(GX Works3 Operating Manual)
8
Step types
The following table lists the types of steps.
Item Description
Initial step A step that indicates the beginning of a block.
While this type of step is active, the transition following the
Initial S0 N Action0 step is constantly checked, and when the transition becomes
TRUE, the next step becomes active.
The attributes of SC and R can be added.
This step can also be used as a step without creation of an
action.
Initial S0
8 SFC PROGRAM
8.2 Structure 77
Step attributes
The following table lists the attributes of steps.
Attribute Item Description
SC Coil HOLD step [SC] Coil HOLD step [SC] is a step that holds the outputs of a coil
that has been turned on by the action even after the active
Step1 S2 state transitions.
N Action2
SC
SE Operation HOLD step A step which continues the operation of the action even after
(without transition check) the active state transitions.
[SE] Step2 S3 After the transition becomes TRUE and the next step is
N Action3
SE activated, the transition is not checked.
ST Operation HOLD step A step which continues the operation of the action even after
(with transition check) the active state transitions.
[ST] Step3 S4 Even after the transition becomes TRUE and the next step is
N Action4
ST activated, the transition is checked repeatedly.
R Reset step [R] Reset step [R] is a step that deactivates the specified step.
Step4 S5
N Action5
R Step1
BC Block start step (with A step that activates the specified block.
END check) [BC] When the specified block becomes inactive and the transition
Step5 S6 becomes TRUE, the active state transitions to the next step.
BC BL1 An action cannot be created.
BS Block start step (without A step that activates the specified block.
END check) [BS] When the transition becomes TRUE, the active state
Step6 S7 transitions to the next step.
BS BL2 An action cannot be created.
• The type of a step can be changed by changing the setting of "Step Attribute" in the "Step Properties"
window.
• For the reset step [R], block start step (with END check) [BC], or block start step (without END check) [BS],
specify a step name or a block No. in "Step Attribute Target" in the Properties window.
For the setting procedure, refer to the following.
GX Works3 Operating Manual
8 SFC PROGRAM
78 8.2 Structure
Normal step (without attribute)
A basic step used to configure a block.
While this type of step is active, the transition condition following the step is constantly checked, and when the transition
becomes TRUE, the next step becomes active.
The output status of the action of a step at a transition to the next step varies depending on the instruction used.
Item Description Example
When the OUT When a transition to the next step occurs and the
instruction is used relevant step becomes inactive, the output by using the
X1 Y0
(Other than the OUT instruction turns off automatically.
(1)
OUT C instruction) Similarly, the timer also clears the current value and
turns off the contact.
However, the select statement of structured text (2)
language or the output by using the OUT instruction
which is repeatedly using within the statement does
not turn off automatically.
When the transition (2) becomes TRUE while Y0 is turned on by using the
OUT instruction triggered by the action of step (1), Y0 is automatically turned
off.
When the OUT C If the execution condition of the counter in the action is
instruction is used already on when the transition becomes TRUE and
activate the step using the counter, the counter is
(1)
incremented by 1.
When a transition to the next step occurs before reset
instructions of the counter is executed, the present (2)
value of the counter and the ON state of the contact is X10
held even if the step using counter becomes inactive. (3) OUT C0 K10
To reset the counter, use the RST instruction in another
step. 8
If X10 is already on while step (1) is active, counter C0 counts once when
execution proceeds to step (3) after the transition (2) becomes TRUE.
When the SET, Even if the active state transitions to the next step and
basic, or application the step that has used the instruction becomes
X2
instruction is used inactive, the ON state or the data stored in the device/
(1) SET Y0
label are held.
To turn off the ON device/label or clear the data stored (2)
in the device/label, use the RST instruction in another (3)
step.
(4)
Even when the contact of the execution condition is on (1), the PLS instruction
is executed every time the step (2) becomes active.
8 SFC PROGRAM
8.2 Structure 79
Initial step
The initial step represents the beginning of each block. Only one initial step can be described in one block. (Page 74
Specifications) Execute the initial steps in the same way as executing other steps.
X10
ON
(3)
No operation in the action is performed after a transition becomes TRUE and the next step is activated. Therefore, the coil
output status will remain unchanged even if the input condition in the action is changed.
8 SFC PROGRAM
80 8.2 Structure
Operation HOLD step (without transition check) [SE]
A step which continues the operation of the action even after the active state transitions.
This step continues the operation in the action even after a transition becomes TRUE and the next step is activated.
Therefore, when the input condition changes, the coil status also changes.
After the transition becomes TRUE and the next step is activated, the transition is not checked and the transition to the next
step does not occur.
When step (2) is activated, step (1) holds the operation.
(1) (3) Y10 While holding the operation, the transition is not checked but the action (3)
X0
is kept executed.
In this case, Y10 turns on or off accordingly as X0 turns on or off.
(2)
■Deactivation timing
An operation HOLD step (without transition check) [SE] becomes inactive when:
• The end step of a block is executed.
• A block is forcibly terminated by using the RST instruction (Ending a block).
• A step is reset by using the RST instruction (Deactivating a step).
• A reset step [R] for resetting the operation HOLD step (without transition check) [SE] becomes active.
• SM321 (Start/stop SFC program) is turned off.
• S999 is specified at a reset step [R] within a block.
■Deactivation timing
An operation HOLD step (with transition check) [ST] becomes inactive when:
• The end step of a block is executed.
• A block is forcibly terminated by using the RST instruction (Ending a block).
• A step is reset by using the RST instruction (Deactivating a step).
• A reset step [R] for resetting the operation HOLD step (with transition check) [ST] becomes active.
• SM321 (Start/stop SFC program) is turned off.
• S999 is specified at a reset step [R] within a block.
8 SFC PROGRAM
8.2 Structure 81
■Precautions
• For the operation HOLD step (with transition check) [ST], the next step is activated every scan while the transition
immediate after the operation HOLD step becomes TRUE. To prevent transition every scan, use instructions executed on
the rising edge such as the PLS instruction for the transition.
By setting the start of rising edge pulse operation as the transition, step (1) is
activated during only one scan caused when X0 is turned on.
Even when step (2) is activated and becomes inactive, step (1) is not activated
X0 unless X0 is turned off and on again.
TRAN
(1)
(2)
• When SM328 (Clear processing mode when the sequence reaches the end step) is on, prevent the transition immediately
after the operation HOLD step (with transition check) [ST] from becoming always TRUE. Otherwise, the next step is kept
activating and holding no operation, therefore the block cannot be ended.
BC BL1
(2)
The operation to be performed if multiple attempts to start one block are performed simultaneously or if an attempt to start an
already started block is performed depends on "Act at block Multi-Activated." (Page 104 Act at block Multi-Activated)
Only one block can be specified. To start multiple blocks simultaneously, use parallel branches and multiple block start steps.
8 SFC PROGRAM
82 8.2 Structure
■Precautions
• An action cannot be created to the block start step (with end check) [BC].
• The block start step (with END check) [BC] cannot be created immediately before convergence of a parallel convergence.
To create the step immediately before the convergence of a parallel convergence, use a block start step (without END
check) [BS].
(1)
BC BL1
X0
(2) TRAN
The operation to be performed if multiple attempts to start one block are performed simultaneously or if an attempt to start an
already started block is performed depends on "Act at block Multi-Activated." (Page 104 Act at block Multi-Activated)
Only one block can be specified. To start multiple blocks simultaneously, use parallel branches and multiple block start steps.
■Precautions
An action cannot be created to the block start step (without END check) [BS].
8 SFC PROGRAM
8.2 Structure 83
End step
End step is a step that ends a block.
• When the active state transitions to the end step, and if there are no active steps other than steps that hold operations in
the block, all the HOLD steps that hold operations in the block are deactivated, and the block is ended.
• When a block contains any active steps other than steps that hold operations in a block, the following processing is
performed depending on the status of SM328 (Clear processing mode when the sequence reaches the END step).
Status of SM328 Description
OFF (default) Clear processing is performed.
The active steps remaining in the block are all terminated forcibly to end the block.
ON Clear processing is not performed.
The block continues running in the state when the end step is reached and does not end.
• When the clear processing is performed, the coil outputs turned on by using the OUT instruction are all turned off. However,
for the coil outputs of the HOLD steps that hold operations, the following processing is performed depending on the status
of SM327 (Output mode at execution of the END step).
Status of SM327 Description
OFF (default) All the outputs of the HOLD steps that hold operations are turned off.
ON All the outputs of the HOLD steps that hold operations are held.
The setting of SM327 is valid for only the coil HOLD step [SC] that holds operation. All the
outputs of the coil HOLD step [SC] that does not hold operation and the transition does not
become TRUE are turned off. Also, even when SM327 is on, the steps become inactive.
However, when a forced end is performed such as by the block end instruction, the coil
outputs of all steps are turned off.
8 SFC PROGRAM
84 8.2 Structure
Precautions
• An action cannot be created to the end step.
• The setting of SM327 (Output mode at execution of the END step) is valid only when the end step becomes active. When a
forced termination is performed by the SFC control instruction (Ending a block) or the like, the coil outputs of all steps are
turned off.
• If only the HOLD steps that hold operations remain when the end step becomes active, those steps are deactivated even
though SM328 (Clear processing mode when the sequence reaches the END step) is on. If it is not required to turn off the
coil outputs of the HOLD steps that hold operations, turn on SM327. The following figure shows the operational relationship
between SM328 and the coil HOLD step [SC].
When a normal active step remains or when a coil HOLD step When an active step that holds an operation remains
[SC] whose transition has not become TRUE remains (the step
does not hold an operation)
SC SC
8
• When SM328 is off, the block is ended by clearing the step. The block is ended by clearing the step regardless of the setting of SM328.
• When SM328 is on, processing is continued without clearing the step.
• If a block is started at the block start step when SM328 is on, execution returns to the source as soon as there are no active
step that does not hold the operation in the block.
• Prevent the transition after the operation HOLD step (with transition check) [ST] from becoming always TRUE. When the
transition immediately after the operation HOLD step (with transition check) [ST] always becomes TRUE, the next step is
kept active and, therefore, the block can no longer be ended when SM328 is on.
• When "FX3 compatible transition operation mode setting" is set to "Enable", the CPU module is powered off and on, or
SM328 is turned on at reset.
8 SFC PROGRAM
8.2 Structure 85
Assigning the step relay (S) areas to steps
The step relay is a device corresponding to each step in the SFC program. It is on when the relevant step is active (even in
the stop or hold state) and is off when the relevant step is inactive.
Step relays are assigned as follows.
• Step relays are assigned sequentially in order of block No. starting from block 0 in an SFC program and in order of step No.
within a block.
• No step relay is assigned to any non-existing block No.
• Step relays are assigned to missing step Nos. in one block. The bits of the missing numbers are constantly off.
• All bits after the step relays assigned in the last block are off.
Ex.
The following example shows the step relay assignments of the following block configuration.
• Block0: The largest step No. is 8, and step No. 3 and 6 are missing.
• Block1: Missing
• Block2: The largest step No. is 12, and step No. 3 is missing.
• Block3 and after: Missing
(1) Stored data
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 (2) Step Nos. in a block
(3) All 0s for missing blocks
S15 to S0 0 0 0 (1)
S6 S5 S4 - S2 S1 S0 S8 S7 - S5 S4 - S2 S1 S0 (2)
Block2 Block0
(3) Block2
Any step No. can be assigned to each step (except end step).
• Assign step Nos. in ascending order wherever possible because any missing step No. will decrease the
maximum number of steps that can be created.
• The step No. other than step No. 0 (S0) cannot be used for the initial step of the top line and left end.
Ex.
Specifying step No. 23 in block No. 12
Program type Device notation Description
SFC program In the same block S23 The block name can be omitted when specifying a step in the
same block.
Other than block 12 BL12\S23 Specify the target block No. and step No.
Sequence program other Specifying the current target block S23 The block name can be omitted when specifying a step in the
than SFC program target block.
Specifying a block different from the current BL12\S23 Specify the target block No. and step No.
target block
8 SFC PROGRAM
86 8.2 Structure
Action
An action is a program which is executed while a step is active.
(1) (3)
SM400 bLabel2
Step1 S1 N Action0
Step2 S2 N M20
(4)
N bLabel5
8 SFC PROGRAM
8.2 Structure 87
Create a contact to be input condition of each instruction in the ladder of detailed expression.
■Restrictions
The following table lists the restrictions on individual programming languages used to create an action.
Language Description
Ladder diagram Detailed expression A pointer and an interrupt pointer cannot be input in the pointer input area.
■Functions/function blocks that cannot be used
• Function/function block that includes an instruction that cannot be used in an action
• Function/function block that includes a pointer
• A macro type function block for which "Use MC/MCR to Control EN" is set to "Yes" and "Use EN/
ENO" is set to "No"
Structured text language Page 47 ST LANGUAGE
FBD/LD language Page 61 FBD/LD LANGUAGE
Precautions
• The step operation is almost the same as the following circuit. For the execution of action, refer to Page 107 Execution
of action.
(1) Input condition of each instruction
(2) Contact indicating the step status (on when active, off
(1)
when inactive)
(1)
(2)
Action
• If the CALL instruction is used to issue a subroutine call in an action of the step, the output of the call destination is not
turned off even when the step becomes inactive after the transition becomes TRUE. To turn off the output of the call
destination when the step becomes inactive after the transition becomes TRUE, use the XCALL instruction.
• Even when the input condition in the action is always on, it is assumed to be off when the action is inactive. Therefore,
immediately after the step becomes active, the instruction is executed when the output is turned on. For example, when the
input condition is set to be always on by using the instructions executed at the rising edge such as the PLS or INCP
instruction, the instruction is executed every time the step becomes active.
• The device that turned on by the OUT C instruction, the SET instruction, a basic instruction, or an application instruction in
the action is not turned off even when the step is deactivated and the action is ended. To turn off the device, execute the
RST instruction separately.
• With the PLS or PLF instruction, the specified device is normally turned on for only one scan and thereafter becomes off.
However, the specified device holds the ON state if it is turned on at the same time when the transition of the coil HOLD
step [SC] becomes TRUE. In this case, it is turned off by changing the condition to the one where the coil output of the coil
HOLD step [SC] turns off or activating the step again. For the conditions where the coil output turns off, refer to the
following.
Page 80 Timing of when coil output turns off
• If the step is deactivated and the action is ended while the input condition of the PLF instruction is on, the specified device
remains on.
• The operation of SFC control instruction depends on the execution condition before the no-execution status is entered.
8 SFC PROGRAM
88 8.2 Structure
Transition
A transition is the basic unit for comprising a block and transfers the active state to the next step when the condition becomes
TRUE.
(3)
Transition1 (1) bLabel1 bLabel2
TRAN
TR0
bLabel1
TR1
Step2 S2
M100 (5)
TR2
Detailed expression of a transition can be created in ladder diagrams, ST language, or FBD/LD language.
8
8 SFC PROGRAM
8.2 Structure 89
Transition types
The following table lists the types of transition.
Item Description
Series sequence When the transition becomes TRUE, the active state transitions from the
preceding step to the subsequent step.
Selective sequence Divergence: A step branches to multiple transitions, and only the step in the line
(divergence/convergence) where the transition becomes TRUE first is activated.
Convergence: The next step is activated when the transition immediately before
convergence, which is in the line where the transition becomes TRUE first,
becomes TRUE.
Simultaneous sequence Divergence: All the steps branched from one step are activated simultaneously.
(divergence/convergence) Convergence: When all the steps immediately before convergence are activated
and the common transition becomes TRUE, the active state transitions to
the next step.
Jump sequence When the transition becomes TRUE, the active state transitions to the specified
step in the same block.
For the operation of transition to the step which is already activated, refer to the following.
Page 114 Behavior when an active step is activated
8 SFC PROGRAM
90 8.2 Structure
Series sequence
When the transition becomes TRUE, the active state transitions from the preceding step to the subsequent step.
When the transition (2) becomes TRUE while the step (1) is active, the step (1) is
deactivated and the step (3) is activated.
(1)
(2)
(3)
Convergence When the transition (1) or transition (2) on the activated branch becomes
TRUE, the step (5) is activated.
The activated step (3) or (4) becomes inactive. However, if it is a coil HOLD
(3) (4)
step [SC], the step holds the coil output or action according to its attribute.
(1) (2)
(5)
(1) (2)
(3)
• An SFC diagram in which the number of branches is different from the number of merges in a selective sequence can also
be created. However, in an SFC diagram, selective divergence and parallel convergence or parallel divergence and
selective convergence cannot be combined.
8 SFC PROGRAM
8.2 Structure 91
• In a selective transition, a convergence can be omitted by a jump transition or end transition.
When transition (2) becomes TRUE during action of step (1), step (3) and step
(4) are sequentially executed. When the transition (5) becomes TRUE, a jump
sequence to step (1) occurs.
(1)
(2)
(3)
(4)
(5)
The above program can be created by changing the steps other than the step of the leftmost branch to end
steps and changing the end step of the leftmost branch to a jump sequence.
For the operation method for changing steps, refer to the following.
GX Works3 Operating Manual
(3) (4)
(5) (6)
(7) (8)
Convergence After the step (1) and step (2) immediately before the convergence become
active, the transition (3) is checked, then becomes TRUE, the step (4) is
activated.
The step (1) and step (2) become inactive. However, if it is a coil HOLD step
[SC], the step holds the coil output or action according to its attribute.
(1) (2)
(3)
(4)
8 SFC PROGRAM
92 8.2 Structure
• The simultaneous sequence allows transitions to up to 32 steps.
• If another block is started by the simultaneous sequence, the START source block and START destination block will be
executed simultaneously.
• A simultaneous convergence is always performed after a simultaneous branch.
■Precautions
• When the steps merged by parallel convergence include HOLD steps that hold operations, the steps are handled as
inactive steps, and the transition to the next step does not occur.
• In the simultaneous convergence, a block start step (with END check) [BC] cannot be created immediately before the
convergence. Use a block start step (without END check) [BS].
Jump sequence
When the transition becomes TRUE, the active state transitions to the specified step in the same block.
When the transition (2) becomes TRUE while the step (1) is active, the step (3)
is activated.
The step (1) becomes inactive. However, if it is a coil HOLD step [SC], the step
holds the coil output or action according to its attribute.
(3)
(1)
(2)
8 SFC PROGRAM
8.2 Structure 93
Ex.
Example of jump sequence that cannot be specified in the simultaneous branch
■Jump sequence to another branch within a ■Jump sequence for exiting from a simultaneous ■Jump sequence to a simultaneous branch from
simultaneous branch branch outside a simultaneous branch
(1) (1)
■Precautions
Under the following conditions, a step cannot be specified as the destination of jump sequence.
• When a step immediately before the preceding transition is specified
• When current step is specified (when "FX3 compatible transition operation mode setting" is set to "Enable", a step can be
specified.)
8 SFC PROGRAM
94 8.2 Structure
Detailed expression of transitions
Create detailed expression of transitions in the Zoom editor. The condition can be created in following programming
languages.
Type Description
Ladder Detailed expression Used to create a transition program consisting of a contact circuit and the TRAN instruction (Creating a dummy
diagram transition condition) in a single circuit block. The transition becomes TRUE when the TRAN instruction is
executed.
bLAbel1 bLabel2
TRAN
■Restrictions
• Inline ST cannot be used.
• Only a TRAN instruction can be input to the coil.
Structured text language Used to create the following transition program.
■Method of writing a TRAN function (Creating a dummy transition condition) call statement
TRAN(bLabel1 & bLabel2);
//The transition becomes TRUE when the Boolean expression of the input argument is true.
■Method of writing an assignment statement of Boolean expression for reserved word "TRAN"
TRAN := bLabel1 & bLabel2;
//The transition becomes TRUE when the Boolean expression of the right-hand side is true.
■Method of writing an assignment statement of Boolean expression for the transition name
Transition1 := bLabel1 & bLabel2;
//Transition1 indicates the transition name input on the SFC editor. The transition becomes TRUE when the
Boolean expression of the right-hand side is true.
FBD/LD language Used to create a transition program ending with the TRAN instruction (Creating a dummy transition condition) in
a single FBD network block.
AND TRAN 8
bLAbel1 IN1 S
1
4
bLAbel2 IN2
2
3
■Restrictions
• Inline ST cannot be used.
• Only one TRAN instruction can be used.
• A program to be assigned to the device/label cannot be created.
• Coil, function block, function (except some), jump, jump label, and return program elements cannot be used.
For usable instructions other than the TRAN instruction, refer to the following.
Page 95 Usable instructions
• The detailed expression of the same transition can be used for multiple transitions.
• The created detailed expression can be confirmed in the Zoom list. (GX Works3 Operating Manual)
■Usable instructions
The following table lists the instructions that can be used in transition programs.
Classification Instruction symbol
Contact instruction LD, LDI, AND, ANI, OR, ORI
LDP, LDF, ANDP, ANDF, ORP, ORF
LDPI, LDFI, ANDPI, ANDFI, ORPI, ORFI
Association instruction ANB, ORB
INV
MEP, MEF
Comparison operation instruction LD, LD_U, AND, AND_U, OR, OR_U
LDD, LDD_U, ANDD, ANDD_U, ORD, ORD_U
Real number instruction LDE, ANDE, ORE
Character string processing instruction LD$, AND$, OR$
Creating a dummy transition condition TRAN
8 SFC PROGRAM
8.2 Structure 95
Direct expression of transitions
The transition which transfers an active state to the next step can be created directly on the SFC diagram. A contact of FBD/
LD element is connected to it.
bLabel1 bLabel2
Coil, function block, function, jump, jump label, and return elements cannot be used.
Select a transition and select [Edit] [Modify] [Direct Expression for Transition] from the menu. This can
connect the FBD/LD element to the left side of the transition. (GX Works3 Operating Manual)
Transition label/device
Bit type label, bit device or Boolean value can be specified as a condition which transfer an active state to the next step.
■Bit type label ■Bit device ■Boolean value
Select a transition name, select [Edit] [Modify] [Name] in the menu, and input the bit type label, bit device
or Boolean value to be specified. (GX Works3 Operating Manual)
■Precautions
• When a device (T, ST, C or LC) of timer or counter is used for transition, the device operates as a contact (TS, STS, CS or
LCS). Also, when a coil (TC, STC, CC or LCC) of timer or counter is used, the coil operates as a contact.
• To use a coil of timer or counter for transition, use a timer type or counter type label.
Ex.
Timer device and timer type label
When a timer device is used When a timer type label is used
TC0 tLabel0.C
TR0 TR0
When the contact (TS0) is on, the transition becomes TRUE. When the coil of the timer type label (tLabel0) is on, the transition becomes TRUE.
[Direct expression] [Direct expression]
TC1 tLabel1.C
TR1 TR1
When the contact (TS1) is off, the transition becomes TRUE. When the coil of the timer type label (tLabel1) is off, the transition becomes TRUE.
8 SFC PROGRAM
96 8.2 Structure
8.3 SFC Control Instructions
SFC control instructions are used to check a block or step operation status (active/inactive), or to execute a forced start, end
or others. If SFC control instructions are used, SFC programs can be controlled from the actions of sequence programs and
SFC programs.
Instruction List
The following table lists the SFC control instructions.
Instruction name Instruction symbol Processing
Checking the status of a step LD, LDI, AND, ANI, OR, ORI [S]*1 Checks whether a specified step is active or inactive.
LD, LDI, AND, ANI, OR, ORI [BL\S]
Checking the status of a block LD, LDI, AND, ANI, OR, ORI [BL] Checks whether a specified block is active or inactive.
Batch-reading the status of steps MOV(P) [KnS]*1 Batch-reads (in units of 16-bit binary data) the status (active or inactive)
of steps in a specified block, and stores the read data in a specified
MOV(P) [BL\KnS]
device. (Kn: K1 to K4)
DMOV(P) [KnS]*1 Batch-reads (in units of 32-bit binary data) the status (active or inactive)
of steps in a specified block, and stores the read data in a specified
DMOV(P) [BL\KnS]
device. (Kn: K1 to K8)
BMOV(P) [KnS]*1 Batch-reads (in units of the specified number of words starting from a
specified step) the status (active or inactive) of steps in a specified
BMOV(P) [BL\KnS]
block. (Kn: K1 to K4)
Starting a block SET [BL] Activates the specified block individually and executes a step
sequence starting from the initial step.
Ending a block RST [BL] Deactivates the specified block.
Pausing a block PAUSE [BL] Temporarily stops a step sequence in a specified block.
Restarting a block RSTART [BL] Releases the temporary stop and restarts the sequence from the step 8
where the sequence was stopped in the specified block.
Activating a step SET [S]*1 Activates the specified step.
SET [BL\S]
Deactivating a step RST [S]*1 Deactivates the specified step.
RST [BL\S]
Step start/end instruction OUT [S]*1 Activates/deactivates the specified step.
OUT [BL\S]
ZRST(P) [S]*1 Deactivates all specified steps collectively.
ZRST(P)[BL\S]
*1 When using in a sequence program, block 0 is the target block. When using in an SFC program, current block is the target block.
For details on the SFC control instructions, refer to the following.
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
■Precautions
• Do not use the SFC control instructions in interrupt programs.
• Execute the SFC control instruction only when SM321 (Start/stop SFC program) is on.
• When using the SFC control instruction, set "SFC Program Setting" to "Use".
• When using the SFC program, do not specify the step relay to the instructions other than the SFC control instruction. If the
step relay is specified to the instructions other than the SFC control instruction, the program may perform an unintended
operation.
• When "SFC Program Setting" is set to "Not to Use", the instructions which specify the step by using the step relay without
block specification (such as LD [S] and MOV(P) [KnS]) operate as the normal instructions.
• In the case of the CPU module not corresponding to the SFC program, when the current value is read/written to the step
relay with block specification (BL\S) by the engineering tool, the current value is read/written to the step relay (S)
without block specification. (Page 126 Added and Changed Functions)
Example: When the current value is read to BL5\S12
- CPU module corresponding to the SFC program: The current value of BL5\S12 is read.
- CPU module not corresponding to the SFC program: The current value of S12 is read.
8 SFC PROGRAM
8.3 SFC Control Instructions 97
Index modification
The SFC control instructions can specify index-modified step relays (S) and SFC block devices (BL). However, instructions
that control a step individually cannot specify index-modified devices.
Device Index modification target part
SZ Step relay
BL\SZ Step of step relay with block specification
BLZ\S Block of step relay with block specification
BLZ\SZ Block and step of step relay with block specification
BLZ SFC block device
The step relays and SFC block devices can be specified within the following range, including the case of index modification.
Device Range
S 0 to 4095
BL\S BL 0 to 31
S 0 to 511
BL 0 to 31
8 SFC PROGRAM
98 8.3 SFC Control Instructions
8.4 SFC Setting
Set start conditions and others of SFC program in CPU parameter or SFC block setting.
CPU parameter
The following table lists the SFC settings.
Type Item Description
SFC setting SFC program setting Set whether to use the SFC program.
SFC program start mode setting Set whether to start the SFC program in the initial status (Initial Start) or to start it
holding the previous execution status (Resume Start).
Start conditions setting Set whether to automatically start and activate the block 0 or to keep it inactive until a
start request is issued when starting the SFC program.
Output mode setting at block stop Set whether to turn off the coil output or to hold it when stopping a block.
FX3 compatible transition operation Set whether to operate the SFC program maintaining compatibility with FX3.
mode setting
Window
Displayed items
Setting Description
Not to Use (default) SFC program is not used.
Use*1 SFC program is used.
*1 When the SFC program is created, a conversion error occurs in the engineering tool. When the parameter for which "SFC Program
Setting" is set to "Not to use" and the SFC program are written separately during the boot operation using the SD memory card, a self-
diagnosis error of the CPU module occurs.
*2 When the step relay (S) is specified to the instructions other than the SFC control instruction, a self-diagnosis error of the CPU module
occurs.
8 SFC PROGRAM
8.4 SFC Setting 99
SFC Program Start Mode Setting
Set whether to start the SFC program in the initial status (Initial Start) or to start it holding the previous execution status
(Resume Start).
[CPU Parameter] [SFC Setting] [SFC Program Start Mode Setting]
Window
Displayed items
Setting Description
Initial Start (default) The program is started after the active state at the previous stop is cleared.
The operation after the start is performed according to "Start Condition Setting" of the SFC Setting. (Page 101
Start Conditions Setting)
Resume Start*1 The program starts in the active state at the previous stop.
When setting the resume start, install a battery to the CPU module. (Page 101 Precautions)
*1 The initial status of SM322 is determined when the operating status of the CPU module is changed from STOP to RUN according to the
setting of the SFC program start mode.
*2 When "SFC Program Start Mode Setting" is set to "Resume Start" and no changes are made to the program before and after the
program is written, the program is resumed.
*3 When the parameter is set to "Initial Start," the on state of M322 is invalid.
*4 Depending on the timing, a program cannot be resumed and starts with initial status.
*5 M322 is turned on, and the program is initialized.
*6 Resume start after the CPU module is powered off and on or reset is applicable only to FX5U/FX5UC CPU modules.
8 SFC PROGRAM
100 8.4 SFC Setting
■Precautions
• When setting the parameter to "Resume Start," install a battery in the CPU module. If a battery trouble, such as no battery
or battery voltage drop, has occurred, the SFC program may start in the Initial Start mode when it is started first time after
the CPU module power is switched from off to on. Battery troubles can be detected by Option Battery Setting. For details,
refer to the user’s manual for the CPU module used.
• When a program is resumed, the SFC program stop position is held, but the status of the label or device used for an action
is not held. Therefore, if labels or devices are required to be held for Resume Start, set them to the latch mode.
(MELSEC iQ-F FX5 User's Manual (Application))
• When a program is resumed under a condition other than conditions ((1), (3), (5) in the table) under which the coil output of
the coil HOLD step [SC] is turned off, the coil HOLD step [SC] that holds an operation is restarted, but the output is not
turned on. To hold the output, set the labels and devices to the latch mode. (MELSEC iQ-F FX5 User's Manual
(Application))
• When the CPU module is powered off or reset, the intelligent function module is initialized. To resume a program, it is
recommended to create the initial program for the intelligent function module in a block which is constantly active or in a
sequence program.
• When the CPU module is powered off or reset, labels and devices are also cleared.
• Depending on the timing, a program may not be resumed after the CPU module is powered off or reset. If a program is
started in the initial status after the start mode is set to Resume Start, an event where the program cannot be resumed is
stored in the event history. To ensure the program is started in the Resume Start mode, power off or reset the CPU module
after switching SM321 from ON to OFF or switch the operating status from RUN to STOP.
Window
Displayed items
Setting Description
At SFC Program START At the end of block 0
Auto-start block 0 Block 0 is started automatically and starts execution from Block 0 is restarted automatically and restarts execution
(default) its initial step. from its initial step.
Do not auto-start block 0 Block 0 is activated by a start request issued by the SFC Block 0 is not restarted automatically and remains
control instruction (Starting a block) or a block start step inactive until another start request is issued.
in the same manner as other blocks.
Use the Start Conditions Setting to control the start block according to the product type.
"Auto-start block 0" is useful when block 0 is used as described below.
• Management block
• Preprocessing block
• Continuous monitoring block
■Precautions
• To execute the SFC program when "Do not auto-start block 0" is set, execute the SET instruction (Starting a block) from the
sequence program.
• When "Auto-start block 0," is set, create block 0 without fail.
8 SFC PROGRAM
8.4 SFC Setting 101
Output mode setting at block stop
Set whether to turn off the coil output or to hold it when stopping a block.
[CPU parameter] [SFC Setting] [Output Mode Setting at Block Stop]
Window
Displayed items
Setting Description
Turn OFF Coil output is turned off.
(default)
Keep ON Coil output is held in the state immediately before stop.
• The settings made are reflected to the initial value of SM325 (Output mode at block stop) at power-on, reset, or switching
from STOP to RUN, and follow the settings of SM325 when the SFC program operates. CPU parameter settings are
ignored.
*1 SC, SE, and ST whose transition does not become TRUE are included.
■Precautions
• When the block specified with the LD instruction (Checking the status of a block) has stopped, the coil output is turned on.
Also, when the step specified with the LD instruction (Checking the status of a step) has stopped, the coil output is turned
on.
• When a block start instruction is executed for an inactive block in its stop state, the block becomes active maintaining its
stop state, but the initial step remains inactive. The initial step becomes active and the action is executed when the block is
restarted.
• When SM325 (holding the coil output at block stop) is on, the block can be stopped while holding the coil output. Even
when SM325 is turned on and off in stopped state, the state of the coil output does not change. When a block restart
request is issued, the coil output restarts while keeping the hold state.
• If the block is stopped when SM325 is on, the coil HOLD step [SC] in the hold state keeps its state even after restart but the
step operation does not restart. To make the coil HOLD step [SC] inactive, execute the RST instruction (Deactivating a
step).
8 SFC PROGRAM
102 8.4 SFC Setting
• When a stop request is issued in the action to the block, the current step will be executed until it finishes, then the stop
request is executed. Therefore, the step being executed does not stop even if a stop request is issued within the step.
• If the RST instruction is executed while the block is stopped, the specified step relay is turned off. However, the monitor of
the engineering tool keeps showing the active status and changes to inactive when the block is restarted. The same applies
to when the instruction is executed while the block is stopped by turning on SM325, but the coil output will not be turned off.
• The SET instruction (Activating a step) is executed immediately even while the block is stopped and the specified step relay
is turned on. The display on the monitor of the engineering tool also shows the active status. However, the action is
executed only after the block is restarted.
Ex.
Block PAUSE/RESTART when the RST instruction is used
(1) When M0 is turned on, block 0 is stopped.
M0 (2) When M1 is turned on, a termination request is executed for step No. 0 and BL0\S0 of the step relay is turned
PAUSE BL0 off but step No. 0 is left active on the monitor of the engineering tool.
(3) BL0\S0 is turned off, so Y0 is also turned off.
M1 (4) When M2 is turned on while M0 and M1 are off, block 0 restarts and step No. 0 ends.
RST BL0¥S0
BL0¥S0 Y0
M2
RSTART BL0
Window
Displayed items
Setting Description
Disable (default) Operation of FX5. "Continuous transition" or "No continuous transition" can be specified.
Enable Operation of FX3. The program operates with continuous transition (operation compatible with FX3).
For the continuous transition, refer to Page 111 Continuous transition ON/OFF operation.
For the replacement of the SFC program from FX3 to FX5, refer to the following.
Transition from MELSEC FX3G, FX3U, FX3UC Series to MELSEC iQ-F Series Handbook
8 SFC PROGRAM
8.4 SFC Setting 103
SFC block setting
Window
(1) Set the range of the block to be stopped.
(1)
Displayed items
Setting Description
No setting (default) Standby CPU module operation continues, and standby until the start destination block becomes inactive while
the transition becomes TRUE.
When the start destination block is deactivated, the block is reactivated.
Block stop range is set Stop An error results.
BL1
BL1
BS
■Precautions
• When the SFC control instruction (Starting a block) is executed for an already active block, the start request is ignored, and
the processing of the SFC program is continued.
• If an attempt to transition to an active block start step is made, the activation of the block start step is ignored. The block is
not executed again from the initial step.
8 SFC PROGRAM
104 8.4 SFC Setting
8.5 SFC Program Execution Order
Whole program processing
CPU module
RUN Type that can be specified as
an SFC program
Initial execution
type program
Event execution
Execute using an type program
interrupt. 8
Fixed scan
execution type
program
■Precautions
In a project with an SFC program, the step ladder (STL/RETSTL instruction) cannot be used.
8 SFC PROGRAM
8.5 SFC Program Execution Order 105
SFC program processing sequence
BS BL1 BS BL2
(2)
Block 0 can be started automatically when "Auto-start block 0" is specified in "Start Conditions Setting" of the SFC setting.
With this setting, even if block 0 reaches the end step and becomes inactive, it will be restarted in the next scan. (Page
101 Start Conditions Setting)
8 SFC PROGRAM
106 8.5 SFC Program Execution Order
Step execution sequence
In the SFC program, the actions of all active steps are processed within one scan.
(1) All the active steps in the block are executed
within a single scan.
(1)
When the action of each step is finished, whether the transition to the next step becomes TRUE or not is checked.
• When the transition has not become TRUE: The action of the same step is executed again in the next scan.
• When the transition has become TRUE: The outputs of the executed actions by using the OUT instruction are all turned off.
When the next scan is executed, the action of the next step is executed. The step executed previously is deactivated and
the action becomes inactive.
Even when the transition becomes TRUE, if coil HOLD step [SC] is set in the step attribute, the step is not deactivated but
performs processing according to the attribute. (Page 80 Coil HOLD step [SC])
Ex.
Example of transition operation (without continuous transition)
(1) Execution of sequence program
STOPRUN (SM321=ON) (2) Execution of action
(3) Checking the transition to the next step (FALSE)
8
(1) (2) (3) (4) (1) (2) (5) (4) (1) (6) (4) END processing
(5) Checking the transition to the next step (TRUE)
1 scan 1 scan 1 scan (6) The next action is executed.
■Execution of action
The action performs the following operation for the instruction input condition described in the action depending on the status
of the step to be executed.
Execution of action Description
Not executed The input condition is not reflected in the output.
Execution in the contact ON status The operation is performed according to the input condition.
Execution in the contact OFF status The input condition is set to off regardless of the actual input condition, and the operation is performed.
When the step is activated, the action is executed in the contact ON status every scan. When the step is deactivated, the
action is executed in the contact OFF status and will not be executed until next time the step is activated. The action is
executed in the contact OFF status in the following cases. Execution in the contact OFF status is enabled only in active steps.
• When the transition just after a normal step becomes TRUE.
• When the end step is executed (other than steps that hold operations when SM327 is on and remaining active steps that do
not hold operations when SM328 is on)
• When the block is forcibly terminated by using the SFC control instruction (Ending a block).
• When the step is forcibly terminated by the SFC control instruction (Ending a step).
• When SM321 (Start/stop SFC program) is turned off
• When the reset step [R] that has been set to reset the running step is activated
• When the reset step [R] that has been set to reset the steps that hold operations is activated and S999 has been specified
for the reset step [R]
• When the block is stopped by the block stop instruction while the output mode at block stop is off
8 SFC PROGRAM
8.5 SFC Program Execution Order 107
■Transition operation
The transition operation with/without continuous transition in the following SFC program is shown below. (Page 111
Continuous transition ON/OFF operation)
Steps (1) to (4) are activated, and the actions (A) to (D) are executed.
Although the transition (a) to (c) for Steps (1) to (3) become TRUE, the
(1) (A)
transition (d) for Step (4) becomes FALSE.
(a)
(2) (B)
(b)
(3) (C)
(c)
(4) (D)
(d)
Scan 1
(1) (A)
(1) Active
(A) Execution in the
contact ON status
(A) Execution in the
(a) contact OFF status
(a) TRUE
End processing
Scan 2
(2) (B)
(2) Active
(B) Execution in the
contact ON status
(B) Execution in the
(b) contact OFF status
(b) TRUE
End processing
Scan 3
(3) (C)
(3) Active
(C) Execution in the
contact ON status
(C) Execution in the
(c) contact OFF status
(c) TRUE
End processing
Scan 4 Scan 5
(4) (D)
(4) Active (4) Active
(D) Execution in the (D) Execution in the
contact ON status contact ON status
(d) (d) FALSE (d) FALSE
End processing End processing
Scan Description
Scan 1 Step (1) is activated and the action (A) is executed in the contact OFF status after the execution in the contact ON status.*1
Scan 2 Step (2) is activated and the action (B) is executed in the contact OFF status after the execution in the contact ON status.*1
Scan 3 Step (3) is activated and the action (C) is executed in the contact OFF status after the execution in the contact ON status.*1
Scan 4 Step (4) is activated and the action (D) is executed in the contact ON status.
Scan 5 and after Step (4) is active until the transition (d) becomes TRUE, and the action (D) is executed in the contact ON status.
*1 In the case of coil HOLD step the action is not executed in the contact OFF status.
8 SFC PROGRAM
108 8.5 SFC Program Execution Order
• With continuous transition
Scan 1
(1) (A)
(1) Active
(A) Execution in the
contact ON status
(a) (A) Execution in the
contact OFF status
(a) TRUE
(2) (B)
(2) Active
(B) Execution in the
contact ON status
(b) (B) Execution in the
contact OFF status
(b) TRUE
(3) (C)
(3) Active
(C) Execution in the
contact ON status
(c) (C) Execution in the
contact OFF status
(c) TRUE
Scan 2
(4) (D)
(4) Active (4) Active
(D) Execution in the (D) Execution in the
contact ON status contact ON status
(d)
(d) FALSE (d) FALSE
End processing End processing
Scan Description
8
Scan 1 Steps (1) to (4) are continuously activated.
When each step is activated, the actions (A) to (C) are executed in the contact OFF status after the execution in the contact ON
status, and the action (D) is executed in the contact ON status. However, in the case of coil HOLD step the action is not executed in
the contact OFF status.
Scan 2 and after Step (4) is active until the transition (d) becomes TRUE, and the action (D) is executed in the contact ON status.
Scan 1 Scan 2
(1) (A)
(1) Active
(A) Execution in the
(A) Execution in the
contact OFF
(a) contact ON status
status
(a) TRUE
(2) (B)
(2) Active
(B) Execution in the
(B) Execution in the
contact OFF
(b) contact ON status
status
(b) TRUE
(3) (C)
(3) Active
(C) Execution in the
(C) Execution in the
contact OFF
(c) contact ON status
status
(c) TRUE Scan 3
(4) (D) (4) Active (4) Active (4) Active
(D) Execution in the (D) Execution in the (D) Execution in the
contact ON status contact ON status contact ON status
(d)
(d) FALSE (d) FALSE (d) FALSE
End processing End processing End processing
Scan Description
Scan 1 Steps (1) to (4) are continuously activated.
When each step is activated, the actions (A) to (D) are executed in the contact ON status.
Scan 2 The actions (A) to (C) are executed in the contact OFF status, and the action (D) is executed in the contact ON status. However, in
the case of coil HOLD step the action is not executed in the contact OFF status.
Scan 3 and after Step (4) is active until the transition (d) becomes TRUE, and the action (D) is executed in the contact ON status.
8 SFC PROGRAM
8.5 SFC Program Execution Order 109
■Precautions
• If the transition for a step becomes TRUE at the first execution, the step starts/ends after one scan. When the step ends
after one scan, the following operation is performed according to the transition condition.
No continuous transition Continuous transition With continuous transition (operation
compatible with FX3)
I/O refresh of coil output, etc. is not reflected. To I/O refresh of coil output, etc. is not reflected, and The step is started and ended in different scans,
reflect the I/O refresh, design the program so that turning on of coil output cannot be detected in any and coil output in an action can be detected by
one step is scanned several times. However, other program. To reflect the I/O refresh, design another program. However, the step relay is turned
turning on of the step relay can be detected before the program so that one step is scanned several off in a scan in which the transition becomes TRUE.
the previous scan (just after the transition from the times.
previous step) even in another program.
• The actions of active steps in a block are executed simultaneously (within the same scan). For this reason, do not create
SFC programs which depend on the execution sequence of actions.
The execution sequence of actions (1), (2), and (3) are
undefined.
(2)
(1) (3)
• In the case of "Continuous transition," when a transition from one step to multiple steps occurs due to jump sequence or
selective convergence, the action of one step may be performed twice in one scan.
• In the case of "Continuous transition," if a program that loops using the jump sequence is executed, an error will occur.
• In the case of "Continuous transition" (operation compatible with FX3) where the transition destination step of jump
sequence is positioned above the transition source in the SFC chart, the destination step will be executed in the next scan
even if the transition becomes TRUE.
8 SFC PROGRAM
110 8.5 SFC Program Execution Order
Continuous transition ON/OFF operation
The transition conditions for the SFC program include "With continuous transition," "With continuous transition (operation
compatible with FX3)" and "Without continuous transition."
The setting "With continuous transition" or "Without continuous transition" is determined by "FX3 Compatible Transition
Operation Mode Setting" and SM323 (presence/absence of continuous transition for entire block).
FX3 compatible transition SM323 Description
operation mode setting
Disable OFF No continuous When the transition becomes TRUE, the action of the transition destination step is
transition executed in the next scan.
ON Continuous When the transition becomes TRUE, the action of the transition destination step is
transition executed within the same scan.
When the transitions of the steps become TRUE continuously, the actions are executed
within the same scan until the transition becomes FALSE or the end step is reached. The
action of the transition source step is executed in the contact OFF status in a scan in
which the transition becomes TRUE.
Enable ON/OFF With continuous When the transition becomes TRUE, the action of the transition destination step is
transition (operation executed within the same scan.
compatible with When the transitions of the steps become TRUE continuously, the actions are executed
FX3) within the same scan until the transition becomes FALSE or the end step is reached.
Unlike normal continuous transitions, the action of the destination step is executed in the
contact OFF status in the next scan where the transition becomes TRUE.
• The tact time can be reduced by setting the condition to "Continuous transition" or "Continuous transition
(operation compatible with FX3)." Accordingly, the wait time from when the transition becomes TRUE until
the action of the destination step is executed can be eliminated. However, the setting to "Continuous
transition" or "Continuous transition (operation compatible with FX3)" may slow down the operation of other 8
blocks and sequence programs.
• SM324 (Continuous transition disable flag) is turned off only when "Continuous transition" is set. (Because
the system is basically turned on automatically when the SFC program is executed, SM324 is always ON.
Also, when "Continuous transition" (FX3 compatible operation) is set, SM324 is always ON.) Therefore,
continuous transition can be prohibited by using SM324 as a transition condition.
• When "FX3 Compatible Transition Operation Mode Setting" is valid, "Continuous transition (operation
compatible with FX3)" is enabled regardless of whether SM323 is on or off.
8 SFC PROGRAM
8.5 SFC Program Execution Order 111
8.6 SFC Program Execution
Starting and stopping the SFC program
The SFC program can be started and stopped by either of the following methods.
• Auto-start by the CPU parameter
• Starting and stopping the program by the special relay (SM321)
Set the CPU parameter "SFC Program Start Mode Setting" to "Resume Start," and the SFC program can be
resumed. (Page 100 SFC Program Start Mode Setting)
Starting a block
A block in the SFC program can be started by either of the following methods.
Item Method Remarks Reference
Auto-start by the CPU Set "Auto-start block 0" to "Start Conditions This method is used to use block 0 as a Page 101 Start
parameter (only for block 0) Setting" in the CPU parameter. When the SFC control block, preprocessing block, or Conditions Setting
program is executed, block 0 starts continuous monitoring block.
automatically and processing is performed
sequentially from the initial step.
Start by the block start step Start another block by using a block start step This method is effective when the control Page 82 Block start step
[BC or BS] in a block. sequence is clear. (with END check) [BC]
Page 83 Block start step
(without END check) [BS]
Start by the SFC control Start the block specified by the SFC control This method is effective to restart the error Page 97 SFC Control
instruction instruction from the action of the SFC program processing block or execute interrupt Instructions
or another sequence program. processing.
• Use the SET [BL] (Starting a block)
instruction to execute the program from the
initial step of the specified block.
• Use the SET [S/BL\S]/OUT [S/
BL\S] (Activating a step) instruction to
execute the program from the specified step
of the specified block.
Start by the engineering tool Start the specified block by turning on the SFC This method is effective for debugging and GX Works3 Operating
block device. test operation. Manual
8 SFC PROGRAM
112 8.6 SFC Program Execution
Ending a block
A block in the SFC program can be ended by either of the following methods.
Item Method Remarks Reference
End by the end step Execute the end step in a block. Processing is This method is effective to stop operation Page 84 End step
stopped and the block becomes inactive. by stopping a cycle in automatic operation.
End by the SFC control End and deactivate the block specified by the This method is effective to end processing Page 97 SFC Control
instruction RST [BL] (Ending a block) instruction from the regardless of the operation status, such as Instructions
action of the SFC program or another sequence an emergency stop.
program. (The block ends when all the active
steps in the specified block are deactivated by
using the RST [BL\S]/OUT [BL\S]/
ZRST(P)[S/BL\S] (Ending a block)
instruction.)
End by the engineering tool End the specified block by turning off the SFC This method is effective for debugging and GX Works3 Operating
block device. test operation. Manual
Activating a step
A step in the SFC program can be activated by either of the following methods.
Item Method Remarks Reference
Activation by the transition The transition is checked at the end of the step. Page 89 Transition
condition If it is TRUE, the next step is automatically
activated.
Activation by the SFC Activate the step specified by the SET [S/ Page 97 SFC Control
control instruction BL\S]/OUT[S/BL\S] (Activating a step)
instruction from the action of the SFC program
Instructions 8
or another sequence program.
Activation by the • Activate the specified step by turning on the This method is effective for debugging and GX Works3 Operating
engineering tool step relay. test operation. Manual
• Activate the selected step from the menu
[Debug][Control SFC Steps].
Deactivating a step
A step in the SFC program can be deactivated by either of the following methods.
Item Method Remarks Reference
Deactivation by the The transition is checked at the end of the step. Page 89 Transition
transition condition If it is TRUE, the current step is automatically
deactivated.
Deactivation by the reset Activating this step deactivates the step This method is effective to deactivate the Page 82 Reset step [R]
step [R] specified for attribute target. coil HOLD step [SC] when the sequence
for error processing is selected in the
selection branch.
Deactivation by the SFC End the step specified by the RST [S/ When all the active steps in the specified Page 97 SFC Control
control instruction BL\S]/OUT[S/BL\S]/ZRST(P)[S/ block are deactivated by the SFC control Instructions
BL\S] (Deactivating a step) instruction from (Deactivating a step) instruction, the block
the action of the SFC program or another also ends.
sequence program.
Deactivation by the • End the specified step by turning off the step This method is effective for debugging and GX Works3 Operating
engineering tool relay. test operation. Manual
• Deactivate the selected step from the menu
[Debug][Control SFC Steps].
8 SFC PROGRAM
8.6 SFC Program Execution 113
Behavior when an active step is activated
When an active step is activated, the step behaves as follows.
Series sequence
When the transition (2) becomes TRUE, the step (1) becomes
inactive.
(1) The step (3) of the transition which is supposed to be multi-
activated is activated.
(2)
(3)
Selective sequence
■Divergence
The transition condition is checked starting from the left side, and, if the destination of the branch where the transition
becomes TRUE is an active step, the same operation as the series sequence is performed. In the same manner as in the
normal selective sequence, the transition condition is not checked in the lines other than the branch where the double start
becomes TRUE.
■Convergence
The same operation as the series sequence is performed.
When the transition (2) becomes TRUE, the step (1) becomes
inactive.
(1) The step (3) of the transition which is supposed to be multi-
activated is activated.
(2)
(3)
Simultaneous sequence
■Divergence
All steps below the transition become active in the next scan.
When the transition (1) becomes
TRUE, the steps (2) to (5) which are
supposed to be multi-activated at
the next scan are all activated.
(1)
■Convergence
The transition source becomes inactive. The coil HOLD step [SC] holds operation.
8 SFC PROGRAM
114 8.6 SFC Program Execution
Operation when a program is modified
To change an SFC program, use the following function.
• Write to the programmable controller
• Online change
• Online change (SFC block)*1
The following table shows the SFC program data that can be changed by the above method.
Change type Write to the programmable Online Online change
controller change (SFC block)*1
STOP/PAUSE RUN
SFC program addition
SFC block addition/deletion
SFC block SFC diagram Step/transition condition addition/
change change deletion
Transition condition (branch/
convergence/jump) change
Step attribute change
Change in SFC Operation output program change
diagram
Transition program change
Block information change
■Precautions
• After an SFC program is modified by writing data to the programmable controller, reset the CPU module, and execute the
SFC program.
• If the CPU parameter "SFC Program Start Mode Setting" has been set to "Resume Start," once turn off (Initial Start) SM322
(SFC program startup status), and modify the program by writing data to the programmable controller. Thereafter, start the
SFC program in the Initial Start mode, and then turn on (Resume Start) SM322 again.
8 SFC PROGRAM
8.6 SFC Program Execution 115
When online change is executed
After an SFC program is modified by online change, the resume start is performed regardless of the CPU parameter setting
("SFC Program Start Mode Setting").
■Precautions
After data are written to the programmable controller in the STOP state, an SFC program cannot be changed online until the
operating status of the CPU module is changed to RUN. Run the CPU module before changing an SFC program online.
Transition 0 Transition 0
(1)
Step 0 N Action 1 Step 0 N Action 1
Transition 1 Transition 1
Added
Step 1 N Action 2
Block 0 Block 0
Transition 2
Transition 0 Transition 0
Transition 1 Transition 1
(1) SFC programs (except active steps) that are in active blocks can be changed.
Before using the online change (SFC block), check the versions of the CPU module and the engineering tool
used.
For the versions of the CPU module and the engineering tool, refer to the following.
Page 126 Added and Changed Functions
■Online change (SFC block) while SM321 (Start/stop SFC program) is off
Online change (SFC block) while SM321 is off always starts in initial start mode, regardless of the following settings.
• SFC Program Start Mode Setting (Resume Start) in the CPU parameter (Page 100 SFC Program Start Mode Setting)
• SM322 (SFC program startup status)
8 SFC PROGRAM
116 8.6 SFC Program Execution
■Changing/adding/deleting a block
The following table describes available operations (changing, adding, or deleting a block) in the online change (SFC block).
Operation Description
When the target block is inactive When the target block is active
Changing a block An existing SFC block program in the CPU module can be An existing SFC block program in the CPU module can be
changed. changed. However, deleting, attribute change, and changing
step number of the active step cannot be performed.
Adding a block An SFC block can be added to an SFC program in the CPU
module.
Deleting a block • A specified SFC block can be deleted from an SFC An active SFC block cannot be deleted.
program in the CPU module.
• When a target block is not in an SFC program in the CPU
module, deleting a block cannot be performed.
In the STOP or PAUSE status, an active step holds its active state. Therefore, when deleting, changing
attribute, or changing step numbers of the active step, inactivate the step that maintains the active state
before the online change (SFC block).
■Area to be overwritten
The ladder in the added/changed steps or transitions and added/changed action or transitions in a target block are
overwritten. The last execution information of the rising instruction and falling instruction for the ladder in added/changed
action and transition is initialized.
■Operation when a target block or step is attempted to be activated during the online change
(SFC block)
A block and step targeted for the online change (SFC block) are not activated even if they are attempted to be activated while
the online change (SFC block) is being executed. The following table describes operations depending on block or step start
methods.
Start method (activation method) Operation at block or step start
Auto-start by the CPU parameter The block or step is not activated until the online change (SFC block) is completed. The
block or step is automatically activated after the online change (SFC block) is completed.
Block start step (without END check) • A target block is not activated but waits until the online change (SFC block) is
completed. Even when a transition following a step is TRUE, the next step does not
become active.
• A target block is activated after the online change (SFC block) is completed. When a
transition is TRUE, the next step becomes active.
Block start step (with END check) • A target block is not activated but waits until the online change (SFC block) is
completed.
• A target block is activated after the online change (SFC block) is completed. When the
block ends and a transition following a step is TRUE, the next step becomes active.
SFC control instructions (SET BL, SET S, SET BL\S A target block is not activated. If an instruction contact remains on, the target block is
instructions) activated after the online change (SFC block) is completed.
Block start by the engineering tool*1 A target block is not activated. A request is ignored. (The system does not activate the
target block until the online change (SFC block) is completed.)
Step start by the transition condition (activate) • Due to the previous transition becoming TRUE, a target step is not activated until the
online change (SFC block) is completed. (The state is not activated but waits.)
• After the online change (SFC block) is completed, when a transition is TRUE, the state
is activated.
*1 This indicates the following activation methods: Changing values of BL and BL\S on the watch window or the device/buffer
memory batch monitoring window and selecting an item in Control SFC steps under Debug.
8 SFC PROGRAM
8.6 SFC Program Execution 117
■Precautions
• Do not power off or reset the CPU module while the online change (SFC block) (including transfer of data to the program
memory) is being executed. If doing so, write the data to the programmable controller again.
• The online change (SFC block) and the following operations from the engineering tool cannot be executed simultaneously.
• Online change (ladder block), online change (SFC block)
• Write to the programmable controller (excluding device, local device, global label, or local label data)
• Memory initialization
• When deleting the OUT instruction (coil) which is not necessary for control, be sure to check that the OUT instruction is off
before deleting it. If the OUT instruction is deleted without turning it off in advance, the output will be retained.
• When the target circuit includes calling of the function block, the initialization availability of the signal flow in the function
block definition depends on the function block type.
Function block type Initialization availability
Global FB Subroutine type
Macro type *1
Local FB Subroutine type
Macro type *1
*1 If a subroutine-type FB is called within the changed ladder block, information of the last execution, such as instructions executed at the
rising edge or falling edge within the FB definition of the called subroutine-type FB, is not initialized.
• Some sections are not targeted for the scan monitoring while the online change (SFC block) is being executed, and
therefore a WDT error may not be detected even though the scan time set in the scan time monitoring time (WDT) setting is
exceeded.
• When an instruction is executed during the online change (SFC block) and an error is detected, a step number stored as
the error location information is the one in a program being written. The step number after the completion of writing is not
stored.
• The online change (SFC block) cannot be executed in the following cases.
• A target program file is not registered in the corresponding parameter.
• The number of SFC steps exceeds the number of step relay points set in the device setting of the CPU parameter.
• Operating status of the CPU module is switched to STOP and data are written to a specified program or a parameter in the programmable controller. (The
function cannot be executed until the operating status of the CPU module is back to RUN.)
• Program execution error (error code: 3204H) has been detected.
8 SFC PROGRAM
118 8.6 SFC Program Execution
• When performing online change (SFC block) including step movement across the active step, perform the following
procedure.
Cut the step to be moved.
Execute the online change (SFC block).
Paste the cut step to the desired position.
Execute the online change (SFC block) again.
When the step is skipped and the procedure is performed in order of , the online change (SFC block) may not
be executed.
Ó Õ
8 SFC PROGRAM
8.6 SFC Program Execution 119
Checking SFC program operation
The functions of the engineering tool that can be used to check the SFC program operation are shown below.
• Monitor
• Watch
• Device/buffer memory batch monitor
• Control SFC steps
• SFC block list
• SFC all blocks batch monitor
• Active step monitor
• For details on each functions and operation check methods, refer to the following.
GX Works3 Operating Manual
• When using the SFC program, the data cannot be written to the step relay (S) by the engineering tool. The
data can be read from the step relay (S).
8 SFC PROGRAM
120 8.6 SFC Program Execution
APPENDICES
Appendix 1 Operations of when the MC/MCR
instructions are used to control EN
The following table lists operations of instructions, devices, and labels used in a function block when "Use MC/MCR to Control
EN" is enabled in the inherent property setting of the function block.
Instruction/device/label used in a function Operation of Instruction/device/label used in a function block
block When "Yes" is selected for "Use MC/ When "No" is selected for "Use MC/MCR
MCR to Control EN" to Control EN"
Instructions executed at the rising edge or falling The next time EN is turned on, the instruction is The next time EN is turned on, the instruction may
edge (PLS instruction, instructions for conversion to executed if the condition contact is TRUE. not be executed even though the condition contact is
pulses (P))*1 TRUE.
Timer (low-speed timer/timer/high-speed timer) The count value becomes 0 and the both coil The state of devices remains unchanged.
and contact turn off.
Retentive timer (low-speed timer/timer/high-speed The coil turns off, but the current count value The state of devices remains unchanged.
timer), counter, long counter and the current state of the contact remain
unchanged.
Devices specified as the device part of the OUT The devices are forcibly turned off. The state of devices remains unchanged.
instruction
When "Yes" is selected for "Use MC/MCR to Control EN", do not use the MC/MCR instructions while the
function block is being executed. If the MC/MCR instructions are used, the EN control may not operate
properly.
APPX
Appendix 1 Operations of when the MC/MCR instructions are used to control EN 121
Instructions executed at the rising/falling edge
The following describes operations of instructions executed at the rising/falling edge.
Ex.
A subroutine-type FB using an instruction executed at the rising edge
EN IN ENO
MOVP
IN OUT
END
Sc
Õ
EN
IN
Ó (1)
Ö
MOVP Ô
Sc: Scan
EN is turned on. (User operation)
IN is turned on. (User operation)
The MOVP instruction is executed. (CPU module operation)
EN is turned off. (User operation)
The MOVP instruction is executed. (CPU module operation)
Sc
Õ
EN
IN
Ó (1)
Ö
MOVP Ô
Sc: Scan
EN is turned on. (User operation)
IN is turned on. (User operation)
The MOVP instruction is executed. (CPU module operation)
EN is turned off. (User operation)
The MOVP instruction is executed when the condition contact is FALSE immediately before EN is turned off at . (CPU module operation) (The MOVP
instruction is not executed when the condition contact is TRUE immediately before EN is turned off at .)
APPX
122 Appendix 1 Operations of when the MC/MCR instructions are used to control EN
Timer (low-speed timer/timer/high-speed timer)
The following describes operations of the timer (low-speed timer/timer/high-speed timer).
Ex.
A subroutine-type FB using a low-speed timer
EN SM400 ENO
OUT T0 K3
END
Sc
Ò
EN
(1) Ó
T0 (Count) 0 1 2 3 0 1 2
Ó
T0 (Coil)
(2)
Sc: Scan
T0 (Count): T0 (count value)
T0 (Coil): T0 (coil)
EN is turned off. (User operation)
The coil turns off and the timer value and the count value are cleared. (CPU module operation)
Sc
Ò
EN
(1) Ó
T0 (Count) 0 1 2 3 3 3 3
T0 (Coil)
Ó
(1)
Sc: Scan
T0 (Count): T0 (count value)
T0 (Coil): T0 (coil)
EN is turned off. (User operation)
The values remain unchanged. (CPU module operation)
APPX
Appendix 1 Operations of when the MC/MCR instructions are used to control EN 123
Retentive timer (low-speed timer/timer/high-speed timer), counter, and long counter
The following describes operations of the retentive timer (low-speed timer/timer/high-speed timer), counter, and long counter.
Ex.
A subroutine-type FB using a low-speed retentive timer
EN SM400 ENO
OUT ST0 K3
END
Sc
Ò
EN
(1) Ó
ST0 (Count) 0 1 2 3 3 3 3
Ó
ST0 (Coil)
(2)
Sc: Scan
ST0 (Count): T0 (count value)
ST0 (Coil): T0 (coil)
EN is turned off. (User operation)
The coil turns off, but the current count value and the current state of the contact remain unchanged. (CPU module operation)
Sc
Ò
EN
(1) Ó
ST0 (Count) 0 1 2 3 3 3 3
ST0 (Coil)
Ó
(1)
Sc: Scan
ST0 (Count): T0 (count value)
ST0 (Coil): T0 (coil)
EN is turned off. (User operation)
The values remain unchanged. (CPU module operation)
APPX
124 Appendix 1 Operations of when the MC/MCR instructions are used to control EN
Devices specified as the device part of the OUT instruction
The following describes operations of devices specified as the device part of the OUT instruction.
Ex.
A subroutine-type FB using M0 for the device part of the OUT instruction.
EN SM400 M0 ENO
END
Sc
Ò
EN
M0
Ó
(1)
Sc: Scan
EN is turned off. (User operation)
The coil turns off. (CPU module operation)
Sc
Ò
EN
A
M0
(1) Ó
Sc: Scan
EN is turned off. (User operation)
The state of coil remains unchanged. (CPU module operation)
APPX
Appendix 1 Operations of when the MC/MCR instructions are used to control EN 125
Appendix 2 Added and Changed Functions
The functions added or changed with the CPU module and engineering tool, and the supported CPU modules' firmware
version and engineering tool software version are given below. The firmware version can be checked through the module
diagnostics (CPU diagnostics). For the module diagnostics (CPU diagnostics), refer to the following manuals.
MELSEC iQ-F FX5S/FX5UJ/FX5U/FX5UC User's Manual (Hardware)
For software version, refer to the GX Works3 Operating Manual.
APPX
126 Appendix 2 Added and Changed Functions
MEMO
APPX
Appendix 2 Added and Changed Functions 127
INDEX
Symbols F
- .. ................................. 49 FB file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
*.. ................................. 49 FBD unit . . . . . . . . . . . . . . . . . . . . . . . . . . . 61,62
**. . ................................. 49 FBD/LD language . . . . . . . . . . . . . . . . . . . . . . 6,61
/ .. ................................. 49 FLOAT [Single Precision] . . . . . . . . . . . . . . . . . .32
&. . ................................. 49 FOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
+. . ................................. 49 FOR...DO . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
<. . ................................. 49 FUN file . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12,14
<= . ................................. 49 Function (FUN). . . . . . . . . . . . . . . . . . . . . . . . 9,12
<> . ................................. 49 Function block (FB) . . . . . . . . . . . . . . . . . . . . . 9,17
=. . ................................. 49 Function block call statement . . . . . . . . . . . . . . . .51
>. . ................................. 49 Function call statement . . . . . . . . . . . . . . . . . . . .52
>= . ................................. 49 FX3 compatible transition operation mode setting
$. . ................................. 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
A G
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Generic data type (ANY) . . . . . . . . . . . . . . . . . . .34
Arrays of structures . . . . . . . . . . . . . . . . . . . . . . 38 Global label . . . . . . . . . . . . . . . . . . . . . . . . . 32,34
Assignment statement . . . . . . . . . . . . . . . . . . . . 50 Global labels . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
B I
BC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 IF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 IF ...ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Block start step (with END check) . . . . . . . . . . . . 78 IF ...ELSIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Block start step (without END check) . . . . . . . . . . 78 Initial step . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
BOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Input variable . . . . . . . . . . . . . . . . . . . . . . . . 13,19
BS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Input/output variable . . . . . . . . . . . . . . . . . . . . . .19
Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
C
Internal variable . . . . . . . . . . . . . . . . . . . . . . . . .19
CASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Interrupt program . . . . . . . . . . . . . . . . . . . . . . . . 10
Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32,34
Coil HOLD step. . . . . . . . . . . . . . . . . . . . . . . . . 78 J
Common unit . . . . . . . . . . . . . . . . . . . . . . . . 61,65
Connecting point . . . . . . . . . . . . . . . . . . . . . . 61,66 Jump sequence . . . . . . . . . . . . . . . . . . . . . . . . .90
Connecting wire . . . . . . . . . . . . . . . . . . . . . . 61,66
Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
L
Constant unit . . . . . . . . . . . . . . . . . . . . . . . . . . 62
COUNTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Label/device. . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Ladder diagram . . . . . . . . . . . . . . . . . . . . . . . 5,42
LCOUNTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
LD unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61,64
D
Local label . . . . . . . . . . . . . . . . . . . . . . . .31,32,34
Data type . . . . . . . . . . . . . . . . . . . . . . . . 32,33,34 Long Counter . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Device assignment . . . . . . . . . . . . . . . . . . . . . . 31
DINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
M
Double Word [Signed] . . . . . . . . . . . . . . . . . . . . 32
Double Word [Unsigned]/Bit String [32-bit] . . . . . . 32 Macro type function block . . . . . . . . . . . . . . . 18,25
DWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Main routine program . . . . . . . . . . . . . . . . . . . . . 10
MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Module labels . . . . . . . . . . . . . . . . . . . . . . . . . . .31
E
EN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13,24
N
End step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
ENO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13,24 Normal step . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
EXIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
External variable . . . . . . . . . . . . . . . . . . . . . . . . 19 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
Number of array elements . . . . . . . . . . . . . . . . . . 36
Number of steps . . . . . . . . . . . . . . . . . . . . . . . . .16
128
O W
Online change (SFC block) . . . . . . . . . . . . . . . 116 WHILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Operation HOLD step (with transition check) . . . . 78 WORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
Operation HOLD step (without transition check) . . 78 Word [Signed] . . . . . . . . . . . . . . . . . . . . . . . . . .32
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Word [Unsigned]/Bit String [16-bit] . . . . . . . . . . . .32
Output variable . . . . . . . . . . . . . . . . . . . . . . . 13,19 Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . 61,67
WSTRING . . . . . . . . . . . . . . . . . . . . . . . .33,58,67
P
X
POINTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Program . . . . . . . . . . . . . . . . . . . . . . . . . . 7,14,24
Program Block . . . . . . . . . . . . . . . . . . . . . . . . . 10
Program file . . . . . . . . . ................... 7
Programming languages ................... 5
Project . . . . . . . . . . . . . ................... 7
R
R. . . . . . . . . . . . . . ..................... 78
REAL . . . . . . . . . . . ..................... 32
REPEAT . . . . . . . . ..................... 53
Reserved word . . . . ..................... 48
Reset step . . . . . . . ..................... 78
Retentive Timer . . . ..................... 33
RETENTIVETIMER . ..................... 33
RETURN . . . . . . . . ..................... 52
S
SC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
SE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Selective sequence (divergence/convergence) . . . 90
Series sequence . . . . . . . . . . . . . . . . . . . . . . . . 90
SFC program . . . . . . . . . . . . . . . . . . . . . . . . . 6,71
SFC program setting . . . . . . . . . . . . . . . . . . . . . 99
SFC program start mode setting . . . . . . . . . . . . . 99
Simultaneous sequence (divergence/convergence) I
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
ST language . . . . . . . . . . . . . . . . . . . . . . . . . . 5,47
Start conditions setting . . . . . . . . . . . . . . . . . . . 99
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
STRING . . . . . . . . . . . . . . . . . . . . . . . . . 33,58,67
String. . . . . . . . . . . . . . . . . . . . . . . . . . . 33,58,67
String [Unicode] . . . . . . . . . . . . . . . . . . . . . . . . 33
Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 33,37
Subroutine program . . . . . . . . . . . . . . . . . . . . . 10
Subroutine type function block . . . . . . . . . . . . 18,26
System labels . . . . . . . . . . . . . . . . . . . . . . . . . . 31
T
TIME . . . . . . . . . . ...................... 33
Time . . . . . . . . . . ...................... 33
TIMER . . . . . . . . . ...................... 33
Timer . . . . . . . . . . ...................... 33
Transition name . . ...................... 89
Transition No. . . . . ...................... 89
Type conversion . . ...................... 50
Type specification . ...................... 59
129
REVISIONS
Revision date Revision Description
October 2014 A First Edition
January 2015 B ■Added functions
FBD/LD language
■Added or modified parts
Chapter 1, Section 3.1, 3.2, 4.1, 4.3, 4.4, 4.5, 5.2, 5.3, Chapter 6, 7
April 2015 C A part of the cover design is changed.
August 2015 D ■Added or modified parts
Section 4.4, Chapter 7
July 2018 E ■Added or modified parts
RELEVANT MANUALS, TERMS, Section 3.2, 4.4, 5.2, 5.3, 6.1, 7.1
December 2018 F ■Added or modified parts
RELEVANT MANUALS, TERMS, Chapter 2, 3, Section 6.1, Appendix 1, TRADEMARKS
October 2019 G ■Added model
FX5UJ CPU module
■Added or modified parts
RELEVANT MANUALS, TERMS, Section 3.4, 5.3, 6.1
May 2020 H ■Added or modified parts
RELEVANT MANUALS, TERMS, Section 3.2, 6.1, TRADEMARKS
October 2020 J ■Added function
SFC program
■Added or modified parts
RELEVANT MANUALS, Chapter 1, Section 5.2, 6.1, 7.1, Chapter 8, Appendix 2
April 2021 K ■Added or modified parts
RELEVANT MANUALS, TERMS, Section 3.2, 3.3, 4.3, 4.4, 4.6, 6.1, 7.1, Appendix 2,
TRADEMARKS
April 2022 L ■Added model
FX5S CPU module
■Added or modified parts
RELEVANT MANUALS, TERMS, GENERIC TERMS AND ABBREVIATIONS, Chapter 1, Section
3.2, 3.3, 5.2, 7.1, 7.2, 8.2, Appendix 2, WARRANTY
April 2023 M ■Added or modified parts
Chapter 1, 8, Appendix 2
130
WARRANTY
Please confirm the following product warranty details before using this product.
1. Gratis Warranty Term and Gratis Warranty 2. Onerous repair term after discontinuation
Range of production
If any faults or defects (hereinafter "Failure") found to be (1) Mitsubishi shall accept onerous product repairs for
the responsibility of Mitsubishi occurs during use of the seven (7) years after production of the product is
product within the gratis warranty term, the product shall discontinued.
be repaired at no cost via the sales representative or Discontinuation of production shall be notified with
Mitsubishi Service Company. However, if repairs are Mitsubishi Technical Bulletins, etc.
required onsite at domestic or overseas location, (2) Product supply (including repair parts) is not available
expenses to send an engineer will be solely at the after production is discontinued.
customer's discretion. Mitsubishi shall not be held
responsible for any re-commissioning, maintenance, or 3. Overseas service
testing on-site that involves replacement of the failed Overseas, repairs shall be accepted by Mitsubishi's local
module. overseas FA Center. Note that the repair conditions at
each FA Center may differ.
[Gratis Warranty Term]
4. Exclusion of loss in opportunity and
The gratis warranty term of the product shall be for one
year after the date of purchase or delivery to a
secondary loss from warranty liability
designated place. Note that after manufacture and Regardless of the gratis warranty term, Mitsubishi shall
shipment from Mitsubishi, the maximum distribution not be liable for compensation to:
period shall be six (6) months, and the longest gratis (1) Damages caused by any cause found not to be the
warranty term after manufacturing shall be eighteen (18) responsibility of Mitsubishi.
months. The gratis warranty term of repair parts shall not (2) Loss in opportunity, lost profits incurred to the user
exceed the gratis warranty term before repairs. by Failures of Mitsubishi products.
(3) Special damages and secondary damages whether
[Gratis Warranty Range] foreseeable or not, compensation for accidents, and
(1) The range shall be limited to normal use within the compensation for damages to products other than
usage state, usage methods and usage environment, Mitsubishi products.
etc., which follow the conditions and precautions, (4) Replacement by the user, maintenance of on-site
etc., given in the instruction manual, user's manual equipment, start-up test run and other tasks.
and caution labels on the product. 5. Changes in product specifications
(2) Even within the gratis warranty term, repairs shall be The specifications given in the catalogs, manuals or technical
charged for in the following cases. documents are subject to change without prior notice.
1. Failure occurring from inappropriate storage or 6. Product application
handling, carelessness or negligence by the
(1) In using the Mitsubishi MELSEC programmable
user. Failure caused by the user's hardware or
controller, the usage conditions shall be that the
software design.
application will not lead to a major accident even if
2. Failure caused by unapproved modifications,
any problem or fault should occur in the
etc., to the product by the user.
programmable controller device, and that backup and
3. When the Mitsubishi product is assembled into a fail-safe functions are systematically provided outside
user's device, Failure that could have been of the device for any problem or fault.
avoided if functions or structures, judged as
(2) The Mitsubishi programmable controller has been
necessary in the legal safety measures the user's
designed and manufactured for applications in general
device is subject to or as necessary by industry
industries, etc. Thus, applications in which the public
standards, had been provided.
could be affected such as in nuclear power plants and
4. Failure that could have been avoided if other power plants operated by respective power
consumable parts (battery, backlight, fuse, etc.) companies, and applications in which a special quality
designated in the instruction manual had been assurance system is required, such as for railway
correctly serviced or replaced. companies or public service purposes shall be excluded
5. Relay failure or output contact failure caused by from the programmable controller applications.
usage beyond the specified life of contact In addition, applications in which human life or property
(cycles). that could be greatly affected, such as in aircraft,
6. Failure caused by external irresistible forces such medical applications, incineration and fuel devices,
as fires or abnormal voltages, and failure caused manned transportation, equipment for recreation and
by force majeure such as earthquakes, lightning, amusement, and safety devices, shall also be excluded
wind and water damage. from the programmable controller range of applications.
7. Failure caused by reasons unpredictable by However, in certain cases, some applications may be
scientific technology standards at time of possible, providing the user consults their local
shipment from Mitsubishi. Mitsubishi representative outlining the special
8. Any other failure found not to be the responsibility requirements of the project, and providing that all
of Mitsubishi or that admitted not to be so by the parties concerned agree to the special circumstances,
user. solely at the user's discretion.
(3) Mitsubishi shall have no responsibility or liability for any
problems involving programmable controller trouble and
system trouble caused by DoS attacks, unauthorized
access, computer viruses, and other cyberattacks.
131
TRADEMARKS
Anywire and AnyWireASLINK are either registered trademarks or trademarks of Anywire Corporation.
Unicode is either a registered trademark or a trademark of Unicode, Inc. in the United States and other countries.
The company names, system names and product names mentioned in this manual are either registered trademarks or
trademarks of their respective companies.
In some cases, trademark symbols such as '' or '' are not specified in this manual.
132 JY997D55701M
Manual number: JY997D55701M
MODEL: FX5-P-PS-E
MODEL CODE: 09R538
HEAD OFFICE: TOKYO BLDG., 2-7-3, MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPAN
NAGOYA WORKS: 1-14, YADA-MINAMI 5-CHOME, HIGASHI-KU, NAGOYA 461-8670, JAPAN
When exported from Japan, this manual does not require application to the
Ministry of Economy, Trade and Industry for service transaction permission.