Mitsubishi Electric SW8D5C GPPW E v6 Operating Manual
![Mitsubishi Electric SW8D5C GPPW E manual cover](/images/7806af2d78df2e6541cb11cf/thumbs/thumb175x175.webp)
![English English](/static/img/blank.webp)
GX Developer Version 8 Operating Manual (Function Block)
-SW8D5C-GPPW-E
A - 1 A - 1
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 " ! WARNING" and " ! 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 minor or moderate injury or property damage.
Note that the ! CAUTION level may lead to serious consequences according to the circumstances. Always follow the precautions of both levels because they are important for personal safety. Please save this manual to make it accessible when required and always forward it to the end user. [Design Precautions]
! 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 Precautions] ! CAUTION
The online operations performed from a personal computer to a running programmable controller CPU (program change when a programmable controller CPU is RUN, forced I/O operation, operating status change such as RUN-STOP switching, and remote control operation) have to 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 (Online program change), it may cause a program corruption in some operating conditions. Fully understand the precautions described in GX Developer Operating Manual before use.
! WARNING
! CAUTION
A - 2 A - 2
CONDITIONS OF USE FOR THE PRODUCT (1) Mitsubishi programmable controller ("the PRODUCT") shall be used in conditions;
i) where any problem, fault or failure occurring in the PRODUCT, if any, shall not lead to any major or serious accident; and ii) where the backup and fail-safe function are systematically or automatically provided outside of the PRODUCT for the case of any problem, fault or failure occurring in the PRODUCT.
(2) The PRODUCT has been designed and manufactured for the purpose of being used in general industries. MITSUBISHI SHALL HAVE NO RESPONSIBILITY OR LIABILITY (INCLUDING, BUT NOT LIMITED TO ANY AND ALL RESPONSIBILITY OR LIABILITY BASED ON CONTRACT, WARRANTY, TORT, PRODUCT LIABILITY) FOR ANY INJURY OR DEATH TO PERSONS OR LOSS OR DAMAGE TO PROPERTY CAUSED BY the PRODUCT THAT ARE OPERATED OR USED IN APPLICATION NOT INTENDED OR EXCLUDED BY INSTRUCTIONS, PRECAUTIONS, OR WARNING CONTAINED IN MITSUBISHI'S USER, INSTRUCTION AND/OR SAFETY MANUALS, TECHNICAL BULLETINS AND GUIDELINES FOR the PRODUCT. ("Prohibited Application") Prohibited Applications include, but not limited to, the use of the PRODUCT in; Nuclear Power Plants and any other power plants operated by Power companies, and/or any other cases in which the public could be affected if any problem or fault occurs in the PRODUCT.
Railway companies or Public service purposes, and/or any other cases in which establishment of a special quality assurance system is required by the Purchaser or End User.
Aircraft or Aerospace, Medical applications, Train equipment, transport equipment such as Elevator and Escalator, Incineration and Fuel devices, Vehicles, Manned transportation, Equipment for Recreation and Amusement, and Safety devices, handling of Nuclear or Hazardous Materials or Chemicals, Mining and Drilling, and/or other applications where there is a significant risk of injury to the public or property.
Notwithstanding the above, restrictions Mitsubishi may in its sole discretion, authorize use of the PRODUCT in one or more of the Prohibited Applications, provided that the usage of the PRODUCT is limited only for the specific applications agreed to by Mitsubishi and provided further that no special quality assurance or fail-safe, redundant or other safety features which exceed the general specifications of the PRODUCTs are required. For details, please contact the Mitsubishi representative in your region.
A - 3 A - 3
REVISIONS
* The manual number is given on the bottom left of the back cover.
Print Date * Manual Number Revision Feb., 2003 SH (NA)-080376E-A First edition Oct., 2003 SH (NA)-080376E-B Correction
Section 3.13, Section 5 Jun., 2004 SH (NA)-080376E-C Correction
Abbreviations and Generic Terms in This Manual Sep., 2004 SH (NA)-080376E-D Addition
Section 3.6.3 Dec., 2004 SH (NA)-080376E-E Correction
Section 3.6.3 Aug., 2005 SH (NA)-080376E-F Correction
Section 3.13 Dec., 2005 SH (NA)-080376E-G Correction
Section 1.5.1, Section 1.5.2, Section 3.3 Mar., 2006 SH (NA)-080376E-H Correction
Section 1.1, Section 3.9, Section 3.10 Oct., 2006 SH (NA)-080376E-I Correction
Section 8.1, Section 8.2 Jul., 2007 SH (NA)-080376E-J Correction
Abbreviations and Generic Terms in This Manual, Section 3.7.3 Dec., 2008 SH (NA)-080376E-K Correction
Abbreviations and Generic Terms in This Manual, Section 1.5.1, Section 1.5.2
Jan., 2010 SH (NA)-080376E-L Addition
CONDITIONS OF USE FOR THE PRODUCT Correction
SAFETY PRECAUTIONS, About Manuals, Abbreviations and Generic Terms in This Manual, Section 1.5.1, Chapter 2, Section 3.1, Section 3.6.1, Section 3.10
Japanese Manual Version SH-080359-M
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.
2003 MITSUBISHI ELECTRIC CORPORATION
A - 4 A - 4
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 programmable controller thoroughly in advance 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 About Manuals ...............................................................................................................................................A- 6 Abbreviations and Generic Terms in This Manual........................................................................................A- 7
1 OVERVIEW 1- 1 to 1- 9
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- 5 1.5 Specifications ........................................................................................................................................... 1- 5
1.5.1 Compatible CPUs............................................................................................................................... 1- 5 1.5.2 Specifications of and precautions for the FB..................................................................................... 1- 6
2 GENERAL PROCEDURES FOR EDITING THE FB 2- 1 to 2- 2
3 CREATING NEW SEQUENCE PROGRAM USING FB 3- 1 to 3-44
3.1 Crating New Project for FB...................................................................................................................... 3- 3 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-13 3.5 Converting the FB Definition (Convert (Compile)) .................................................................................. 3-16 3.6 Pasting the Converted FB to Sequence Program (FB Utilization) ......................................................... 3-18
3.6.1 Pasting the FB definition to sequence program ................................................................................ 3-18 3.6.2 Changing the name (FB name) of the pasted FB (FB name changing) .......................................... 3-21 3.6.3 Changing the module start I/O addresses of the FB definition......................................................... 3-23
3.7 Creating the Sequence Program............................................................................................................. 3-25 3.7.1 Editing the sequence program........................................................................................................... 3-25 3.7.2 Confirming the data of the pasted FB................................................................................................ 3-28 3.7.3 Searching/replacing the sequence program (Search/replace) ......................................................... 3-30 3.7.4 Creating/displaying the comments, statements or notes (Sentence creation) ......................................... 3-32
3.8 Converting the Sequence Program into Program to Be Executed on the Programmable Controller CPU (Convert (Compile)) .............................................................................. 3-33
3.9 Reading the Sequence Program from the Programmable Controller CPU (Read from PLC) .............. 3-36 3.10 Writing the Sequence Program to the Programmable Controller CPU (Write to PLC) ....................... 3-37
A - 5 A - 5
3.11 Monitoring and Testing the Sequence Program ................................................................................... 3-38
3.11.1 Monitoring the sequence program................................................................................................... 3-38 3.11.2 Testing the sequence program (Device test) .................................................................................. 3-41
3.12 Correcting the FB................................................................................................................................... 3-43 3.13 Making Online Program Correction to the Sequence Program............................................................ 3-44
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 (Convert (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
Programmable Controller CPU (Convert (Compile)) .............................................................................. 4- 9 4.9 Writing the Converted Sequence Program to the Programmable Controller 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- 5
8.1 Printing the Sequence Program Including FB......................................................................................... 8- 1 8.2 Printing the FB Definition ......................................................................................................................... 8- 4
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 - 6 A - 6
About Manuals
The manuals related to this product are shown below. Refer to the following table when ordering required manuals.
Related Manuals
Manual Name Manual Number (Model Code)
GX Developer Version 8 Operating Manual (Startup) Explains the system configuration, installation method and start-up procedure of GX Developer.
(Sold separately)
SH-080372E (13JU40)
GX Developer Version 8 Operating Manual Explains operation methods such as creating, printing, monitoring, and debugging programs using GX
Developer. (Sold separately)
SH-080373E (13JU41)
GX Developer Version 8 Operating Manual (Structured Text) Describes operation methods such as creating and printing structured text (ST) programs using GX
Developer. (Sold separately)
SH-080367E (13JU37)
MELSEC-Q/L Programming Manual (Structured Text) Explains the programming methods in structured text language.
(Sold separately)
SH-080366E (13JF68)
Structured Text (ST) Programming Guide Book Intended for beginners, i.e., those who will create structured text (ST) programs for the first time.
Explains basic operation methods and functions through sample programs.
(Sold separately)
SH-080368E (13JF69)
REMARK
The Operating Manuals and Structured Text (ST) Programming Guide Book 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 - 7 A - 7
Abbreviations and Generic Terms in This Manual
This manual uses the generic terms and abbreviations listed in the following table to discuss the software packages and programmable controller CPUs. Corresponding module models are also listed if needed.
Generic terms and abbreviations Description
GX Developer Generic product name of product types SW8D5C-GPPW-E, SW8D5C-GPPW-EA, SW8D5C-GPPW-EV and SW8D5C-GPPW-EVA.
FB Abbreviation of the function block. ST Abbreviation of a structured text.
QCPU (Q mode)
Generic term for Q00J, Q00UJ, Q00, Q00U, Q01, Q01U, Q02(H), Q02PH, Q02U, Q03UD, Q03UDE, Q04UDH, Q04UDEH, Q06H, Q06PH, Q06UDH, Q06UDEH, Q10UDH, Q10UDEH, Q12H, Q12PH, Q12PRH, Q13UDH, Q13UDEH, Q20UDH, Q20UDEH, Q25H, Q25PH, Q25PRH, Q26UDH and Q26UDEHCPU.
LCPU Generic term for L02CPU and L26CPU-BT. QnACPU Generic term for the MELSEC-QnA series programmable controller CPUs.
ACPU Generic term for the MELSEC-A series programmable controller CPUs. It includes the QCPUs (A mode) and motion controllers (SCPU).
QCPU (A mode) Generic term for the Q02(H)CPU-A and Q06HCPU-A.
FXCPU Generic term for the MELSEC-FX series programmable controller CPUs. (The target programmable controllers are the FX0, FX0S, FX0N, FX1, FXu, FX2C, FX1S, FX1N, FX2N and FX2NC.)
A - 8 A - 8
MEMO
1 - 1 1 - 1
MELSOFT1 OVERVIEW
1 OVERVIEW
This manual describes the operations of editing the function block (hereafter abbreviated to the FB) of the GX Developer Version 8 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 programmable controller CPU. When writing the program to a programmable controller with "Label program (ST, FB, Structure) " selected, the FB can be restored using "Read from PLC".
1
1 - 2 1 - 2
MELSOFT1 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
MELSOFT1 OVERVIEW
FB definition
FB variables Program body
FB definition program
(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
1 - 4 1 - 4
MELSOFT1 OVERVIEW
(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 data list 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.
Name Description
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 - 5 1 - 5
MELSOFT1 OVERVIEW
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 of a ladder program or in a ST program. 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 8 Operating Manual" given in the related manuals.
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)
Q00JCPU, Q00UJCPU, Q00CPU, Q00UCPU, Q01CPU, Q01UCPU, Q02CPU, Q02HCPU, Q02PHCPU, Q02UCPU, Q03UDCPU, Q03UDECPU, Q04UDHCPU, Q04UDEHCPU, Q06HCPU, Q06PHCPU, Q06UDHCPU, Q06UDEHCPU, Q10UDHCPU, Q10UDEHCPU, Q12HCPU, Q12PHCPU, Q12PRHCPU, Q13UDHCPU, Q13UDEHCPU, Q20UDHCPU, Q20UDEHCPU, Q25HCPU, Q25PHCPU, Q25PRHCPU, Q26UDHCPU, Q26UDEHCPU
LCPU L02CPU, L26CPU-BT
QnACPU Q2ASCPU, Q2ASCPU-S1, Q2ASHCPU, Q2ASHCPU-S1, Q2ACPU, Q2ACPU-S1, Q3ACPU, Q4ACPU, Q4ARCPU
The FB is not available for the ACPU, QCPU (A mode), FXCPU and motion controller of the PLC series, either.
1 - 6 1 - 6
MELSOFT1 OVERVIEW
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 2048 steps (For ST Program: FB Definition Convert, maximum 2048 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,ST
(b) Precautions
1) The FB cannot be used within the FB. 2) Index qualification is not available for labels.
To make index qualification, use an actual device as the target device. 3) 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.
4) 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.
5) 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.
1 - 7 1 - 7
MELSOFT1 OVERVIEW
(2) For creation of sequence program including FB
(a) Specifications
Item Specifications
Language of sequence program that can be created
Ladder,ST
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.
2) A parallel connection cannot be used with an input ladder section and an output ladder section as it causes an error at the ladder conversion.
3) The FB cannot be used in SFC and MELSAP-L programs.
1 - 8 1 - 8
MELSOFT1 OVERVIEW
4) 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.
5) 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
1 - 9 1 - 9
MELSOFT1 OVERVIEW
MEMO
2 - 1 2 - 1
MELSOFT2 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 FB variables
Creation of program body
Compile of FB definition
Pasting of FB to sequence program
Creation of sequence program
Compile of sequence program
Write to PLC CPUWrite to PLC CPU
Monitor/test of sequence program
Correction of FB definition
Compile of sequence program
Write to PLC CPU
End
Ladder
Refer to Section 3.1
Refer to Section 3.2
Refer to Section 3.4
Refer to Section 3.3
Refer to Section 3.5
Refer to Section 3.6
Refer to Section 3.7
Refer to Section 3.8
Refer to Section 3.10
Refer to Section 3.11
Refer to Section 3.12
Refer to Section 3.8
ST
Refer to Section 3.10
Refer to Section 3.5
Refer to Section 3.4
Refer to Section 3.3
Refer to Section 3.2
Refer to Section 3.1
Refer to "MELSEC-Q/L Programming Manual (Structured Text)"
Refer to "GX Developer Operating Manual (Structured Text)"
Refer to "GX Developer Operating Manual (Structured Text)"
Refer to "GX Developer Operating Manual (Structured Text)"
Refer to "GX Developer Operating Manual (Structured Text)"
Refer to "GX Developer Operating Manual (Structured Text)"
Refer to "GX Developer Operating Manual (Structured Text)"
Refer to "GX Developer Operating Manual (Structured Text)"
POINT This general procedure is for reference. Each operation can be performed in any order, independently of the above procedure.
2
2 - 2 2 - 2
MELSOFT2 GENERAL PROCEDURES FOR EDITING THE FB
MEMO
2
3 - 1 3 - 1
MELSOFT3 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 using 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
MELSOFT3 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
MELSOFT3 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), LCPU or QnACPU. 2) PLC Type
As the PLC type, choose the CPU type to be used. 3) Program Type
As the Program type, select Ladder program or ST program. 4) Label setting
As the Label setting, select "Use label". 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
MELSOFT3 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.
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
MELSOFT3 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]
Choose [Project] [Edit Data] [New]. Click the right button of the mouse on the project data list and choose [New].
[Dialog Box]
1)
2)
3)
4)
[Description] 1) Data type
Choose Function block. 2) Program type
When creating the FB, select Ladder program or ST program. 3) 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
MELSOFT3 CREATING NEW SEQUENCE PROGRAM USING FB
4) Title
Sets the title for the project in up to 32 characters.
5) 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
MELSOFT3 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 <
[Window] Ladder program
3 - 8 3 - 8
MELSOFT3 CREATING NEW SEQUENCE PROGRAM USING FB
[Window] ST Program
[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. 2048 steps (For ST Program: FB Definition Convert, maximum 2048 steps)
Language Ladder, list, ST Supported mode Write, read Number of labels Max. 500 pcs.
(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.
3 - 9 3 - 9
MELSOFT3 CREATING NEW SEQUENCE PROGRAM USING FB
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 - 10 3 - 10
MELSOFT3 CREATING NEW SEQUENCE PROGRAM USING FB
1) I/O variable (bit)
2) Input variable (bit)
3) Input variable (word)
4) Output variable (word)
5) Output variables (bit)
6) Internal variables (bit) 1) IN1 is a variable that turns ON/OFF using external ON/OFF information as a
condition and outputs the result calculated in the FB inside (ON/OFF information) to the outside.
2) IN2 is a variable that turns ON/OFF using external ON/OFF information as a condition.
3) PLUS1 is a variable that inputs external numerical information to the FB inside. 4) PLUS2 is a variable that outputs the result calculated in the FB inside
(numerical information) to the outside. 5) OUT1 and OUT2 are variables that control external outputs with the results
calculated in the FB inside (ON/OFF information). 6) RA1 and RA2 are variables used in the FB inside only.
(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 - 11 3 - 11
MELSOFT3 CREATING NEW SEQUENCE PROGRAM USING FB
The input variable turns ON/OFF using the external ON/OFF information as a condition.
Controls an external output using the ON/OFF information of the output variable (bit) as a condition.
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/Compile] (c) Right-click on the FB definition window and then choose [Convert/Compile]
(for ladder only) .
(7) 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 - 12 3 - 12
MELSOFT3 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) 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.
(c) 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.
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 8 Operating Manual given in the related manuals.
3 - 13 3 - 13
MELSOFT3 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 <
[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 - 14 3 - 14
MELSOFT3 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 : Da