0% found this document useful (0 votes)
5 views

Fx5U Programming Documentsjy997d55701m

The MELSEC iQ-F FX5 Programming Manual provides essential instructions and functions for programming the FX5 PLCs, emphasizing the importance of safety precautions and proper usage. Users are advised to consult relevant manuals and ensure the product is suitable for their specific applications, especially in critical industries. The manual includes detailed chapters on program configuration, organization, and various programming languages, along with necessary precautions and guidelines.

Uploaded by

Công Cầu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Fx5U Programming Documentsjy997d55701m

The MELSEC iQ-F FX5 Programming Manual provides essential instructions and functions for programming the FX5 PLCs, emphasizing the importance of safety precautions and proper usage. Users are advised to consult relevant manuals and ensure the product is suitable for their specific applications, especially in critical industries. The manual includes detailed chapters on program configuration, organization, and various programming languages, along with necessary precautions and guidelines.

Uploaded by

Công Cầu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 136

MELSEC iQ-F

FX5 Programming Manual (Program Design)


SAFETY PRECAUTIONS
(Read these precautions before using this product.)
Before using the FX5 PLCs, please read the manual supplied with each product and the relevant manuals introduced in that
manual carefully and pay full attention to safety to handle the product correctly.
Store this manual in a safe place so that it can be taken out and read whenever necessary. Always forward it to the end user.

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.

Regarding use of this product


• This product has been manufactured as a general-purpose part for general industries, and has not been designed or
manufactured to be incorporated in a device or system used in purposes related to human life.
• Before using the product for special purposes such as nuclear power, electric power, aerospace, medicine or passenger
movement vehicles, consult with Mitsubishi Electric.
• This product has been manufactured under strict quality control. However when installing the product where major
accidents or losses could occur if the product fails, install appropriate backup or failsafe functions in the 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 2 PROGRAM CONFIGURATION 7

CHAPTER 3 PROGRAM ORGANIZATION UNITS 9


3.1 Program Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2 Functions (FUN). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Function Blocks (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

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 5 LADDER DIAGRAM 42


5.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Ladder symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Program execution order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Precautions for using a function block in ladder diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.2 Inline ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.3 Statements and Notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

CHAPTER 6 ST LANGUAGE 47
6.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Delimiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Label and device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

CHAPTER 7 FBD/LD LANGUAGE 61


7.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Program unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Labels and devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

2
7.2 Inline ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.3 Program Execution Order. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
The order of executions of program units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

CHAPTER 8 SFC PROGRAM 71


8.1 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
8.2 Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

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

GENERIC TERMS AND ABBREVIATIONS


Unless otherwise specified, this manual uses the following generic terms and abbreviations.
Generic term/abbreviation Description
FX3 intelligent function module A generic term for FX3U-4AD, FX3U-4DA, FX3U-4LC, FX3U-1PG, FX3U-2HC, FX3U-16CCL-M, FX3U-
64CCL, FX3U-128ASL-M, and FX3U-32DP
FX5 A generic term for FX5S, FX5UJ, FX5U, and FX5UC programmable controllers
FX5 CPU module A generic term for FX5S CPU module, FX5UJ CPU module, FX5U CPU module, and FX5UC CPU module
FX5 intelligent function module A generic term for FX5-4AD, FX5-4DA, FX5-8AD, FX5-4LC, FX5-20PG-P, FX5-20PG-D, FX5-40SSC-G,
FX5-80SSC-G, FX5-40SSC-S, FX5-80SSC-S, FX5-ENET, FX5-ENET/IP, FX5-CCLGN-MS, FX5-CCLIEF,
FX5-CCL-MS, FX5-ASL-M, and FX5-DP-M
GX Works3 The product name of the software package, SWnDND-GXW3, for the MELSEC programmable controllers
(The 'n' represents a version.)
Intelligent function module A generic term for FX5 intelligent function modules and FX3 intelligent function modules
Operand A generic term for items, such as source data (s), destination data (d), number of devices (n), and others,
used to configure instructions and functions

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

Type of programming languages


With the FX5 series, the optimal programming language can be selected according to the application.
: Applicable : Inapplicable
Programming Description Applicability to CPU
language module
FX5S FX5UJ FX5U/
FX5UC
Ladder diagram Ladder diagram is a graphic language that indicates circuits using contacts, coils, and others.   
The ladder diagram describes logic circuits with symbolized contacts and coils for easy-to-
understand sequence control.
Structured text language ST language is a text language that describes programs with IF statements, operators, and   
(ST language) others.
Because operation processing that is difficult to describe in ladder diagram can be easily and
briefly described with ST language, ST language is suitable for applications requiring
complicated arithmetic operation or comparative operation. With ST language, programs can
be easily described with syntax using selective branches with conditional statements and
repetition by repetitive statements in the same way as C language.
Function block diagram/ This is a graphic language that describes a program by wiring blocks for specific processing   
ladder diagram (FBD/LD (function elements, FB elements), variable elements, and constant elements along with the
language) flows of data and signals.
You can easily create a program that may be complicated to create by using a ladder program.
So you can enhance the productivity of programs.
Sequential function chart SFC is a program description format in which a sequence of control operations is split into a   
(SFC program) series of steps to enable a clear expression of each program execution sequence and
execution conditions.

■Ladder diagram

When using ladder diagram, refer to the following.


Page 42 LADDER DIAGRAM

■ST language

When using ST language, refer to the following.


Page 47 ST LANGUAGE

1 OUTLINE
5
■FBD/LD language

When using FBD/LD language, refer to the following.


Page 61 FBD/LD LANGUAGE

■SFC program

When using SFC program, refer to the following.


Page 71 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

Function block Function

Program block

For POUs, refer to the following.


Page 9 PROGRAM ORGANIZATION UNITS

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

A structured program is a program created by components. Processes in lower levels of hierarchical


sequence program are divided into several components according to their processing information and
functions.
Each component of a program is specified to have a high degree of independence for easy addition and
replacement.
The following are the examples of processing that would be ideal to be structured.
• Processing which is used repeatedly in a program
• Processing which can be separated as one function

This chapter describes three types of POUs using labels.


Devices can also be used in the program (worksheet) of each POU. For details on devices, refer to the following.
 MELSEC iQ-F FX5 User's Manual (Application)

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)

3 PROGRAM ORGANIZATION UNITS


9
3.1 Program Blocks
A program block is a unit for making up a program.
Multiple program blocks can be created in a program file and executed in the order specified in the program file setting. If the
order is not specified in the program file setting, the program blocks are executed in ascending order of their names.
By separating program blocks for individual functions and processing, the order of programs can be changed easily and
programs can be exchanged easily.
The program of a program block is stored by each registration destination program in a program file.

Program block 1
Program file

Program block 2

Dividing into program blocks


A main routine program, subroutine program, and interrupt program can be created separately in individual program blocks.
Program type Description
Main routine program A program beginning with step 0 and ending with the FEND instruction
Subroutine program A program beginning with a pointer (P) and ending with the RET instruction.
This program is executed only when it is called by a subroutine call instruction (CALL and XCALL instructions).
Interrupt program A program beginning with an interrupt pointer (I) and ending with the IRET instruction.
When an interrupt factor occurs, the interrupt program corresponding to the interrupt pointer number is executed.

■Program file setting


In the program file setting, the order of executions of program blocks in a program file can be set.
[Convert]  [Program File Setting]
[Navigation window]  Select and right-click the program file.  [Program File Setting]

For details of the program file setting, refer to the following.


GX Works3 Operating Manual

3 PROGRAM ORGANIZATION UNITS


10 3.1 Program Blocks
Ex.
Create a program block as shown below.
ProgPou1 ProgPou2 ProgPou3

P0 I0
Main routine program Subroutine program Interrupt program

FEND RET IRET


END END END

Execute the program according to the order of the execution of program file setting. 3
Program file setting

The order of the program blocks

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)

3 PROGRAM ORGANIZATION UNITS


3.1 Program Blocks 11
3.2 Functions (FUN)
A function is a POU called and executed by program blocks, function blocks, and other functions.
After the processing completes, a function passes a value to the calling source. This value is called a return value.
A function always outputs the same return value, as the processing result, for the same input.
By defining simple, independent algorithms that are frequently used, functions can be reused efficiently.

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.

3 PROGRAM ORGANIZATION UNITS


12 3.2 Functions (FUN)
Input variables and output variables
Input and output variables can be defined in functions. Output data which is different from the return value can be assigned to
the output variable.
Ladder program FBD/LD program

(1) (1) Function name


(1)
(2) Input variable
(2) (2) (3) Output variable
(3)
(3)

The return value of the function is not displayed.

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".

3 PROGRAM ORGANIZATION UNITS


3.2 Functions (FUN) 13
Creating programs
The program of a function can be created by using the engineering tool.
[Navigation window]  [FB/FUN]  Right-click  [Add New Data]
Select "Function" for "Data Type" in "Basic Setting".
The created program is stored in the FUN file.
[CPU Parameter]  [Program Setting]  [FB/FUN File Setting]
Up to 64 created programs can be stored in one FUN file.
The rising edge execution instruction or falling edge execution instruction cannot be used in the function.
For details on program creation, refer to the following.
Item Reference
How to create function programs  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)

■Applicable devices and labels


The following table lists the devices and labels that can be used in function programs.
: Applicable, : Applicable only in instructions (Cannot be used to indicate the program step.), : Not applicable
Type of device/label Availability
Label (other than the pointer type) Global label 
Local label *1
Label (pointer type) Pointer type global label 
Pointer type local label 
Device Global device 
Pointer Global pointer 

*1 The following data types cannot be used.


Timer, retentive timer, counter, and long counter

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.

3 PROGRAM ORGANIZATION UNITS


14 3.2 Functions (FUN)
Labels defined by a function
The labels defined by a function are assigned in the temporary areas of the storage-target memory during execution of the
function, and the areas are freed after the processing completes.

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)

Label area of FUN3

Label area of FUN1 Label area of FUN1 Label area of FUN1

Temporary area

Ö × Ø
Main program being executed FUN2 being executed Main program being executed

Label area of FUN2

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.

3 PROGRAM ORGANIZATION UNITS


3.2 Functions (FUN) 15
Number of steps
To call a function, the number of steps is required not only for the program itself but also for the processing that passes the
argument and return value and the processing that calls the program.

■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

M0 FUN1 Y20 MOV D0 XX


(1)
D0 M0

FUNCall FUN1 (2)


M10 FUN2 Y40
D10
Y20 (3)
The call-target program is
replaced with the instruction ·
for calling a function. Calling the function
FUN file
FUN1 program

• Passing the argument


The instruction used to pass the argument differs depending on the class and data type of the argument. The following table
summarizes the instructions that can be used to pass the argument.
Argument class Data type Instruction used Number of steps
VAR_INPUT Bit LD+OUT For the number of steps required for
LD+MOVB each instruction, refer to the following.
(Either of the instruction sets is used  MELSEC iQ-F FX5 Programming
depending on the combination of Manual (Instructions, Standard
programming language, function, and input Functions/Function Blocks)
argument used.)
Word [unsigned]/bit string [16 bits] LD+MOV
Double word [unsigned]/bit string [32 bits] LD+DMOV
Word [signed]
Double word [signed]
Single-precision real number LD+EMOV
Time LD+DMOV
String(32) LD+$MOV
String [Unicode](32) LD+$MOV_WS
Array, Structure LD+BMOV

• Calling the program


The following table lists the number of steps required to call the program of the function.
Item Number of steps
With EN 10
Without EN 12

• Passing the return value


The instruction and the number of steps used for passing the return value are identical to those for passing the argument.
Argument class Data type Instruction used Number of steps
VAR_OUTPUT Same as for passing the argument Same as for passing the argument Same as for passing the argument

3 PROGRAM ORGANIZATION UNITS


16 3.2 Functions (FUN)
• 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.)

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

Unlike a function, a function block does not have a return value.


A function block can hold values in variables and thus can hold input states and processing results.
A function block uses the value it holds for the next processing and therefore it does not always output the same result even
with the same input value.
Ladder language FBD/LD language

(1) (1) Instance name


(1)
(2) Function block name
(2) (3) Output variable
(2)
(4) Input variable

(3) (3)

(4)
(4)

A function block needs to be instantiated to be used in programs.


Page 20 Instances

• For details on standard function blocks, refer to the following.


 MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
• For details on module function blocks, refer to the following.
 Function Block Reference for the module used

3 PROGRAM ORGANIZATION UNITS


3.3 Function Blocks (FB) 17
Operation overview
■Macro type function blocks
The program of a macro type function block is loaded by a calling source program along the execution flow. At the time of
program execution, the loaded program is executed in the same way as the main program.
Use a macro type function block when giving a higher priority to the processing speed of the 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

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.

■Subroutine type function blocks


The program of a subroutine type function block is stored in the FB file and called by the calling source program when
executed.
Use a subroutine type function block to reduce the program size.

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.

3 PROGRAM ORGANIZATION UNITS


18 3.3 Function Blocks (FB)
Input variables, output variables, and input/output variables
Input variables, output variables, and input/output variables need to be defined in function blocks.
A function block can output multiple operation results. It can also be set not to output operation results.
(1) The operation result(s) is output.
Instance Instance
(2) No operation result is output.
SR SAMPLE_FB1
_S1 Q1 IN_Bool

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

Function block Function block

bLabel1 bLabel10 bLabel4 bLabel10


Count contact bLabel13 bLabel3 Count contact bLabel13 bLabel6
uLabel2 uLabel12 Counting-up uLabel5 uLabel12 Counting-up
Count set value Count set value

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.

External variables and public variables


Function blocks can use external variables (global label) and public variables.
Public variables are set in the VAR_PUBLIC and VAR_PUBLIC_RETAIN class.

3 PROGRAM ORGANIZATION UNITS


3.3 Function Blocks (FB) 19
Instances
■Instances
An instance is a label assigned to realize a function block definition. Multiple instances can be created from one function block
definition.
An instance consists of the following items.
Item Description
Local label area Used to assign the local label of the function block.
Local latch label area Used to assign the latch attribute local label of the function block.
Signal flow area (Signal flow for FB) Used to assign the signal flow for the instruction in the function block definition.

Ex.
Structure of instance (Example of subroutine type function block)

FB1 definition FB1 instance structure


Ladder program (FB1) Local label area
bLabel0 bLabel0
INCP wLabel0 Padding size
3 words 52 words
Local label definition (FB1) Reserved area 48 words
Label name Data type Class
bLabel0 BIT VER
Local latch label area
wLabel0 WORD VER_RETAIN Creating an
wLabel0
instance based on
Reserved area (FB1) FB1 definition Padding size
Area Size 3 words 20 words
Local label area 48 words
Reserved area 16 words
Local latch label area 16 words
Signal flow for FB 8 words
Signal flow for FB
For INCP(3 bits) For LD(2 bits)

9 words
Reserved area 8 words

Creating another
instance based on
FB1 definition Another instance of FB1
(same area size)
Local label area

Local latch label area

Signal flow for FB

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).

3 PROGRAM ORGANIZATION UNITS


20 3.3 Function Blocks (FB)
Ex.
Structure of instance for nested function block
FB1 definition FB1 instance structure
Ladder program (FB1) Local label area
bLabel0
bLabel0 bLabel1
INCP wLabel0
bLabel2
bLabel1 wLabel1
Padding size
2 words
bLabel2
FB2 wLabel1
bLabel1
3
Creating an wLabel0 bLabel0
instance based on wLabel1
Local label definition (FB1) FB1 definition
Padding size 1 word
Label name Data type Class FB2 area
bLabel0 BIT VER 52 words FB1 area
bLabel1 BIT VER 104 words
bLabel2 BIT VER Reserved area 48 words
wLabel0 WORD VER_RETAIN
wLabel1 WORD VER
FB2_a FB2 VER

Reserved area (FB1)


Area Size
Reserved area 48 words
Local label area 48 words
Local latch label area 16 words
Signal flow for FB 8 words

Local latch label area


FB2 definition
wLabel0
Ladder program (FB2)
Padding size
bLabel0 3 words
INC wLabel0

FB2 area
bLabel1 Reserved area 16 words FB1 area
16 words
MOVP wLabel0 wLabel1 36 words

Local label definition (FB2)


Reserved area 16 words
Label name Data type Class
bLabel0 BIT VER_INPUT
bLabel1 BIT VER_INPUT
wLabel0 WORD VER
wLabel1 WORD VER_OUTPUT
Signal flow for FB
For INCP (3 bits)
Reserved area (FB2)
Area Size
Local label area 48 words
Local latch label area 16 words FB2 area
For MOVP (4 bits) 9 words FB1 area
Signal flow for FB 8 word Reserved area 8 words 18 words

Reserved area 8 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.

3 PROGRAM ORGANIZATION UNITS


3.3 Function Blocks (FB) 21
■Creating instances
A function block needs to be instantiated to be used in programs.
By creating instances, a function block can be called and executed by a program block or another function block.
Declare instances with global labels or local labels.
Label type Instance type Class
Global label Global FB VAR_GLOBAL
Local label*1 Local FB VAR

*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

Function block Function block

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

(1) Same instances use the same internal variables.


(2) Different instances use different internal variables.

3 PROGRAM ORGANIZATION UNITS


22 3.3 Function Blocks (FB)
■Capacity of instance
The capacity of each data area of an instance should be calculated as follows.
• Capacity of local label area
Capacity of local label area of instance = Total capacity of data of local labels (except the ones with latch attribute) + Capacity
of reserved area
Item Description
Capacity of local labels (except the ones with latch Total capacity of the data used for local labels.
attribute) The capacity of areas to be used differs depending on the memory assignment of labels. For details on
memory assignment of labels, refer to the following.
 GX Works3 Operating Manual 3
Capacity of reserved area 48 words.

• Capacity of local latch label area


Capacity of local latch label area of instances = Total capacity of data of local labels with latch attribute + Capacity of reserved
area
Item Description
Capacity of latch attribute local labels Total capacity of the data used for latch attribute local labels.
The capacity of areas to be used differs depending on the memory assignment of labels. For details on
memory assignment of labels, refer to the following.
 GX Works3 Operating Manual
Capacity of reserved area 16 words.

• Capacity of signal flow for FB


In the macro type function block, the number of steps are the same as the program.
The capacity of the subroutine type function block is as follows.
Capacity of signal flow for FB (word) = The number of program steps of the function block / 16 + Capacity of reserved area
Item Description
Capacity of signal flow for FB Total capacity of the signal flow for FB for the instruction in the function block definition
Capacity of reserved area 8 words.

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).

3 PROGRAM ORGANIZATION UNITS


3.3 Function Blocks (FB) 23
EN and ENO
In the same way as a function, EN (enable input) and ENO (enable output) can also be appended to a function block to control
execution processing.
Page 13 EN and ENO
When the instance of a function to which EN/ENO has been appended is called, an actual argument must be assigned to EN.

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.

3 PROGRAM ORGANIZATION UNITS


24 3.3 Function Blocks (FB)
■Inherent property setting
The following items can be set when a program of a function block is created. ( GX Works3 Operating Manual)
Item Description
Use MC/MCR to Control EN*1 For "Yes", the MC/MCR instructions are used to control EN. For "No", the CJ instruction is used to control EN.
Select "Yes" when instructions executed at the rising edge or falling edge are used in an FB. The operations of a
timer/counter and the OUT instruction used in an FB differ depending on the selected item. For details, refer to the
following.
Page 121 Operations of when the MC/MCR instructions are used to control EN
Use EN/ENO For "Yes", a function block with EN/ENO is created, and EN/ENO labels can be used in a program without
registering as local labels. For "No", a function block without EN/ENO is created.
For details on EN/ENO, refer to the following. 3
Page 24 EN and ENO

*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)

■Applicable devices and labels


The following table lists the devices and labels that can be used by function block programs.
: Applicable, : Applicable only in instructions (Cannot be used to indicate the program step.), : Not applicable
Type of device/label Availability
Label (other than the pointer type) Global label 
Local label 
Label (pointer type) Pointer type global label 
Pointer type local label 
Device Global device 
Pointer Global pointer 

Number of steps (Macro type function blocks)


■Calling source
When calling a macro type function block, the calling source loads the call-target program during compilation.
Program block 1 (displayed) Program file

FB1_a
FB1 program
FB1
(FB1_a)

FB1_b
FB1

FB1 program
(FB1_b)

(1)

(1) The program is loaded in two or more call locations.

■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)

3 PROGRAM ORGANIZATION UNITS


3.3 Function Blocks (FB) 25
Number of steps (Subroutine type function blocks)
■Calling source
When calling a subroutine type function block, the calling source generates the processing that passes the argument before
and after the call processing.
Program block 1 (1) Passing the argument (input argument, input/output
(displayed) Program file argument)
(2) Calling the FB1 program
FB1_a
MOV D0 XX (3) Passing the argument (output argument, input/output
M0 FB1 Y20
(1) argument)
D0 M0

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

• Passing the argument


The instruction used to pass the argument differs depending on the class and data type of the argument. The following table
summarizes the instructions that can be used to pass the argument.
Argument class Data type Instruction used Number of steps
VAR_INPUT Bit LD+OUT For the number of steps required for
VAR_IN_OUT LD+MOVB each instruction, refer to the following.
VAR_OUTPUT (Either of the instruction sets is used  MELSEC iQ-F FX5 Programming
depending on the combination of Manual (Instructions, Standard
programming language, function, and input Functions/Function Blocks)
argument used.)
Word [unsigned]/bit string [16 bits] LD+MOV
Double word [unsigned]/bit string [32 bits] LD+DMOV
Word [signed]
Double word [signed]
Single-precision real number LD+EMOV
Time LD+DMOV
String(32) LD+$MOV
String [Unicode](32) LD+$MOV_WS
Array, Structure LD+BMOV

• Calling the program


The following table lists the number of steps required to call the program of the function block.
Item Number of steps
With EN 10
Without EN 12

• 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)

3 PROGRAM ORGANIZATION UNITS


26 3.3 Function Blocks (FB)
3.4 Precautions

When a subroutine program or an interrupt program is used


• Set subroutine programs and interrupt programs after the FEND instruction. When the subroutine program and interrupt
program are set before the FEND instruction, an error occurs.
Program file
Execution
order
P0
3
Because the subroutine
Subroutine program program is set before the
FEND instruction, an error
occurs.
RET

Change the execution order in the


program file setting.
Main routine program

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

The program after the FEND instruction is not


executed as the main routine program.
Main routine program

FEND

I0
Interrupt program

IRET
END

When a function is used


■Global pointer/pointer type global labels
The global pointer and pointer type global labels cannot be used as the labels indicating the number of program steps.

3 PROGRAM ORGANIZATION UNITS


3.4 Precautions 27
When a function block is used
■Global pointer/pointer type global labels
The global pointer and pointer type global labels cannot be used as the labels indicating the number of program steps.

■When the index register is used


When the index register is used in the function block program, ladder programs for saving and returning the index register
values are required to protect the values.
Setting the index register data to 0 when saving can prevent an error that could be caused by an index modification validity
check. (Whether the device number exceeds the device range or not is checked.)

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

Save the index register values.


SM400 Before the program execution,
MOV Z1 index_reg_tmp1 save the index register values in
index_reg_tmp.
MOV Z2 index_reg_tmp2

Clear the index register values.

MOV K0 Z1 Set 0 to the index register areas.

MOV K0 Z2

Program execution

Return the register values.


SM400 After the program execution, return the
MOV index_reg_tmp1 Z1 values saved in index_reg_tmp to the
index register.
MOV index_reg_tmp2 Z2

■Argument of macro type function block


Except in the program of the macro type function block, use the device/label used for passing the argument instead of the
argument of the function block.

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;

3 PROGRAM ORGANIZATION UNITS


28 3.4 Precautions
■When a conversion error occurs in VAR_INPUT, VAR_OUTPUT, or VAR_IN_OUT in a macro
type function block
A program block that is the calling source of the function block or the function block may cause the error. In this case, check
the inputs and outputs of the program block that is the calling source of the function block and the function block.

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.

■Restrictions for module function blocks


The following describes the restrictions for the use of module function blocks.
• Do not turn off the contact of the MC instruction when calling a module function block between the MC instruction and MCR
instruction.
• Do not perform the jump processing that prevents module function blocks from being called by the CJ instruction.
• Execute a subroutine program every scan when calling a module function block in the subroutine program. Do not perform
the non-execution processing of a subroutine program by using the XCALL instruction.
• Do not call a module function block in an interrupt program or event execution type program.
• Do not call a module function block between the FOR and NEXT instructions, in the inline ST, or the control syntax of the
structured text language (IF statement, FOR statement, and CASE statement.)

■When a master control instruction is used


Shown here is the operation when the master control is OFF.
• Macro type function block
The operation in the function block is the same as contact OFF (OFF execution or no execution is made).
• Subroutine type function block and function
No execution is made in the function block.

3 PROGRAM ORGANIZATION UNITS


3.4 Precautions 29
Changing program capacity (FX5U/FX5UC CPU module only)
When the program capacity setting parameter is changed to 128000 steps from 64000 steps, the operation changes as
follows.
• Signal flow area for FB is expanded from 16K bytes to 32K bytes.
• Temporary area capacity is expanded form 700 words to 32767 words.
• Execution time for each instruction is prolonged.
Do not write a program with more than 64000 steps to the CPU module firmware version earlier than 1.100. The program
does not operate normally.
For the program capacity setting, refer to the following.
MELSEC iQ-F FX5 User's Manual (Application)

3 PROGRAM ORGANIZATION UNITS


30 3.4 Precautions
4 LABELS
Labels are variables for I/O data or internal processing, specified by a character string.
Users can create a program without considering devices or buffer memory size by using labels.
Thus, a program, where labels are used, can be reused in a system with a different module configuration easily.
When labels are used, there are some precautions on programming and functions used. For details, refer to the following.
Page 40 Precautions

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.3 Data Type


Labels are classified into several data types according to the bit length, processing method, or value range.
The following two data types are provided.
• Primitive data type
• Generic data type (ANY)

Primitive data type


The following data types are available as the primitive data type.
Data type Description Value range Bit
length
Bit BOOL Represents binary status, such as ON or 0 (FALSE), 1 (TRUE) 1-bit
OFF
Word [Unsigned]/Bit String [16-bit] WORD Represents 16-bit 0 to 65535 16-bit
Double Word [Unsigned]/Bit String DWORD Represents 32-bit 0 to 4294967295 32-bit
[32-bit]
Word [Signed] INT Handles positive and negative integer -32768 to +32767 16-bit
values
Double Word [Signed] DINT Handles positive and negative double word -2147483648 to +2147483647 32-bit
integer values
FLOAT [Single Precision] REAL Handles the portion after the decimal point -2128 to -2-126, 0, 2-126 to 2128 32-bit
of the float (single precision)
Effective digits: 7 (after the decimal point:
6)

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.

■Data types of timers and counters


The data types of a timer, retentive timer, counter, and long counter are structures that have contacts, coils, and current
values.
Data type Member Data type of Description Value range
name member
Timer TIMER S Bit Indicates contacts. The operation is the same 0 (FALSE), 1
as the contact of a timer device (TS). (TRUE)
C Bit Indicates coils. The operation is the same as the 0 (FALSE), 1
coil of a timer device (TC). (TRUE)
N Word [unsigned]/Bit Indicates a current value. The operation is the 0 to 32767*1
String [16-bit] same as the current value of a timer device
(TN).
Retentive Timer RETENTIVETIMER S Bit Indicates contacts. The operation is the same 0 (FALSE), 1
as the contact of a retentive timer device (STS). (TRUE)
C Bit Indicates coils. The operation is the same as the 0 (FALSE), 1
coil of a retentive timer device (STC). (TRUE)
N Word [unsigned]/Bit Indicates a current value. The operation is the 0 to 32767*1
String [16-bit] same as the current value of a retentive timer
device (STN).
Counter COUNTER S Bit Indicates contacts. The operation is the same 0 (FALSE), 1
as the contact of a counter device (CS). (TRUE)
C Bit Indicates coils. The operation is the same as the 0 (FALSE), 1
coil of a counter device (CC). (TRUE)
N Word [unsigned]/Bit Indicates a current value. The operation is the 0 to 32767
String [16-bit] same as the current value of a counter device
(CN).
Long Counter LCOUNTER S Bit Indicates contacts. The operation is the same 0 (FALSE), 1
as the contact of a long counter device (LCS). (TRUE)
C Bit Indicates coils. The operation is the same as the 0 (FALSE), 1
coil of a long counter device (LCC). (TRUE)
N Double Word [unsigned]/ Indicates a current value. The operation is the *2

Bit string [32-bit] same as the current value of a long counter


device (LCN).

*1 The unit of the current value is specified by instruction name.


*2 When use a long counter in the OUT LC instruction: 0 to 4294967295
When use a long counter in the UDCNTF instruction: -2147483648 to +2147483647
For the operation of each device, refer to the following.
MELSEC iQ-F FX5 User's Manual (Application)
The specification method of each member is the same as the member specification of the structure data type. (Page 37
Structures)

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)

Definable data types


The following tables list the definable data types possibilities for each label class.
Global label
Class Definable data type
VAR_GLOBAL Primitive data type, array, structure, function block
VAR_GLOBAL_CONSTANT Primitive data type*1
VAR_GLOBAL_RETAIN Primitive data type*1, array, structure

Local label (program block)


Class Definable data type
VAR Primitive data type, array, structure, function block
VAR_CONSTANT Primitive data type*1
VAR_RETAIN Primitive data type*1, array, structure

Local label (function)


Class Definable data type
VAR Primitive data type*2, array, structure
VAR_CONSTANT Primitive data type*1
VAR_INPUT Primitive data type*1*2, array, structure
VAR_OUTPUT
Return value

Local label (function block)


Class Definable data type
VAR Primitive data type, array, structure, function block
VAR_CONSTANT Primitive data type*1
VAR_RETAIN Primitive data type*1, array, structure
VAR_INPUT
VAR_OUTPUT
VAR_OUTPUT_RETAIN
VAR_IN_OUT
VAR_PUBLIC
VAR_PUBLIC_RETAIN

*1 The pointer type cannot be defined.


*2 None of the timer, retentive timer, long timer, counter, long timer, long retentive timer, and long counter types can be defined.

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

bLabel1 [0] [1] … [n] [0,0] [0,1] [0,n]


bLabel2

[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)

How to use arrays


To identify individual labels of an array, append an index enclosed by "[ ]" after the label name.
For an array with two or more dimensions, delimit indexes in "[ ]" by using "comma (,)".
The following table lists the types of indexes that can be specified for arrays.
bLabel1 [0] bLabel2 [0,3]

Label name Indexes

Type Specification example Remarks


Constant bLabel1[0] An integer equal to or greater than 0 can be specified. Decimal constant or hexadecimal constant can be specified.
Device bLabel1[D0] A word device or double-word device can be specified.
Label bLabel1[uLabel2] The following data types can be specified.
• Word [unsigned]/bit string [16 bits]
• Double word [unsigned]/bit string [32 bits]
• Word [signed]
• Double word [signed]
Expression bLabel1[5+4] Expressions can be specified only in ST language.

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.

Maximum number of array elements


The maximum number of array elements differs depending on data types.
Data type Setting range
Bit 1 to 32768
Word [Unsigned]/Bit String [16-bit]
Double Word [Unsigned]/Bit String [32-bit]
Word [Signed]
Double Word [Signed]
FLOAT [Single Precision]
Time
Timer
Retentive Timer
Counter
Long Counter
String(32) 1 to 32768  character string length
String [Unicode](32) 1 to 16384  character string length

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

Program using the label defined as an array

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)

How to use structures


To use structures, register the label with the defined structure as a new data type.
To specify each member, append an element name after the structure label name with "period (.)" as a member name.

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]

Member (Label 1) Member (Label 1) Member (Label 1) Member (Label 1)


Member (Label 2) Member (Label 2) Member (Label 2) Member (Label 2)
Member (Label 3) Member (Label 3) Member (Label 3) Member (Label 3)
Member (Label 4) Member (Label 4) Member (Label 4) Member (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

Data types that can be specified


The following data types can be specified as a member of a structure.
• Primitive data type
• Pointer type
• Arrays
• Other structures

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.)

When "$" is used in character string type data


"$" is used as an escape sequence. Two hexadecimal numbers after "$" are recognized as an ASCII code, and characters
corresponding to the ASCII code are inserted in the character string. If no ASCII code for the two hexadecimal numbers after
"$" exists, a conversion error occurs. However, when any of the following characters is described after "$", no error occurs.
Expression Symbol that is used in character string, or printer code
$$ $
$' '
$'' ''
$L or $l Line feed
$N or $n Newline
$P or $p Page (form feed)
$R or $r Return
$T or $t Tab

4 LABELS
4.6 Constant 39
4.7 Precautions

Functions with limitations


In the following functions, there is a limitation on label use.
Item Description
Trigger of an event execution type program Labels cannot be used. Consider taking the following measures.
• Use devices.
• Define a label to be used as a global label and assign devices to the global label.
Intelligent function module refresh setting Labels cannot be used. Consider taking the following measures.
• Use devices.

■Defining and using a global label with a device assigned


Define a global label following the procedure below, and use it when the functions having restriction on the use of labels are
executed.
Since the device area in the device/label memory is used, reserve device area capacity. (The label area is not consumed.)
1. Reserve the device area to be used.
CPU Parameter  Memory/Device Setting  Device/Label Memory Area Capacity Setting

2. Define a label as a global label, and assign a device manually.

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.

■Copying the label data into a specified device


Copy the label data into a specified device following the procedure below, and use the copy-target device.
Since the device area in the device/label memory is used, reserve device area capacity.
1. Reserve the device area to be used.
CPU Parameter  Memory/Device Setting  Device/Label Memory Area Capacity Setting

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

123 Search range :


-123 (n) points

20
123
wLabel1[n]

Specify a label which has a larger data range than the search range (n) points.

Limitations on label names


Label names have the following limitations:
• A label name must start with a nonnumeric character or underscore (_). It cannot start with a number.
• Reserved words cannot be used as label names.
For details of reserved words, refer to the following.
GX Works3 Operating Manual

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)

(1) A ladder consists of contacts and coils


(2) A ladder connected in series
(3) A ladder connected in parallel
(4) A ladder where instructions are used
(5) A ladder where standard functions and function blocks are used

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.

NC contact Turns on when a specified device or label is OFF.

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.

Coil Outputs an operation result to a specified device or a label.

Instruction Executes an instruction specified in [ ].

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)

Program execution order


The program is executed in order of the following numbers.

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

Precautions for directly connecting to an FB instance from the left rail


When EN and input variables (bit type) are directly connected to the left rail in the input circuit of the FB instance, the on/off
state does not change.
(1): The on/off state does not change.

(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;

• Program without the inline ST


X0
MOV K0 W0

+ 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

The inline ST cannot be used in the Zoom editor of SFC programs.

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.

Types of statements and notes


"PLC" and "Peripheral" are the types of statements and notes.
Type Type Description
PLC • Line statement Statements and notes can be stored on the CPU module.
• P statement PLC statement uses the following number of steps. (Decimal fraction is rounded down.)
• I statement • Without character: 3 steps
• Note • With character: 4 + (Number of characters + 2 + 14) / 15 + Number of characters (steps)
Peripheral • Line statement Strings of the description are not embedded in the program, but they are saved as attached
• P statement information of the program.
• I statement One statement or note line uses one step.
• Note A * symbol is prefixed to the entered text automatically.

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.

intV2 := ABS(intV1); Assignment statement

IF M1 THEN
btn01 := TRUE;
ELSE Conditional statement
btn01 := FALSE;
END_IF;

Output_ENO := ENEG(btn01,Input1); Calling a function

LadderFBInstance(Input1:=bool1,Input2:=bool2,Input3:=bool3); Calling a function block


(* user function block *)
A statement must end with ";" (semicolon).

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

Comments can be inserted in a program.

intV1 := 0;
(* Substitution *) Comment
intV2 := 2;

Constituent elements of a program


An ST program consists of the following elements.
Item Example Reference
Delimiter ;, ( ) Page 49 Delimiter
Operator +, -, <, >, = Page 49 Operator
Reserved word Syntax IF, CASE, WHILE, RETURN Page 50 Syntax
Device X0, Y10, M100 MELSEC iQ-F FX5 User's Manual (Application)
Data type BOOL, DWORD Page 32 Data Type
Function ADD, REAL_TO_STRING_E MELSEC iQ-F FX5 Programming Manual
(Instructions, Standard Functions/Function Blocks)
Constant 123, 'abc' Page 58 Constant
Label Switch_A Page 59 Label and device
Comment (* Turn ON *), //Turn ON, /*Turn ON*/ Page 60 Comment
Other symbols One-byte space, line feed code, tab code 

• Use one-byte delimiters, operators, and reserved words.


• For details of reserved words, refer to the following.
GX Works3 Operating Manual

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)

*1 WSTRING data type Unicode character string cannot be specified.


The following table shows the priorities of the operators.
Operator Description Example Priority
() Parenthesized expression (2+3)*(4+5) 1
Function ( ) Argument of a function CONCAR('AB','CD') 2
** Exponentiation 3.0**4 3
- Inversion of sign -10 4
NOT Bit type complement NOT TRUE
* Multiplication 10 * 20 5
/ Division 20 / 10
MOD Modulus operation 17 MOD 10
+ Addition 1.4 + 2.5 6
- Subtraction 3-2
<, >, <=, => Comparison 10 > 20 7
= Equality T#26h = T#1d2h 8
<> Inequality 8#15 <> 13
&, AND Logical AND TRUE AND FALSE 9
XOR Exclusive OR TRUE XOR FALSE 10
OR Logical OR TRUE OR FALSE 11

• 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

Write statements using half width characters.

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;

■Automatic conversion of data types


In the ST language, if a different data type is assigned or a different arithmetic operation is described, the data type may be
automatically converted.

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).

dintLabel1 := dintLabel2 + intLabel1;


// Arithmetic operation expression : Automatically convert the INT type variable (intLabel1) to a DINT type
variable, and perform DINT type addition.
Type conversion is performed in an assignment statement, input argument pass to a function block and function (VAR_INPUT
part), and an arithmetic operation.

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

Sub-program control statement


■Function block call statement
Format Description
Instance name(Input variable1:= Variable1, ... Output Enclose the assignment statement that assigns variables to the input variable and output
variable1: => Variable2, ...); variable by "( )" after the instance name.
When using multiple variables, delimit the assignment statement by "," (comma).
Instance name.Input variable1:= Variable1; List the assignment statement that assigns variables to the input variable and output variable
: before and after a function block call statement.
Instance name();
Variable2:= Instance name.Output variable1;

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).

Assigning to variables stores the execution result of the function.


Function Example
Calling a function with one input variable (Example: ABS)
Outout1 := ABS(Input1);
Calling a function with three input variables (Example:
Outout1 := MAX(Input1, Input2, Input3);
MAX)
Calling a function with EN/ENO (standard functions)
Output1 := MAX_E(boolEN, boolENO, Input1, Input2, Input3);
(Example: MAX_E)
Calling other than standard functions (Example: MOV)
boolENO := MOV(boolEN, Input1, Output1);
(The execution result of the function is ENO and the first argument (Variable1) is EN.)

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);

■When an assigned arithmetic operation is used


When an arithmetic operation result is assigned to a variable of the larger data type, convert the variable of the arithmetic
operation to the data type of the left side in advance and execute the operation.

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

IF bLabel1 THEN bLabel1


SET bLabel2
bLabel2 := TRUE;
END_IF;

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

IF bLabel1 THEN bLabel1 bLabel2


bLabel2 := TRUE;
ELSE
bLabel2 := FALSE;
END_IF;

*1 The above program can also be described as follows.


bLabel2 := bLabel1;
or
OUT(bLabel1,bLabel2);
However, when the OUT instruction is used in <Statement>, the program status becomes the same as the program whose bit type label
is always set to on.

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.

■When the FOR...DO statement is used


• Structure members and array elements cannot be used as repeat variables.
• Match the type used for a repeat variable with the types of <Last value expression> and <Incremental expression>.
• <Incremental expression> can be omitted. When omitted, <Incremental expression> is treated as 1 and executed.
• When 0 is assigned to <Incremental expression>, the statements after the FOR syntax may not be executed or the
processing goes into an infinite loop.
• In the FOR...DO syntax, the counting process of repeat variables is executed after the execution of <Statement> in the
FOR syntax. If the count is greater than the maximum value or smaller than the minimum value of the data type of the
repeat variable, the processing goes into an infinite loop.

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

Methods for expressing constants


The following table shows the expression methods for setting a constant in an ST program.
Data type Expressing method Example
String(32) STRING Enclose character string (ASCII, Shift JIS) with single quotation ( ' ). Stest := 'ABC';
String [Unicode](32) WSTRING Enclose a Unicode character string in double quotation marks ("). Stest := "ABC";

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)

■Device expression with type specification


A word device can be used in ST language as an arbitrary data type by adding a device type specifier to its name.
Device type specifier Data type Example Description
N/A Generic data type ANY16. D0 When no type specifier is added to D0
When only devices are used in arithmetic operations,
the data type is Word [signed].
However, when the data is specified as a device
without the type specification in the argument part of
FUN/FB, the data type is the one of the argument 6
definition.
:U Word [Unsigned]/Bit String [16-bit] D0:U The value when D0 is Word [unsigned]/Bit string [16-bit]
:D Double Word [Signed] D0:D The value when D0 and D1 are Double word [signed]
:UD Double Word [Unsigned]/Bit String [32-bit] D0:UD The value when D0 and D1 are Double word [unsigned]/Bit
string [32-bit]
:E FLOAT (Single Precision) D0:E The value when D0 and D1 are single-precision real
numbers

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)

■Device specification method


The following methods can be used for specifying a device.
• Indexing
• Bit specification
• Nibble specification
• Indirect specification
For details, refer to the following.
MELSEC iQ-F FX5 User's Manual (Application)
MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)

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.

Function (FUN) 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 (FB) 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)

■The data type of a constant unit


In the case of a constant unit, the data type of the constant value is not determined at the time when the constant value is
input. The data type is determined when the constant unit and an FBD unit are connected over a connecting wire. The data
type of the constant value is the same data type as the FBD unit at the destination of the connecting wire.

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)

■Automatic conversion of data types


The data type of an element may be automatically converted when it is connected to another element of a different data type.
To avoid the deletion of the data during the type conversion, only conversion from smaller type to larger type is performed.
Automatic conversion of data type in the FBD/LD language behaves in the same way as that in the ST language. For details,
refer to the following.
Page 50 Automatic conversion of data types

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

bLabel1 IN1 IN1 BOOL_OUT_DATA1

bLabel2 IN2 IN2

bLabel3 (1) Connect ENO and EN over a connecting wire.


■When the step relay (S) or SFC block device (BL) is used
If the step relay (S) or SFC block device (BL) is used as a variable element, a conversion error may occur. If an error occurs, 7
change the variable element to a contact element.

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

16 bit 32 bit 16 bit 16 bit

K4S0 D0: UD K4S0 D0

TRUE 32 bit TRUE 32 bit

DMOV DMOV
16 bit EN ENO 32 bit EN ENO

BL1\K4S10 S d D100 BL1\K8S10 S d D100: UD

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.

NO contact Turns on when a specified device or label is ON.

NC contact Turns on when a specified device or label is OFF.

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.

■The AND operation and OR operation of a contact symbol


A contact symbol executes an AND operation or an OR operation depending on the status of the connection of a circuit chart.
This is reflected in the operation result.
• In the case of a series connection (1), an AND operation is executed with the operation results so far. This will be the
operation result.
• In the case of a parallel connection (2), an OR operation is executed with the operation results so far. This will be the
operation result.
(1) Series connection contact

(2) Parallel connection contact

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.

Inline ST*1 An ST program is displayed in the FBD/LD editor.


By double-clicking an inserted inline ST element, the ST editor is displayed for editing or monitoring
an ST program.
For details, refer to the following. 7
Page 69 Inline ST

*1 These elements cannot be used in the Zoom editor of SFC programs.

■Precautions for a jump unit


• If the timer of a coil that is ON is jumped over by using a jump unit, a normal measurement cannot be conducted.
• You can add a jump label on the top side (the execution is earlier) of a jump unit. In this case, create the program by
including a method to break the loop in order not to exceed the setting value of the watchdog timer.
• You can specify only a local label of a pointer type for a jump element and jump label. The structure members cannot be
used.
• The pointer branch instruction (CJ) cannot be used. For jumping, use jump elements.
• Jumps to or from outside the program block cannot be executed. The following is a list of jump operations that cannot be
executed.
- Jumping to outside the program block*1
- Jumping from outside the program block*1
- Calling subroutine programs
- Called as subroutine programs
*1 Includes branches caused by the BREAK instruction.

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

Var6 Var7 Var8 Coil1


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 

Function Function Block

The return value is not


shown on a function.

The connecting point is hidden after connecting a wire.

■Inverting input and output points


You can invert an input to an unit or an output from an unit by using a connecting point.
The connecting point having been inverted is circled with a black circle. The data to be input or
output is inverted (FALSE to TRUE or TRUE to FALSE).
You can invert the following data types: BOOL, WORD, DWORD, ANY_BIT, and ANY_BOOL.

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

Methods for expressing constants


The following table shows the expression methods for setting a constant in FBD/LD language.
Data type Expressing method Example
String(32) STRING Enclose character string (ASCII, Shift JIS) with single
quotation ( ' ). 'ABC'
String [Unicode](32) WSTRING Enclose a Unicode character string in double quotation marks
("). "ABC"

For the expression methods other than the one described the above, refer to the following.
Page 39 Constant

Labels and devices

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)

■Device expression with type specification


A word device can be used as any data by adding a device type specifier to its name. If you do not specify a data type, the
word device operates as a word [signed] (INT).
For the device type specifiers and the devices you can use, refer to the following.
Page 59 Device expression with type specification
If you do not specify a data type for a word device, the data type is determined by the type of device.
Word device Data type
The current value of a timer device (TN), the current value of a retentive timer device (STN), the current value of a counter WORD
device (CN)
The current value of a long counter device (LCN) DWORD
Other than the above INT

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

• Program that does not use the inline ST

The inline ST cannot be used in the Zoom editor of SFC programs.

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

Var001 IN1 Var003


12 15
Var002 IN2
13
14

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

Always ON Drill rotation


SM400 Y22

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.

Station 1 Station 2 Station 3


control unit control unit control unit
Step transition
control unit for Transfer machine
overall process
Overall process (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)

Station 1 start Pallet clamping


(Block 1 start) (Step 1)

Station 2 start Hole making


Repeated
(Block 2 start) (Step 2)

Station 3 start Pallet unclamping


(Block 3 start) (Step 3)

End
(End step)
(End step)

Station 2 control unit


(Block 2)
Start
(Initial step)

Pallet clamping
(Step 1)

Tapping
(Step 2)
8
Pallet unclamping
(Step 3)

(End step)

Station 3 control unit


(Block 3)
Start
(Initial 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

*1 For the online change (SFC block), refer to the following.


Page 116 Online change (SFC block)
Before using the online change (SFC block), check the versions of the CPU module and the engineering tool used.
Page 126 Added and Changed Functions

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

Basic operation of SFC


An SFC program starts at an initial step, executes the next step every time the relevant transition becomes TRUE, and ends a
series of operations at an end step.
(1) Initial step
(2) Action
(1) (3) Transition
(2) (4) Normal step
(5) Normal step
(3) (6) End step

(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.

Block0 Block1 Block2

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

Normal step A basic step used to configure a block.


While this type of step is active, the transition following the
Step0 S1 N Action1 step is constantly checked, and when the transition becomes
TRUE, the next step becomes active.
The attributes of SC, R, BC, and BS can be added.
This step can also be used as a step without creation of an
action.
Step0 S1

End step A step that ends a block.


An action cannot be created.
EndStep

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)

When Y0 is turned on by using the SET instruction triggered by the action in


step (1), the ON state will be held even when the transition (3) becomes TRUE
and a transition to step (4) occurs.
When the PLS Even when the contact of the execution condition is
instruction or constantly on, the instruction is executed every time
ON
instructions the step using the instruction changes from inactive to
(2) PLS Y0
executed at the active.
rising edge is used (1)

Even when the contact of the execution condition is on (1), the PLS instruction
is executed every time the step (2) becomes active.

■Step without action


A step without an action can also be used as a waiting step.
• While a step is active, the transition is always checked and, when the transition becomes TRUE, the next step becomes
active.
• This type of step works as a normal step if an action is added to it.

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.

■Active steps at block START


When multi-initial steps are used, the active steps change depending on the starting method as described below.
Operation of active step Method
All initial steps become active. When a start is made using the block start step
When a start is made using the block START instruction of the SFC control instructions
When block 0 is started using the auto-start setting of block 0
Only the specified step is activated. When any of the initial steps is specified using the step control instruction of the SFC control instructions

■Operation of the initial steps with step attributes


The attribute of SC (coil HOLD step) or R (reset step) can be added to the initial step. When the attribute is added, the
operations other than the operation that will be automatically activated at the start of the block are the same as those in other
steps. This step can also be used without an action.

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 state
transitions.
Y10 (1) that has been turned on by the OUT instruction is not turned off and
remains on (3) even when the transition (2) becomes TRUE.
Y10
SC
ON ON
(2) (1)

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.

■Timing of when coil output turns off


The coil output holding ON state is turned off in the coil HOLD step [SC] after transition when:
• The end step of a block is executed (other than the case where SM327 is on).
• A block is forcibly terminated by the SFC control instruction (Ending a block).
• A step is reset by using the SFC control instruction (Ending a step).
• A reset step [R] for resetting the coil HOLD step [SC] becomes active.
• SM321 (Start/stop SFC program) is turned off.
• The coil is reset by the program.
• S999 is specified at a reset step [R] within a block.

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.

Operation HOLD step (with transition check) [ST] 8


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.
Even after the transition becomes TRUE and the next step is activated, the transition is checked repeatedly. When the
transition becomes TRUE again, the operation in the action is continued while activating the next step again.
When step (2) is activated, step (1) holds the operation.
The action (3) is kept executed the same as a normal active step while
X0 Y10
the step holds the operation.
(1) (3)
In this case, Y10 turns on or off accordingly as X0 turns on or off.
The transition is also checked and, when the transition becomes TRUE,
the next step becomes active.
(2)

■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.

Reset step [R]


Reset step [R] is a step that deactivates the specified step.
• The reset step [R] deactivates the specified step in the current block before executing the output of every scan. Except for
resetting the specified step, the reset step is the same as a normal step (without step attributes).
• The step No. of the coil HOLD step [SC, SE, ST] or S999 can be specified as specified step No.
• When the specified step No. is S999, the HOLD steps [SC, SE, ST] that hold operations in the current block are all
deactivated. In this case, only the HOLD steps [SC, SE, ST] that hold operations can be deactivated. However, any
operation HOLD step [SE, ST] is not deactivated when operating with the state that does not hold an operation.
• The current step No. cannot be specified as specified step No.

Block start step (with END check) [BC]


A step that activates the specified block.
When the specified block becomes inactive and the transition becomes TRUE, the active state transitions to the next step.
When this step is activated, the block start step (with END check) [BC] starts
BL1 block (BL1).
No processing is performed until the execution of the start destination block
(BL1) ends and becomes inactive and the transition (2) is not checked.
When the execution of block (BL1) ends and becomes inactive, only the
(1) transition (2) check is performed and, when the transition (2) becomes TRUE,
the transition to the next step occurs.

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].

Block start step (without END check) [BS]


Block start step (without END check) [BS] is a step that activates the specified block.
When the transition becomes TRUE, the active state transitions to the next step.
After this step starts block (BL1), only the transition (2)
BL1 is checked and, when the transition becomes TRUE,
execution proceeds to the next step without waiting for
the start destination block to end.

(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.

• The following shows how to restart the block once ended.


Item Description
Block 0 "Start Conditions Setting" is set to "Auto-start The initial step is automatically activated again and processing is executed repeatedly.
block 0" in the SFC Setting of parameters.
"Start Conditions Setting" is set to "Do not auto- The block is restarted when a start request is issued for the specified block in the following
start block 0" in the SFC Setting of parameters. methods.
• The block start step is activated by another block.
All blocks other than block 0
• The SFC control instruction (Starting a block) is executed.

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.

Multiple end steps can be created in the SFC diagram.


To do so, select a step in the selection branch and select [Edit]  [Modify]  [End Step/Jump] from the menu.

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

b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0


S31 to S16 0 0 0 0 0 0 0 0 0 0 (1)
S12 S11 S10 S9 S8 S7 (2)

(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.

Step No. 0 is assigned to the initial step in a block.


For the step Nos. that can be used per block, refer to the following.
Page 74 Specifications
Any step No. exceeding the upper limit cannot be assigned. Any step No. must be unique within a block. Same step Nos. can
be used in different blocks.
To specify a step relay in another block, use the following format.

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

MOV wLabel3 wLabel4


Transition1 (2)
TR1

Step2 S2 N M20
(4)
N bLabel5

(1) Action name


(2) Qualifier*1
(3) Detailed expression of the action
(4) Action label/device
*1 N indicates that the action is executed while a step is active. Nothing but N can be set.
When the step becomes active, the action is executed every scan. When the step becomes inactive, the action is ended and
not executed until next time the step becomes active.
Up to 4 actions can be created in one step. When multiple actions are created, they will be executed in order from the top.
The detailed expression of actions can be created in ladder, ST or FBD/LD language.

For details on detailed expression or labels/devices, refer to the following.


GX Works3 Operating Manual 8

Instructions that cannot be used


Some instructions cannot be used in actions. The following table lists the instructions that cannot be used.
Classification Instruction symbol
Master control instruction MC*1
MCR*1
Termination instruction FEND
END
Program branch instruction CJ*1
GOEND
Program execution control instruction IRET
Structure creation instruction BREAK*1
RET
SRET
Creating a dummy transition condition TRAN
Step ladder instruction STL
RETSTL
Initial state IST

*1 This instruction can be used in a function or a function block in the action.

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

(4) Step1 S1 (2)

bLabel1

TR1

Step2 S2

M100 (5)
TR2

(1) Transition name


(2) Transition No.
(3) Detailed expression of transition (Page 95 Detailed expression of transitions)
(4) Direct expression of transitions (Page 96 Direct expression of transitions)
(5) Transition label/device (Page 96 Transition label/device)

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)

Selective sequence (divergence/convergence)


A step branches to multiple transitions, and only the step in the line where the transition becomes TRUE first is activated. The
next step is activated when the transition immediately before convergence, which is in the line where the transition becomes
TRUE first, becomes TRUE.
Item Description
Divergence When the step (1) is active, the step whose transition becomes TRUE first is
activated. (When the transition (3) becomes TRUE before (2) becomes TRUE,
the step (5) is activated.)
(1)
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.
(2) (3) • If multiple transitions become TRUE simultaneously, the condition to the left
will take precedence.
• Subsequent processing will proceed from step to step in the selected column
(4) (5)
until another convergence occurs.

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)

• The selective sequence allows branching to up to 32 transitions.


• If multiple transitions become TRUE simultaneously, the condition to the left will take precedence.
If transition (1) and (2) become TRUE simultaneously, the action of step (3) will
be executed.

(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

Simultaneous sequence (divergence/convergence)


All the steps branched from one step are activated simultaneously. When all the steps immediately before convergence are
activated and the common transition becomes TRUE, the active state transitions to the next step.
Item Description
Divergence When the transition (2) becomes TRUE while the step (1) is active, both of the
step (3) and step (4) are activated at the same time.
The step (1) becomes inactive. However, if it is a coil HOLD step [SC], the step
(1)
holds the coil output or action according to its attribute.
Processing will proceed to step (7) when the transition (5) becomes TRUE and
(2) to step (8) when the transition (6) becomes TRUE.

(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)

• There are no restrictions regarding the number of jump sequences.


• A jump sequence in the simultaneous sequence is possible only in the same branch. A jump sequence to another branch
within a simultaneous branch, a jump sequence for exiting from a simultaneous branch, or a jump sequence to a
simultaneous branch from outside a simultaneous branch cannot be created.
8
Ex.
Example of jump sequence that can be specified in the simultaneous branch

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)

(1) A simultaneous convergence cannot be performed.

■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

bLabel1 M100 TRUE

TR1 TR2 TR3

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
SZ Step relay
BL\SZ Step of step relay with block specification
BLZ\S Block of step relay with block specification
BLZ\SZ Block and step of step relay with block specification
BLZ 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

For details on index modification, refer to the following.


MELSEC iQ-F FX5 User's Manual (Application)

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

SFC program setting


Set whether to use the SFC program. If the parameter is set to "Not use," other SFC settings cannot be operated.
[CPU Parameter]  [SFC Setting]  [SFC Program Setting]

Window

Displayed items
Setting Description
Not to Use (default) SFC program is not used.
Use*1 SFC program is used.

*1 When the program language of a project is SFC, the default is "Use."


The following tables list the operation which changes according to the SFC program setting and operation depending on the
setting of the SFC program setting.

■Operation which changes according to the setting


Operation Description
SFC program execution The SFC program can be executed only when "SFC Program Setting" is set to "Use".
Specifying the step relay (S) to the When "SFC Program Setting" is set to "Use", the step relay (S) cannot be specified to the instructions other than the
instruction SFC control instruction.

■Operation depending on the setting


SFC Program Setting SFC program execution Specifying the step relay (S) to the instruction
Not to use Not supported*1 No restrictions
Use Supported Can be specified only to the SFC control instruction.*2

*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 Applicable only to FX5U/FX5UC CPU module.


The combination of SFC Program Start Mode Setting and SM322 (SFC program startup status) determines whether to
perform Initial Start or Resume Start.
Operation SFC Program Start Mode Setting: Initial Start SFC Program Start Mode Setting: Resume
Start
SM322: OFF SM322: ON SM322: ON SM322: OFF
(Initial status)*1 (When the setting is (Initial status)*1 (When the setting is
changed) changed)
(1) SM321 is turned off and on. Initial Start Initial start*3 Resume Start Initial Start
(2) The CPU module is powered off Initial Start (M322 is turned Resume Start/Initial Resume Start/Initial
and on. off, and the program is Start*4*6 Start*5*5
initialized.)
(3) SM321 is turned on and off, or the Resume Start*6 Resume Start*5
CPU module is powered off and
on after the operating status is
changed from RUN to STOP.
(4) CPU module is reset and the Resume Start/Initial Resume Start/Initial
operating status is changed to Start*4*6 Start*4*5
RUN.
(5) SM321 is turned on and off, or Resume Start*6 Resume Start*5
CPU module is reset and the
operating status is changed to
RUN after RUN to STOP.
(6) Operating status is changed from Resume Start
STOP to RUN.
(7) Operating status is STOP, write a Initial Start Resume Start Initial Start
program (other than the SFC
program), and the status is
changed to RUN.
(8) Operating status is STOP, write a Initial Start*2
program (SFC program), and the
status is changed to RUN.

*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.

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. 8
[CPU Parameter]  [SFC Setting]  [Start Conditions Setting]

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.

■Operation when the block is paused or restarted


Operation when the block is paused or restart depends on the combination of the SM325 (Output mode at block stop) status,
block stop mode bit setting of the SFC information device, and step hold status.
The following table lists the operations at block PAUSE/RESTART.
Output mode setting at Operation
block stop Active step other than Step that holds operation
step that holds Coil HOLD step [SC] Operation HOLD step Operation HOLD step
operation*1 (without transition (with transition check)
check) [SE] [ST]
SM325=OFF Immediately after a stop Immediately after a stop Immediately after a stop request is made, the coil output of
(coil output OFF) request is made, the coil request is made, the coil the action is turned off and the block is stopped. The status
output of the action is turned output of the action is turned remains active.
off and the block is stopped. off and the block is
The status remains active. deactivated.
SM325=ON Immediately after a stop Immediately after a stop request is made, the block is stopped with the coil output of the action
(coil output held) request is made, the block is being held. The status remains active.
stopped with the coil output
of the action being held. The
status remains active.
At restart Returns to normal operation. Coil output is off: Becomes Restarts the execution of the In the hold status, the action
inactive and restart is action in a HOLD status. is restarted and the transition
disabled is also checked.
Coil output is held: Restarts
with the hold state

*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

FX3 compatible transition operation mode setting


This setting is designed to operate the SFC program in the same manner as on FX3. Use this setting to maintain the
compatibility with FX3 when the configuration of FX3 used on the user’s equipment is replaced with the configuration of FX5. 8
[CPU Parameter]  [SFC Setting]  [FX3 Compatible Transition Operation Mode Setting]

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

Act at block Multi-Activated


Set this item to stop the operation of the CPU module when a start request for an already active block is issued in the block
start step (with end check) [BC] or block start step (without end check) [BS]. For the setting range, set the range of the block
to be stopped.
[Navigation window]  [Program]  Properties of SFC program file to be set

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

Execution type that can be specified


This section shows whether the execution type of SFC program can be specified.

CPU module
RUN Type that can be specified as
an SFC program

Initial execution
type program

Execute only when required.


Scan execution Stand-by type
type program program

Event execution
Execute using an type program
interrupt. 8

Fixed scan
execution type
program

Execution Type Specification Remarks


enable/disable
Initial execution type program  
Scan execution type program  Only one SFC program can be executed.
Stand-by type program  
Event execution type program  
Fixed scan execution type program  
No specification  

■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

Block execution sequence


While the SFC program is running, the actions of each step are executed sequentially starting from the initial step of an active
block.
An SFC program containing multiple blocks checks the state (active/inactive) of the blocks in ascending order of block
numbers (block 0  block 1  block 2).
An active block executes the actions of active steps in the block.
An inactive block checks for existence of a start request. If a start request exists, the block is activated and the active steps in
the block are executed.
Processing is performed in the following order.
(1) (3) (5) (1) Processing of block 0 (BL0)
BL0 BL1 (2) Execution of the step in block 0 (BL0)
(3) Processing of block 1 (BL1)
(4)
(4) Execution of the initial step of block 1 (BL1)
(5) Processing of the next block

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
STOPRUN (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)

• Without continuous transition

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.

• With continuous transition (operation compatible with FX3)

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)

Auto-start by the CPU parameter


Set "Start Conditions Setting" to "Auto-start block 0," in the CPU parameter. Block 0 of the SFC program starts automatically
when the CPU module is powered on or reset, or the operating status is changed from STOP to RUN. (Page 101 Start
Conditions Setting)

Starting and stopping the program by the special relay (SM321)


SM321 (Start/stop SFC program) automatically turns on at execution of the SFC program.
• The program execution can be stopped by turning off SM321.
• The terminated SFC program can be re-executed by turning on 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 and ending a block

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 and deactivating a step

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)

(2) (3) (4) (5)

■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    

*1 For the online change (SFC block), refer to the following.


Page 116 Online change (SFC block)
Before using the online change (SFC block), check the versions of the CPU module and the engineering tool used.
Page 126 Added and Changed Functions

When data is written to the programmable controller 8


Shown here is the operation when an SFC program is modified by writing data to the programmable controller.
SM322 (SFC program startup status) Program modification status
Modified Not modified
OFF (Initial start) Initial start Initial start
ON (Resumption) Initial start Resumption

■When the operating status is changed from STOP to RUN


If the CPU module is stopped during execution (running) of an SFC program, the device state and the SFC program active/
inactive state will be restored to the state immediately before the stop when the CPU module status is changed from STOP to
RUN. The program will start in the Resume Start mode regardless of the CPU parameter setting "SFC Program Start Mode
Setting."
If the sequence program file (including an SFC program) or the FB file is written to the CPU module while it is in the STOP
status, the SFC program will start in the Initial Start mode if the SFC program exists when the operating status is changed
back to RUN. Note that it may start in the Resume Start mode if there are no changes before and after writing of the SFC
program. (Page 100 SFC Program Start Mode Setting)

■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.

Online change (SFC block)


An SFC program can be changed in units of blocks. Since an SFC program can be changed online in units of blocks with the
active state held, efficiency of debugging and maintenance of SFC programs will be improved.
Before change After change

Initial N Action 0 Initial N Action 0

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

Block 100 End step Block 100 End step

Block 200 Initial N Action 0 Block 200 Initial N Action 0

Transition 0 Transition 0

Block 319 Step 0 N Action 1 Block 319 Step 0 N Action 1

Transition 1 Transition 1

End step End step

Inactive block or step


Active block or step

(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

■Available execution type


The online change (inactive SFC block) can be executed to a scan execution type program. (cannot be executed to a standby
type program)

■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.

■Checking execution status


Execution status of the online change (SFC block) can be checked in SM329 (Online change (SFC block) status flag) and
SD329 (Online change (SFC block) target block number). (MELSEC iQ-F FX5 User's Manual (Application)) 8
■Online change (SFC block) during the boot operation
When the online change (SFC block) is executed while booting from an SD memory card, the corresponding files on the
booting SD memory card can also be changed.

■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

*1 Instructions specified in the coil side apply.

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

■When "Yes" is selected for "Use MC/MCR to Control EN"


When EN is turned on, the instruction is executed if the condition contact is TRUE ((1) in the following figure).

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)

■When "No" is selected for "Use MC/MCR to Control EN"


When EN is turned off, operations of the instruction differ depending on the condition contact status ((1) in the following
figure).

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

■When "Yes" is selected for "Use MC/MCR to Control EN"


The count value becomes 0 ((1) in the following figure). The coil turns off ((2) in the following figure).

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)

■When "No" is selected for "Use MC/MCR to Control EN" A


The current count value and the current state of the coil remain unchanged. ((1) in the following figure).

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

■When "Yes" is selected for "Use MC/MCR to Control EN"


The current count value remain unchanged. ((1) in the following figure). The coil turns off ((2) in the following figure).

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)

■When "No" is selected for "Use MC/MCR to Control EN"


The current count value and the current state of the coil remain unchanged. ((1) in the following figure).

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

■When "Yes" is selected for "Use MC/MCR to Control EN"


M0 is forcibly turned off ((1) in the following figure).

Sc

Ò
EN

M0
Ó

(1)

Sc: Scan
 EN is turned off. (User operation)
 The coil turns off. (CPU module operation)

■When "No" is selected for "Use MC/MCR to Control EN"


The current state of M0 remains unchanged ((1) in the following figure).

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.

FX5S CPU module


Add/Change Function Supported CPU module Supported engineering tool Reference
firmware version software version
Applicable to FX5S CPU module From the first "1.080J" or later 
• Ladder diagram
• Structured text language
• FBD/LD language
Unicode character strings are From the first "1.080J" or later 
supported.
Applicable to SFC program "1.010" or later "1.095Z" or later Page 71 SFC PROGRAM

FX5UJ CPU module


Add/Change Function Supported CPU module Supported engineering tool Reference
firmware version software version
Applicable to FX5UJ CPU module From the first 1.060N and above 
• Ladder diagram
• Structured text language
• FBD/LD language
Unicode character strings are "1.030" or later "1.085P" or later 
supported.
Applicable to SFC program "1.050" or later "1.095Z" or later Page 71 SFC PROGRAM

FX5U/FX5UC CPU module


Add/Change Function Supported CPU module Supported engineering tool Reference
firmware version software version
Applicable to FX5U/FX5UC CPU From the first From the first 
module
• Ladder diagram
• Structured text language
• FBD/LD language
Applicable to SFC program "1.220" or later "1.070Y" or later Page 71 SFC PROGRAM
Unicode character strings are "1.240" or later "1.075D" or later 
supported.
Online change (SFC block) is "1.290" or later "1.095Z" or later Page 116 Online change (SFC
supported. block)
SE and ST are added to the step "1.290" or later "1.095Z" or later Page 78 Step attributes
attribute.

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

Japanese manual number: JY997D54601-L


This manual confers no industrial property rights or any rights of any other kind, nor does it confer any patent licenses. Mitsubishi Electric Corporation cannot
be held responsible for any problems involving industrial property rights which may occur as a result of using the contents noted in this manual.

© 2014 MITSUBISHI ELECTRIC CORPORATION

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.

Specifications subject to change without notice.

You might also like