(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.
• 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.
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.
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.
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.
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.
■ 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.
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...
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.
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.
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.
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. •...
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 Ö...
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.
• 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...
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.
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.
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...
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...
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 ■...
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 ...
■ 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...
■ 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"...
■ 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)
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.
• 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...
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 ■...
■ 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.
■ 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.
■ 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.
Local Label Setting window Set operating parameters in the "Initial Value" field. 3 PROGRAM ORGANIZATION UNITS 3.4 Precautions...
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), ...
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.
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.
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...
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...
• 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. ...
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.
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...
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  bLabel2 [0,3] Label name...
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.
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)
Structure arrays A structure can also be used as an array. Structure label  Structure label  Structure label  Structure label  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)
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#"...
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. •...
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.
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. •...
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.
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 ...
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.
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.
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. •...
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.
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.
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.
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.
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 "...
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)
■ 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;...
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;...
■ 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;...
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...
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. •...
■ 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.
■ 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...
■ 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>. •...
• 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.
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.
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].
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 "(*"...
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. •...
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.
■ 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.
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.
■ 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...
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.
■ 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.
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.
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.
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].
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.
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.
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.
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...
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...
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...
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.
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.
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. •...
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.
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.
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.
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.
■ 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...
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). •...
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.
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. •...
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. •...
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.
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.
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.
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...
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.
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.
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.
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.
• 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. •...
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.
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.
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.
■ 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...
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.
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>=...
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] ...
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.
■ 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 SZ...
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.
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.
■ 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.
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.
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.
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.
■ 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.
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. •...
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.
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...
■ 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. •...
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...
■ 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.
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.
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.
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.
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/...
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 ...
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. •...
■ 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.
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"...
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.
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...
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.
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.
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...
■ 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.
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...
■ 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.
■ 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 ...
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 •...
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...
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).
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). Ò...
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.
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).
MEMO APPX Appendix 1 Operations of when the MC/MCR instructions are used to control EN...
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.
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.
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.
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.