Mitsubishi Electric GX Developer Version 7 Operating Manual v2
![Mitsubishi Electric GX Developer Version 7 manual cover](/images/cb7de5a88e8d8a9e89dec6b1/thumbs/thumb175x175.webp)
![English English](/static/img/blank.webp)
SW7D5-GPPW-O-FB-E
13JU20
SH(NA)-080174-A(0106)MEE
SW7D5C-GPPW-E
Operating Manual (Function Block) Operating Manual
Specifications subject to change without notice.
HEAD OFFICE : MITSUBISHI DENKI BLDG MARUNOUCHI TOKYO 100-8310 TELEX : J24532 CABLE MELCO TOKYO NAGOYA WORKS : 1-14 , YADA-MINAMI 5 , HIGASHI-KU, NAGOYA , JAPAN
MODEL
MODEL CODE
When exported from Japan, this manual does not require application to the Ministry of Economy, Trade and Industry for service transaction permission.
O
G X
D eveloper V
ersion7 O perating M
anual (F unction B
lock)
(Function Block)
A - 1 A - 1
SAFETY PRECAUTIONS (Always read these instructions before using this equipment.)
Before using this product, please read this manual and the relevant manuals introduced in this manual
carefully and pay full attention to safety to handle the product correctly.
The instructions given in this manual are concerned with this product. For the safety instructions of the
programmable controller system, please read the CPU module user's manual.
In this manual, the safety instructions are ranked as "DANGER" and "CAUTION".
! DANGER
CAUTION!
Indicates that incorrect handling may cause hazardous conditions, resulting in death or severe injury.
Indicates that incorrect handling may cause hazardous conditions, resulting in medium or slight personal injury or physical damage.
Note that the ! CAUTION level may lead to a serious consequence according to the circumstances.
Always follow the instructions of both levels because they are important to personal safety.
Please save this manual to make it accessible when required and always forward it to the end user.
[Design Instructions]
! DANGER
For data change, program change, and status control made to the PLC which is running from a
Personal computer, configure the interlock circuit externally so that the system safety is
ensured.The action to be taken for the system at the occurrence of communication errors
caused by such as loose cable connection must be determined for online operation of PLC from
Personal computers.
! CAUTION
Before connecting a Personal computer to a CPU module in the RUN status and carrying out
online operation (particularly program changes, forced output, and changing the operating
status), read the manual carefully and confirm safety. Failure to do this could result in damage to
the machine and accidents due to misoperation.
A - 2 A - 2
REVISIONS * The manual number is given on the bottom left of the back cover.
Print Date * Manual Number Revision May, 2001 SH (NA) 080174-A First edition Jun., 2002 SH (NA) 080174-B Addition
Section 4.2.1
Japanese Manual Version SH-080173-C
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.
2001 MITSUBISHI ELECTRIC CORPORATION
A - 3 A - 3
INTRODUCTION
Thank you for choosing the Mitsubishi MELSOFT series Integrated FA software. Read this manual and make sure you understand the functions and performance of MELSOFT series sequencer thoroughly in advance to ensure correct use.
CONTENTS
Safety Precautions .........................................................................................................................................A- 1
Revisions ........................................................................................................................................................A- 2
Contents .........................................................................................................................................................A- 3
About Manuals ...............................................................................................................................................A- 5
About the Generic Terms and Abbreviations ................................................................................................A- 6
1 OVERVIEW 1- 1 to 1- 7
1.1 What Is Function Block (FB)?.................................................................................................................. 1- 1
1.2 Features ................................................................................................................................................... 1- 2
1.3 Layouts and Names of Windows for Creating FB................................................................................... 1- 2
1.4 What You Should Understand Before Using the FB............................................................................... 1- 4
1.5 Specifications ........................................................................................................................................... 1- 5
1.5.1 Compatible CPUs............................................................................................................................... 1- 5
1.5.2 Specifications of and precautions for the FB..................................................................................... 1- 5
2 GENERAL PROCEDURES FOR EDITING THE FB 2- 1 to 2- 2
3 CREATING NEW SEQUENCE PROGRAM USING FB 3- 1 to 3-39
3.1 Crating New Project for FB ...................................................................................................................... 3- 1
3.2 Adding New FB Definition to the Created Project................................................................................... 3- 5
3.3 Creating FB Definition Program............................................................................................................... 3- 7
3.4 Creating FB Variables.............................................................................................................................. 3-11
3.5 Converting the FB Definition (Compile)................................................................................................... 3-14
3.6 Pasting the Converted FB to Sequence Program (FB Utilization) ......................................................... 3-16
3.6.1 Pasting the FB definition to sequence program ................................................................................ 3-16
3.6.2 Changing the name (FB name) of the pasted FB (FB name changing) .......................................... 3-19
3.7 Creating the Sequence Program............................................................................................................. 3-21
3.7.1 Editing the sequence program........................................................................................................... 3-21
3.7.2 Confirming the data of the pasted FB................................................................................................ 3-24
3.7.3 Searching/replacing the sequence program (Search/replace) ......................................................... 3-26
3.7.4 Creating/displaying the comments, statements or notes (Sentence creation) ......................................... 3-28
3.8 Converting the Sequence Program into Program to Be Executed on the PLC CPU (Compile) ........... 3-29
3.9 Writing the Converted Sequence Program to the PLC CPU (Write to PLC) ......................................... 3-32
3.10 Monitoring and Testing the Sequence Program ................................................................................... 3-33
3.10.1 Monitoring the sequence program................................................................................................... 3-33
3.10.2 Testing the sequence program (Device test) .................................................................................. 3-36
3.11 Correcting the FB................................................................................................................................... 3-38
3.12 Making Online Program Correction to the Sequence Program............................................................ 3-39
A - 4 A - 4
4 UTILIZING THE EXISTING FB TO CREATE SEQUENCE PROGRAM 4- 1 to 4- 9
4.1 Creating Project for FB ............................................................................................................................ 4- 1
4.1.1 Creating a new project ....................................................................................................................... 4- 1
4.1.2 Reading the existing project............................................................................................................... 4- 1
4.2 Utilizing the Existing FB Definition (Copy)............................................................................................... 4- 2
4.2.1 Utilizing the existing FB definition from another project.................................................................... 4- 2
4.2.2 Utilizing the existing FB definition within the same project ............................................................... 4- 4
4.3 Changing the FB Definition Name........................................................................................................... 4- 6
4.4 Correcting the Program Body or FB Variables of the Utilized FB Definition.......................................... 4- 8
4.5 Converting the FB Definition (Compile)................................................................................................... 4- 9
4.6 Pasting the Converted FB to the Sequence Program (FB Utilization) ................................................... 4- 9
4.7 Creating the Sequence Program............................................................................................................. 4- 9
4.8 Converting the Sequence Program into the Program to Be Executed on the PLC CPU (Compile)..... 4- 9
4.9 Writing the Converted Sequence Program to the PLC CPU (Write to PLC) ......................................... 4- 9
5 DELETING UNNECESSARY FB DEFINITION FROM THE PROJECT 5- 1 to 5- 2
6 COMBINING MULTIPLE PROGRAMS INTO ONE 6- 1 to 6- 2
6.1 Combining Sequence Programs into One .............................................................................................. 6- 1
6.2 Combining Comments into One (Data Joint) .......................................................................................... 6- 2
7 VERIFYING THE PROJECTS 7- 1 to 7- 2
8 PRINTING 8- 1 to 8- 4
8.1 Printing the Sequence Program Including FB......................................................................................... 8- 1
8.2 Printing the FB Definition ......................................................................................................................... 8- 3
APPENDICES Appendix- 1 to Appendix - 2
Appendix 1 Character Strings Unusable as Labels and FB Names ...............................................Appendix- 1
INDEX Index - 1 to Index - 2
A - 5 A - 5
About Manuals
The following manuals are also related to this product.
In necessary, order them by quoting the details in the tables below.
Related Manuals
Manual Name Manual Number (Model Code)
GX Developer Version 7 Operating Manual (Startup)
Describes the system configuration, installation method and starting method of GX Developer.
(Option)
SH-080165 (13JU13)
GX Developer Version 7 Operating Manual
Explains the functions of the programming, printout, monitoring and debugging methods and so on
GX Developer. (Option)
SH-080166 (13JU14)
REMARK
The above manuals are contained in the CD-ROM together with the software
package as a set.
If you want the manuals separately, they are available optionally as printed matter.
When placing an order, please indicate the manual numbers (type codes) given in
the above table.
A - 6 A - 6
About the Generic Terms and Abbreviations
This manual uses the following generic names and abbreviations to represent the GX Developer software package and PLC CPU modules. The module type is given when the corresponding type must be indicated clearly.
Generic Term/Abbreviation Description
GX Developer Generic product name of product types SWnD5C-GPPW, SWnD5C-GPPW-A, SWnD5C-GPPW-V and SWnD5C-GPPW-VA. (n indicates Version 7 or later.)
FB Abbreviation of the function block.
QnACPU Generic name of the MELSEC-QnA series PLC CPUs.
QCPU (Q mode) Generic name of the Q00(J)CPU, Q01CPU, Q02(H)CPU, Q06HCPU, Q12HCPU and Q25HCPU.
ACPU Generic name of the MELSEC-A series PLC CPUs. It includes the QCPUs (A mode) and motion controllers (SCPU).
QCPU (A mode) Generic name of the Q02(H)CPU-A and Q06HCPU-A.
FXCPU Generic name of the MELSEC-FX series PLC CPUs. (The target PLCs are the FX0, FX0S, FX0N, FX1, FX2, FX2C, FX1S, FX1N, FX2N and FX2NC.)
QnA series When GX Developer is started on the QnACPU.
Q series When GX Developer is started on the QCPU (Q mode).
1 - 1 1 - 1
MELSOFT 1 OVERVIEW
1 OVERVIEW
This manual describes the operations of editing the function block (hereafter
abbreviated to the FB) of the GX Developer Version 7 software package (hereafter
abbreviated to GX Developer).
For the explanation of the functions other than the FB, refer to the corresponding
manuals given in the "Related Manuals".
1.1 What Is Function Block (FB)?
The FB is a function designed to convert a ladder block, which is used in a sequence
program repeatedly, into a component (FB) to utilize it in the sequence program.
This not only increases the efficiency of program development but also reduces
programming mistakes to improve program quality.
FB
Definition of FB
Definition of FB definition program and FB variables
FB variables
FB definition program
Utilization of FB
Pasting of FB to sequence program Creation of sequence program
Compile
Debugging
Write to PLC 1
1: GX Developer performs write to PLC to write the compiled sequence program to the PLC CPU.
Hence, the FB cannot be displayed if read from PLC is performed to read the sequence program
from the PLC CPU. Carefully store the sequence program that is not yet compiled since it is
needed to correct the FB.
1
1 - 2 1 - 2
MELSOFT 1 OVERVIEW
1.2 Features
The FB has the following features. (1) Conversion of program into component
Displaying a standard program as a single block improves the reuse and
readability of the program, facilitating editing and debugging. This ensures ease
of configuring a large-scale program.
(2) Uniform program quality Reusing the components of a standard program provides uniform program
quality, which is independent of the technological level of a program developer. It
also prevents programming mistakes during utilization.
(3) Editing function of high operability The FB can be utilized easily in a sequence program by drag and drop operation.
1.3 Layouts and Names of Windows for Creating FB
This section describes the layouts and names of the windows used to create the FB.
(1) Window used to create FB definition program (FB definition window) This window is used to edit an FB definition program, which is created in a ladder
or list format.
Labels define variable types, device types and others on the FB variable setting
window in (2).
FB definition
FB variables
Program body
Function Block tab (FB tab) FB definition window
FB definition program
1
1 - 3 1 - 3
MELSOFT 1 OVERVIEW
(2) Window used to create FB definition labels (variables) (FB variable setting window) This window is used to define the labels used for the FB definition.
FB variable setting window
(3) Window used to create a sequence program (Sequence program window) This window is used to edit a sequence program where the FB is pasted.
Create the sequence program in a ladder format. A list format cannot be used.
Project tab Sequence program window
Output ladder section
Function block (FB)
Input ladder section 1
1: The step numbers of the sequence program, which is not yet compiled, are
displayed with parentheses, i.e. (Step number).
After completion of compile, the step numbers are displayed without parentheses.
When compile is complete, the step numbers may be changed.
1 - 4 1 - 4
MELSOFT 1 OVERVIEW
Name Description
Function Block tab (FB tab) Tab that displays the FB definition of the project data list.
FB variables (Header) Label used for the FB definition.
FB definition Data having a Body and Header as a pair.
FB definition window Window used to edit an FB definition program.
FB definition program (body) Program whose labels have been created on the FB definition window.
FB variable setting window Window used to set FB variables.
Project tab Table that displays project information in the project data list.
FB Function block pasted to a sequence program.
FB section Square symbol that represents the FB pasted to the sequence program.
Input ladder section Input ladder on the left side of the FB section.
Output ladder section Output ladder on the right side of the FB section.
Sequence program window Window used to edit the sequence program where the FB is pasted.
FB definition name Name of the FB definition displayed on the FB tab
FB name Name of the FB pasted to the sequence program. Different names are attached to
the FBs that are pasted from the same FB definition.
FB window Window used to read or monitor the program in the FB pasted to the sequence
program.
The FB window cannot be used to write a program. Use the FB definition window
to write a program.
1.4 What You Should Understand Before Using the FB
As in a normal sequence program, the FB is used to create a program using labels in a
ladder or list format.
Before creating the FB, therefore, fully understand the way to create a sequence
program using labels on GX Developer.
When you want to know any operation to create a sequence program on GX
Developer, refer to the "GX Developer Version 7 Operating Manual" given in the
related manuals.
1 - 5 1 - 5
MELSOFT 1 OVERVIEW
1.5 Specifications
1.5.1 Compatible CPUs
The following CPU models allow you to use the FB on GX Developer.
PLC Series Type
QCPU (Q mode) Q02CPU,Q02HCPU,Q06HCPU,Q12HCPU,Q25HCPU
QnACPU Q2ASCPU,Q2ASCPU-S1,Q2ASHCPU,Q2ASHCPU-S1,
Q2ACPU,Q2ACPU-S1,Q3ACPU,Q4ACPU,Q4ARCPU
The FB is not available for the Q00JCPU, Q00CPU and Q01CPU of the QCPU (Q mode).
The FB is not available for the ACPU, QCPU (A mode), FXCPU and motion controller of
the PLC series, either.
1.5.2 Specifications of and precautions for the FB
The following are the specifications of the FB and precautions for use of the FB.
(1) For creation of FB definition program (a) Specifications
Item Specifications
Program capacity 500 steps
Number of labels usable
as devices
500 pcs.
Input variables + I/O variables = 24 pcs.
Output variables + I/O variables = 24 pcs.
(At least one input variable and one output variable are needed.)
Labels other than the input, output and I/O variables are used as
internal variables.
Programming language Ladder, list
(b) Precautions 1) The FB cannot be used within the FB.
2) When the FB definition program has been corrected, online program
correction cannot be made to the sequence program that includes the
FB.
When writing the sequence program including the corrected FB to the
PLC CPU, perform write to PLC in the online mode.
3) Index qualification is not available for labels.
To make index qualification, use an actual device as the target device.
4) If an internal variable is used as the result of a division instruction, its
remainder cannot be used for control since a label cannot be assigned to
the remainder of division.
To use the remainder of a division instruction for control, use an actual
device as the device for storing the division result.
1 - 6 1 - 6
MELSOFT 1 OVERVIEW
5) Since the numerical device that may be handled by an input variable is up to a
double word, the instruction exceeding three words in input count cannot be
input from the outside.
To input three or more words from the outside, use an actual device as the
device for storing an input value or create the input instructions by the number
of necessary times.
6) Since the numerical device that may be handled by an output variable is up to
a double word, the instruction whose result will be three or more words cannot
be output to the outside.
To output three or more words to the outside, use an actual device as the
device for storing the result.
(2) For creation of sequence program including FB (a) Specifications
Item Specifications
Language of sequence
program that can be
created
Ladder
Pastable FB
Already compiled FB
If you attempt to paste the FB not yet compiled, GX Developer
displays an error message.
Number of FBs that may
be pasted to one ladder
block
1 pc.
The output from the FB cannot be connected directly to the input of
the other FB. If you want to connect the FBs, receive the output
from the FB with a coil once, and then connect the contact of that
coil to the input of the other FB.
(b) Precautions 1) A return connection cannot be used with an input ladder section and an
output ladder section. Return connection cannot be programmed.
Receive it with a coil once and then use the contact of that coil as the condition of the target instruction.
1 - 7 1 - 7
MELSOFT 1 OVERVIEW
2) The FB cannot be used in SFC and MELSAP-L programs.
3) If the device type of the FB differs from that of the input or output ladder
section, GX Developer displays an error message.
There are the following five FB device types.
BOOL : Data represented by ON/OFF.
INT : Data represented by 16 bits.
DINT : Data represented by 32 bits.
REAL : Floating-point data represented by 32 bits.
STRING : Character string data represented by JIS8 code.
For example, connection of a contact to the input of the FB whose
device type is a word will result in an error.
4) The FB definition automatically assigns devices to the labels used in a
program. When creating a sequence program, avoid automatically
assigned devices.
Like local devices, the automatically assigned devices are set in
accordance with the automatically assigned device setting, which
defaults to the following device ranges.
Word device : D6144 to D12287
Bit device : M4096 to M8191
Timer : T64 to T2047
Counter : C512 to C1023
2 - 1 2 - 1
MELSOFT 2 GENERAL PROCEDURES FOR EDITING THE FB
2 GENERAL PROCEDURES FOR EDITING THE FB
The following flowcharts give the general procedures from project creation to
debugging for use of the FB.
(1) Creating new sequence program using FB
Creation of new program
Creation of project
Addition of new FB definition
Creation of program body
Creation of FB variables
Compile of FB definition
Pasting of FB to sequence program
Creation of sequence program
Compile of sequence program
Write to PLC CPU
Monitor/test of sequence program
Correction of FB definition
Compile of sequence program
Write to PLC CPU
End
Refer to Section 3.9
Refer to Section 3.1
Refer to Section 3.2
Refer to Section 3.3
Refer to Section 3.4
Refer to Section 3.5
Refer to Section 3.6
Refer to Section 3.7
Refer to Section 3.8
Refer to Section 3.9
Refer to Section 3.10
Refer to Section 3.11
Refer to Section 3.8
2
2 - 2 2 - 2
MELSOFT 2 GENERAL PROCEDURES FOR EDITING THE FB
(2) Utilizing the existing FB to create a sequence program
Creation of new project
Creation of new project
Utilization of existing FB definition from another project
Refer to Section 3.1
Refer to Section 4.2.1
Addition to same project
Read of existing project
Utilization of existing FB definition from same project
Refer to Section 4.2.2
Refer to Section 4.1.2
Changing of FB definition name
Correction of utilized program body/FB variables
Compile of FB definition
Pasting of FB to sequence program
Creation of sequence program
Compile of sequence program
Write to PLC CPU
Monitor/test of sequence program
Correction of FB definition
Compile of sequence program
End
Write to PLC CPU Refer to Section 3.9
Refer to Section 4.3.
Refer to Section 4.4.
Refer to Section 3.5
Refer to Section 3.6
Refer to Section 3.7
Refer to Section 3.8
Refer to Section 3.9
Refer to Section 3.10
Refer to Section 3.11
Refer to Section 3.8
POINT This general procedure is for reference.
Each operation can be performed in any order, independently of the above
procedure.
2
3 - 1 3 - 1
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
3 CREATING NEW SEQUENCE PROGRAM USING FB
The following explains the operations to be performed to create a new sequence
program uing the FB.
This chapter is designed to create the following FB definition (program body, FB
variables) and sequence program.
(1) FB definition (program)
(2) FB definition (FB variables)
(3) Sequence program
The sample project (qcpu_fb) of the sequence program described in this chapter is
contained in the CD-ROM of this product.
After installing GX Developer, choose [Project]-[Open project] to open the sample project.
3
3 - 2 3 - 2
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
Handle the FB as described below.
1) Create a FB definition in the FB tab of the project.
2) Create the program body and FB variables of the FB definition.
3) Paste the FB definition registered to the FB tab to the sequence program.
4) Create the ladder block including the FB after pasting the FB.
Creation of new FB definition
Creation of program body and FB variables
Registration of program body and FB variables
Pasting of FB to sequence program
Creation of sequence program
3
3 - 3 3 - 3
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
3.1 Crating New Project for FB
[Setting Purpose]
Set the PLC series, PLC type and project name necessary to create a new project for
the FB.
[Operation Procedure]
Choose [Project] [New project] or click ( Ctrl + N ).
[Dialog Box]
1)
2)
3)
8)
5)
6)
7)
4)
9)
[Description]
1) PLC Series
As the PLC series, choose the QCPU (Q mode) or QnACPU.
2) PLC Type
As the PLC type, choose the CPU type to be used.
3) Program Type
When creating the FB, choose Ladder.
4) Label setting
When setting the FB, choose " Use Label + FB ".
5) Setup project name
Designate a project name to save the created data.
When designating a project name before creating a program, check the
checkbox.
The project name can be designated before and after program creation.
When designating the project name after data creation, use the [Save As]
menu.
6) Drive/Path
Set the path where the project will be saved (is saved).
Specifying only the project name without specifying the drive/path (blank)
automatically creates the default drive/path and saves the project there.
3 - 4 3 - 4
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
7) Project name
Designates a project name.
The following shows the characters and the number of characters that can be
used to designate a drive path, project name, or data name.
Number of characters
The total number of characters used for designating both the project path
and the project name (8 or more characters may be set) is 150.
C:\SW3D5GPPW\ABCDEFGHIJKLMNOPQRSTUVWXYZ
Characters not available in A, QnA and FX series
/, \, >, <, , ?, , |, :, ; (: and \ can be set for drive designation only)
Do not use a period (.) or space ( ) at the end of the project name. (If there
is a space right after the project name, the space is deleted automatically.)
8) Title
Sets the title for the project in up to 32 characters.
9) OK button
Click this button to create a new project.
3 - 5 3 - 5
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
3.2 Adding New FB Definition to the Created Project
[Setting Purpose]
Add a new FB definition for the new FB to the created project.
The FB definition consists of an FB Body and Header used to set the labels
(variables) used in the program.
[Operation Procedure]
Click the right button of the mouse on the <
Choose [Project] [Edit Data] [New].
Click the right button of the mouse on the <
[Dialog Box]
1)
2)
3)
4)
[Description]
1) Data type
Choose Function block.
2) Data name
Set the data name (FB definition name) to be added newly.
Set the data name within eight characters.
Usable characters
Alphanumeric characters, _, ^, $, , ~ (tilde), !, #, %, &, ( ), -, { }, @,
* (apostrophe), ' (single quotation)
Unusable characters
Any of " = | : ; , \ [ ] + * ? <> . / will result in an error.
If the other FB definition has already been created in the project, displaying the
New dialog box sets that FB definition name in the Data name field.
3 - 6 3 - 6
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
8) Title
Sets the title for the project in up to 32 characters.
9) OK button
Click this button to create the new FB definition.
POINT (1) There are no restrictions on the number of FB definitions that can be created in
a project. (It depends on the capacity of the project saving destination.)
(2) If multiple FB definitions are created in one project, we recommend you to
create a title for ease of searching for the object FB definition.
3 - 7 3 - 7
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
3.3 Creating FB Definition Program
[Setting Purpose]
Create an FB definition program using labels (variables).
[Operation Procedure]
Double-click Function block on the <
double-click Body individually.
[Window]
[Program Creation]
(1) To create an FB definition program, perform the same operation as in creating a
normal sequence program on the FB definition window.
The program can be created in the following specifications.
Item Description
Program capacity Max. 500 steps
Language Ladder, list
Supported mode Write, read
Number of labels Max. 500 pcs.
3 - 8 3 - 8
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
(2) Use labels (variables) to create the program.
The used labels define the following four different functions. Use FB variables to
define the labels. (Refer to Section 3.4.)
Type Description
Input variable Variable input from the FB outside.
Up to 24 pcs. including I/O variables, at least 1 pc.
Output variable Variable output to the FB outside.
Up to 24 pcs. including I/O variables, at least 1 pc.
I/O variable Variable having the functions of both the input and output.
Up to 24 pcs.
Internal variable Variable used only in the FB inside.
{500 - (input variables + output variables + I/O variables)} pcs.
Create a label within 16 characters.
Characters that cannot be used as a label are those of the reserved words and
actual device names.
If the characters of the reserved word or actual device name are used, re-set the
other label name as the "The reserved word is used." or "Device name is used."
error message appears. Refer to Appendix 1 for unusable character strings.
REMARK
Though the FB definition allows a program to be created using actual devices (e.g.
X100, Y110), it will be difficult to use multiple pieces of the same FB definition in a
sequence program. (We cannot recommend this as it may result in double-coil.)
The following program example is used to explain how to use labels.
(a) FB definition program using labels
1) Input variables (bit)
2) Input variable (word)
3) Output variables (word)
4) Output variables (bit)
5) Internal variables (bit)
1) IN1 and IN2 are variables that turn ON/OFF using external ON/OFF
information as conditions.
2) PLUS1 is a variable that inputs external numerical information to the FB inside.
3) PLUS2 is a variable that outputs the result calculated in the FB inside
(numerical information) to the outside.
4) OUT1 and OUT2 are variables that control external outputs with the results
calculated in the FB inside (ON/OFF information).
5) RA1 and RA2 are variables used in the FB inside only.
3 - 9 3 - 9
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
(b) Operation example of the sequence program using the created FB definition
The input variables turn ON/OFF using the external ON/OFF information as conditions.
Control external outputs using the ON/OFF information of the output variables (bit) as conditions.
Inputs the external numerical information to the input variable (word).
Outputs the numerical information from the output variable (word) to the outside.
(3) The other FB cannot be used in the FB definition program.
(4) For the FB definition, do not create the program that jumps to outside the FB
definition. (Example: CALL instruction that jumps to a subroutine program)
(5) Create a program on the FB definition window, starting with step 0.
The FB definition program does not have an END instruction.
Entry of an END instruction will display an error.
(6) After program creation is complete, convert the program.
Make program conversion in any of the following three operations.
(a) F4 key
(b) [Convert] [Convert]
(c) Right-click on the FB definition window and then choose [Convert].
(7) The program created in the program body cannot be used in the sequence
program if it has only been converted.
The program created can be used in the sequence program after the labels have
been defined by the FB variables and the FB definition has been compiled.
GX Developer is initialized to perform up to compile when Compile option is used
for conversion. Compile option can be set by choosing [Convert] [Compile
option].
On the FB definition window, the window title is provided with "*" to indicate that the
program is not compiled.
No marking: Already compiled : Not yet compiled
3 - 10 3 - 10
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
(8) Note the following when creating the FB definition program with labels.
(a) Index qualification cannot be used with labels.
An index-qualified label is recognized as a new label.
(Example)
When "PLUS1Z1" is input to qualify the label "PLUS1" with the index register
"Z1", the FB definition program is recognized as the label "PLUS1Z1".
(Action)
Use an actual device as the device to be index-qualified.
(b) When an internal variable is used as the result of a division instruction, its
remainder cannot be used for control since a label cannot be assigned to the
remainder of division.
(Example)
" / PLUS 1 K10 PLUS2 " stores the division result into the PLUS2 label of the
internal variable, but there is no label for storing the remainder of division.
(Action)
When you want to use the remainder of a division instruction for control, use an
actual device as the device for storing the division result.
(c) Since the numerical device that may be handled by an input variable is up to a
double word, the instruction exceeding three words in input count cannot be
input from the outside.
(Example)
For the data write instruction "TO" to the intelligent function module, up to two
words can be input by an input variable.
(Action)
To input three or more words from the outside, use an actual device as the
device for storing an input value or create the input instructions by the number of
necessary times.
(d) Since the numerical device that may be handled by an output variable is up to a
double word, the instruction whose result will be three or more words cannot be
output to the outside.
(Example)
For the BIN 32-bit multiplication "D*", the device for storing the multiplication
result needs four words.
(Action)
To output three or more words to the outside, use an actual device as the device
for storing the result.
POINT Online program correction cannot be made to the FB definition if the program is corrected. If program correction has been made, compile the program and then perform online write to PLC to write it to the PLC CPU.
REMARK
This manual does not detail the operations for creating programs. For details of the operations for creating programs, refer to the GX Developer Version 7 Operating Manual given in the related manuals.
3 - 11 3 - 11
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
3.4 Creating FB Variables
[Setting Purpose]
Set the variable types, constant values, device types and comments to the labels
(variables) used in the FB definition program.
The FB variables must be paired with the FB definition program body.
[Operation Procedure]
Double-click Function block on the <
click Header individually.
[Window]
5)4)3)2)1)
6)7)
[Description]
1) Input/Output
Choose the label type. There are the following four different types.
VAR_INPUT: Variable input from the FB outside
VAR_OUTPUT: Variable output to the FB outside
VAR_IN_OUT: Variable having the functions of both the input and output
"Blank": Variable used in the FB inside
2) Label
Set the label (variable) used in the FB definition program.
3) Constant
Set a constant value when you want to set a constant to the label where
"Blank" has been selected for the variable type.
Enter a constant value with K, H, E or " " for ease of identifying that it is a
decimal, hexadecimal, real number or character string constant.
3 - 12 3 - 12
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
4) Device type
For the input, output and I/O variables, choose any of Bit, Word, Double
word, Real number and Character string.
The contents of the devices are as follows.
1) BOOL : Data represented by ON/OFF.
2) INT : Data represented by 16 bits.
3) DINT : Data represented by 32 bits.
4) REAL : Floating-point data represented by 32 bits.
5) STRING : Character string data represented by JIS8 code.
For the internal variable, choose any of ARRAY, TIMER, COUNTER,
STORED TIMER and POINTER.
6) Array: Specify the number of data to be handled when multiple data,
such as the BMOV or FMOV instruction, are handled.
Selecting STRING or ARRAY displays the corresponding one of the
following dialog boxes.
Number of letters
: The input range is 1 to 50
characters.
Number of elements
: The input range is 1 to 255.
5) Comment
Set a comment within 64
characters.
The comment set in this field
appears under the label within the
FB when the sequence program
is displayed with comments.
When FB pasted to sequence program is displayed with comments
Comment set on FB variable window
Label
6) Edit operation
Insert button
Used to insert a blank row in the current cell position.
When you want to batch-insert multiple rows, choose the cells of the rows you
want to insert. Blank rows are inserted in the cell-selected range.
Add button
Used to add a blank row under the row of the current cell position.
When you want to batch-add multiple rows, choose the cells of the rows you
want to add. Rows are added, starting with the row under the first one of the
range-selected cells.
Delete button
Used to delete the cell-selected range.
3 - 13 3 - 13
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
7) Resister button
Clicking the Resister button registers the FB variables.
If any of the labels, constant values
and device types is set incorrectly,
the dialog box on the right appears
to indicate that the variables cannot
be registered.
Choosing Contents of error and
clicking the Jump button displays the
error location.
POINT On the FB variable setting window, the set data are sorted in label order, constant
order and device type order. The sorting order is as follows.
1. Symbols
2. Alphabets (uppercase characters)
3. Alphabets (lowercase characters)
The FB definition automatically assigns
devices to the labels used in the program.
When creating a sequence program, avoid
automatically assigned devices.
Like local devices, the automatically assigned
devices are set in accordance with the
automatically assigned device setting, which
defaults to the following device ranges.
1) Word device : D6144 to D12287
2) Bit device : M4096 to M8191
3) Timer : T64 to T2047
4) Counter : C512 to C1023
When you want to change the device range, choose [Edit] [Auto device
setting] to display the Auto device setting dialog box, and change the device
range.
REMARK
For details of the operations performed on the Auto device setting dialog box, refer
to Label Program" in the GX Developer Version 7 Operating Manual.
3 - 14 3 - 14
MELSOFT 3 CREATING NEW SEQUENCE PROGRAM USING FB
3.5 Converting the FB Definition (Compile)
[Setting Purpose]
Convert the created FB definition so that it may be used in a sequ