Mitsubishi Electric MELSEC iQ-R Series Programming Manual

Hide thumbs Also See for MELSEC iQ-R Series:
Table of Contents

Advertisement

MELSEC iQ-R Programming Manual
(Program Design)

Advertisement

Table of Contents
loading

Summary of Contents for Mitsubishi Electric MELSEC iQ-R Series

  • Page 1 MELSEC iQ-R Programming Manual (Program Design)
  • Page 3: Safety Precautions

    (Read these precautions before using this product.) Before using the Mitsubishi Electric MELSEC iQ-R series programmable controllers, please read the manuals for the product and the relevant manuals introduced in those manuals carefully, and pay full attention to safety to handle the product correctly.
  • Page 4 • For Safety CPUs (1) Although MELCO has obtained the certification for Product's compliance to the international safety standards IEC61508, EN954-1/ISO13849-1 from TUV Rheinland, this fact does not guarantee that Product will be free from any malfunction or failure. The user of this Product shall comply with any and all applicable safety standard, regulation or law and take appropriate safety measures for the system in which the Product is installed or used and shall take the second or third safety measures other than the Product.
  • Page 5: Introduction

    Before using this product, please read this manual and the relevant manuals carefully and develop familiarity with the functions and performance of the MELSEC iQ-R series programmable controller to handle the product correctly. When applying the program examples provided in this manual to an actual system, ensure the applicability and confirm that it will not cause system control problems.
  • Page 6 MEMO...
  • Page 7: Table Of Contents

    CONTENTS SAFETY PRECAUTIONS ..............1 CONDITIONS OF USE FOR THE PRODUCT .
  • Page 8 CHAPTER 7 FBD/LD Configuration ................75 Program elements .
  • Page 9: Relevant Manuals

    System configuration, parameter settings, and online e-Manual [SH-081215ENG] operations of GX Works3 e-Manual refers to the Mitsubishi Electric FA electronic book manuals that can be browsed using a dedicated tool. e-Manual has the following features: • Required information can be cross-searched in multiple manuals.
  • Page 10: Terms

    Safety program A program that performs safety control Standard CPU A generic term for MELSEC iQ-R series CPU modules (other than Safety CPU) that perform standard control (This term is used to distinguish from the Safety CPU.) Standard control Machine control by standard programs and standard data communications. Programmable controllers other than the safety programmable controller perform only standard control.
  • Page 11: Chapter 1 Overview

    For information on creating, editing, and monitoring programs using an engineering tool, refer to the following.  GX Works3 Operating Manual Programming languages With the MELSEC iQ-R series, an optimal programming language can be selected and used according to the application. Programming language Description Ladder diagram (Ladder) A graphic language which describes ladders consisting of contacts and coils.
  • Page 12: Chapter 7 Fbd/Ld

    ■ Function block diagram/ladder diagram (FBD/LD) For details, refer to the following. Page 75 FBD/LD ■ SFC program For details, refer to the following. Page 87 SFC PROGRAM • Programming in ladder is suitable for users who have knowledge and experience of sequence control and logical ladders.
  • Page 13: Chapter 2 Program Configuration

    PROGRAM CONFIGURATION Using the engineering tool, multiple programs and program organization units (POUs) can be created. Programs and POUs can be divided according to processing. This chapter describes the program configuration. Project Program file 1 Program file 2 FB/FUN file Program block Program block Function block...
  • Page 14 MEMO 2 PROGRAM CONFIGURATION...
  • Page 15: Chapter 3 Program Organization Units

    PROGRAM ORGANIZATION UNITS There are three types of program organization units (POUs). • Program block • Function • Function block Processing can be described in the programming language that suits the control performed in each POU. Processing can be described in the ladder diagram, structured text language, or FBD/LD in a function or a function block. Functions and function blocks are called and executed by program blocks.
  • Page 16: Program Blocks

    Program Blocks A program block is a unit for making up a program. Multiple program blocks can be created in a program file and executed in the order specified in the program file setting. If the order is not specified in the program file setting, the program blocks are executed in ascending order of their names. By separating program blocks for individual functions and processing, the order of programs can be changed easily and programs can be exchanged easily.
  • Page 17: Functions (Fun)

    Functions (FUN) A function is a POU called and executed by program blocks, function blocks, and other functions. After the processing completes, a function passes a value to the calling source. This value is called a return value. A function always outputs the same return value, as the processing result, for the same input. By defining simple, independent algorithms that are frequently used, functions can be reused efficiently.
  • Page 18 EN and ENO EN (enable input) and ENO (enable output) can be appended to a function to control execution processing. • Set a boolean variable used as an execution condition of a function to EN. • A function with EN is executed only when the execution condition of EN is TRUE. •...
  • Page 19 Operation overview The program of a function is stored in the FB/FUN file and called by the calling source program when executed. Execution (Program file) flow (FB file) (FB file) Main program FUN1 program FUN3 program Ò Ó Ô FUN3 FUN1 Ö...
  • Page 20 Number of steps To call a function, the number of steps is required not only for the program itself but also for the processing that passes the argument and return value and the processing that calls the program. ■ Program The number of steps required for a function program is the total number of instruction steps plus 22 steps.
  • Page 21 • Passing the return value The instruction and the number of steps used for passing the return value are identical to those for passing the argument. Argument Data type Instruction used Number of steps class VAR_OUTPUT Same as for passing the argument Same as for passing the Same as for passing the argument argument...
  • Page 22: Function Blocks (Fb)

    Function Blocks (FB) A function block is a POU called and executed by program blocks and other function blocks. Function Program block block Function Program block block Unlike a function, a function block does not have a return value. A function block can hold values in variables and thus can hold input states and processing results. A function block uses the value it holds for the next processing and therefore it does not always output the same result even with the same input value.
  • Page 23 Input variables, output variables, and input/output variables Input variables, output variables, and input/output variables need to be defined in function blocks. A function block can output multiple operation results. It can also be set not to output operation results. (1) The operation result(s) is output. Instance Instance (2) No operation result is output.
  • Page 24 Instances ■ Instances An instance is a label assigned to realize a function block definition. Multiple instances can be created from one function block definition. The following figure shows the instance structure. FB1 definition Instance A of FB1 Ladder program (FB1) Local label area bLabel0 bLabel0...
  • Page 25 Same function blocks can be instantiated with different names in a single POU. Instance A Function block wLabel5 wLabel1 Input variable 1 wLabel8 Output variable wLabel4 wLabel6 wLabel2 Input variable 2 wLabel7 wLabel9 wLabel3 Input variable 3 Local variable Instance A Instance B Function block Function block...
  • Page 26 Setting initial values ■ Initial values of local label For the local label of a function block, an initial value can be set for each function block definition or instance. Local labels whose initial value can be set differ depending on the type and attribute. Page 42 Definable data types and initial values ■...
  • Page 27 For function blocks, both the FB definition and instance initial values can be set. If both initial values are set, the initial values used will take the following priority. Priority Type Remarks  High Instance initial value   FB definition initial value ...
  • Page 28 ■ Example The following figure shows an example where the function block initial values are used. [Defining FB] Local label definition (FB1) Setting initial value of FB definition Label Initial Data type name value TRUE 65535 [Creating instances] Initial value setting (FB1_a) FB1_a Label Data type Initial...
  • Page 29 ■ Inherent property setting The following items can be set when a program of a function block is created.( GX Works3 Operating Manual) Item Description Use MC/MCR in EN Control For "Yes", the MC/MCR instructions are used to control EN. For "No", the CJ instruction is used to control EN. Select "Yes"...
  • Page 30 ■ Subroutine type function blocks The program of a subroutine type function block is stored in the FB/FUN file and called by the calling source program when executed. Use a subroutine type function block to reduce the program size. Execution (Program file) flow (FB file)
  • Page 31 Number of steps (Macro type function blocks) ■ Calling source When calling a macro type function block, the calling source loads the call-target program during compilation. Program block 1 (displayed) Program file FB1_a FB1 program (FB1_a) FB1_b FB1 program (FB1_b) (1) The program is loaded in two or more call locations.
  • Page 32 • Passing the argument The instruction used to pass the argument differs depending on the class and data type of the argument. The following table summarizes the instructions that can be used to pass the argument. Argument Data type Instruction used Number of steps class VAR_INPUT...
  • Page 33: Precautions

    Precautions When a function is used ■ Global pointer/local pointer/pointer type global labels Global pointer, local pointer, and pointer type global labels cannot be used as labels indicating program steps in the function program. When a function block is used ■...
  • Page 34 ■ When a conversion error occurs in VAR_INPUT, VAR_OUTPUT, or VAR_IN_OUT in a macro type function block A program block that is the calling source of the function block or the function block may cause the error. In this case, check the inputs and outputs of the program block that is the calling source of the function block and the function block.
  • Page 35 ■ Specifying the start I/O number of intelligent function module When accessing the buffer memory or I/O signals of the intelligent function module, specify the start I/O number using the index register. By receiving the start I/O number as an input variable, the same function block can be shared in multiple intelligent function modules without changing the start I/O number.
  • Page 36 ■ Restrictions for module function blocks The following describes the restrictions for the use of module function blocks. • Do not turn off the contact of the MC instruction when calling a module function block between the MC instruction and MCR instruction.
  • Page 37 Local Label Setting window Set operating parameters in the "Initial Value" field. 3 PROGRAM ORGANIZATION UNITS 3.4 Precautions...
  • Page 38: When A Safety Program Is Used

    When a Safety Program Is Used A function used in a safety program is called a safety function, and a function block used in a safety program is called a safety function block. Information not described in this section is same as that of standard functions and function blocks. ( Page 15 Functions (FUN), ...
  • Page 39: Safety Function Blocks (Safety Fb)

    Safety function blocks (Safety FB) This section describes safety function blocks. Instances ■ Structure of instance An instance of a safety function block consists of the following data areas. : Applicable, : Not applicable Data area Description Availability Local label area Used to assign the local label of the function block.
  • Page 40: Chapter 4 Labels

    LABELS A label is a variable consisting of a specified string used in I/O data or internal processing. Using labels in programming enables creation of programs without being aware of devices and buffer memory sizes. For this reason, a program using labels can be reused easily even in a system having a different module configuration. When labels are used, there are some precautions on programming and functions used.
  • Page 41: Classes

    Classes The label class indicates from which POU and how a label can be used. Different classes can be selected depending on the type of POU. Global label Class Description Applicable POU Program Function block Function block    VAR_GLOBAL A common label that can be used in both program blocks and function blocks...
  • Page 42: Data Types

    Data Types The data types of a label are classified according to the bit length, processing method, and value range. There are two data types. • Primitive data type • Generic data type (ANY type) Primitive data type The following table lists the data types included in the primitive data type. Data type Description Value range...
  • Page 43 • The bit data in the word type label can be used by specifying a bit number. • The bit type array label can be used as 16-bit or 32-bit data by specifying the number of digits. For the bit specification and digit specification methods, refer to the following. ...
  • Page 44 Generic data type (ANY type) The generic data type is the data type of the labels which summarize several primitive data types. Generic data types are used when multiple data types are allowed for function and function block arguments and return values.
  • Page 45: Arrays

    Arrays An array represents a consecutive aggregation of same data type labels as a single name. Primitive data types and structures can be defined as arrays. • One-dimensional array • Two-dimensional array Label name Index Label name Index [0,0] [0,1] [0,n] bLabel1 bLabel2...
  • Page 46 How to use arrays To use an array, add an index enclosed by '[ ]' after each label name to identify individual labels. An array with two or more dimensions should be represented with indexes delimited by a comma (,) in '[ ]'. bLabel1 [0] bLabel2 [0,3] Label name...
  • Page 47 Precautions ■ When an interrupt program is used When a label or device is specified for the array index, the operation is performed with a combination of multiple instructions. For this reason, if an interrupt occurs during operation of the label defined as an array, data inconsistency may occur producing an unintended operation result.
  • Page 48: Structures

    Structures A structure is a data type containing one or more labels and can be used in all POUs. Members (labels) included in a structure can be defined even when their data types are different. Creating structures To create a structure, first define the structure, and then define members in the structure. Structure Member (label 1) Member (label 2)
  • Page 49 Structure arrays A structure can also be used as an array. Structure label [1] Structure label [2] Structure label [3] Structure label [4] Member (label 1) Member (label 1) Member (label 1) Member (label 1) Member (label 2) Member (label 2) Member (label 2) Member (label 2) Member (label 3)
  • Page 50: Constants

    Constants Types of constants The following table provides information on how to set constants to labels. Applicable data type Type How to set Example Boolean Set FALSE or TRUE. TRUE, FALSE Binary Add "2#" before the binary number to be used. 2#0, 2#1 Octal Add "8#"...
  • Page 51: Precautions

    Precautions Functions with restrictions The following functions have restrictions on the use of labels. Item Description CPU parameter • Trigger of an event execution type Use devices because global labels nor local labels cannot be specified for these program functions. •...
  • Page 52 Precautions for creating programs When specifying a label as an operand used in instructions, match the data type of the label with that of the operand. In addition, when specifying a label as an operand used in instructions that control continuous data, specify the data range used in instructions within the data range of the label.
  • Page 53: When A Safety Program Is Used

    When a Safety Program Is Used A label used in safety programs is called a safety label. Information not described in this section is same as that of standard labels. ( Page 38 LABELS) Safety label types There are three safety label types. Only the following labels can be used in safety programs. •...
  • Page 54: Classes

    Classes The following table lists the availability of the classes of safety global labels and standard/safety shared labels. : Applicable, : Not applicable Class Availability Safety global label Standard/safety shared label   VAR_GLOBAL   VAR_GLOBAL_CONSTANT   VAR_GLOBAL_RETAIN The following table lists the availability of the classes of safety local labels.
  • Page 55: Data Types

    Data types Primitive data type The following table lists the availability of primitive data types. : Applicable, : Not applicable Data type Availability  BOOL  Word [unsigned]/bit string [16 bits] WORD  Double word [unsigned]/bit string [32 bits] DWORD ...
  • Page 56: Chapter 5 Ladder Diagram

    LADDER DIAGRAM RnPCPU RnPCPU RnSFCPU RnSFCPU RnCPU RnENCPU (Process) (Redundant) (Standard) (Safety) Ladder diagram is a programming language used to describe sequence control. Each ladder consists of contacts and coils and represents logical operations consisting of AND/OR in combinations of series and parallel. This chapter describes the operation and specifications of the ladder diagram.
  • Page 57: Program Execution Order

    Item Description Operation result rising edge Energized on the rising edge (off to on) of the operation result. De-energized while the pulse conversion operation result is not on the rising edge. Operation result falling edge Energized on the falling edge (on to off) of the operation result. De-energized while the pulse conversion operation result is not on the falling edge.
  • Page 58: Inline St

    Inline ST The inline ST is the function used to create an inline ST box that displays an ST program in the cell of the instruction corresponding to a coil in the ladder editor, and edit and monitor it. This function enables to create numerical operations and character string processing easily in ladder programs. •...
  • Page 59 Precautions • Only one inline ST can be created on a single line of a ladder program. • Both a function block and inline ST box cannot be used on a single line of a ladder program. • Creating an inline ST box at the position of an instruction corresponding to a contact creates an inline ST box at the position of an instruction corresponding to a coil.
  • Page 60: Statements And Notes

    Statements and Notes Statements and notes can be used in ladder programs. Statements A statement is used to add a comment to a ladder block. Adding a comment makes it easy to understand the flow of processing. There are three types of statements: line statement, P statement, and I statement. The line statement can be displayed in the tree of the navigation window.
  • Page 61: Chapter 6 Structured Text Language

    STRUCTURED TEXT LANGUAGE RnPCPU RnPCPU RnSFCPU RnSFCPU RnCPU RnENCPU (Process) (Redundant) (Standard) (Safety) ST language is defined by International Standard IEC61131-3 that defines the logic description system. ST language is a text language with a similar grammatical structure to C. This language is suitable for programming complicated processing that cannot be easily described by ladder diagram.
  • Page 62: Configuration

    Configuration Programs written in ST language consist of operators and control statements. Assignment statement Select statement Function call statement Function block call statement Each statement must end with a semicolon ";". End of the statement Spaces, tabs, and line feeds can be inserted between an operator and data. Space Linefeed Comments can be inserted into a program.
  • Page 63: Delimiters

    Delimiters ST language supports the following delimiters to make the program structure clear. Symbol Description Parenthesized expression Specification of array element . (period) Specification of structure or function block members , (comma) Argument separation : (colon) Device specifier ; (semicolon) Termination of statement "...
  • Page 64: Control Statements

    Control statements The following table lists the control statements that can be used in ST programs. Item Description Reference Assignment statement Assignment statement Page 62 Assignment statement Subprogram control statement Function block and function call statements Page 64 Subprogram control statements RETURN statement Select statement IF statement (IF THEN, IF ELSE, IF ELSIF)
  • Page 65 ■ Automatic conversion of data type When assignment or arithmetic operational expressions between different data types is described in ST language, one data type may be converted automatically. Example of automatic conversion dintLabel1 := intLabel1; // Assignment statement: Automatically convert the INT type variable (intLabel1) to a DINT type variable, and assign it to the DINT type variable (dintLabel1). dintLabel1 := dintLabel2 + intLabel1;...
  • Page 66 Subprogram control statements ■ Function block call statement Format Description Instance name (input variable1:=variable1,...output Enclose the assignment statements to the input and output variables in '()' after the instance name. variable1=>variable2,...); When using multiple variables, delimit individual assignment statements with a comma ','. Instance name.input variable1:=variable1;...
  • Page 67 ■ RETURN statement Control statement Format Description Example ■RETURN RETURN; The statement is used to terminate a program, function block, or IF bool1 THEN function during operation. RETURN; When the RETURN statement is used in a program, control jumps to END_IF;...
  • Page 68 Iteration statements Control Format Description Example statement ■FOR...DO FOR<iteration variable Data to be used as an iteration variable is initialized. FOR intV1 := 0 initialization> One or more statements between the DO statement and the END_FOR TO 30 TO<final value> statement are executed repeatedly, adding or subtracting the initialized BY 1 DO BY<increase...
  • Page 69 Precautions ■ When an assignment statement is used • Up to 255 characters can be assigned to a string. If characters are assigned exceeding the valid range, a conversion error occurs. • Timer type and counter type contacts and coils cannot be used at the left side of an assignment statement. •...
  • Page 70 ■ When a sign inversion operator is used in the arithmetic operational expression If a sign inversion operator is used for the minimum value of each data type, the value remains unchanged. For example, the minimum value of INT type data will be -(-32768) = -32768. If a sign inversion operator is used for variables targeted for automatic conversion of data type, an intended operation result may not be obtained.
  • Page 71 ■ When a bit type label is used Once the boolean expression (conditional formula) is established in a select or iteration statement and if a bit type label is set to on in <statement>, the state of the label will be always on. Program that keeps the label status on ST program Ladder program performing the processing equivalent to ST program...
  • Page 72 ■ When a FOR...DO statement is used • A structure member or array element cannot be used for the iteration variable. • Match the type used in the iteration variable with the types of <final value expression> and <increase expression>. •...
  • Page 73: Constants

    • To execute instructions at the rising edge or falling edge in an iteration statement (FOR, WHILE, or REPEAT statement), use the edge relay (V) or perform index modification. In this case, one point of the edge relay (V) is used for each instruction that uses the edge relay (V) in the system.
  • Page 74: Labels And Devices

    Labels and devices Specification method Labels and devices can be directly described on ST programs. Labels and devices can be used for the left or right side of an expression or as an argument or return value of a standard function/function block. For the applicable labels, refer to the following.
  • Page 75 Precautions • The pointer type cannot be used in ST programs. • When the timer, counter, or retentive timer device is used as current value, the data type will be the word [unsigned]/bit string [16 bits]. When the long timer, long counter, or long retentive timer device is used as current value, the data type will be the double word [unsigned]/bit string [32 bits].
  • Page 76: Comments

    Comments The following table lists the comments that can be used in ST programs. Type Symbol Description Example Single-line comment The portion from the start symbol "//" to the end of the line is regarded //comment as a comment. Multiple-line comment (**) The portion from the start symbol "(*"...
  • Page 77: Configuration

    FBD/LD RnPCPU RnPCPU RnSFCPU RnSFCPU RnCPU RnENCPU (Process) (Redundant) (Standard) (Safety) FBD/LD (function block diagram/ladder diagram) is a graphic language which describes programs by connecting blocks that perform predefined processing, variable elements, and constant elements along the flow of data and signals. •...
  • Page 78: Program Elements

    Program elements FBD elements The following table lists FBD elements consisting an FBD/LD program. Item Description Variable Stores a value. A specific data type is assigned to each variable, and only data of the assigned data type are stored. Labels and devices can be specified as a variable. Constant Outputs a specified value.
  • Page 79 ■ Input/output points of a function • Connect all input points of a function with another FBD element. • The data type is assigned to each input variable and output variable of a function. Match the data type of an element connected to the input point or output point with that of the input variable or output variable.
  • Page 80 LD elements The following table lists the LD elements that can be used in FBD/LD programs. Item Description Left rail A start point of ladder program. The output of the left rail is always on. Normally open contact Energized when the specified device or label is on. Normally closed contact Energized when the specified device or label is off.
  • Page 81 ■ When another program element is connected to a connection point of coil for output When another program element is connected to a connection point of coil for output in series, the operation is the same as that of the parallel connection. Item Description Program example...
  • Page 82 Common elements The following table lists the common elements that can be used in FBD/LD programs. Item Description Jump Jumps the execution processing to a jump element. Processing between this element and a jump label is not performed. Whether to perform jump processing or not is controlled by inputting on/off information to the element.
  • Page 83 ■ Return element • The operation of a return element differs depending on the POU (program, function, or function block) used. POU used Description Program Execution of the program is stopped. Function Execution of the function is stopped, and processing returns to the step next to the instruction that called the function. Function block Execution of the function block is stopped, and processing returns to the step next to the instruction that called the function block.
  • Page 84 Connection line A connection line is a line that connects the end points of FBD element, LD element, and common element. When connected, the value is passed from the left end to the right end of the line. The data types of the program elements connected must be identical, or support automatic data type conversion.
  • Page 85: Constant

    Constant Notation of constants The following table lists the notations of strings in FBD/LD programs. Data type Notation Example String STRING Enclose a string (ASCII, Shift JIS) in single quotation marks ('). String [Unicode] WSTRING Enclose a Unicode string in double quotation marks ("). For the notations of constants other than the above, refer to the following.
  • Page 86 Precautions ■ When labels are used • Local devices cannot be used as an array index. To use local devices as an array index, assign the target device to another device, and specify the assigned device. ■ When performing automatic conversion of data type with devices Add a device type specifier when using a word device in a data type other than word [signed].
  • Page 87: Program Execution Order

    Program Execution Order Execution order of program elements The execution order of program elements in the FBD/LD editor is determined by the location and connecting status. (1) Program elements are executed from left to right. (2) Program elements are executed from top to bottom. The execution order is displayed under each program element.
  • Page 88 Precautions For a program that uses functions, do not directly connect the return value of a function and an input variable of another function, but connect a variable element between them. When the variable element (1) is connected between the return value and input variable Connecting the return value of a function and the input variable of another function directly may lead an execution order to an unintended one.
  • Page 89: Chapter 8 Sfc Program

    SFC PROGRAM RnPCPU RnPCPU RnSFCPU RnSFCPU RnCPU RnENCPU (Process) (Redundant) (Standard) (Safety) SFC is a program description format in which a sequence of control operations is split into a series of steps to enable a clear expression of each program execution sequence and execution conditions. This chapter describes the operations and specifications of SFC programs.
  • Page 90 The SFC program consists of steps that represent units of operations in a series of machine operations. In each step, the actual detailed control is programmed. SFC diagram Ladder diagram of the action or transition of each step Machining operation flowchart Workpiece detection...
  • Page 91 It is possible to correspond the controls of the entire facility, mechanical devices of each station, and all machines to the blocks and steps of the SFC program on a one-to-one basis. Station 1 Station 2 Station 3 control unit control unit control unit Step transition...
  • Page 92: Specifications

    Specifications This section lists the performance specifications related to SFC Programs. Item Specifications Number of executable SFC programs Number of blocks 320 blocks maximum Number of SFC steps All blocks in total: 16384 maximum One block alone: 512 maximum Number of branches 32 branches maximum Number of simultaneously active steps All blocks in total: 1280 maximum...
  • Page 93: Structure

    Structure Basic operation An SFC program starts at an initial step, executes the next step every time the relevant transition becomes TRUE, and ends a series of operations at an end step. (1) Initial step (2) Action (3) Transition (4) Normal step (5) Normal step (6) End step When starting a block, the initial step (1) is activated first and then the action (2) is executed.
  • Page 94: Block

    Block A block is a unit showing a series of operation consisting of steps and transitions. Block0 Block1 Block2 Up to 320 blocks can be created in an SFC program. A block begins with an initial step, a step and a transition are connected alternately, and ends with an end step or jump sequence.
  • Page 95: Step

    Step A step is the basic unit for comprising a block. (1) Step name (2) Step No. (3) Attribute (4) Attribute target Steps have the following characteristics. • When the step becomes active, the related action is executed. • Up to 512 steps can be created in one block. •...
  • Page 96 Step types The following table lists the types of steps. Item Description Initial step A step that indicates the beginning of a block. While this type of step is active, the transition following the step is always checked, and when the transition becomes TRUE, the next step becomes active.
  • Page 97 Normal step (without attribute) Normal step is a basic step used to comprise a block. While this type of step is active, the transition following the step is always checked, and when the transition becomes TRUE, the next step becomes active. The output status of the action of a step, when a transition to the next step occurs, varies depending on the instruction used.
  • Page 98 Initial step The initial step represents the beginning of a block. Up to 32 initial steps per block can be described. ( Page 90 Specifications) When there are more than one initial step, the convergence enabled is only a selective convergence. Execute the initial steps in the same way as executing other steps.
  • Page 99 Coil HOLD step [SC] Coil HOLD step [SC] is a step that holds the outputs of a coil that has been turned on by the action even after the active state transitions. Y10 (1) that has been turned on by using the OUT instruction remains on (3) even when the transition (2) becomes TRUE. No operation in the action is performed after a transition becomes TRUE and the next step is activated.
  • Page 100 ■ Operation when the block is paused or restarted Operation when the block is paused or restart depends on the combination of SM325 (Output mode at block stop), block stop mode bit setting of SFC information device, and step hold status. ( Page 133 Operation when the block is paused or restarted) Operation HOLD step (with transition check) [ST] Operation HOLD step (with transition check) [ST] is a step which continues the operation of the action even after the active...
  • Page 101 Reset step [R] Reset step [R] is a step that deactivates the specified step. • The reset step [R] deactivates the specified step in the current block before execution of the action every scan. Except for resetting the specified step, the reset step is the same as a normal step (without step attributes). •...
  • Page 102 Block start step (without END check) [BS] Block start step (without END check) [BS] is a step that activates the specified block. When the transition becomes TRUE, the active state transitions to the next step. After this step starts block (BL1), only the transition (2) is checked and, when the transition becomes TRUE, execution proceeds to the next step without waiting for the start destination block to end.
  • Page 103 End step End step is a step that ends a block. • When the active state transitions to the end step and no active step exists other than steps that hold operations in the block, all the HOLD steps [SC, SE, ST] that hold operations in the block are deactivated and the block is ended. •...
  • Page 104 When a normal active step remains or when a HOLD step [SC, When an active step that holds an operation remains SE, ST] whose transition has not become TRUE remains (the step does not hold an operation) • When SM328 is off, the block is ended by clearing the step. •...
  • Page 105 Assigning the step relay (S) areas to steps The step relay is a device corresponding to each step in the SFC program. It is on when the relevant step is active (including stop and hold state), and is off when the relevant step is inactive. Step relays are assigned as follows.
  • Page 106: Action

    Action An action is a program which is executed while a step is active. (1) Action name (2) Qualifier (3) Detailed expression of the action (4) Action label/device *1 N indicates that the action is executed while a step is active. Nothing but N can be set. When the step becomes active, the action is executed every scan.
  • Page 107 Action in MELSAP-L (instruction format) In MELSAP-L (instruction format), instructions for actions are described in text format in a SFC diagram. To switch from detailed expression in ladder diagrams to MELSAP-L (instruction format), select [View]  [Switch Ladder Display]  [MELSAP-L (Instruction Format)] from the menu. ( GX Works3 Operating Manual) For actions in MELSAP-L (instruction format), instructions and coils to output are described without contacts to be input conditions of each instruction.
  • Page 108 Instructions that cannot be used Some instructions cannot be used in actions. The following table lists the instructions that cannot be used. Classification Instruction symbol Master control instruction Termination instruction FEND Program branch instruction GOEND Program execution control instruction IRET Structure creation instruction BREAK Creating a dummy transition condition...
  • Page 109 Precautions • The step operation is almost the same as the following circuit. Action (1)Input condition of each instruction (2)Contact (on when active, off when inactive) indicating the step status • If the CALL instruction is used to issue a subroutine call in an action of the step, the output of the call destination is not turned off even when the step becomes inactive after the transition becomes TRUE.
  • Page 110: Transition

    Transition A transition is the basic unit for comprising a block and transfers the active state to the next step when the condition becomes TRUE. (1) Transition name (2) Transition No. (3) Detailed expression of the transition (Page 114 Detailed expression of transitions) (4) Direct expression of a transition (Page 118 Direct expression of transitions) (5) Transition label/device (Page 118 Transition label/device) Detailed expression of a transition can be created in ladder diagrams, ST language, or FBD/LD.
  • Page 111 Transition types The following table lists the types of transition. Item Description Series sequence When the transition becomes TRUE, the active state transitions from the preceding step to the subsequent step. Selective sequence Divergence: A step branches to multiple transitions, and only the step in the line (divergence/convergence) where the transition becomes TRUE first is activated.
  • Page 112 Series sequence When the transition becomes TRUE, the active state transitions from the preceding step to the subsequent step. When the transition (2) becomes TRUE while the step (1) is active, the step (1) is deactivated and the step (3) is activated.
  • Page 113 • The selective sequence allows branching to up to 32 transition. • If multiple transitions become TRUE simultaneously, the condition to the left will take precedence. If transition (1) and (2) become TRUE simultaneously, the action of step (3) will be executed. •...
  • Page 114 Simultaneous sequence (divergence/convergence) All the steps branched from one step are activated simultaneously. When all the steps immediately before convergence are activated and the common transition becomes TRUE, the active state transitions to the next step. Item Description Divergence When the transition (2) becomes TRUE while the step (1) is active, both of the step (3) and step (4) are activated at the same time.
  • Page 115 Jump sequence When the transition becomes TRUE, the active state transitions to the specified step in the same block. When the transition (2) becomes TRUE while the step (1) is active, the step (3) is activated. The step (1) becomes inactive. However, if it is a HOLD step [SC, SE, ST], the step holds the coil output or action according to its attribute.
  • Page 116 Detailed expression of transitions Create detailed expression of transitions in the Zoom editor. The condition can be created in following programming languages. Type Description Ladder Detailed Used to create a transition program consisting of a contact circuit and the TRAN instruction (Creating a dummy transition condition) diagram expression in a single circuit block.
  • Page 117 ■ Usable instructions The following table lists the instructions that can be used in transition programs. Classification Instruction symbol Contact instruction LD, LDI, AND, ANI, OR, ORI LDP, LDF, ANDP, ANDF, ORP, ORF LDPI, LDFI, ANDPI, ANDFI, ORPI, ORFI Association instruction ANB, ORB MEP, MEF EGP, EGF...
  • Page 118 Transition in MELSAP-L (instruction format) In MELSAP-L (instruction format), transitions are described in text format in a SFC diagram. To switch from detailed expression in ladder diagrams to MELSAP-L (instruction format), select [View]  [Switch Ladder Display]  [MELSAP-L (Instruction Format)] from the menu. ( GX Works3 Operating Manual) In MELSAP-L (instruction format), transitions are described using the instructions corresponding to contacts.
  • Page 119 Item MELSAP-L (instruction format) Example Comparison operation Describe instructions in the same way as in ladder diagrams. < D10 D20 instruction corresponding to The following comparison operation instructions can be used. contacts Comparing 16-bit binary data (signed): <, <=, <>, =, >, >= Comparing 32-bit binary data (signed): D<, D<=, D<>, D=, D>, D>= Comparing single-precision real numbers: E<, E<=, E<>, E=, E>, E>= Comparing double-precision real numbers: ED<, ED<=, ED<>, ED=, ED>, ED>=...
  • Page 120 Direct expression of transitions The transition which transfers an active state to the next step can be created directly on the SFC diagram. A contact of FBD/ LD element is connected to it. Coil, function block, function, jump, jump label, and return elements cannot be used. Select a transition and select [Edit] ...
  • Page 121: Sfc Control Instructions

    SFC Control Instructions SFC control instructions are used to check a block or step operation status (active/inactive), or to execute a forced start, end or others. If SFC control instructions are used, SFC programs can be controlled from the actions of sequence programs and SFC programs.
  • Page 122 ■ Precautions • Do not use the SFC control instructions in interrupt programs. • Execute the SFC control instruction only when SM321 (SFC program start/stop) is on. Index modification The step relays and SFC block devices specified by SFC control instructions can be index-modified. Device Index modification target part SZ...
  • Page 123: Sfc Information Devices

    SFC Information Devices SFC information device is the device or label which operates the forced start/termination and pause/restart direction to a block, check of the status of transition and the number of active steps, or direction of continuous transition operation of a transition.
  • Page 124 Block START/END bit This bit is a device or label to check whether the block is active. Setting the bit to on can start the block and setting it to off can end the block. If a program to start a block is not available or because the START/END of a block can also be controlled from the engineering tool, this device or label can be used for debugging or test operation in units of block.
  • Page 125 ■ Precautions • The following table shows the restart operation after the set block is deactivated. Set block Description Block 0 When the start conditions setting of is Operation is restarted from the initial step following end step processing. "Auto-start block 0" in the SFC setting of the CPU parameter.
  • Page 126 Step transition bit This bit is a device or label to check whether the transition of the step being executed becomes TRUE. This bit turns on when the transition to the next step becomes TRUE after execution of the action of each step. A step transition bit which is on is automatically turned off when processing of the specified block is performed again.
  • Page 127 Block PAUSE/RESTART bit This bit is a device or label to pause or restart an active block. Setting the bit to on stops the block at the step in execution and setting it to off restarts executing the block from the step where the block was stopped previously.
  • Page 128 Continuous transition bit This bit is a device or label that determines the continuous transition action when the transition becomes TRUE. Setting the bit to on enables continuous transition and accordingly the action of the next step is executed in the same scan. Setting the bit to OFF disables continuous transition and accordingly one step is executed every scan.
  • Page 129 ■ Precautions • If the continuous transition bit is turned on, execution of actions (from a transition becoming TRUE to destination step) takes priority over the other processing. allows to shorten a takt time. In this case, however, the operations of the other blocks and sequence program may become slower.
  • Page 130 Number of Active Steps Register This register is a device or label in which the number of active steps of a block is to be stored. The number of active steps stored in the number of active steps register includes the following steps. •...
  • Page 131: Sfc Setting

    SFC Setting Set start conditions and others of SFC program in CPU parameter or SFC block setting. CPU parameter The following table lists the SFC settings. Type Item Description SFC Setting SFC Program Start Mode Setting Set whether to start with initial status (Initial Start) or to start holding the previous execution status (Resume Start) at the start-up of SFC program.
  • Page 132 SFC program start mode setting Set whether to start with initial status (Initial Start) or to start holding the previous execution status (Resume Start) at the start- up of SFC program. [CPU Parameter][SFC Setting][SFC Program Start Mode Setting] Window Displayed items Setting Description Initial Start...
  • Page 133 ■ Precautions • When a program is resumed, the SFC program stop position is held but the status of the label or device used for an action is not held. Therefore, if labels or devices are required to be held to start with previous status, set them to be latched. •...
  • Page 134 Start condition setting Set whether to automatically start and activate block 0 or to keep it inactive until a start request is issued, when starting the SFC program. [CPU parameter][SFC Setting][Start Conditions Setting] Window Displayed items Setting Description At SFC Program START At the end of block 0 Auto-start block 0 Block 0 is started automatically and starts execution from its...
  • Page 135 ■ Operation when the block is paused or restarted Operation when the block is paused or restart depends on the combination of the SM325 (Output mode at block stop) status, block stop mode bit setting of the SFC information device, and step hold status. The following table lists the operations at block PAUSE/RESTART.
  • Page 136 M100 is the block stop mode bit and M101 is the block PAUSE/RESART bit. Block0 SM400 M100 PAUSE M101 M100 If M0 is turned on during execution of the above action, the PAUSE instruction is executed and the block PAUSE/RESTART bit (M101) of Block0 is turned on but the execution continues to the end of the action, so Y0 is turned on.
  • Page 137: Sfc Block Setting

    SFC block setting Act at block multi-activated Set the operation mode to stop the operation of the CPU module when a start request is issued by the block start step (with end check) [BC] or block start step (without end check) [BS] for an already active block. For the setting range, set the range of the block to be stopped.
  • Page 138: Sfc Program Execution Order

    SFC Program Execution Order Whole program processing Execution type that can be specified This section shows whether the execution type of SFC program can be specified. Type that can be specified as CPU module: RUN an SFC program Initial execution type program Execute only when required.
  • Page 139 Changing the execution type by an instruction The execution type of a program can be changed by using a program control instruction. The following table lists program control instructions with regard to whether an SFC program can be specified. Instruction symbol Specification Remarks enable/...
  • Page 140: Sfc Program Processing Sequence

    SFC program processing sequence Block execution sequence While the SFC program is running, the actions of each step are executed sequentially starting from the initial step of an active block. An SFC program containing multiple blocks checks the state (active/inactive) of the blocks in ascending order of block numbers(block 0 ...
  • Page 141 Step execution sequence In the SFC program, the actions of all active steps are processed within one scan. All the active steps in the block are executed within a single scan. When the action of each step is finished, whether the transition to the next step becomes TRUE or not is checked. •...
  • Page 142 ■ Precautions • As a step for which the transition becomes TRUE at the first execution is deactivated in a single scan, the I/O refresh of coil output is not reflected and therefore other programs cannot detect that the coil output is on. To reflect the I/O refresh, create a program so that one step is executed in multiple scans.
  • Page 143: Sfc Program Execution

    SFC Program Execution Starting and stopping the SFC program The SFC program can be started and stopped by either of the following methods. • CPU parameter • Starting and stopping the program by the special relay (SM321) • Starting and stopping the program by using instructions CPU parameter Set "Auto-start block 0"...
  • Page 144: Starting And Ending A Block

    Starting and ending a block Starting a block A block in the SFC program can be started by either of the following methods. Item Method Remarks Reference Page 132 Start CPU parameter Set “Auto-start block 0” to “Start Conditions Setting” in the This method is used to use block 0 (auto start, only for block 0) CPU parameter.
  • Page 145: Pausing And Restarting A Block

    Pausing and restarting a block Pausing a block The specified block in the SFC program being executed can be paused by either of the following methods. Item Method Remarks Reference Page 119 SFC SFC control instruction Pause the block specified by the PAUSE [BL] (Pausing This method is effective to clear the a block) instruction used in the action of the SFC error by temporarily stopping the...
  • Page 146: Activating And Deactivating A Step

    Activating and deactivating a step Activating a step A step in the SFC program can be activated by either of the following methods. Item Method Remarks Reference  Page 108 Transition condition The transition is checked at the end of the step. If it is TRUE, the next step is automatically activated.
  • Page 147: Behavior When An Active Step Is Activated

    Behavior when an active step is activated When an active step is activated, the step behaves as follows. Series sequence When the transition (2) becomes TRUE, the step (1) becomes inactive. Selective sequence ■ Divergence Transitions are checked from left to right. If the step connected to the transition having a TRUE value is active, the steps behave in the same way as in the series sequence.
  • Page 148: Operation When A Program Is Modified

    Operation when a program is modified To change an SFC program, use the following functions. • Write to the programmable controller • Online change • Online change (inactive SFC block) The following table lists changes that can be made to SFC programs by executing each function above. Change type Write to the programmable Online change...
  • Page 149 ■ When the operating status is changed from STOP to RUN If the operating status of the CPU module is changed from RUN to STOP during execution of an SFC program, device values and active/inactive state of the SFC program immediately before the stop are held and restored after the operating status is changed back to RUN.
  • Page 150 Online change (inactive SFC block) RnPCPU RnPCPU RnSFCPU RnSFCPU RnCPU RnENCPU (Process) (Redundant) (Standard) (Safety) An inactive SFC block can be changed in units of blocks. Since an SFC program can be changed online in units of blocks as long as the target block is inactive, efficiency of debugging and maintenance of SFC programs will be improved. Before change After change Initial...
  • Page 151 ■ Available execution type The online change (inactive SFC block) can be executed to a scan execution type program (cannot be executed to a standby type program). ■ Availability depending on block status (active or inactive) The online change (inactive SFC block) can be executed to a block that has been already inactive at the start of writing (cannot be executed while a target block is active *1 While SM321 (Start/stop SFC program) is off, the online change (inactive block) can be executed regardless of a target block status immediately before SM321 turns off.
  • Page 152 ■ Operation when a target block is activated during the online change (inactive SFC block) A target block is not activated when the target block is attempted to be activated while the online change (inactive SFC block) is executed. The following table describes operations depending on block start methods. Start method (activation method) Operation at block start ...
  • Page 153: Checking Sfc Program Operation

    Checking SFC program operation Use the following functions of the engineering tool to check SFC program operation. • Monitor • Watch • Device/buffer memory batch monitor • Control SFC steps • SFC block list • SFC all blocks batch monitor •...
  • Page 154: Appendix

    APPENDIX Appendix 1 Operations of when the MC/MCR instructions are used to control EN The following table lists operations of instructions, devices, and labels used in a function block when "Use MC/MCR in EN Control" is enabled in the inherent property setting of the function block. Instruction/device/label used in a function Operation of Instruction/device/label used in a function block block...
  • Page 155 Instructions executed at the rising/falling edge The following describes operations of instructions executed at the rising/falling edge. A subroutine-type FB using an instruction executed at the rising edge MOVP ■ When "Yes" is selected for "Use MC/MCR in EN Control" When EN is turned on, the instruction is executed if the condition contact is TRUE ((1) in the following figure).
  • Page 156 Timer (low-speed/high-speed) and long timer The following describes operations of the timer (low-speed/high-speed) and long timer. A subroutine-type FB using a low-speed timer SM400 ■ When "Yes" is selected for "Use MC/MCR in EN Control" The count value becomes 0 ((1) in the following figure). The coil turns off ((2) in the following figure). Ò...
  • Page 157 Retentive timer (low-/high-speed), long retentive timer, counter, and long counter The following describes operations of the retentive timer (low-speed/high-speed), long retentive timer, counter, and long counter. A subroutine-type FB using a low-speed retentive timer SM400 ■ When "Yes" is selected for "Use MC/MCR in EN Control" The current count value remain unchanged.
  • Page 158 Devices specified as the device part of the OUT instruction The following describes operations of devices specified as the device part of the OUT instruction. A subroutine-type FB using M0 for the device part of the OUT instruction. SM400 ■ When "Yes" is selected for "Use MC/MCR in EN Control" M0 is forcibly turned off ((1) in the following figure).
  • Page 159 MEMO APPX Appendix 1 Operations of when the MC/MCR instructions are used to control EN...
  • Page 160: Index

    INDEX ......94 Symbols End step ......16,26 .
  • Page 161 ....... . 61 ......40,71,83 STRING .
  • Page 162: Revisions

    Japanese manual number: SH-081225-I This manual confers no industrial property 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.
  • Page 163: Warranty

    WARRANTY Please confirm the following product warranty details before using this product. 1. Gratis Warranty Term and Gratis Warranty Range If any faults or defects (hereinafter "Failure") found to be the responsibility of Mitsubishi occurs during use of the product within the gratis warranty term, the product shall be repaired at no cost via the sales representative or Mitsubishi Service Company.
  • Page 164: Trademarks

    TRADEMARKS Ethernet is a registered trademark of Fuji Xerox Co., Ltd. in Japan. The company names, system names and product names mentioned in this manual are either registered trademarks or trademarks of their respective companies.   In some cases, trademark symbols such as ' ' or ' ' are not specified in this manual.
  • Page 166 SH(NA)-081265ENG-H(1706) MODEL: R-P-PS-E 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. Specifications subject to change without notice.

Table of Contents