GX Works2 Version 1 Operating Manual (Simple Project, Function Block)
GX Works2 Version 1 Operating Manual (Simple Project, Function Block)
GX Works2 Version 1 Operating Manual (Simple Project, Function Block)
Operating Manual
(Simple Project, Function Block)
-SW1DND-GXW2-E
-SW1DNC-GXW2-E
SAFETY PRECAUTIONS
(Always read these instructions before using this product.)
Before using this product, thoroughly read this manual and the relevant manuals introduced in this manual
and pay careful attention to safety and handle the products properly.
The precautions given in this manual are concerned with this product. For the safety precautions of the
programmable controller system, refer to the User's Manual for the CPU module.
In this manual, the safety precautions are ranked as " WARNING" and " CAUTION".
Note that the CAUTION level may lead to serious consequences according to the circumstances.
Always follow the precautions of both levels because they are important for personal safety.
Please save this manual to make it accessible when required and always forward it to the end user.
[Design Instructions]
WARNING
● When data change, program change, or status control is performed from a personal computer to a running
programmable controller, create an interlock circuit outside the programmable controller to ensure that the whole
system always operates safely.
Furthermore, for the online operations performed from a personal computer to a programmable controller CPU, the
corrective actions against a communication error due to such as a cable connection fault should be predetermined as
a system.
● To maintain the safety of the programmable controller system against unauthorized access from external devices
via the network, take appropriate measures.
To maintain the safety against unauthorized access via the Internet, take measures such as installing a firewall.
[Startup/Maintenance Instructions]
CAUTION
● The online operations performed from a personal computer to a running programmable controller CPU (Program
change when a programmable controller CPU is RUN, operating status changes such as forced input/output
operation and RUN-STOP switching, and remote control operation) must be executed after the manual has been
carefully read and the safety has been ensured.
When changing a program while a programmable controller CPU is RUN, it may cause a program corruption in some
operating conditions. Fully understand the precautions described in Section 12.9 before use.
● The positioning test functions of OPR, JOG, inching or positioning data for QD75/LD75 positioning module must be
executed with the programmable controller set to STOP after the manual has been carefully read and the safety has
been ensured. Specially when executing the function on the network system, ensure the safety thoroughly since the
machinery whose operation cannot be checked by an operator may be activated. The operation failure may cause the
injury or machine damage.
A-1
CONDITIONS OF USE FOR THE PRODUCT
(1) Mitsubishi programmable controller ("the PRODUCT") shall be used in conditions;
i) where any problem, fault or failure occurring in the PRODUCT, if any, shall not lead to any major or
serious accident; and
ii) where the backup and fail-safe function are systematically or automatically provided outside of the
PRODUCT for the case of any problem, fault or failure occurring in the PRODUCT.
(2) The PRODUCT has been designed and manufactured for the purpose of being used in general
industries.
MITSUBISHI SHALL HAVE NO RESPONSIBILITY OR LIABILITY (INCLUDING, BUT NOT LIMITED
TO ANY AND ALL RESPONSIBILITY OR LIABILITY BASED ON CONTRACT, WARRANTY, TORT,
PRODUCT LIABILITY) FOR ANY INJURY OR DEATH TO PERSONS OR LOSS OR DAMAGE TO
PROPERTY CAUSED BY the PRODUCT THAT ARE OPERATED OR USED IN APPLICATION NOT
INTENDED OR EXCLUDED BY INSTRUCTIONS, PRECAUTIONS, OR WARNING CONTAINED IN
MITSUBISHI'S USER, INSTRUCTION AND/OR SAFETY MANUALS, TECHNICAL BULLETINS AND
GUIDELINES FOR the PRODUCT.
("Prohibited Application")
Prohibited Applications include, but not limited to, the use of the PRODUCT in;
• Nuclear Power Plants and any other power plants operated by Power companies, and/or any other
cases in which the public could be affected if any problem or fault occurs in the PRODUCT.
• Railway companies or Public service purposes, and/or any other cases in which establishment of a
special quality assurance system is required by the Purchaser or End User.
• Aircraft or Aerospace, Medical applications, Train equipment, transport equipment such as Elevator
and Escalator, Incineration and Fuel devices, Vehicles, Manned transportation, Equipment for
Recreation and Amusement, and Safety devices, handling of Nuclear or Hazardous Materials or
Chemicals, Mining and Drilling, and/or other applications where there is a significant risk of injury to
the public or property.
Notwithstanding the above, restrictions Mitsubishi may in its sole discretion, authorize use of the
PRODUCT in one or more of the Prohibited Applications, provided that the usage of the PRODUCT is
limited only for the specific applications agreed to by Mitsubishi and provided further that no special
quality assurance or fail-safe, redundant or other safety features which exceed the general
specifications of the PRODUCTs are required. For details, please contact the Mitsubishi representative
in your region.
A-2
REVISIONS
Print date Manual number*1 Revision
Nov. 2011 SH(NA)-080984ENG-A First edition
Jan. 2012 SH(NA)-080984ENG-B Model Addition
FX3GC
Correction
Section 4.1
May 2012 SH(NA)-080984ENG-C Model Addition
Q02PH, Q06PH, Q12PH, Q12PRH, Q25PH, Q25PRH
Correction
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL, Section 1.5.1, Section 2.3.4,
Section 3.1.1, Appendix 3
Sept. 2012 SH(NA)-080984ENG-D Correction
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL, Section 2.6, Section 3.1.4,
Appendix 2
Feb. 2013 SH(NA)-080984ENG-E Model Addition
Q03UDV, Q04UDV, Q06UDV, Q13UDV, Q26UDV, L02S, L06, L26
Addition
Section 4.2.1
Correction
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL, TERMS, Section 1.5.1,
Section 2.3.3, Section 2.6, Section 3.1.1, Section 3.1.2, Section 4.2.2, Section 5.2,
Appendix 2
Modification
Section 4.2 → Section 4.2.2
May 2013 SH(NA)-080984ENG-F Model Addition
L02S-P, L06-P, L26-P, FX3S
Correction
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL, Section 2.3.3, Appendix 2
Sept. 2013 SH(NA)-080984ENG-G Addition
Section 4.2.1, Section 4.2.2
Correction
TERMS, Section 4.2.3
Modification
Section 4.2.1 → Section 4.2.3, Section 4.2.2 → Section 4.3,
Section 4.3 to Section 4.6 → Section 4.4 to Section 4.7
Dec. 2013 SH(NA)-080984ENG-H Correction
Section 2.1
Mar. 2014 SH(NA)-080984ENG-I Correction
Section 2.6, Appendix 3
Jun. 2014 SH(NA)-080984ENG-J Correction
Section 4.2.1, Section 4.2.2, Section 4.2.3, Appendix 3
Sept. 2014 SH(NA)-080984ENG-K Correction
Section 5.3
Mar. 2015 SH(NA)-080984ENG-L Correction
Section 4.4
Jan. 2018 SH(NA)-080984ENG-M Correction
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL
A-3
Print date Manual number*1 Revision
Jun. 2018 SH(NA)-080984ENG-N Correction
SAFETY PRECAUTIONS, Section 4.2.3
*1 : The manual number is written at the bottom left of the back cover.
Japanese Manual Version SH-080983-P
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.
A-4
INTRODUCTION
CONTENTS
SAFETY PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A - 1
CONDITIONS OF USE FOR THE PRODUCT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A - 2
REVISIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A - 3
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A - 5
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A - 5
MANUALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A - 8
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL . . . . . . . . . . . . . . . . . . . . . . . . . A - 16
TERMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A - 17
A-5
3 USING FUNCTION BLOCKS
5 USING FB LIBRARIES
APPENDIX
Appendix 1 Character Strings that cannot be Used for Label Names and FB Data Names/Instance
Names App - 2
A-6
Appendix 2 Supported CPU modules App - 5
INDEX
A-7
■ MANUALS
Related manuals are separately issued according to the purpose of their functions in GX Works2.
● Related manuals
The manuals related to this product are shown below.
Refer to the following tables when ordering required manuals.
1) Operation of GX Works2
Manual number
Manual name
(Model code)
GX Works2 Version 1 Operating Manual (Common)
Explains the system configuration of GX Works2 and the functions common to Simple project and SH-080779ENG
Structured project such as parameter setting, operation method for the online function. (13JU63)
(Sold separately)
GX Works2 Version 1 Operating Manual (Simple Project)
SH-080780ENG
Explains methods for such as creating and monitoring programs in Simple project of GX Works2.
(13JU64)
(Sold separately)
GX Works2 Version 1 Operating Manual (Structured Project)
SH-080781ENG
Explains methods for such as creating and monitoring programs in Structured project of GX Works2.
(13JU65)
(Sold separately)
GX Works2 Version 1 Operating Manual (Intelligent Function Module)
SH-080921ENG
Explains methods of intelligent function module for such as parameter setting, monitoring programs,
(13JU69)
and predefined protocol support function in GX Works2. (Sold separately)
GX Works2 Beginner's Manual (Simple Project)
SH-080787ENG
Explains fundamental methods for such as creating, editing, and monitoring programs in Simple project
(13JZ22)
for users inexperienced with GX Works2. (Sold separately)
GX Works2 Beginner's Manual (Structured project)
SH-080788ENG
Explains fundamental methods for such as creating, editing, and monitoring programs in Structured
(13JZ23)
project for users inexperienced with GX Works2. (Sold separately)
2) Structured Programming
Manual number
Manual name
(Model code)
MELSEC-Q/L/F Structured Programming Manual (Fundamentals)
SH-080782ENG
Explains the programming methods, types of programming languages, and other information required
(13JW06)
to create structured programs. (Sold separately)
MELSEC-Q/L/F Structured Programming Manual (Common Instructions)
SH-080783ENG
Explains the specifications and functions of common instructions such as sequence instructions, basic
(13JW07)
instructions, and application instructions, that can be used in structured programs. (Sold separately)
MELSEC-Q/L Structured Programming Manual (Application Functions)
SH-080784ENG
Explains the specifications and functions of application functions that can be used in structured
(13JW08)
programs. (Sold separately)
MELSEC-Q/L Structured Programming Manual (Special Instructions)
Explains the specifications and functions of special instructions such as module dedicated instruction, SH-080785ENG
PID control instruction, and built-in I/O function dedicated instruction, that can be used in structured (13JW09)
programs. (Sold separately)
FXCPU Structured Programming Manual (Device & Common)
JY997D26001
Explains the devices and parameters provided in GX Works2 for structured programming.
(09R925)
(Sold separately)
FXCPU Structured Programming Manual (Basic & Applied Instruction)
JY997D34701
Explains the sequence instructions provided in GX Works2 for structured programming.
(09R926)
(Sold separately)
FXCPU Structured Programming Manual (Application Functions)
JY997D34801
Explains the application functions provided in GX Works2 for structured programming.
(09R927)
(Sold separately)
A-8
3) Operation of iQ Works
Manual number
Manual name
(Model code)
Let's start iQ Works Version 2
SH-081261ENG
Explains fundamental methods for such as managing the system using MELSOFT Navigator and using
(13JZ79)
system labels for users inexperienced with GX Works2. (Sold separately)
The Operating Manuals are included on the DVD-ROM and CD-ROM of the software package in a PDF file format.
Manuals in printed form are sold separately for single purchase. Order a manual by quoting the manual number (model
code) listed in the table above.
A-9
● Purpose of this manual
This manual explains the operations for creating sequence programs with function blocks (FB) in
Simple project using the functions supported by GX Works2.
Manuals for reference are listed in the following table according to their purpose.
For information such as the content and number of each manual, refer to the list of 'Related manuals'.
1) Installation of GX Works2 and the USB driver
GX Works2 Version 1
Purpose GX Works2 Installation Instructions Operating Manual
Common
Learning the operating
environment and installation Details
method
2) Operation of GX Works2
GX Works2 Beginner's GX Works2 Version 1
Manual Operating Manual
Purpose Simple Project Intelligent
Simple Structured Structured
Common Function Function
Project Project Project
Block Module
A - 10
3) Operations in each programming language
For details of instructions used in each programming language, refer to the section 4 and
the section 5 on the following pages.
GX Works2 Version 1
GX Works2 Beginner's Manual
Operating Manual
Purpose
Simple Structured Simple Structured
Project Project Project Project
Ladder Outline
Details
Diagram
*1
Simple Sequential
Outline Details
Project Function Chart
Outline
Structured Text Details
Ladder Outline
Details
Diagram
*1
Sequential
Outline Details
Function Chart
Structured
project
Structured Ladder Outline
Details
/FBD
Outline
Structured Text Details
A - 11
4) Details of instructions in each programming language (for QCPU (Q mode)/LCPU)
MELSEC-Q/L/F Manual
MELSEC-Q/L MELSEC-Q/L for
Structured MELSEC-Q/L/QnA
Structured Programming Programming module
Programming Programming Manual to be
Purpose Manual Manual
Manual used
Common Special Application Common PID Control
Fundamentals SFC -
Instructions Instructions Functions Instruction Instructions
Learning details
of programmable
controller CPU
All
error codes, Details
languages
special relays,
and special
registers
Learning the
types and details
Details
of common
instructions
Learning the
types and details
of instructions for Details
intelligent
Using function modules
Ladder
Diagram Learning the
types and details
Details
of instructions for
network modules
Learning the
types and details
of instructions for Details
the PID control
function
Learning details
Using
of specifications,
Sequential
functions, and Details
Function
instructions of
Chart
SFC (MELSAP3)
Learning the
fundamentals for
creating a Details
structured
program
Learning the
types and details
Details
of common
instructions
Learning the
types and details
Using of instructions for Outline Details
Structured intelligent
Ladder/ function modules
FBD or
Structured Learning the
Text types and details
Outline Details
of instructions for
network modules
Learning the
types and details
of instructions for Outline Details
the PID control
function
Learning the
types and details
Details
of application
instructions
A - 12
5) Details of instructions in each programming language (for FXCPU)
MELSEC-Q/L/F
FXCPU FXCPU
Structured
Structured Programming Programming
Programming
Manual Manual
Purpose Manual
FX0, FX0S, FX1S, FX1N, FX3S,
Device & Sequence Application
Fundamentals FX0N, FX1, FX2N, FX1NC, FX3G,FX3U,
Common Instructions Functions
FXU, FX2C FX2NC FX3GC,FX3UC
Learning the
types and details
of basic/
Using
application
Ladder Details Details Details
instructions,
Diagram
descriptions of
devices and
parameters
Learning details
Using
of specifications,
Sequential
functions, and Details Details Details
Function
instructions of
Chart
SFC
Learning the
fundamentals for
creating a Details
structured
program
Learning the
Using descriptions of
Structured devices, Details
A - 13
● How to read this manual
Screen display
Chapter heading
Section title
Operating procedure
Reference location
A - 14
This manual also uses the following columns:
This explains notes requiring attention or useful functions relating to the information given on the
same page.
1
2
3
4
A - 15
■ GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL
The following are the generic terms/abbreviations of such as software packages and programmable
controller CPUs used in this manual.
A - 16
■ TERMS
Term Description
An actual device assigned to label after compiling a project with labels,
Actual device
or a device that is not described using a label
Generic term for sequence instructions, basic instructions, application instructions, data link
Common instruction instructions, multiple CPU dedicated instructions, and multiple CPU high-speed transmission
dedicated instructions
Generic term for module dedicated instructions, PID control instructions, socket communication
Special instruction
function instructions, built-in I/O function instructions, and data logging function instructions
Generic term for projects created using Ladder Diagram, Sequential Function Chart, Structured
Simple Project
Text
Without labels Generic term for projects created without selecting "Use Label" when creating new projects
With labels Generic term for projects created with selecting "Use Label" when creating new projects
Project without labels Generic term for Simple projects that do not use labels
Project with labels Generic term for Simple projects that use labels and Structured projects
Project with security Generic term for projects whose securities are set
Utilization To paste FB to a sequence program
Reuse To use FB to other project
Library (project) A project to be used as an FB library
FB instance An FB pasted to a sequence program
A label which becomes effective for all program data when multiple program data items are created
Global label
in a project
A label which becomes effective only for each program data
Local label
Set for each program data.
A data type which allows various device types (bit device, word device, etc.) to be stored in single
Structure
aggregate (single data)
Array A data type which allows the same device type to be stored in a consecutive area
A - 17
MEMO
A - 18
1
OVERVIEW OF
FUNCTION
BLOCKS
1 OVERVIEW OF 2
FUNCTION BLOCKS
CREATING
FUNCTION
BLOCKS
This chapter explains features of FBs, overview of labels, and work flow for using FBs.
USING FUNCTION
BLOCKS
4
1.1 Function Blocks (FBs) 1-2
EDITING FUNCTION
MANAGING AND
1.2 Features of FBs 1-3
BLOCKS
1.3 Labels 1-4
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
1-1
1 OVERVIEW OF FUNCTION BLOCKS
Program 1 Program 1
FB
Program 2
Program 2
Convert the FB
repeatedly-used
ladder block to
a component Utilize
FB
Project B
Program 3
Project B
FB
Program 3
1-2
1.2 Features of FBs
1
1.2 Features of FBs
OVERVIEW OF
FUNCTION
■ Creating programs efficiently
BLOCKS
Converting a standard program into a component as a single block enables the program to be utilized
easily. As an easy utilization for a sequence program is possible, the efficiency of creating a large-scale 2
program is improved. In addition, converting a program into a component improves program readability
and eases editing and debugging.
CREATING
FUNCTION
■ Consistency of program quality
BLOCKS
Converting a program into a component as an FB to utilize the program allows consistency of program
quality, without relying on the technological skills of the program developers. In addition, programming 3
mistakes which may occur at the time of utilization can be prevented.
USING FUNCTION
■ Reducing program creation man-hours with FB libraries
BLOCKS
With QCPU (Q mode)/LCPU, man-hours for creating a program can be reduced using FB libraries.
There are FB libraries which support various devices such as CPU modules, analog input/output 4
modules, and counter modules. FB libraries which support partner products are also supplied.
EDITING FUNCTION
MANAGING AND
■ Programming languages according to the intended use are selectable
BLOCKS
In Simple projects, Ladder Diagram or Structured Text can be selected as a programming language for
FBs.
The optimum programming language which meets the intended use can be selected to create FBs. 5
FXCPU Simple project supports only Ladder Diagram.
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
1-3
1 OVERVIEW OF FUNCTION BLOCKS
1.3 Labels
A label is a character string which represents a device.
Using labels allows a program to be created without considering devices in the program.
Therefore, a program with labels can be easily utilized even for a system with different module
configuration.
There are two types of labels, global labels and local labels.
• Global labels
Global labels are shared among all sequence programs in a project. A specific device can be
assigned to a global label.
• Local labels
Local labels are used only in a single sequence program.
They cannot be shared even if local labels with the same name are set for multiple sequence
programs.
Different devices are assigned to local labels for each sequence program.
1-4
1.4 Programming Flow with FBs
1
1.4 Programming Flow with FBs
OVERVIEW OF
This manual explains the operating procedures with examples of FBs used on QCPU (Q mode)/LCPU.
FUNCTION
BLOCKS
For the instructions and functions which are available for FXCPU, refer to the following manuals.
FXCPU user's manuals and programming manuals
2
1.4.1 FB creation procedure
CREATING
FUNCTION
BLOCKS
Operating procedure
1. Creating a project for FBs
3
Procedure Reference
USING FUNCTION
Create a project with labels. Section 2.1
BLOCKS
2. Creating new FB data 4
EDITING FUNCTION
Procedure Reference
MANAGING AND
Create new FB data. Section 2.2
BLOCKS
3. Setting local labels 5
Procedure Reference
Set local labels to be used for the FB program. Section 2.3
LIBRARIES
USING FB
4. Creating an FB program 6
FUNCTION BLOCKS
EXAMPLES USING
Procedure Reference
Create an FB program using labels. Section 2.4
PROGRAM
A
5. Converting FBs
Procedure Reference
Conversion finalizes the edited FB program content. Section 2.5
APPENDIX
I
INDEX
OVERVIEW OF
Operating procedure
FUNCTION
BLOCKS
1. Pasting FBs
Procedure Reference 2
Paste FBs to the sequence program. Section 3.1.1
Paste FBs of the FB Library to the sequence program. Chapter 5
CREATING
FUNCTION
BLOCKS
2. Creating input/output circuits of an FB instance.
3
Procedure Reference
USING FUNCTION
Create input and output circuits of the FB instance. Section 3.1.2
BLOCKS
3. Converting/compiling a sequence program 4
EDITING FUNCTION
Procedure Reference
MANAGING AND
Convert/compile the sequence program. Section 3.1.4
BLOCKS
4. Writing a program to a programmable controller CPU 5
Procedure Reference
Write the sequence program to the programmable controller CPU. Section 3.1.5
LIBRARIES
USING FB
5. Checking the operation
6
FUNCTION BLOCKS
EXAMPLES USING
Procedure Reference
Monitor the operation of the sequence program written to the programmable controller
PROGRAM
Section 3.2
CPU.
A
APPENDIX
I
INDEX
This section explains the screen configuration of the main frame (basic screen) of GX Works2 that is
displayed when it is started up. The following is an example of a screen on which a work window and
docked windows are displayed.
Screen display
Title bar
Menu bar
Toolbar
FB component
Navigation
window Element Selection
window
Sequence
program
FB data
Work
window
FB instance (Entity)
Docked window
Status bar
Display contents
1
Name Description Reference
OVERVIEW OF
Title bar Display a project name. —
FUNCTION
BLOCKS
Menu bar Display menu options for executing each function. —
GX Works2 Version 1
Toolbar Display tool buttons for executing each function. Operating Manual
(Simple Project) 2
A main screen used for operations such as programming,
Work window
parameter setting, and monitoring. GX Works2 Version 1
Operating Manual
Docking window A sub screen to support operations performed on a work window.
(Common)
CREATING
FUNCTION
Navigation Display contents of a project in tree format.
BLOCKS
Element Selection Display a list of functions (such as FBs) used for programming.
Section 3.1.1
FB component An FB registered as a component
GX Works2 Version 1 3
Output Display compilation and check results (errors and warnings). Operating Manual
USING FUNCTION
(Simple Project)
Cross Reference Display cross reference results.
Device List Display the device list.
BLOCKS
A screen used for monitoring and changing current device
Watch 1 to 4
values.
Intelligent function module
monitor 1 to 10
A screen used for monitoring intelligent function modules.
GX Works2 Version 1
Operating Manual
4
(Common)
EDITING FUNCTION
A screen used for searching and replacing character strings in
Find/Replace
MANAGING AND
the project.
A screen used for setting the debug which uses the simulation
Debug
BLOCKS
function.
Status bar Display information about a project being edited.
Sequence program A program and local labels. —
FB data A program and local labels of FB. — 5
FB instance (entity) An FB pasted to a sequence program. —
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
*1 : Section 2.3
OVERVIEW OF
FUNCTION
BLOCKS
2 CREATING FUNCTION 2
BLOCKS
CREATING
FUNCTION
BLOCKS
This chapter explains how to create FBs.
For the basic operations of GX Works2, refer to the following manuals.
GX Works2 Version 1 Operating Manual (Common) 3
GX Works2 Version 1 Operating Manual (Simple Project)
USING FUNCTION
BLOCKS
4
2.1 Creating Projects for FBs 2-2
EDITING FUNCTION
MANAGING AND
2.2 Creating New FB Data 2-3
BLOCKS
2.3 Setting Local Labels 2-4
LIBRARIES
USING FB
2.6 Considerations when Creating FB Programs 2 - 14
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
2-1
2 CREATING FUNCTION BLOCKS
Operating procedure
1. Select [Project] [New] ( ).
The New Project screen is displayed.
● Existing projects
FBs can be created in an existing project with labels.
For a project without labels, select [Project] [Change Project Type] to change the project to a project with labels, and
create FBs.
2-2
2.2 Creating New FB Data
1
2.2 Creating New FB Data
OVERVIEW OF
This section explains how to create new FB data in a project with labels.
FUNCTION
BLOCKS
Operating procedure
1. Select [Project] [Object] [New] ( ). 2
The New Data screen is displayed.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
2.
EDITING FUNCTION
Set the items on the screen.
MANAGING AND
Item Description
BLOCKS
Data Types Select "Function Block".
Enter a data name of an FB to be created with a maximum of 32 characters.
Data Name
For unusable characters, refer to Appendix 1.
Select a programming language to be used. 5
The programming languages available for FB creation in Simple projects are Ladder
Program Language
Diagram and Structured Text.
FXCPU Simple projects support Ladder Diagram only.
LIBRARIES
USING FB
3. Click the button.
The newly created FB data is added under "FB_Pool" on the Project view, and the FB editing
screen is displayed on the work window. 6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
● Maximum number of data to be created
Up to 800 FB data including other data types such as programs can be created.
INDEX
2-3
2 CREATING FUNCTION BLOCKS
Set items such as label classes, label names, and data types.
Screen display
Select Project view "POU" "FB_Pool" "(function block)" "Local Label".
Operating procedure
• Set the items on the screen.
Item Description Maximum number of characters
Select a label class from the list displayed by clicking .
Class —
(Section 2.3.2)
• Ladder Diagram
32 (Input, output, input/output labels:
Enter a desired label name. 16)
Label Name
For unusable characters, refer to Appendix 1.
• Structured Text
32
Specify a data type from the Data Type Selection screen
Data Types displayed by clicking . (Section 2.3.4) 128
It can also be entered directly.
Enter a constant value when "VAR_CONSTANT" is selected
Constant 128
for "Class" and simple type is selected for "Data Type".
Comment*1,*2 Enter a comment. 1024
*1 : A new line can be inserted into a cell by pressing the + keys.
*2 : Comments on a program editor can be displayed/hidden by selecting [View] [Comment]/[Statement]/[Note].
1
● Class setting
OVERVIEW OF
When an item other than the class, such as a label name and data type, is set in a blank column, "VAR" is automatically
FUNCTION
set for "Class". Change it if necessary.
BLOCKS
● Characters that cannot be used for label names
Any of the following label names causes an error at compilation.
• A label name that includes a space.
• A label name that begins with a numeral.
2
• A label name which is same as the one used for devices.
For characters that cannot be used for label names, refer to Appendix 1.
● When the local label setting of an FB is changed
CREATING
FUNCTION
BLOCKS
When the local label setting of an FB pasted to a sequence program is changed, compile the program or all programs.
The change of input/output label is applied to the sequence program to which the FB is pasted at compilation. Note that
the change is not applied when the FB instance name is not registered in the global label setting or local label setting.
3
■ Maximum number of input/output labels
USING FUNCTION
The maximum number of input/output labels which can be used in an FB program differs according to
BLOCKS
the programming language.
When setting input/output labels with local label setting of FB, set within the number of the input/output
labels shown in the following table.
4
Applicable number of labels in an FB program
EDITING FUNCTION
Programming language of FB
MANAGING AND
Input Output
Ladder Diagram 1 to 24*1 (Including input/output labels) 1 to 24*1 (Including input/output labels)
BLOCKS
Structured Text 0 to 253*2 (Including input/output labels)
*1 : For input/output labels, each input label and output label is counted as one label.
*2 : When pasting labels to a sequence program in Ladder Diagram, the applicable number of input/output labels is 1 to 24
(including input/output labels). Each input label and output label is counted as one label. 5
2.3.2 Classes
LIBRARIES
USING FB
A class indicates the POU applicability and the usage of label.
Selectable classes differ according to the type of label setting editor. 6
The following table shows the selectable classes on the Function/FB Label Setting screen.
FUNCTION BLOCKS
Class Description EXAMPLES USING
PROGRAM
VAR_INPUT
A label that is used for an input of FB program (input label). A
Its value cannot be changed in an FB program.
VAR_OUTPUT A label that is used for an output of FB program (output label).
A label that can be used for both input and output with the same name (input/output label).
APPENDIX
VAR_IN_OUT
Its value can be changed in an FB program.
*1 : Not supported by FXCPU.
I
INDEX
Programming language
Data type
Ladder Diagram Structured Text
Bit
Word [signed]
Double word [signed]
Word [unsigned]/16-bit string ×
Double word [unsigned]/32-bit string ×
Single-precision real*1
Double-precision real*2
String*3
Time ×
Timer *4 ×
Counter *4 ×
Retentive timer*5 *4 ×
Pointer *4 ×
*1 : For FXCPU, this item is supported by FX2N, FX2NC, FX3S, FX3G, FX3GC, FX3U, and FX3UC only.
*2 : Supported by Universal model QCPU/LCPU only.
*3 : For FXCPU, this item is supported by FX3U and FX3UC only.
*4 : The data type cannot be used as input/output labels when pasting an FB to a ladder program.
*5 : For FXCPU, this item is supported by FX1N, FX1NC, FX2N, FX2NC, FX3S, FX3G, FX3GC, FX3U, and FX3UC only.
For value ranges and details of each data type, refer to the following manuals.
• QCPU (Q mode)/LCPU
CPU user's manuals (Function Explanation, Program Fundamentals)
MELSEC-Q/L Programming Manual (Common Instruction)
• FXCPU
FXCPU user's manuals and programming manuals
OVERVIEW OF
Selecting data type.
FUNCTION
BLOCKS
A data type can be specified by directly entering the type in text or selecting it on the Data Type
Selection screen.
Operating procedure 2
1. Click on the data type entry field on the Function/FB Label Setting screen.
The Data Type Selection screen is displayed.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
2. Select a type for "Type Class".
Item Description
Simple Types Specify this to select a data type from basic types such as bit and word.
LIBRARIES
USING FB
Specify this to select a data type from the defined structures.
Structured Data Types For details of structures, refer to the following manual.
GX Works2 Version 1 Operating Manual (Simple Project)
Function Blocks Specify this to select a data type from the defined function blocks. 6
FUNCTION BLOCKS
EXAMPLES USING
3. On the "Libraries" field, select the reference source such as the defined structure
that is used as the data type.
PROGRAM
Item Description
<ALL> Browse data types, structures, and function blocks defined in the project, and all libraries.
<PROJECT>
Browse data types, structures, and function blocks defined in the project. A
(Not displayed when "Simple Types" is selected.)
Browse function blocks of application functions.
Standard Lib
(Not displayed when "Simple Types" or "Structured Data Types" is selected.)
APPENDIX
4. On the "Data Type" field, select the data type, structure, or function block name.
Operation
1. Click on the data type entry field on the
Function/FB Label Setting screen.
The Data Type Selection screen is displayed.
2. Select "ARRAY" under "Array Element".
3. Enter the number of elements for "Element".
4. Set the data type of the array element in the
same manner as setting the normal data type.
OVERVIEW OF
Devices are automatically assigned to labels when a program is compiled.
FUNCTION
BLOCKS
The ranges of devices which are automatically assigned to labels can be changed on the Device/Label
Automatic-Assign Setting screen.
Set the ranges not to overlap with devices used in a sequence program.
2
■ QCPU (Q mode)/LCPU
CREATING
FUNCTION
Screen display
BLOCKS
Select [Tool] [Device/Label Automatic-Assign Setting].
3
USING FUNCTION
BLOCKS
Latch selection
field 4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
Operating procedure
• Set the items on the screen. 6
FUNCTION BLOCKS
EXAMPLES USING
Item Description
Select latch (1) or latch (2).
Latch selection field This item can be selected when the range of latch (1) or latch (2) is set on the
PROGRAM
Assignment Start
Enter the range of device points to be assigned automatically.
Range End
APPENDIX
Total Points Display the total points of each device range for VAR and VAR_RETAIN.
Display the device point range set on the <<Device>> tab of PLC parameter.
When the latch range is set, display the device point range with the latch range.
PLC Parameter
Device Setting Range
Example: When D: 0 to 12287, latch D: 5000 to 6000 are set on the I
<<Device>> tab of PLC parameter, display range of D: 0 to 12287,
range of latch D: 5000 to 6000.
INDEX
■ FXCPU
Screen display
Select [Tool] [Device/Label Automatic-Assign Setting].
Operating procedure
• Select the device type, and set the start and end addresses to be assigned
automatically.
OVERVIEW OF
FUNCTION
All programs need to be compiled when the range of automatically assigned device is changed.
BLOCKS
Compiling all programs changes the device assignment to labels. Therefore, device values set before
the program change remain on the device-assigned labels.
For QCPU (Q mode)/LCPU, reset the programmable controller CPU, clear all device memories
including latches, clear all file registers, then switch the programmable controller CPU to RUN for a
2
precautionary measure.
(GX Works2 Version 1 Operating Manual (Common))
CREATING
FUNCTION
For the considerations for compiling all programs, refer to the following manual.
BLOCKS
(GX Works2 Version 1 Operating Manual (Simple Project))
● Assigning devices with the "Device/Label Automatic-Assign Setting" function
Assign devices to labels with the "Device/Label Automatic-Assign Setting" function when a program 3
is compiled.
USING FUNCTION
(GX Works2 Version 1 Operating Manual (Simple Project))
The assigned devices can be checked with the cross reference function.
(GX Works2 Version 1 Operating Manual (Common))
BLOCKS
Devices within the range set on the Device/Label Automatic-Assign Setting screen cannot be used in
a program.
● Considerations when the multiple types of devices are assigned automatically (QCPU (Q 4
mode)/LCPU)
EDITING FUNCTION
MANAGING AND
Refer to Considerations of compilation.
(GX Works2 Version 1 Operating Manual (Simple Project))
BLOCKS
● Device types and setting ranges
The types of automatically assigned devices differ by the type of CPU.
The setting ranges depend on the number of device points set in PLC parameter. 5
For details of PLC parameter, refer to the following manual.
(GX Works2 Version 1 Operating Manual (Common))
● Considerations when displaying the Device/Label Automatic-Assign Setting screen
LIBRARIES
USING FB
When displaying the Device/Label Automatic-Assign Setting screen, an error message may be
displayed.
In this case, terminate GX Works2, copy "vsflex8n.ocx" stored in the folder of GX Works2 installation
destination to "C:\WINDOWS\system32" (for Windows® XP), and restart GX Works2.
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
Operating procedure
1. Select Project view "POU" "FB_Pool" "(function block)" "Program".
The FB editing screen is displayed.
2. Create an FB program.
2 - 12
2.5 Converting FBs
1
2.5 Converting FBs
OVERVIEW OF
For FB programs in Ladder Diagram, the edited content can be confirmed by converting the program.
FUNCTION
BLOCKS
Operating procedure
1. Select [Compile] [Build] ( ). 2
The Confirm Build Method screen is displayed.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
2.
EDITING FUNCTION
Select "Convert the selected program" and click the button.
MANAGING AND
The edited content of the FB program is confirmed.
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
2 - 13
2 CREATING FUNCTION BLOCKS
Item Description
• Fixed-cycle execution type program
Program to be executed multiple times in a • Interrupt program
single scan • Subroutine program
• FOR-NEXT instruction program
Instruction which requires multiple scans before the execution completion
(JP.READ/JP.WRITE instruction, SORT instruction, SP.FREAD/SP.FWRITE
instruction, etc.)
Unusable instructions for FBs which are
Rising instruction
used for above programs
(P instruction (such as MOVP instruction), PLS, etc.)
Falling instruction
(PLF, LDF, ANDF, ORF, MEF, FCALLP, EFCALLP, etc.)
2 - 14
2.6 Considerations when Creating FB Programs
OVERVIEW OF
Through a method that the index register value is set to 0 when its value is temporarily saved, an
FUNCTION
BLOCKS
operation error, which is detected by the consistency check of index modification (whether if the device
number exceeds the device range), can be prevented.
Example: When the values of index registers Z1 and Z2 are temporarily saved in the FB program
before the execution of the program and the saved values of the index registers are restored 2
after execution of the program.
Save the index register values in index_reg_tmp before execution of the program.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
Set the index
BLOCKS
register values
to "0".
EDITING FUNCTION
MANAGING AND
BLOCKS
Restore the values saved in index_reg_tmp after execution of the program to the index registers.
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
2 - 15
2 CREATING FUNCTION BLOCKS
<Sequence program>
<FB program>
2 - 16
2.6 Considerations when Creating FB Programs
OVERVIEW OF
WAND instruction to switch ON/OFF the individual bits of the target word data.
FUNCTION
BLOCKS
<For QCPU (Q mode)/LCPU>
Set 1 (ON) to the first bit of int_WordData.
CREATING
FUNCTION
BLOCKS
Set 0 (OFF) to the fifth bit of int_WordData.
Set ON to the 0th bit and the 4th bit of int_WordData with the WOR instruction.
<For FXCPU> *For the specification of the bit position, refer to the following table. 3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
Set OFF to the 1st bit and the 5th bit of int_WordData with the WAND instruction.
* For the specification of the bit position, refer to the following table.
BLOCKS
(WOR instruction) (WAND instruction)
Bit position
Set a bit to ON. Set a bit to OFF.
0th bit H0001 HFFFE
5
1st bit H0002 HFFFD
2nd bit H0004 HFFFB
3rd bit H0008 HFFF7
LIBRARIES
USING FB
4th bit H0010 HFFEF
5th bit H0020 HFFDF
6th bit H00 4 0 HFFBF
7th bit H0080 HFF7F 6
FUNCTION BLOCKS
EXAMPLES USING
8th bit H0100 HFEFF
9th bit H0200 HFDFF
PROGRAM
I
INDEX
2 - 17
2 CREATING FUNCTION BLOCKS
Storage destination
of D1000
Specification of the number
of points to be imported
Transferring destination of
multiple word data
B) In the sequence program, save values for six points to D devices from D1000.
D1000 1234 H
D1001 2345 H
D1002 3456 H
D1003 4567 H
D1004 5678H
D1005 6789H
D) Using the BMOV instruction in the FB program, transfer values for six points from the
input variable (i_Write_Data) to the array (int_Write_Array).
2 - 18
1
OVERVIEW OF
FUNCTION
BLOCKS
3 USING FUNCTION 2
BLOCKS
CREATING
FUNCTION
BLOCKS
This chapter explains how to create a sequence program with FBs.
For the basic operations and screen details of GX Works2, refer to the following manual.
GX Works2 Version 1 Operating Manual (Common) 3
USING FUNCTION
BLOCKS
4
3.1 Creating Sequence Programs with FBs 3-2
EDITING FUNCTION
MANAGING AND
3.2 Checking Operations of Sequence Programs 3 - 19
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
3-1
3 USING FUNCTION BLOCKS
On the pasted FB instance, label names of I/O variables and their corresponding data types are
displayed.
Paste FBs from the Project view of the Navigation window or from the Element Selection window to a
sequence program. When the FB is pasted, an FB instance name is registered to the local label or the
global label as a label.
Operating procedure
1. Select an FB from the Project view of the Navigation window and move to a desired
position on the sequence program with the drag-and-drop operation.
2. Click to select local label or global label to register the FB instance name.
OVERVIEW OF
FUNCTION
BLOCKS
2
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
● FB instance name
• FB instance names can be changed later. (Section 4.6) 4
• A name can be set using up to 16 characters. Alphabets are case-sensitive.
EDITING FUNCTION
• Numeric characters cannot be used as the first character. For unusable characters, refer to Appendix 1.
MANAGING AND
● Registering FB instance names to local label or global label
When an FB is pasted, an FB instance name is automatically registered as a label on the setting screen of the label
BLOCKS
selected in step 2.
LIBRARIES
USING FB
FBs can also be pasted from the Element Selection window with the drag-and-drop operation. The Element Selection
window is displayed by selecting [View] [Docking Window] [Element Selection].
● When the same FB is pasted repeatedly
Pasting an FB to a sequence program causes the file size to be increased. Pasting the same FB to one sequence
program repeatedly also causes the size increase of the sequence program according to the number of times of 6
pasting.
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
■ Display of FB instance
On the pasted FB instance, label names of I/O variables and their corresponding data types are
displayed.
FB instance name
By entering an FB name in an ST program, the FB can be called in the same manner as pasting an FB
OVERVIEW OF
in a ladder program.
FUNCTION
BLOCKS
Operating procedure
• Enter an FB label name, input variable, and output variable in the ST program. 2
Values must be specified for entered input variable and output variable.
Note that entering of output variable can be omitted when a result of output variable is not required.
CREATING
FUNCTION
BLOCKS
Example: When the defined FB is "TIMER"
USING FUNCTION
stop
Output variable: In operation, timer up 1, timer up 2
BLOCKS
[Data entering example]
Enter data in the ST program as shown below.
4
EDITING FUNCTION
Device that assigns a value to
FB label name Input variable
MANAGING AND
an input variable
BLOCKS
FB_TIMER (Setting value 1 second: = X0,
Setting value 10 seconds: = X1,
Setting value 100 seconds: = X2,
Start: = X3, Stop: = X4, In operation: = Y70,
Timer up 1: = Y71, Timer up2: = Y72); 5
LIBRARIES
USING FB
The output of the FB can be obtained by specifying the output variable name with a 'period (.)'
suffixed to the FB name.
Enter an instruction to obtain the output after performing the FB call.
6
FUNCTION BLOCKS
EXAMPLES USING
Y70: = FB_TIMER. In operation;
PROGRAM
A
APPENDIX
I
INDEX
Create input and output circuits of the FB instance pasted to a sequence program.
Operating procedure
1. Select [Compile] [Build].
The Confirm Build Method screen is displayed.
OVERVIEW OF
meeting data type of input variable.
FUNCTION
BLOCKS
<Bit type>
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
If the data type of input variable is not a bit type, enter the device directly on the Enter Symbol
screen. 5
<Other than bit type>
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
4. Enter elements to the output circuit in the same manner as the input circuit.
Edit the program other than FBs as necessary. After finishing the editing, convert/compile the A
program.
APPENDIX
I
INDEX
● Number of contacts that can be created in input circuit and output circuit
By setting "Display Connection of Ladder Diagram", the number of contacts occupied in input circuit or output circuit of
an FB instance is determined as below.
Instructions that exceed the number of occupied contacts cannot be entered. When instructions cannot be placed by
changing the number of displayed contacts, the ladder block is not displayed properly.
For the setting of the number of displayed contacts, refer to the following manual.
GX Works2 Version 1 Operating Manual (Simple Project)
● Comment
A comment can be entered on a program.
Statement
Note
Device comment
Label
comment
OVERVIEW OF
The output of an FB instance cannot be directly connect to the input of another FB instance.
FUNCTION
BLOCKS
When connecting FBs each other, use a coil to initially receive the output of a single FB, and then
connect the contact of the coil to the input of the other FB.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
2) Wrapping lines cannot be created in the input and output circuits.
Insert a coil to receive the output and use the contact of the coil as the target instruction condition.
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
3) Parallel connections cannot be created in the input or output circuit. An error occurs when
PROGRAM
4) The data type of the input or output circuit of the FB instance, and the data type of the
APPENDIX
6) When the label setting of FB is changed, compile the program or all programs.
The change of input/output label is applied to the utilization destination ladder program at
compilation. Note that the change is not applied when the FB instance is not registered in the
global label setting or local label setting.
Execute compilation
7) Function blocks using inline structured text programs cannot be used in programs other
than Ladder Diagram.
OVERVIEW OF
An alignment of a sequence program and an FB program allows a sequence program to be edited
FUNCTION
BLOCKS
while checking the FB program.
Operating procedure
2
1. Move the cursor to the FB instance.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
Move the cursor to the FB instance.
5
LIBRARIES
USING FB
The sequence program and the FB program are displayed horizontally.
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
Operating procedure
1. Select [Compile] [Rebuild All] ( ).
The following message is displayed.
Clear the check box if the duplicated coil check, ladder program check, and consistency (pairing)
check are not performed after the compilation.
Output window
1
● When a program is compiled with [Compile]
OVERVIEW OF
Since only programs that are not compiled are subjected to compilation, time required for compilation can be reduced.
FUNCTION
For considerations of compilation, refer to the following manual.
BLOCKS
GX Works2 Version 1 Operating Manual (Simple Project)
● Program size after compilation
When compilation is executed, the FB is applied to a program as an internal processing of a sequence program,
resulting in increase of the program size. 2
The program size can be checked on the Memory Capacity Calculation Result screen.
CREATING
FUNCTION
BLOCKS
FB
USING FUNCTION
BLOCKS
Apply the FB to the program
as an internal processing
4
EDITING FUNCTION
MANAGING AND
■ Calculating memory size (QCPU(Q mode)/LCPU)
BLOCKS
Data size required for writing a program to a programmable controller CPU can be checked on the
Memory Capacity Calculation Result screen. Excess of the capacity when writing a program to a
programmable controller CPU can be prevented by checking the memory size.
5
Operating procedure
1. Select [Tool] [Confirm Memory Size].
LIBRARIES
USING FB
The Confirm Memory Size screen is displayed.
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
File list
APPENDIX
I
INDEX
Target section
Calculation
result section Sum total section
Memory status
graph
graph section
section
Display sizes and capacities of program and symbolic information calculated offline.
OVERVIEW OF
Displayed values are values when the program and parameters are written to a programmable
FUNCTION
BLOCKS
controller CPU.
Operating procedure
2
• Select [Tool] [Confirm Memory Size].
The Confirm Memory Size screen is displayed. For details, refer to the following manual.
GX Works2 Version 1 Operating Manual (Common)
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
Operating procedure
1. Select [Online] [Write to PLC] ( ).
The Online Data Operation screen is displayed.
OVERVIEW OF
occur between the data on the project and the data written to the programmable controller CPU.
FUNCTION
BLOCKS
2
CREATING
FUNCTION
BLOCKS
3. Click the button. 3
USING FUNCTION
● Writing target for symbolic information
BLOCKS
When symbolic information is selected, the memory size for the symbolic information is required.
For QCPU(Q mode)/LCPU, the writing target for symbolic information can be changed to standard ROM or memory
card (other than program memory or device memory), resulting that the capacity of program memory can be reserved.
● Default writing target for symbolic information 4
The default writing target for symbolic information can be set for each project.
EDITING FUNCTION
Select [Tool] [Options] "Symbolic Information", and select a writing target from "Setting for Writing of Symbolic
MANAGING AND
Information to PLC".
BLOCKS
5
LIBRARIES
USING FB
● FXCPU
• Symbolic information can be read from/write to a programmable controller CPU in a project of FX3U/FX3UC version
3.00 or later only.
• When a memory cassette to which the symbolic information has been written is used on an FXCPU other than FX3U/ 6
FX3UC version 3.00 or later, the memory cassette can be used, however, the symbolic information cannot be read
FUNCTION BLOCKS
from the memory cassette. When the symbolic information is written to a memory cassette on an FXCPU other than
EXAMPLES USING
FX3U/FX3UC version 3.00 or later, the symbolic information may be corrupted. PROGRAM
A
APPENDIX
I
INDEX
■ Symbolic information
The symbolic information is data that store the program configuration such as labels and FBs.
To restore these data included in the symbolic information when reading a program from the
programmable controller CPU, write/read the symbolic information to/from the programmable controller
CPU.
Data such as labels and FBs included in the symbolic information cannot be restored if only sequence
programs are read.
The following table shows the program data included in the symbolic information.
Symbolic Programs
information Local labels
FBs
Structures
1
3.2 Checking Operations of Sequence Programs
OVERVIEW OF
Execute the monitoring function to check the operation of the programs written to the programmable
FUNCTION
BLOCKS
controller CPU.
FB programs can also be monitored.
Operating procedure
2
• Select [Online] [Monitor] [Start Monitoring] ( ).
The monitoring starts.
CREATING
FUNCTION
BLOCKS
Double-click the FB instance to monitor the FB program.
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
Double-click the FB instance.
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
3 - 19
3 USING FUNCTION BLOCKS
3 - 20
1
OVERVIEW OF
FUNCTION
BLOCKS
4 MANAGING AND EDITING 2
FUNCTION BLOCKS
CREATING
FUNCTION
BLOCKS
This chapter explains how to manage and edit FBs.
For the basic operations and screen details of GX Works2, refer to the following manual.
GX Works2 Version 1 Operating Manual (Common) 3
USING FUNCTION
BLOCKS
4
4.1 Reading FB Programs from Programmable Controller
EDITING FUNCTION
MANAGING AND
CPU 4-2
BLOCKS
4.2 Reusing FBs from Library (Project) 4-3
LIBRARIES
USING FB
4.6 Protecting FBs 4 - 13
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
4-1
4 MANAGING AND EDITING FUNCTION BLOCKS
Operating procedure
1. Select [Online] [Read from PLC].
The Online Data Operation screen is displayed.
● FXCPU
For FXCPU projects with labels, created project data can be read from FX3U/FX3UC version 3.00 or later only.
4-2
4.2 Reusing FBs from Library (Project)
1
4.2 Reusing FBs from Library (Project)
OVERVIEW OF
This section explains how to reuse the created FBs in another project.
FUNCTION
BLOCKS
The created FB programs can be used as program assets in multiple projects by using the project
files created in Simple project (with labels) as FB library.
2
4.2.1 Library (project) reusing procedure
CREATING
FUNCTION
BLOCKS
The following shows the procedure for reusing the FBs in the created library (project) to other project.
Operating procedure 3
1. Creating a library (project).
USING FUNCTION
Procedure Reference
BLOCKS
Create a Simple project (with labels).
GX Works2 Version 1
Name and save the project.
Operating Manual (Common)
Close the project.
4
EDITING FUNCTION
MANAGING AND
2. Exporting FBs to a library (project).
BLOCKS
Procedure Reference
GX Works2 Version 1
Open the project that contains FBs to be reused.
Operating Manual (Common) 5
Export FBs to the library (project). Section 4.2.2
LIBRARIES
USING FB
3. Acquiring FBs from the library (project).
Procedure Reference
6
FUNCTION BLOCKS
EXAMPLES USING
GX Works2 Version 1
Open the project to which FBs are to be used.
Operating Manual (Common) PROGRAM
A
APPENDIX
I
INDEX
Export the FBs which are created in the project being edited to other project using the Export FB to
Library (Project) screen. Global labels and structures can be exported at the same time.
An FB whose PLC type is different from that of the project being edited can be exported.
However, FBs created with QCPU(Q mode)/LCPU project cannot be exported to FXCPU project, and
vice versa.
Operating procedure
1. Select [Project] [Library] [Export FB to Library (Project)]
The Export FB to Library (Project) screen is displayed.
2. Select FBs, global labels, and structures to be exported to the target project from
1
the FB List.
OVERVIEW OF
Click the button to export the FBs or structures in the selected FBs at the
FUNCTION
same time.
BLOCKS
2
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
3. Click the button to select the export target project.
EDITING FUNCTION
MANAGING AND
4. Click the button.
BLOCKS
The selected FBs, global labels, and structures are exported to the target project.
5
● Block password
An FB with a block password cannot be exported. Unlock the block password of the project being edited before export
the FB.
LIBRARIES
USING FB
The block password of FB is unset to the export target project.
● Considerations for "Indexing Setting for ZR Device"
FBs cannot be exported when the device set for "Indexing Setting for ZR Device" on the <<Device>> tab of PLC
parameter is different between the target project and the project being edited.
Set the same setting for "Indexing Setting for ZR Device" before exporting FBs. 6
When an FB with the different start number of index register is exported, check the program using the index setting
FUNCTION BLOCKS
EXAMPLES USING
because the operation of the index setting may be changed.
● When the data name of output target data is overlapped
When the data name of each export target FB, global label, or structure is overlapped, the existing data in the target
PROGRAM
A
APPENDIX
I
INDEX
Import the FBs which are created in other project to the project being edited using the Import Library to
Project screen. The global labels and the structures can be imported at the same time.
An FB whose PLC type is different from that of the project being edited can be imported.
However, FBs created with QCPU(Q mode)/LCPU project cannot be imported to FXCPU project, and
vice versa.
Operating procedure
1. Select [Project] [Library] [Install].
The Import Library to Project screen is displayed.
2. Select "Select Library (Project)" from the "Library List" combo box.
5. Select FBs, global labels, and structures to be imported to the editing project from
1
the FB List.
OVERVIEW OF
Click the button to import the FBs or structures in the selected FBs at the
FUNCTION
same time.
BLOCKS
2
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
6. Click the button.
BLOCKS
The imported FBs, global labels, and structures are displayed on the project view.
For utilizing FBs, refer to Chapter 3.
4
EDITING FUNCTION
MANAGING AND
● Considerations of "Indexing Setting for ZR Device"
FBs cannot be imported when the device set for "Indexing Setting for ZR Device" on the <<Device>> tab of PLC
BLOCKS
parameter is different between the source project and the project being edited.
Set the same setting for "Indexing Setting for ZR Device", and import FBs.
When an FB with the different start number of index register is imported, check the program using the index setting
because the operation of the index setting may be changed. 5
● When the data name of import source data is overlapped
When the data name of each import source FB, global label, or structure is overlapped, the existing data in the target
project is overwritten and deleted.
In this case, change the data name before importing the data.
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
Set the conversion method when the FBs to be added contain instructions or devices which are not
applicable to the target project.
Operating procedure
1. Click the button on the Install screen.
1
4.3 Copying FBs from Project
OVERVIEW OF
FBs can be reused by starting another GX Works2, and copying and pasting the FBs from the source
FUNCTION
BLOCKS
project to the target project.
This section explains how to reuse FBs in an existing project.
Operating procedure
2
1. Open the source project.
CREATING
FUNCTION
BLOCKS
2. Start another GX Works2, and open the target project.
If the programmable controller types differ between the two projects, match the programmable
controller type. A programmable controller type can be changed by selecting [Project] [Change 3
PLC Type].
USING FUNCTION
3. Move the FB data in the source project to "FB_Pool" in the target project with the
drag-and-drop operation.
BLOCKS
Source project Target project
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
4-9
4 MANAGING AND EDITING FUNCTION BLOCKS
Operating procedure
1. Move the cursor to the FB instance.
FB instance name
3. Enter a new FB instance name, and select "Change All" or "Change Only Selection
FB".
5. Open the global label or local label setting screen, and register/change the label
name to the same as the new FB instance name.
If the program is compiled without registering/changing the label, a compilation error occurs.
4 - 10
4.5 Deleting Unnecessary FB Data from Projects
1
4.5 Deleting Unnecessary FB Data from Projects
OVERVIEW OF
This section explains how to delete FB data from a project.
FUNCTION
BLOCKS
FB instances and FB instance names registered to the global label or local label may be deleted at the
same time.
Operating procedure
2
1. Select an FB to be deleted on the Project view.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
2. Select [Project] [Object] [Delete].
A confirmation message for deleting data is displayed. 5
LIBRARIES
USING FB
3. Click the button. 6
FUNCTION BLOCKS
A message for selecting the deletion method is displayed.
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
4 - 11
4 MANAGING AND EDITING FUNCTION BLOCKS
4 - 12
4.6 Protecting FBs
1
4.6 Protecting FBs
OVERVIEW OF
Setting a block password protects created FB programs and disables browsing program contents.
FUNCTION
BLOCKS
The following operations are disabled when a block password is set.
● Displaying and editing FB programs
● Editing FB local labels
2
● Copying data to other projects
Operating procedure
CREATING
FUNCTION
BLOCKS
1. Select [Tool] [Block Password].
The Set Block Password screen is displayed.
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
2. Select an FB to be protected, and click the button.
The Change Block Password screen is displayed.
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
4 - 13
4 MANAGING AND EDITING FUNCTION BLOCKS
4 - 14
4.6 Protecting FBs
OVERVIEW OF
Unlock of the block password is valid while the project is being opened. The lock status is restored
FUNCTION
BLOCKS
when the project is opened again.
Operating procedure
2
1. Select [Tool] [Block Password].
CREATING
FUNCTION
BLOCKS
The Unlock Block Password screen is displayed.
USING FUNCTION
BLOCKS
4
3. Enter a password, and click the button.
EDITING FUNCTION
MANAGING AND
The block password is unlocked, and "Unlocked" is displayed on the "Registration Status" field of
the Set Block Password screen.
BLOCKS
■ Deleting block passwords
Operating procedure
LIBRARIES
USING FB
1. Select [Tool] [Block Password].
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
3. Click the button.
The password is deleted.
APPENDIX
I
INDEX
4 - 15
4 MANAGING AND EDITING FUNCTION BLOCKS
Operating procedure
1. Select [Find/Replace] [Find String].
The Find/Replace screen is displayed.
2. Enter an FB instance name to be searched for "Find In", and click the
button or the button.
When the button is clicked, the cursor moves to the corresponding position.
When the button is clicked, the search result is displayed. By double-clicking the row
in the search result, the cursor jumps to the corresponding character string.
4 - 16
1
OVERVIEW OF
FUNCTION
BLOCKS
5 USING FB LIBRARIES 2
The FB Library is a collection of FBs and it is provided as MELSOFT Library.
This chapter explains how to use the FB Library.
CREATING
FUNCTION
BLOCKS
For the overview of the FB Library, refer to the following manual.
GX Works2 Version 1 Operating Manual (Common)
Note that the FB Library is not supported by FXCPU.
3
USING FUNCTION
BLOCKS
4
5.1 Installing FB Library 5-2
EDITING FUNCTION
MANAGING AND
5.2 Using FB Libraries 5-3
BLOCKS
5.3 Displaying Reference Manual 5-5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
5-1
5 USING FB LIBRARIES
Operating procedure
1. Decompress the installer file.
1
5.2 Using FB Libraries
OVERVIEW OF
Import the installed FB libraries to a project.
FUNCTION
BLOCKS
Operating procedure
1. Select [Project] [Library] [Install]. 2
The Install screen is displayed.
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
2. Select a library from "Library List", and click the
EDITING FUNCTION
MANAGING AND
button.
"FB List" is updated.
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
3. Select FBs to be imported from "FB List". PROGRAM
A
APPENDIX
I
INDEX
5-3
5 USING FB LIBRARIES
● Editing FB libraries
• Since a folder which contains FB library project files is for a system use, do not change the folder name or delete the
folder. If the folder name is changed or the folder is deleted, a system malfunction may occur. In addition, do not
store GX Works2 project files or any other files. For a location to which FB library project files are to be stored, refer
to Section 5.1.2.
• FB libraries (whose name starts with M+/P+) are read-only files. They can be deleted but cannot be edited. To edit a
library, copy or paste FB library data after importing the library.
● Copying FB libraries
FB library data can be copied or pasted even for projects with different programmable controller types as long as
project types are identical.
5-4
5.3 Displaying Reference Manual
1
5.3 Displaying Reference Manual
OVERVIEW OF
This section explains how to check the usage of the imported FB library and the application of labels.
FUNCTION
BLOCKS
Operating procedure
1. Select an FB from the Project view. 2
CREATING
FUNCTION
menu.
BLOCKS
The reference manual of the selected FB data is displayed.
USING FUNCTION
BLOCKS
4
● Displaying reference manual from utilized FB
EDITING FUNCTION
A reference manual can be displayed from the utilized FB of the FB library on the program.
MANAGING AND
Select an FB on the project and press the key.
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
5-5
5 USING FB LIBRARIES
This section explains how to uninstall the installed FB Library, using Windows® XP as an example.
Operating procedure
1. Select [Start] [Control Panel] [Add or Remove Programs].
5-6
1
OVERVIEW OF
FUNCTION
BLOCKS
6 PROGRAM EXAMPLES 2
USING FUNCTION
CREATING
FUNCTION
BLOCKS
BLOCKS
3
This chapter explains program examples using FBs.
USING FUNCTION
BLOCKS
4
6.1 System Configuration of Program Examples 6-2
EDITING FUNCTION
MANAGING AND
6.2 Processing of Program Examples 6-3
BLOCKS
6.3 Creating Program Examples 6-4
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
6-1
6 PROGRAM EXAMPLES USING FUNCTION BLOCKS
Sensor
(X1)
Conveyor Motor
Control panel
Operation panel
Operation Buzzer
(X0) (Y1)
(Y0)
# $ % & '
6-2
6.2 Processing of Program Examples
1
6.2 Processing of Program Examples
OVERVIEW OF
When the number of boxes to be conveyed is set, and the operation switch is pressed, the conveyor
FUNCTION
BLOCKS
starts to operate. When conveying the set number of boxes is completed, the conveyor stops.
Buzzer sound is produced for three seconds when the operation is started and stopped.
Start
2
CREATING
FUNCTION
Turn the operation switch (X0) ON.
BLOCKS
The buzzer (Y1) sounds
for 3 seconds.
3
USING FUNCTION
Operation of the conveyor
BLOCKS
(Y0) is started.
EDITING FUNCTION
MANAGING AND
BLOCKS
Count the number of
conveyed boxes.
5
Has the set NO
number of boxes
LIBRARIES
USING FB
been conveyed?
YES
6
The buzzer (Y1) sounds
FUNCTION BLOCKS
for 3 seconds again.
EXAMPLES USING
PROGRAM
A
End
APPENDIX
I
INDEX
6-3
6 PROGRAM EXAMPLES USING FUNCTION BLOCKS
The following is a setting example displayed on the Function/FB Label Setting screen.
6-4
■
FB program example
6-5
PROGRAM MANAGING AND CREATING OVERVIEW OF
EXAMPLES USING USING FB EDITING FUNCTION USING FUNCTION FUNCTION FUNCTION
I
INDEX APPENDIX FUNCTION BLOCKS LIBRARIES BLOCKS BLOCKS BLOCKS BLOCKS
6
5
4
3
2
1
A
6 PROGRAM EXAMPLES USING FUNCTION BLOCKS
Paste FBs to a sequence program to create the input circuit and output circuit. (Chapter 3)
In the program example below, the number of boxes to be conveyed is six.
Converting conveyor control functions into components as FBs enables a sequence program to be
easily altered when a conveyor which performs the same control is added.
Additional conveyor
Conveyor
6-6
6.3 Creating Program Examples
The additional conveyor operation switch, sensor, conveyor driving relay, and buzzer are to be 1
assigned X2, X3, Y2, and Y3 respectively.
In the program sample below, the number of boxes to be conveyed with the additional conveyor is 12.
OVERVIEW OF
FUNCTION
BLOCKS
2
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
6-7
6 PROGRAM EXAMPLES USING FUNCTION BLOCKS
MEMO
6-8
1
OVERVIEW OF
FUNCTION
BLOCKS
APPENDIX 2
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4
Appendix 1 Character Strings that cannot be Used for Label
EDITING FUNCTION
MANAGING AND
Names and FB Data Names/Instance Names App - 2
BLOCKS
Appendix 2 Supported CPU modules App - 5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
App - 1
APPENDIX
Appendix 1 Character Strings that cannot be Used for Label Names and FB Data Names/Instance Names
Character strings used for application function names, common instruction names, special
instruction names, instructions, etc. are called reserved words.
These reserved words cannot be used for label names, FB data names, or FB instance names. If the
character string defined as a reserved word is used, an error occurs during entry or compilation.
The following tables show character strings that cannot be used for FB data names, FB instance
names or label names.
: Applicable, ×: Not applicable
FB data name/FB
Category Character string Label name
instance name
VAR, VAR_RETAIN, VAR_ACCESS, VAR_CONSTANT,
VAR_CONSTANT_RETAIN, VAR_INPUT,
VAR_INPUT_RETAIN, VAR_OUTPUT,VAR_OUTPUT_RETAIN,
VAR_IN_OUT, VAR_IN_EXT, VAR_EXTERNAL,
Class identifier VAR_EXTERNAL_CONSTANT, × ×
VAR_EXTERNAL_CONSTANT_RETAIN,
VAR_EXTERNAL_RETAIN, VAR_GLOBAL,
VAR_GLOBAL_CONSTANT,
VAR_GLOBAL_CONSTANT_RETAIN, VAR_GLOBAL_RETAIN
BOOL, BYTE, INT, SINT, DINT, LINT, UINT, USINT, UDINT,
ULINT, WORD, DWORD, LWORD, ARRAY, REAL, LREAL,
TIME, STRING, TIMER, COUNTER, RETENTIVETIMER,
Data type POINTER, Bit, Word [Unsigned]/Bit String [16-bit], Double Word × ×
[Unsigned]/Bit String [32-bit], Word [Signed], Double Word
[Signed], FLOAT (Single Precision), FLOAT (Double Precision),
String, Time, Timer, Counter, Retentive Timer, Pointer
ANY, ANY_NUM, ANY_BIT, ANY_REAL, ANY_INT, ANY_DATE × ×
Data type hierarchy
ANY_SIMPLE, ANY16, ANY32 ×
X, Y, D, M, T, B, C, F, L, P, V, Z, W, I, N, U, J, K, H, E, A, SD, SM,
Device name ×
SW, SB, FX, FY, DX, DY, FD, TR, BL, , SG, VD, ZR, ZZ*1
Character string recognized
as device (Device name + Such as X0 × ×
Numeral)
NOT, MOD × ×
ST operator
(, ), - ×
LD, LDN, ST, STN, S, S1, R, R1, AND, ANDN, OR, ORN, XOR,
XORN, ADD, SUB, , MUL, DIV, GT, GE, EQ, NE, LE, LT, JMP, × ×
JMPC, JMPCN, CAL, CALC, CALCN, RET, RETC, RETCN
IL operator LDI, LDP, LDF, ANI, ANDP, ANDF, ANB, ORI, ORP, ORF, ORB,
MPS, MRD, MPP, INV, MEP, MEF, EGP, EGF, OUT(H), SET,
×
RST, PLS, PLF, FF, DELTA(P), SFT(P), MC, MCR, STOP,
PAGE, NOP, NOPLF
Application instructions such as DMOD, PCHK, INC(P)
Application instruction in GX (MELSEC-Q/L Programming Manual (Common Instructions),
×
Works2 MELSEC-Q/L Structured Programming Manual (Common
Instructions)
SFCP, SFCPEND, BLOCK, BEND, TRANL, TRANO, TRANA,
TRANC, TRANCA, TRANOA, SEND, TRANOC, TRANOCA,
TRANCO, TRANCOC, STEPN, STEPD, STEPSC, STEPSE,
SFC instruction ×
STEPST, STEPR, STEPC, STEPG, STEPI, STEPID, STEPISC,
STEPISE, STEPIST, STEPIR, TRANJ, TRANOJ, TRANOCJ,
TRANCJ, TRANCOJ, TRANCOCJ
RETURN, IF, THEN, ELSE, ELSIF, END_IF, CASE, OF,
END_CASE, FOR, TO, BY, DO, END_FOR, WHILE,
END_WHILE, REPEAT, UNTIL, END_REPEAT, EXIT, TYPE,
ST code body END_TYPE, STRUCT, END_STRUCT, RETAIN, VAR_ACCESS, × ×
END_VAR, FUNCTION, END_FUNCTION, FUNCTION_BLOCK,
END_FUNCTION_BLOCK, STEP, INITIAL_STEP, END_STEP,
TRANSITION, END_TRANSITION, FROM, UNTILWHILE
App - 2
Appendix 1 Character Strings that cannot be Used for Label Names and FB Data Names/Instance Names
FB data name/FB
1
Category Character string Label name
instance name
Function name in application
OVERVIEW OF
Function names in application functions such as AND_E, NOT_E ×
function
FUNCTION
BLOCKS
Function block name in
Function block names in application functions such as CTD, CTU ×
application function
/, \, *, ?, <, >, |,", :, [, ], ,, =, +, %, ', ~, @, {, }, &, ^, ., tab character,
Symbol × ×
;, !, #, $, `
2
Date and time literal DATE, DATE_AND_TIME, DT, TIME, TIME_OF_DAY, TOD × ×
ACTION, END_ACTION, CONFIGURATION,
END_CONFIGURATION, CONSTANT, F_EDGE, R_EDGE, AT,
CREATING
FUNCTION
PROGRAM, WITH, END_PROGRAM, TRUE, FALSE,
BLOCKS
READ_ONLY, READ_WRITE, RESOURCE, END_RESOURCE,
Others × ×
ON, TASK, EN, ENO, BODY_CCE, BODY_FBD, BODY_IL, ,
BODY_LD, BODY_SFC, BODY_ST, END_BODY,
END_PARAMETER_SECTION, PARAM_FILE_PATH,
PARAMETER_SECTION, SINGLE, RETAIN, INTERVAL 3
String that starts with K1 to
USING FUNCTION
Such as K1AAA ×
K8
Address Such as %IX0 × ×
BLOCKS
;FB BLK START, ;FB START, ;FB END, ;FB BLK END,
Statement in Ladder
;FB IN, ;FB OUT, ;FB_NAME, ;INSTANCE_NAME, ;FB, × ×
Diagram
;INSTANCE
Common instruction Such as MOV × 4
COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8,
EDITING FUNCTION
Windows® reserved word COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, ×
MANAGING AND
LPT9, AUX, CON, PRN, NUL
*1 : Whether to handle a device name indexed with ZZ device as a reserved word depends on the parameter setting.
BLOCKS
When Z device is specified for 32-bit index setting: Not handled as a reserved word.
When ZZ device is specified for 32-bit index setting: Handled as a reserved word.
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
App - 3
APPENDIX
● In a function, the same name as the function cannot be used for a label.
● Inapplicable character strings differ between label names and data names such as FB data
names and structure names. Therefore, if a label name which contains an FB data name or
structure name is set when setting a label of instance or structure, an error may occur.
● A space cannot be used.
● A numeral cannot be used at the beginning of label name.
● A label name is not case-sensitive. An error may occur at compilation when the same label
names with different cases (example: 'AAA' and 'aaa') are declared.
● In ST programs, the same label name can be used for a global label and local label by setting
the following option.
Select "Use the same label name in global label and local label" under [Tool] [Options]
"Compile" "Basic Setting".
● An underscore (_) cannot be used at the beginning or end of label name.
Consecutive underscores (_) cannot be used for a data name or a label name.
● For Simple projects, function names and function block names in common instructions and
application functions can be used.
App - 4
Appendix 2 Supported CPU modules
1
Appendix 2 Supported CPU modules
OVERVIEW OF
The following are the programmable controller CPUs with which the FBs can be used in GX Works2.
FUNCTION
BLOCKS
Programmable controller
Programmable controller type
series
Basic model QCPU (Q00J, Q00, Q01) 2
High-performance model QCPU (Q02, Q02H, Q06H, Q12H, Q25H)
Process CPU (Q02PH, Q06PH, Q12PH, Q25PH)
QCPU (Q mode)
Redundant CPU (Q12PRH, Q25PRH)
CREATING
FUNCTION
BLOCKS
Universal model QCPU (Q00UJ, Q00U, Q01U, Q02U, Q03UD, Q03UDE, Q03UDV, Q04UDH,
Q04UDEH, Q04UDV, Q06UDH, Q06UDEH, Q06UDV, Q10UDH, Q10UDEH, Q13UDH, Q13UDEH,
Q13UDV, Q20UDH, Q20UDEH, Q26UDH, Q26UDEH, Q26UDV, Q50UDEH, Q100UDEH)
LCPU L02S, L02S-P, L02, L02-P, L06, L06-P, L26, L26-P, L26-BT, L26-PBT
3
FXCPU FX1S, FX1N, FX1NC, FX2N, FX2NC, FX3S, FX3G, FX3GC, FX3U, FX3UC
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
App - 5
APPENDIX
App - 6
Appendix 3 Using FBs Created with GX Developer in GX Works2
● "Enable calling function block and using inline ST" in the option setting 1
Depending on the selection status of "Enable calling function block and using inline ST" in "Enable
calling function block and using inline ST" under [Tool] [Options] "Compile" "Basic Setting",
OVERVIEW OF
the program after compilation will differ.
FUNCTION
BLOCKS
When the option item is unselected, the program after the compilation matches with GX Developer,
therefore, calling function blocks created with Structured Text from ladder programs and calling
function blocks created with Ladder Diagram from ST programs are enabled.
Alternatively, when the option item is selected, calling an inline structured text and calling FBs from 2
FB program are enabled.
However, the program after the compilation will be differ from that of GX Developer. Modify the
program as necessary.
CREATING
FUNCTION
BLOCKS
The differences with GX Developer are as follows:
USING FUNCTION
Since an input/output variable is
Since a temporary variable is directly assigned to the argument
Number of steps after assigned to the argument of FB, of FB, the number of steps after Check the influence of scan time due to
compilation the number of steps will be the compilation will be decreased decrease the number of steps.
BLOCKS
increased after compilation. compared to that of GX
Developer.
When changing the value of an input
Input variable
The value of an input variable can
be changed in FB.
The value of an input variable
cannot be changed in FB.
variable in FB, substitute the value to 4
the label whose class is VAR.
EDITING FUNCTION
MANAGING AND
Initial value will be the value of
Initial value of Initial value will be undefined When using the initial value, initialize
device/label assigned to the
Output output variable value. the output variable in FB.
argument.
BLOCKS
variable
Connectable When output the value to DY device,
DY device can be connected. DY device cannot be connected.
device modify the program.*1
The value of input side of device/
label is not changed. To make the value of device/label of 5
Value of I/O The value of input side and output
The operation result is returned input side not to be changed, modify the
variable side will be the same.
only to device/label of the output local label setting of the FB.*2
side.
LIBRARIES
USING FB
When connecting two or more contacts
I/O variable Two or more contacts or the Two or more contacts or the
Connectable or comparison operation contact to FB,
comparison operation contact can comparison operation contact
elements modify the local label settings of the
be connected to input side. cannot be connected to input side.
FB.*3
FUNCTION BLOCKS
constant input side. to input side.
EXAMPLES USING
of the FB.*4
*1 : Output FB to other device/label once, and then output it to DY in a rung other than the FB is used as follows:
PROGRAM
I
INDEX
App - 7
APPENDIX
App - 8
INDEX
Index - 1
PROGRAM MANAGING AND CREATING OVERVIEW OF
EXAMPLES USING USING FB EDITING FUNCTION USING FUNCTION FUNCTION FUNCTION
I
INDEX APPENDIX FUNCTION BLOCKS LIBRARIES BLOCKS BLOCKS BLOCKS BLOCKS
6
5
4
3
2
1
A
INDEX
Index - 2
Symbolic information ......................................................3-18 1
Default writing target ...............................................3-17
Writing target ...........................................................3-17
OVERVIEW OF
FUNCTION
[U]
BLOCKS
Utilizing .............................................................................4-9
[W] 2
Work window ....................................................................1-9
Write to PLC ...................................................................3-16
CREATING
FUNCTION
Writing sequence programs ...........................................3-16
BLOCKS
3
USING FUNCTION
BLOCKS
4
EDITING FUNCTION
MANAGING AND
BLOCKS
5
LIBRARIES
USING FB
6
FUNCTION BLOCKS
EXAMPLES USING
PROGRAM
A
APPENDIX
I
INDEX
Index - 3
Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation
in the United States and/or other countries.
Ethernet is a registered trademark of Fuji Xerox Co., Ltd. in Japan.
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.
SH(NA)-080984ENG-N(1806)KWIX
MODEL:GXW2-VER1-O-FB-E
MODEL CODE: 13JU72
HEAD OFFICE : TOKYO BUILDING, 2-7-3 MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPAN
NAGOYA WORKS : 1-14 , YADA-MINAMI 5-CHOME , HIGASHI-KU, NAGOYA , JAPAN
When exported from Japan, this manual does not require application to the
Ministry of Economy, Trade and Industry for service transaction permission.