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)
-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 Users Manual for the CPU module.
In this manual, the safety precautions are ranked as "
CAUTION".
WARNING
CAUTION
[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.
[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 GX Works2 Version 1 Operating Manual
(Common) 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
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
*1 :
The manual number is written at the bottom left of the back cover.
Japanese Manual Version SH-080983-N
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-3
INTRODUCTION
Thank you for purchasing the Mitsubishi integrated FA software, MELSOFT series.
Before using the product, thoroughly read this manual to develop full familiarity with the functions and performance
to ensure correct use.
CONTENTS
SAFETY PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A - 1
CONDITIONS OF USE FOR THE PRODUCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A - 2
REVISIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A - 3
INTRODUCTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A - 4
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A - 4
MANUALS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A - 7
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL . . . . . . . . . . . . . . . . . . . . . . . . .A - 15
TERMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A - 16
1-2
1.2
Features of FBs
1-3
1.3
Labels
1-4
1.4
1-5
1.5
1.4.1
FB creation procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 - 5
1.4.2
1-8
1.5.1
1.5.2
2-2
2.2
2-3
2.3
2-4
2.3.1
2.3.2
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 - 5
2.3.3
Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 - 6
2.3.4
2.3.5
2.4
Creating FB Programs
2 - 12
2.5
Converting FBs
2 - 13
2.6
2 - 14
A-4
3.2
3-2
3.1.1
3.1.2
3.1.3
3.1.4
3.1.5
3 - 19
4-2
4.2
4-3
4.2.1
4.2.2
4.2.3
4.3
4.4
4 - 10
4.5
4 - 11
4.6
Protecting FBs
4 - 13
4.7
4 - 16
4-9
USING FB LIBRARIES
5.1
Installing FB Library
5-2
5.1.1
Obtaining FB Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 - 2
5.1.2
Installing FB Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 - 2
5.2
Using FB Libraries
5-3
5.3
5-5
5.4
Uninstalling FB Library
5-6
6-2
6.2
6-3
6.3
6-4
APPENDIX
Appendix 1
Character Strings that cannot be Used for Label Names and FB Data Names/Instance
Names
App - 2
A-5
Appendix 2
App - 5
Appendix 3
App - 6
INDEX
A-6
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 name
Manual number
(Model code)
SH-080779ENG
(13JU63)
SH-080780ENG
(13JU64)
SH-080781ENG
(13JU65)
SH-080921ENG
(13JU69)
SH-080787ENG
(13JZ22)
SH-080788ENG
(13JZ23)
2)
Structured Programming
Manual name
Manual number
(Model code)
SH-080782ENG
(13JW06)
SH-080783ENG
(13JW07)
SH-080784ENG
(13JW08)
SH-080785ENG
(13JW09)
JY997D26001
(09R925)
JY997D34701
(09R926)
JY997D34801
(09R927)
A-7
3)
Operation of iQ Works
Manual name
Manual number
(Model code)
SH-081261ENG
(13JZ79)
The Operating Manuals are included on the 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-8
Purpose
GX Works2 Version 1
Operating Manual
Common
Details
2)
Details
Operation of GX Works2
GX Works2 Beginner's
Manual
Purpose
Simple
Project
Structured
Project
GX Works2 Version 1
Operating Manual
Simple Project
Common
Outline
Outline
Intelligent
Function
Module
Details
Details
Outline
Structured
Project
Details
Function
Block
Details
Details
Details
Details
A-9
3)
Purpose
Ladder
Diagram
Simple
Project
Sequential
Function Chart
Simple
Project
Structured
project
Sequential
Function Chart
Structured Ladder
/FBD
Structured Text
*1 :
A - 10
Simple
Project
Structured
Project
Outline
Details
*1
Outline
Details
Outline
Structured Text
Ladder
Diagram
Structured
Project
GX Works2 Version 1
Operating Manual
Details
Outline
Details
*1
Outline
Details
Outline
Details
Outline
Details
4)
Purpose
MELSEC-Q/L/F
Structured
Programming
Manual
MELSEC-Q/L
Structured Programming
Manual
Fundamentals
Common
Special
Application
Instructions Instructions Functions
Manual
MELSEC-Q/L
for
MELSEC-Q/L/QnA
Programming
module
Programming Manual to be
Manual
used
Common
Instruction
Learning details
of programmable
controller CPU
All
error codes,
languages
special relays,
and special
registers
Details
Learning the
types and details
of common
instructions
Details
Using
Ladder
Diagram
PID Control
Instructions
SFC
Learning the
types and details
of instructions for
intelligent
function modules
Details
Learning the
types and details
of instructions for
network modules
Details
Learning the
types and details
of instructions for
the PID control
function
Details
Learning details
Using
of specifications,
Sequential
functions, and
Function
instructions of
Chart
SFC (MELSAP3)
Learning the
fundamentals for
creating a
structured
program
Learning the
types and details
of common
instructions
Learning the
types and details
Using
of instructions for
Structured intelligent
Ladder/
function modules
FBD or
Structured Learning the
types and details
Text
of instructions for
network modules
Learning the
types and details
of instructions for
the PID control
function
Learning the
types and details
of application
instructions
Details
Details
Details
Outline
Details
Outline
Details
Details
Outline
Details
A - 11
5)
Purpose
MELSEC-Q/L/F
Structured
Programming
Manual
Fundamentals
FXCPU
Structured Programming
Manual
Device &
Common
Sequence
Instructions
Application
Functions
FXCPU
Programming
Manual
FX0, FX0S,
FX0N, FX1,
FXU, FX2C
FX1S, FX1N,
FX3S,
FX2N, FX1NC, FX3G,FX3U,
FX2NC
FX3GC,FX3UC
Using
Ladder
Diagram
Learning the
types and details
of basic/
application
instructions,
descriptions of
devices and
parameters
Details
Details
Details
Using
Sequential
Function
Chart
Learning details
of specifications,
functions, and
instructions of
SFC
Details
Details
Details
Learning the
fundamentals for
creating a
structured
program
Using
Structured
Ladder/
FBD or
Structured
Text
Learning the
descriptions of
devices,
parameters, and
error codes
Learning the
types and details
of sequence
instructions
Learning the
types and details
of application
instructions
A - 12
Details
Details
Details
Details
Screen display
Describes the screen display
procedure.
Follow the
and select [(menu)] to
open the screen.
*Screen display may differ
depending on the CPU type.
In that case, typical example is
described.
Chapter heading
Index on the right of the page
number clarifies the chapter of
currently open page.
Section title
Clarifies the section of currently
open page.
Operating procedure
Describes the operating procedure
of the function.
Reference location
leads to the reference location
and reference manual.
A - 13
This explains notes requiring attention or useful functions relating to the information given on the
same page.
Symbols used in this manual
The following shows the symbols used in this manual with descriptions and examples.
1
2
3
4
No.
Symbol
[
(Underline)
<<
>>
""
A - 14
[Project]
Screen name
<<PLC System>>
Button on a screen
Example
Toolbar icon
Description
Menu name on a menu bar
Keyboard key
button
The following are the generic terms/abbreviations of such as software packages and programmable
controller CPUs used in this manual.
Generic term and
abbreviation
Description
GX Works2
GX Developer
Personal computer
High Performance
model QCPU
Process CPU
Redundant CPU
Generic term for Q00UJ, Q00U, Q01U, Q02U, Q03UD, Q03UDE, Q03UDV, Q04UDH, Q04UDEH,
Q04UDV, Q06UDH, Q06UDEH, Q06UDV, Q10UDH, Q10UDEH, Q13UDH, Q13UDEH, Q13UDV,
Q20UDH, Q20UDEH, Q26UDH, Q26UDEH, Q26UDV, Q50UDEH, and Q100UDEH
QCPU (Q mode)
Generic term for Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU, and Universal model QCPU
LCPU
Generic term for L02S, L02S-P, L02, L02-P, L06, L06-P, L26, L26-P, L26-BT, and L26-PBT
FXCPU
Generic term for FX0S, FX0, FX0N, FX1, FX1S, FX1N, FX1NC, FXU, FX2C, FX2N, FX2NC, FX3S, FX3G,
FX3GC, FX3U, FX3UC
SFC
MELSOFT Library
Generic term for components (FB library, sample programs, drawing data) which provide easy
operation of programmable controller related modules and GOTs, and various devices that are
connected to them
Contact your local Mitsubishi representative to obtain components of MELSOFT Library.
FB
A - 15
TERMS
Common instruction
Generic term for sequence instructions, basic instructions, application instructions, data link
instructions, multiple CPU dedicated instructions, and multiple CPU high-speed transmission
dedicated instructions
Special instruction
Generic term for module dedicated instructions, PID control instructions, socket communication
function instructions, built-in I/O function instructions, and data logging function instructions
Simple Project
Generic term for projects created using Ladder Diagram, Sequential Function Chart, Structured
Text
Without labels
With labels
Project without labels
A - 16
Description
Generic term for projects created without selecting "Use Label" when creating new projects
Generic term for projects created with selecting "Use Label" when creating new projects
Generic term for Simple projects that do not use labels
Generic term for Simple projects that use labels and Structured projects
Utilization
Reuse
Library (project)
FB instance
Global label
A label which becomes effective for all program data when multiple program data items are created
in a project
Local label
Structure
A data type which allows various device types (bit device, word device, etc.) to be stored in single
aggregate (single data)
Array
A data type which allows the same device type to be stored in a consecutive area
OVERVIEW OF
FUNCTION BLOCKS
2
CREATING
FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
This chapter explains features of FBs, overview of labels, and work flow for using FBs.
USING FUNCTION
BLOCKS
1-2
1.2
Features of FBs
1-3
1.3
Labels
1-4
1.4
1-5
1.5
1-8
USING FB
LIBRARIES
1.1
MANAGING AND
EDITING FUNCTION
BLOCKS
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
1-1
GX Works2
1.1
An FB is designed to convert a ladder block, which is used repeatedly in a sequence program, into a
component to be utilized in a sequence program.
FBs can be used in projects with labels.
This manual explains FBs used in Simple projects. In the operation examples, Ladder Diagram is
selected as a programming language, but Structured Text can also be selected.
Note, however, that FXCPU Simple projects do not support Structured Text.
<After use of FB>
Project A
Program 1
FB
Program 2
Program 2
Convert the
repeatedly-used
ladder block to
a component
FB
Utilize
FB
Project B
Program 3
Project B
FB
Program 3
1-2
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
mistakes which may occur at the time of utilization can be prevented.
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
modules, and counter modules. FB libraries which support partner products are also supplied.
5
USING FB
LIBRARIES
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.
FXCPU Simple project supports only Ladder Diagram.
OVERVIEW OF
FUNCTION
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
program is improved. In addition, converting a program into a component improves program readability
and eases editing and debugging.
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
Features of FBs
MANAGING AND
EDITING FUNCTION
BLOCKS
1.2
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
1-3
GX Works2
1.3
Labels
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
This manual explains the operating procedures with examples of FBs used on QCPU (Q mode)/LCPU.
For the instructions and functions which are available for FXCPU, refer to the following manuals.
FXCPU user's manuals and programming manuals
OVERVIEW OF
FUNCTION
BLOCKS
1.4
2
FB creation procedure
CREATING
FUNCTION
BLOCKS
1.4.1
Operating procedure
Creating a project for FBs
Section 2.1
Creating an FB program
Procedure
Create an FB program using labels.
5.
Reference
Section 2.3
USING FB
LIBRARIES
Procedure
Set local labels to be used for the FB program.
4.
Reference
Section 2.2
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
3.
MANAGING AND
EDITING FUNCTION
BLOCKS
Reference
Section 2.4
Converting FBs
Procedure
Conversion finalizes the edited FB program content.
Reference
Section 2.5
APPENDIX
2.
Reference
USING FUNCTION
BLOCKS
Procedure
INDEX
1.
1-5
GX Works2
1-6
OVERVIEW OF
FUNCTION
BLOCKS
1.4.2
Operating procedure
Pasting FBs
Procedure
Paste FBs to the sequence program.
4
MANAGING AND
EDITING FUNCTION
BLOCKS
Reference
Section 3.1.4
Reference
Section 3.1.5
USING FB
LIBRARIES
Procedure
Reference
Section 3.2
APPENDIX
INDEX
5.
Section 3.1.2
4.
3
Reference
USING FUNCTION
BLOCKS
Procedure
3.
Chapter 5
CREATING
FUNCTION
BLOCKS
2.
Reference
Section 3.1.1
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
1.
1-7
GX Works2
1.5
1.5.1
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
1-8
Toolbar
Work window
GX Works2 Version 1
Operating Manual
(Simple Project)
Navigation
GX Works2 Version 1
Operating Manual
A sub screen to support operations performed on a work window.
(Common)
Display contents of a project in tree format.
Element Selection
Docking window
FB component
Output
Cross Reference
Device List
Watch 1 to 4
Find/Replace
Debug
A screen used for setting the debug which uses the simulation
function.
Status bar
Section 3.1.1
An FB registered as a component
GX Works2 Version 1
Operating Manual
(Simple Project)
GX Works2 Version 1
Operating Manual
(Common)
FB data
FB instance (entity)
5
USING FB
LIBRARIES
Sequence program
2
CREATING
FUNCTION
BLOCKS
Menu bar
Reference
USING FUNCTION
BLOCKS
Description
Display a project name.
MANAGING AND
EDITING FUNCTION
BLOCKS
Name
Title bar
OVERVIEW OF
FUNCTION
BLOCKS
Display contents
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
1-9
GX Works2
1.5.2
*1 :
1 - 10
Section 2.3
*1)
CREATING FUNCTION
BLOCKS
2
CREATING
FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
2-2
2.2
2-3
2.3
2-4
2.4
Creating FB Programs
2 - 12
2.5
Converting FBs
2 - 13
2.6
2 - 14
USING FB
LIBRARIES
2.1
MANAGING AND
EDITING FUNCTION
BLOCKS
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
2-1
GX Works2
2.1
This section explains how to create a project with labels for creating FBs.
Operating procedure
1.
).
2.
Type
Select a programmable controller type (programmable controller CPU model) used for
the project.
Project Type
Use Label
Language
3.
Description
Click the
button.
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
OVERVIEW OF
FUNCTION
BLOCKS
2.2
This section explains how to create new FB data in a project with labels.
Operating procedure
1.
).
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
3.
Description
Data Types
Data Name
Program Language
Click the
5
USING FB
LIBRARIES
2.
MANAGING AND
EDITING FUNCTION
BLOCKS
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.
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
2-3
GX Works2
2.3
2.3.1
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
Class
Label Name
Ladder Diagram
32 (Input, output, input/output labels:
16)
Structured Text
32
Data Types
128
Constant
128
Comment*1,*2
Enter a comment.
1024
*1 :
*2 :
2-4
Description
2
CREATING
FUNCTION
BLOCKS
Class setting
When an item other than the class, such as a label name and data type, is set in a blank column, "VAR" is automatically
set for "Class". Change it if necessary.
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.
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
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.
OVERVIEW OF
FUNCTION
BLOCKS
The maximum number of input/output labels which can be used in an FB program differs according to
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.
Applicable number of labels in an FB program
Programming language of FB
Input
Output
Ladder Diagram
Structured Text
For input/output labels, each input label and output label is counted as one label.
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.
2.3.2
Classes
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
Class
Description
VAR
VAR_CONSTANT
VAR_RETAIN*1
VAR_INPUT
VAR_OUTPUT
VAR_IN_OUT
A label that can be used for both input and output with the same name (input/output label).
Its value can be changed in an FB program.
INDEX
*1 :
5
USING FB
LIBRARIES
*1 :
*2 :
4
MANAGING AND
EDITING FUNCTION
BLOCKS
APPENDIX
USING FUNCTION
BLOCKS
2.3.2 Classes
2-5
GX Works2
2.3.3
Data types
Programming language
Ladder Diagram
Structured Text
Bit
Word [signed]
Single-precision
real*1
Double-precision
real*2
String*3
Time
Timer
*4
Counter
*4
Retentive timer*5
*4
Pointer
*4
*1 :
*2 :
*3 :
*4 :
*5 :
For FXCPU, this item is supported by FX2N, FX2NC, FX3S, FX3G, FX3GC, FX3U, and FX3UC only.
Supported by Universal model QCPU/LCPU only.
For FXCPU, this item is supported by FX3U and FX3UC only.
The data type cannot be used as input/output labels when pasting an FB to a ladder program.
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
2-6
OVERVIEW OF
FUNCTION
BLOCKS
2.3.4
Operating procedure
1.
Click
on the data type entry field on the Function/FB Label Setting screen.
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
Specify this to select a data type from basic types such as bit and word.
Function Blocks
Specify this to select a data type from the defined function blocks.
USING FB
LIBRARIES
Description
Simple Types
On the "Libraries" field, select the reference source such as the defined structure
that is used as the data type.
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.
(Not displayed when "Simple Types" is selected.)
Standard Lib
4.
On the "Data Type" field, select the data type, structure, or function block name.
5.
Click the
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
Item
3.
A
APPENDIX
2.
INDEX
The settings are displayed on the "Data Type" column on the Function/FB Label Setting screen.
2-7
GX Works2
Operation
1. Click
2-8
QCPU (Q mode)/LCPU
CREATING
FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
2.3.5
Screen display
Select [Tool] [Device/Label Automatic-Assign Setting].
USING FUNCTION
BLOCKS
Latch selection
field
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
Operating procedure
Description
Device
Digit
Assignment Selection
Assignment
Range
Start
End
Total Points
PLC Parameter
Device Setting Range
APPENDIX
Item
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
INDEX
2-9
GX Works2
FXCPU
Screen display
Operating procedure
2 - 10
Select the device type, and set the start and end addresses to be assigned
automatically.
Assign devices to labels with the "Device/Label Automatic-Assign Setting" function when a program
is compiled.
(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))
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
mode)/LCPU)
Refer to Considerations of compilation.
(GX Works2 Version 1 Operating Manual (Simple Project))
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.
For details of PLC parameter, refer to the following manual.
(GX Works2 Version 1 Operating Manual (Common))
CREATING
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
All programs need to be compiled when the range of automatically assigned device is changed.
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
precautionary measure.
(GX Works2 Version 1 Operating Manual (Common))
For the considerations for compiling all programs, refer to the following manual.
(GX Works2 Version 1 Operating Manual (Simple Project))
4
MANAGING AND
EDITING FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
USING FB
LIBRARIES
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
2 - 11
GX Works2
2.4
Creating FB Programs
Operating procedure
1.
2.
Create an FB program.
2 - 12
Converting FBs
For FB programs in Ladder Diagram, the edited content can be confirmed by converting the program.
Operating procedure
1.
OVERVIEW OF
FUNCTION
BLOCKS
2.5
).
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
button.
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
2.
MANAGING AND
EDITING FUNCTION
BLOCKS
2 - 13
GX Works2
2.6
2)
3)
4)
When using FBs for a sequence program to be executed multiple times in a single scan
If an FB, which contains a rising instruction, falling instruction, or an instruction that requires multiple
scans before the execution completion, is used in a sequence program to be executed multiple times in a
single scan, the program may not operate normally.
Item
Description
Fixed-cycle execution type program
Interrupt program
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.)
Rising instruction
(P instruction (such as MOVP instruction), PLS, etc.)
Falling instruction
(PLF, LDF, ANDF, ORF, MEF, FCALLP, EFCALLP, etc.)
2 - 14
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
after execution of the program.
Save the index register values in index_reg_tmp before execution of the program.
OVERVIEW OF
FUNCTION
BLOCKS
2
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
3
Set the index
register values
to "0".
4
MANAGING AND
EDITING FUNCTION
BLOCKS
5
USING FB
LIBRARIES
Restore the values saved in index_reg_tmp after execution of the program to the index registers.
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
5)
2 - 15
GX Works2
6)
<Sequence program>
<FB program>
#
$
2 - 16
1
OVERVIEW OF
FUNCTION
BLOCKS
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
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.
(WAND instruction)
Set a bit to OFF.
0th bit
H0001
HFFFE
1st bit
H0002
HFFFD
2nd bit
H0004
HFFFB
3rd bit
H0008
HFFF7
4th bit
H0010
HFFEF
5th bit
H0020
HFFDF
6th bit
H00 4 0
HFFBF
7th bit
H0080
HFF7F
8th bit
H0100
HFEFF
9th bit
H0200
HFDFF
10th bit
H0 4 00
HFBFF
11th bit
H0800
HF7 FF
12th bit
H1000
HEFFF
13th bit
H2000
HDFFF
14th bit
H4 000
HBFFF
15th bit
H8000
H7 FFF
5
USING FB
LIBRARIES
(WOR instruction)
Set a bit to ON.
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
Bit position
MANAGING AND
EDITING FUNCTION
BLOCKS
A
APPENDIX
<For FXCPU>
Set ON to the 0th bit and the 4th bit of int_WordData with the WOR instruction.
*For the specification of the bit position, refer to the following table.
INDEX
7)
2 - 17
GX Works2
8)
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).
1234 H
int_Write_Array[0]
1234 H
D1001
2345 H
int_Write_Array[1]
2345 H
D1002
3456 H
int_Write_Array[2]
3456 H
D1003
4567 H
int_Write_Array[3]
4567 H
D1004
5678H
int_Write_Array[4]
5678H
D1005
6789H
int_Write_Array[5]
6789H
D1000(i_Write_Data)
2 - 18
Transfer 6
points with
BMOV
USING FUNCTION
BLOCKS
2
CREATING
FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
4
MANAGING AND
EDITING FUNCTION
BLOCKS
3 - 19
5
USING FB
LIBRARIES
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
3.2
3-2
A
APPENDIX
INDEX
3.1
3-1
GX Works2
3.1
This section explains how to create a sequence program using FBs as components.
3.1.1
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
3.
When changing the name, avoid creating the same name in the same program.
3-2
4.
Click the
button.
OVERVIEW OF
FUNCTION
BLOCKS
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
FB instance name
A name can be set using up to 16 characters. Alphabets are case-sensitive.
Numeric characters cannot be used as the first character. For unusable characters, refer to Appendix 1.
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
selected in step 2.
MANAGING AND
EDITING FUNCTION
BLOCKS
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
USING FB
LIBRARIES
APPENDIX
INDEX
3-3
GX Works2
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
Data name
Data name
Label name
Label name
3-4
By entering an FB name in an ST program, the FB can be called in the same manner as pasting an FB
in a ladder program.
Operating procedure
Enter an FB label name, input variable, and output variable in the ST program.
CREATING
FUNCTION
BLOCKS
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.
4
MANAGING AND
EDITING FUNCTION
BLOCKS
FB label name
Output variable
3
USING FUNCTION
BLOCKS
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
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.
Y70: = FB_TIMER. In operation;
APPENDIX
INDEX
OVERVIEW OF
FUNCTION
BLOCKS
USING FB
LIBRARIES
3-5
GX Works2
3.1.2
Create input and output circuits of the FB instance pasted to a sequence program.
Input circuit
Output circuit
Operating procedure
1.
2.
button.
The ladder block is converted, and lines are connected to the input labels and output labels of the
FB instance.
3-6
3.
OVERVIEW OF
FUNCTION
BLOCKS
Enter elements in the same manner as creating normal ladder programs. Create a program
meeting data type of input variable.
<Bit type>
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
If the data type of input variable is not a bit type, enter the device directly on the Enter Symbol
screen.
5
USING FB
LIBRARIES
Enter elements to the output circuit in the same manner as the input circuit.
A
APPENDIX
Edit the program other than FBs as necessary. After finishing the editing, convert/compile the
program.
INDEX
4.
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
3-7
GX Works2
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.
Setting of the number of displayed
contacts
9 contacts
3 contacts
2 contacts + 1 coil
11 contacts
4 contacts
3 contacts + 1 coil
13 contacts
5 contacts
4 contacts + 1 coil
17 contacts
7 contacts
6 contacts + 1 coil
21 contacts
9 contacts
8 contacts + 1 coil
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
Description
Device comment
Label comment
Statement
Note
Reference
GX Works2 Version 1 Operating
Manual (Common)
GX Works2 Version 1 Operating
Manual (Simple Project)
3-8
1)
OVERVIEW OF
FUNCTION
BLOCKS
CREATING
FUNCTION
BLOCKS
2)
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
3)
Parallel connections cannot be created in the input or output circuit. An error occurs when
the program is converted.
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
A
The data type of the input or output circuit of the FB instance, and the data type of the
contact/coil/application instruction to be connected must be the same.
Using different data types at the connection causes an error at compilation.
5)
If the instance is not registered on the label setting screen when utilizing the FB to the
ladder program, the information of FB name change and FB deletion are not applied to the
label setting and the program.
In this case, delete the FB instance in the program manually, and utilize the FBs again.
APPENDIX
4)
INDEX
3-9
GX Works2
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)
3 - 10
Function blocks using inline structured text programs cannot be used in programs other
than Ladder Diagram.
Operating procedure
1.
OVERVIEW OF
FUNCTION
BLOCKS
3.1.3
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
2.
3 - 11
GX Works2
3.1.4
Operating procedure
1.
).
2.
Click the
button after reading and understanding the considerations
described on the message.
All programs are converted/compiled and the result is displayed on the Output window.
By double-clicking the result (errors/warnings only), the corresponding error location in the
program is displayed.
Output window
3 - 12
2
CREATING
FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
FB
USING FUNCTION
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.
MANAGING AND
EDITING FUNCTION
BLOCKS
Operating procedure
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
A
APPENDIX
File list
INDEX
1.
3 - 13
GX Works2
2.
Description
Set the memory whose size is to be calculated, and memory card type.
For details of the memory card application, refer to the following manuals.
QCPU User's Manual (Hardware Design, Maintenance and Inspection)
MELSEC-L CPU Module User's Manual (Hardware Design, Maintenance and
Inspection)
File list
Target
3.
Click the
button.
Target section
Calculation
result section
3 - 14
OVERVIEW OF
FUNCTION
BLOCKS
Display sizes and capacities of program and symbolic information calculated offline.
Displayed values are values when the program and parameters are written to a programmable
controller CPU.
Operating procedure
The Confirm Memory Size screen is displayed. For details, refer to the following manual.
GX Works2 Version 1 Operating Manual (Common)
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
3 - 15
GX Works2
3.1.5
Operating procedure
1.
).
3 - 16
OVERVIEW OF
FUNCTION
BLOCKS
2.
CREATING
FUNCTION
BLOCKS
button.
USING FUNCTION
BLOCKS
Click the
4
MANAGING AND
EDITING FUNCTION
BLOCKS
3.
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
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/
FX3UC version 3.00 or later, the memory cassette can be used, however, the symbolic information cannot be read
from the memory cassette. When the symbolic information is written to a memory cassette on an FXCPU other than
FX3U/FX3UC version 3.00 or later, the symbolic information may be corrupted.
USING FB
LIBRARIES
APPENDIX
INDEX
3 - 17
GX Works2
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.
Item
Included data
Global labels
POU
Symbolic
information
Programs
Local labels
FBs
Structures
3 - 18
Execute the monitoring function to check the operation of the programs written to the programmable
controller CPU.
FB programs can also be monitored.
Operating procedure
Select [Online] [Monitor] [Start Monitoring] (
).
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
OVERVIEW OF
FUNCTION
BLOCKS
3.2
3 - 19
GX Works2
3 - 20
2
CREATING
FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
4-3
4.3
4-9
4.4
4 - 10
4.5
4 - 11
4.6
Protecting FBs
4 - 13
4.7
4 - 16
5
USING FB
LIBRARIES
4.2
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
4-2
A
APPENDIX
INDEX
4.1
MANAGING AND
EDITING FUNCTION
BLOCKS
4-1
GX Works2
4.1
Read FB programs from a programmable controller CPU. When reading FB programs, read symbolic
information with a project with labels using the Read from PLC function.
Before reading data, set a communication route of a personal computer and programmable controller
CPU with the connection destination setting. For details of connection destination setting, refer to the
following manual.
GX Works2 Version 1 Operating Manual (Common)
Operating procedure
1.
2.
3.
Click the
button.
FXCPU
For FXCPU projects with labels, created project data can be read from FX3U/FX3UC version 3.00 or later only.
4-2
This section explains how to reuse the created FBs in another project.
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.
OVERVIEW OF
FUNCTION
BLOCKS
4.2
The following shows the procedure for reusing the FBs in the created library (project) to other project.
Operating procedure
Reference
Reference
GX Works2 Version 1
Operating Manual (Common)
Section 4.2.2
5
USING FB
LIBRARIES
Reference
GX Works2 Version 1
Operating Manual (Common)
Section 4.2.3
A
APPENDIX
3.
MANAGING AND
EDITING FUNCTION
BLOCKS
INDEX
2.
USING FUNCTION
BLOCKS
1.
CREATING
FUNCTION
BLOCKS
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
4.2.1
4-3
GX Works2
4.2.2
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.
4-4
Select FBs, global labels, and structures to be exported to the target project from
the FB List.
Click the
same time.
1
OVERVIEW OF
FUNCTION
BLOCKS
2.
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
Click the
4.
Click the
MANAGING AND
EDITING FUNCTION
BLOCKS
3.
button.
The selected FBs, global labels, and structures are exported to the target project.
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
Block password
An FB with a block password cannot be exported. Unlock the block password of the project being edited before export
the 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.
When an FB with the different start number of index register is exported, check the program using the index setting
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
project is overwritten and deleted.
In this case, change the data name before exporting the data.
USING FB
LIBRARIES
APPENDIX
INDEX
4-5
GX Works2
4.2.3
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.
2.
Select "Select Library (Project)" from the "Library List" combo box.
3.
Click the
4.
Click the
4-6
Select FBs, global labels, and structures to be imported to the editing project from
the FB List.
Click the
same time.
1
OVERVIEW OF
FUNCTION
BLOCKS
5.
CREATING
FUNCTION
BLOCKS
button.
The imported FBs, global labels, and structures are displayed on the project view.
For utilizing FBs, refer to Chapter 3.
Block passwords
An FB with a block password cannot be imported. Delete the block password of the source project before importing the
FB.
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
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.
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.
MANAGING AND
EDITING FUNCTION
BLOCKS
Click the
5
USING FB
LIBRARIES
6.
USING FUNCTION
BLOCKS
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
4-7
GX Works2
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
2.
Item
Description
3.
Click the
button.
4-8
FBs can be reused by starting another GX Works2, and copying and pasting the FBs from the source
project to the target project.
This section explains how to reuse FBs in an existing project.
1.
2.
Move the FB data in the source project to "FB_Pool" in the target project with the
drag-and-drop operation.
Source project
Target project
CREATING
FUNCTION
BLOCKS
Operating procedure
3.
OVERVIEW OF
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
4.3
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
A
APPENDIX
INDEX
4-9
GX Works2
4.4
This section explains how to change the FB instance name of an FB pasted to a ladder program.
The global label or local label need to be registered/changed to the same name as the changed FB
instance name.
Operating procedure
1.
FB instance name
2.
3.
Enter a new FB instance name, and select "Change All" or "Change Only Selection
FB".
4.
Click the
button.
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
Operating procedure
Select an FB to be deleted on the Project view.
CREATING
FUNCTION
BLOCKS
1.
OVERVIEW OF
FUNCTION
BLOCKS
4.5
USING FUNCTION
BLOCKS
2.
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
button.
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
Click the
APPENDIX
INDEX
3.
4 - 11
GX Works2
4.
button.
Deletion target
FB data
4 - 12
FB data
Protecting FBs
Setting a block password protects created FB programs and disables browsing program contents.
The following operations are disabled when a block password is set.
Displaying and editing FB programs
Editing FB local labels
CREATING
FUNCTION
BLOCKS
Operating procedure
1.
OVERVIEW OF
FUNCTION
BLOCKS
4.6
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
5
Select an FB to be protected, and click the
button.
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
2.
4 - 13
GX Works2
3.
button.
On the "Registration Status" field of the Set Block Password screen, "Unlocked" is displayed.
4.
Click the
button.
The protection of the FB by the block password becomes effective when the project is saved and
opened once again.
The lock marks are appended to the FB icons on the Project view.
4 - 14
Operating procedure
OVERVIEW OF
FUNCTION
BLOCKS
2.
button.
CREATING
FUNCTION
BLOCKS
1.
USING FUNCTION
BLOCKS
button.
The block password is unlocked, and "Unlocked" is displayed on the "Registration Status" field of
the Set Block Password screen.
MANAGING AND
EDITING FUNCTION
BLOCKS
3.
1.
2.
USING FB
LIBRARIES
Operating procedure
button.
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
A
Click the
button.
APPENDIX
INDEX
3.
4 - 15
GX Works2
4.7
Operating procedure
1.
2.
Enter an FB instance name to be searched for "Find In", and click the
button or the
When the
button.
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
OVERVIEW OF
FUNCTION
BLOCKS
USING FB LIBRARIES
2
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
Installing FB Library
5-2
5.2
Using FB Libraries
5-3
5.3
5-5
5.4
Uninstalling FB Library
5-6
5
USING FB
LIBRARIES
5.1
MANAGING AND
EDITING FUNCTION
BLOCKS
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
5-1
GX Works2
5 USING FB LIBRARIES
5.1
Installing FB Library
5.1.1
Obtaining FB Library
5.1.2
Installing FB Library
Operating procedure
1.
2.
5-2
Using FB Libraries
OVERVIEW OF
FUNCTION
BLOCKS
5.2
Operating procedure
1.
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
2.
4
button.
"FB List" is updated.
USING FB
LIBRARIES
APPENDIX
INDEX
3.
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
5-3
GX Works2
5 USING FB LIBRARIES
4.
Click the
button.
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
This section explains how to check the usage of the imported FB library and the application of labels.
Operating procedure
Select an FB from the Project view.
2.
2
CREATING
FUNCTION
BLOCKS
1.
OVERVIEW OF
FUNCTION
BLOCKS
5.3
USING FUNCTION
BLOCKS
4
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
5-5
GX Works2
5 USING FB LIBRARIES
5.4
Uninstalling FB Library
This section explains how to uninstall the installed FB Library, using Windows XP as an example.
Operating procedure
1.
2.
3.
Click the
button.
5-6
PROGRAM EXAMPLES
USING FUNCTION
BLOCKS
2
CREATING
FUNCTION
BLOCKS
OVERVIEW OF
FUNCTION
BLOCKS
3
USING FUNCTION
BLOCKS
6-3
6.3
6-4
5
USING FB
LIBRARIES
6.2
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
6-2
A
APPENDIX
INDEX
6.1
MANAGING AND
EDITING FUNCTION
BLOCKS
6-1
GX Works2
6.1
Sensor
(X1)
Conveyor
Motor
Control panel
Operation panel
Operation Buzzer
(X0)
(Y1)
(Y0)
#
No.
6-2
Category
Model name
&
'
Description
Base unit
Q33B
Q62P
CPU module
Q02UCPU
Input module
QX40
Output module
QY40P
When the number of boxes to be conveyed is set, and the operation switch is pressed, the conveyor
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.
OVERVIEW OF
FUNCTION
BLOCKS
6.2
2
CREATING
FUNCTION
BLOCKS
Start
3
USING FUNCTION
BLOCKS
4
MANAGING AND
EDITING FUNCTION
BLOCKS
5
NO
USING FB
LIBRARIES
YES
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
A
APPENDIX
End
INDEX
6-3
GX Works2
6.3
This section explains how to set FB local labels, and the examples of FB program and sequence
program using FBs, based on the system configuration and processing aforementioned.
Label name
FB_EN
Data type
Bit
Comment
Operation switch
VAR_INPUT
i_sensor
Bit
Sensor
VAR_OUTPUT
FB_ENO
Bit
FB is running
VAR_OUTPUT
FB_OK
Bit
Normal end
VAR_OUTPUT
o_conveyor
Bit
Conveyor
VAR_OUTPUT
o_buzzer
Bit
Buzzer
VAR_INPUT
i_counter
Word [signed]
VAR
counter
Word [signed]
VAR
counter_end
Bit
conveying completed
VAR
conveyor_end
Bit
VAR
timer1
Word [signed]
VAR
timer2
Word [signed]
The following is a setting example displayed on the Function/FB Label Setting screen.
6-4
APPENDIX
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
USING FB
LIBRARIES
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
CREATING
FUNCTION
BLOCKS
INDEX
FB program example
6-5
GX Works2
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
1
OVERVIEW OF
FUNCTION
BLOCKS
The additional conveyor operation switch, sensor, conveyor driving relay, and buzzer are to be
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.
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
6-7
GX Works2
MEMO
6-8
OVERVIEW OF
FUNCTION
BLOCKS
APPENDIX
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
App - 6
5
USING FB
LIBRARIES
App - 5
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
A
APPENDIX
App - 2
INDEX
MANAGING AND
EDITING FUNCTION
BLOCKS
App - 1
GX Works2
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
Character string
FB data name/FB
instance name
Label name
Class identifier
Data type
Device name
X, Y, D, M, T, B, C, F, L, P, V, Z, W, I, N, U, J, K, H, E, A, SD, SM,
SW, SB, FX, FY, DX, DY, FD, TR, BL, , SG, VD, ZR, ZZ*1
Such as X0
NOT, MOD
(, ), -
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
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 instruction in GX
Works2
SFC instruction
ST code body
Category
ST operator
IL operator
App - 2
Appendix 1 Character Strings that cannot be Used for Label Names and FB Data Names/Instance Names
Symbol
Others
Such as K1AAA
Address
Such as %IX0
Statement in Ladder
Diagram
;FB BLK START, ;FB START, ;FB END, ;FB BLK END,
;FB IN, ;FB OUT, ;FB_NAME, ;INSTANCE_NAME, ;FB,
;INSTANCE
Common instruction
Such as MOV
4
MANAGING AND
EDITING FUNCTION
BLOCKS
Whether to handle a device name indexed with ZZ device as a reserved word depends on the parameter setting.
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.
USING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
*1 :
1
OVERVIEW OF
FUNCTION
BLOCKS
Label name
Character string
CREATING
FUNCTION
BLOCKS
FB data name/FB
instance name
Category
App - 3
GX Works2
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
The following are the programmable controller CPUs with which the FBs can be used in GX Works2.
Programmable controller
series
OVERVIEW OF
FUNCTION
BLOCKS
Appendix 2
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
5
USING FB
LIBRARIES
FX1S, FX1N, FX1NC, FX2N, FX2NC, FX3S, FX3G, FX3GC, FX3U, FX3UC
6
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
FXCPU
A
APPENDIX
L02S, L02S-P, L02, L02-P, L06, L06-P, L26, L26-P, L26-BT, L26-PBT
INDEX
LCPU
CREATING
FUNCTION
BLOCKS
App - 5
GX Works2
APPENDIX
Appendix 3
FBs created with GX Developer can be used by selecting [Open Other Project] under [Project]
[Open Other Data], and open the project in GX Works2.
Note that GX Works2 and GX Developer differ in the following points.
Character strings that cannot be used for label names
For unusable character strings with GX Developer, refer to the following manual.
GX Developer Version 8 Operating Manual
Usable instructions with ST programs
Instruction names differ between GX Developer ST and GX Works2 ST.
If compilation results in an error, change the relevant part to the instruction name of GX Works2.
For the ST instructions of GX Developer and GX Works2, refer to the following.
GX Works2 Version 1 Operating Manual (Common)'s "ST instruction table for GX Works2 and
GX Developer"
Alternatively, select "Use Dedicated Instruction for GX Developer, GX IEC Developer" under [Tool]
[Options] "Project" "Common Setting" "Other Project Dedicated Instruction Setting".
App - 6
Correction method
Input variable
Connectable
device
Value of I/O
variable
Connectable
elements
Connection of
constant
*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:
*2 :
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
A
APPENDIX
I/O variable
INDEX
Output
variable
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
Difference
2
CREATING
FUNCTION
BLOCKS
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",
the program after compilation will differ.
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
FB program are enabled.
However, the program after the compilation will be differ from that of GX Developer. Modify the
program as necessary.
The differences with GX Developer are as follows:
OVERVIEW OF
FUNCTION
BLOCKS
"Enable calling function block and using inline ST" in the option setting
App - 7
GX Works2
APPENDIX
*3 :
*4 :
App - 8
INDEX
APPENDIX
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
USING FB
LIBRARIES
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
CREATING
FUNCTION
BLOCKS
INDEX
OVERVIEW OF
FUNCTION
BLOCKS
Index - 1
GX Works2
INDEX
[A]
Assigning devices automatically ...................................... 2-9
FXCPU .................................................................... 2-10
QCPU (Q mode)/LCPU ............................................. 2-9
[B]
block password .............................................................. 4-13
Deleting ................................................................... 4-15
Setting ..................................................................... 4-13
Unlocking ................................................................ 4-15
[C]
Calculating memory size (FXCPU) ................................ 3-15
Calculating memory size (QCPU(Q mode)/LCPU) ........ 3-13
Change Instance (Function Block) screen ..................... 3-20
Checking Operations of Sequence Programs ................ 3-19
Classes ............................................................................ 2-5
Comment ......................................................................... 3-8
Compatible CPU ..........................................................App-5
Compile .......................................................................... 3-12
Considerations of automatically assigned devices ........ 2-11
Converting ...................................................................... 2-13
Converting/compiling ..................................................... 3-12
Creating Projects for FBs ................................................. 2-2
Creating Sequence program ............................................ 3-2
[D]
[G]
Global labels .................................................................... 1-4
[L]
Label name ....................................................... 2-4, 3-2, 3-4
Labels ............................................................................... 1-4
Character strings that cannot be used ..................App-2
Ladder editing mode ...................................................... 3-20
Local labels ...................................................................... 1-4
Setting ....................................................................... 2-4
[E]
[F]
FB .................................................................................... 1-2
Create FBs ................................................................ 2-1
Creating New FB Data .............................................. 2-3
Programming Flow with FBs ..................................... 1-5
Protecting ................................................................ 4-13
FB component .................................................................. 1-9
FB data ............................................................................ 1-9
Deleting ................................................................... 4-11
FB instance ...................................................................... 1-9
Creating input and output circuits ............................. 3-6
FB instance name ............................................................ 3-2
Changing ................................................................ 4-10
Character strings that cannot be used ..................App-2
Searching/Replacing ............................................... 4-16
FB Label Setting screen ..........................................1-10, 2-4
FB Libraries ...................................................................... 5-1
Index - 2
[M]
[N]
[O]
Output window ............................................................... 3-12
[P]
password ........................................................................ 4-13
Program examples ........................................................... 6-1
Program size after compilation ....................................... 3-13
[R]
Read from PLC ................................................................ 4-2
Rebuild All ...................................................................... 3-12
Reusing ............................................................................ 3-2
[S]
Selecting data types ......................................................... 2-7
Setting arrays for data type .............................................. 2-8
1
OVERVIEW OF
FUNCTION
BLOCKS
[U]
Utilizing .............................................................................4-9
[W]
CREATING
FUNCTION
BLOCKS
USING FUNCTION
BLOCKS
MANAGING AND
EDITING FUNCTION
BLOCKS
USING FB
LIBRARIES
PROGRAM
EXAMPLES USING
FUNCTION BLOCKS
APPENDIX
INDEX
Index - 3
Microsoft, Windows are trademarks or registered trademarks of Microsoft Corporation in the United States
and other countries.
Ethernet is a trademark or registered trademark of Xerox Corporation.
All other company names and product names used in this manual are trademarks or registered trademarks of
their respective companies.
SH(NA)-080984ENG-L(1503)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.