Mitsubishi MELSEC-Q Series Programming Manual

Mitsubishi programmable controller
Hide thumbs Also See for MELSEC-Q Series:
Table of Contents

Advertisement

Advertisement

Table of Contents
loading

Summary of Contents for Mitsubishi MELSEC-Q Series

  • Page 3: Safety Precautions

    SAFETY PRECAUTIONS (Always read these instructions before using this product.) Before using the MELSEC-Q series, MELSEC-L series, and MELSEC-F series programmable controllers, thoroughly read the manuals attached to the products and the relevant manuals introduced in the attached manuals. Also pay careful attention to safety and handle the products properly.
  • Page 4: Conditions Of Use For The Product

    PRODUCT in one or more of the Prohibited Applications, provided that the usage of the PRODUCT is limited only for the specific applications agreed to by Mitsubishi and provided further that no special quality assurance or fail-safe, redundant or other safety features which exceed the general specifications of the PRODUCTs are required.
  • Page 5: Revisions

    This manual confers no industrial property rights or any rights of any other kind, nor does it confer any patent licenses. Mitsubishi Electric Corporation cannot be held responsible for any problems involving industrial property rights which may occur as a result of using the contents noted in this manual.
  • Page 6: Table Of Contents

    INTRODUCTION Thank you for purchasing the Mitsubishi MELSEC-Q series/MELSEC-L series/MELSEC-F series programmable controller. Before using the product, thoroughly read this manual to develop full familiarity with the programming specifications to ensure correct use. Please forward this manual to the end user.
  • Page 7 4.3 Labels 4 - 15 4.3.1 Global labels ..........................4 - 15 4.3.2 Local labels..........................4 - 15 4.3.3 Label classes ..........................4 - 16 4.3.4 Setting labels ..........................4 - 17 4.3.5 Data types............................ 4 - 18 4.3.6 Expressing methods of constants....................4 - 20 4.4 Method for Specifying Data 4 - 21 4.4.1 Bit data............................
  • Page 8: Manuals

    MANUALS Related manuals The manuals related to this product are shown below. Refer to the following tables when ordering required manuals. (1) Structured programming Manual number Manual name (Model code) MELSEC-Q/L Structured Programming Manual (Common Instructions) SH-080783ENG Explains the specifications and functions of common instructions such as sequence instructions, basic instructions, and application instructions that can be used in structured programs.
  • Page 9 OVERVIEW Overview............1-2 Purpose of This Manual .
  • Page 10: Purpose Of This Manual

    Overview This manual describes program configurations and contents for creating sequence programs using a structured programming method, and provides basic knowledge for writing programs. Purpose of This Manual This manual explains programming methods, programming languages, and other information necessary for creating structured programs. Manuals for reference are listed in the following table according to their purpose.
  • Page 11 (2) Programming (for QCPU (Q mode)/LCPU) User's Manual for MELSEC- MELSEC- MELSEC- intelligent Q/L/F function module/ MELSEC-Q/L Q/L/QnA Structured Reference Manual Structured Programming Manual Programming Programming Programming for network Manual Manual Manual module Purpose Common PID Control Common Special Application −...
  • Page 12 (3) Programming (for FXCPU) MELSEC- Q/L/F FXCPU Structured Programming Structured FXCPU Programming Manual Manual Programming Manual Purpose , FX , FX Basic & , FX Device & Application Fundamentals Applied , FX Common Functions Instruction , FX Learning the types and details of Programming basic/application...
  • Page 13: Generic Terms And Abbreviations In This Manual

    Generic Terms and Abbreviations in This Manual This manual uses the generic terms and abbreviations listed in the following table to discuss the software packages and programmable controller CPUs. Corresponding module models are also listed if needed. Generic term and Description abbreviation Generic product name for the SWnDNC-GXW2-E...
  • Page 14: Features Of Structured Programs

    Features of Structured Programs This section explains the features of structured programs. (1) Structured design A structured design is a method to program control contents performed by a programmable controller CPU, which are divided into small processing units (components) to create hierarchical structures.
  • Page 15: Applicable Cpu Modules

    Applicable CPU Modules The following table shows the applicable CPU modules for programs in the Structured project. Table 1.5-1 Applicable CPU modules Programmable controller CPU type Basic model QCPU Q00J, Q00, Q01 High Performance model QCPU Q02, Q02H, Q06H, Q12H, Q25H Q00UJ, Q00U, Q01U, Q02U, Q03UD, Q03UDE, Q04UDH, Universal model QCPU Q04UDEH, Q06UDH, Q06UDEH, Q10UDH, Q10UDEH, Q13UDH,...
  • Page 16 MEMO...
  • Page 17: Structured Design Of Sequence Programs

    STRUCTURED DESI G N OF SEQUENCE PROGRAMS What is a Hierarchical Sequence Program?......2-2 What is a Structured Sequence Program? .
  • Page 18: What Is A Hierarchical Sequence Program

    What is a Hierarchical Sequence Program? The hierarchy is to create a sequence program by dividing control functions performed in a programmable controller CPU into a number of levels. In higher levels, the processing order and timing in a fixed range is controlled. With each move from a higher level to a lower level, control contents and processes are progressively subdivided within a fixed range, and specific processes are described in lower levels.
  • Page 19: What Is A Structured Sequence Program

    What is a Structured Sequence Program? A structured program is a program created by components. Processes in lower levels of hierarchical sequence program are divided to several components according to their processing information and functions. In a structured program design, segmenting processes in lower levels as much as possible is recommended.
  • Page 20 MEMO...
  • Page 21: Procedure For Creating Programs

    PROCEDURE FOR CREATING PROGRAMS Procedure for Creating Sequence Programs in Structured Project ..3-2...
  • Page 22: 3.1 Procedure For Creating Sequence Programs In Structured Project

    Procedure for Creating Sequence Programs in Structured Project This section explains the basic procedure for creating a sequence program in the Structured project. (1) Creating a program structure Procedure Create program files. Create tasks. (2) Creating POUs Procedure Create POUs. Define global labels.
  • Page 23: Program Configuration

    PROGRAM CONFIGURATION Overview of Program Configuration ....... . . 4-2 POUs .
  • Page 24: Overview Of Program Configuration

    Overview of Program Configuration A sequence program created in the Structured project is composed of program files, tasks, and POUs. For details of program components, refer to the following sections. For projects: Section 4.1.1 Project For program files: Section 4.1.2 Program files For tasks: Section 4.1.3 Tasks For POUs:...
  • Page 25: Project

    4.1.1 Project A project is a generic term for data (such as programs and parameters) to be executed in a programmable controller CPU. One or more program files need to be created in a project. 4.1.2 Program files One or more tasks need to be created in a program file. (Created tasks are executed under the control of the program file.) The execution types (such as scan execution and fixed scan execution) for executing program files in a programmable controller CPU are set in the program setting of the parameter.
  • Page 26: Tasks

    4.1.3 Tasks A task is an element that contains multiple POUs, and it is registered to a program file. One or more program blocks of POU need to be registered in a task. (Functions and function blocks cannot be registered in a task.) Project Program file 1 Program file 2...
  • Page 27: Pous

    POUs A POU (abbreviation for Program Organization Unit) is a program component defined by each function. 4.2.1 Types of POU The following three types can be selected for each POU according to the contents to be defined. • Program block •...
  • Page 28: Program Blocks

    4.2.2 Program blocks A program block is an element that is stated at the highest level of POU. Libraries, functions, and function blocks are used to edit program blocks. Library Program block Function Function block Sequence programs executed in a programmable controller CPU are created by program blocks of POU.
  • Page 29: Function Blocks

    4.2.4 Function blocks Libraries, functions, and other function blocks are used to edit function blocks. Function blocks can be used by calling them from program blocks or function blocks. Note that they cannot be called from functions. Function block Library Function Function block Function blocks can retain the input status since they can store values in internal and output...
  • Page 30: Ladder Blocks

    4.2.5 Ladder blocks In the structured ladder language, a program is divided into units of ladder blocks. In the ST language, ladder blocks are not used. ● Ladder block labels A ladder block label can be set to a ladder block. A ladder block label is used to indicate a jump target for the Jump instruction.
  • Page 31: Programming Languages For Pous

    4.2.6 Programming languages for POUs Two types of programming language are available for programs of POU. The following explains the features of each programming language. (1) ST: Structured text Control syntaxes such as selection branch by conditional syntaxes or repetitions by iterative syntaxes can be described in the ST language, as in the high-level language such as C language.
  • Page 32: Functions And Function Blocks

    4.2.7 Functions and function blocks The following table shows differences between functions and function blocks. Table 4.2.7-1 Differences between functions and function blocks Item Function Function block Output variable assignment Can not be assigned Can be assigned Internal variable Not used Used Creating instances Not necessary...
  • Page 33 (2) Internal variables A function does not use internal variables. It uses devices assigned directly to each input variable and repeats operations. (a) A program that outputs the total of three input variables (When using a function (FUN1)) Function D109 D109 FUN1 D120...
  • Page 34 (3) Creating instances When using function blocks, create instances to reserve internal variables. Variables can be called from program blocks and other function blocks by creating instances for function blocks. To create an instance, declare as a label in a global label or local label of POU that uses function blocks.
  • Page 35: En And Eno

    4.2.8 EN and ENO An EN (enable input) and ENO (enable output) can be appended to a function and function block to control their execution. A Boolean variable used as an executing condition of a function is set to an EN. A function with an EN is executed only when the executing condition of the EN is TRUE.
  • Page 36 ● Usage example of EN and ENO Control description When the EN input is directly connected from the left base line, the EN input is always TRUE and the instruction is always executed. ➀ If the ADD_E instruction is used in this manner, the operation result is the same as the ADD instruction without the EN input.
  • Page 37: Labels

    Labels Labels include global labels and local labels. 4.3.1 Global labels The global labels are labels that can be used in program blocks and function blocks. In the setting of a global label, a label name, a class, a data type, and a device are associated with each other.
  • Page 38: Label Classes

    4.3.3 Label classes The label class indicates from which POU and how a label can be used. Different classes can be selected according to the type of POU. The following table shows label classes. Table 4.3.3-1 Label classes Applicable POU Class Description Program...
  • Page 39: Setting Labels

    4.3.4 Setting labels Labels used in a program require setting of either global label or local label. The following describes setting examples of the arguments Var_D10 and Var_D20 of the DMOV instruction. DMOV Var_D10 Var_D20 ● Using the arguments of the DMOV instruction as global labels Set the Class, Label Name, Data Type, Device, and Address.
  • Page 40: Data Types

    4.3.5 Data types Labels are classified into several data types according to the bit length, processing method, or value range. (1) Elementary data types The following data types are available as the elementary data type. • Boolean type (bit): Represents the alternative status, such as ON or OFF. •...
  • Page 41 (2) Generic data types Generic data type is the data type of labels summarizing some elementary data types. Data type name starts with 'ANY'. ANY data types are used when multiple data types are allowed for function arguments and return values. Labels defined in generic data types can be used in any sub-level data type.
  • Page 42: Expressing Methods Of Constants

    4.3.6 Expressing methods of constants The following table shows the expressing method for setting a constant to a label. Table 4.3.6-1 Constant expressing method Constant Expressing method Example type Bool Input FALSE or TRUE, or input 0 or 1. TRUE, FALSE Binary Append '2#' in front of a binary number.
  • Page 43: Method For Specifying Data

    Method for Specifying Data The following shows the six types of data that can be used for instructions in CPU modules....... Section 4.4.1 Bit data Data that can be handled by CPU module ..Section 4.4.2 Numeric data Word (Signed) data Integer data ..
  • Page 44: Bit Data

    4.4.1 Bit data Bit data are data handled in units of 1 bit, such as contacts and coils. 'Bit devices' and 'bit specification for word devices' can be used as bit data. (1) Using bit devices A bit device is specified in unit of one point. One point of M0 is the target bit device One point of Y10 is...
  • Page 45: Word (16 Bits) Data

    4.4.2 Word (16 bits) data Word data are 16-bit numeric value data used in basic instructions and application instructions. The following shows the two types of word data that can be handled in CPU modules. • Decimal constants ....-32768 to 32767 •...
  • Page 46 (c) When the destination is a word device For the word device at the destination side, 0s are stored to bits starting from the digit specified at the source. Ladder example Processing Instruction that processes 16-bit data K1X0 X3 X2 X1 X0 X010 0s are stored K1X0...
  • Page 47: Double Word (32 Bits) Data

    4.4.3 Double word (32 bits) data Double word data are 32-bit numeric value data used in basic instructions and application instructions. The following shows the two types of double word data that can be handled in CPU modules. • Decimal constants ....-2147483648 to 2147483647 •...
  • Page 48 (c) When the destination is a word device For the word device at the destination side, 0s are stored to bits starting from the digit specified at the source. (Data_s:K1X0, Data_d:D0) Ladder example Processing Instruction that processes 32-bit data K1X0 X3 X2 X1 X0 0s are stored DMOV...
  • Page 49: Single-Precision Real/Double-Precision Real Data

    (2) Using word devices Devices used in lower 16 bits are specified for a word device. 'Specified device number' and 'specified device number +1' are used for instructions that process 32-bit data. Transfers 32-bit data DMOV Two points (32 bits) of D0 and D1 are the target word devices 4.4.4 Single-precision real/double-precision real data...
  • Page 50 (2) Double-precision real (double-precision floating-point data) Devices used in lower 16 bits are specified for instructions that use real number data. Real number data are stored in 64 bits of 'specified device number' and 'specified device number + 3'. Transfers real number data EDMOV Var_R100 Var_D0...
  • Page 51 1. Floating-point data in a CPU module can be monitored by the monitoring function of the programming tool. 2. To express 0 in floating-point data, set all of the following bits to 0. (a) Single-precision floating-point data: b0 to b31 (b) Double-precision floating-point data: b0 to b63 3.
  • Page 52: String Data

    4.4.5 String data String data are character data used in basic instructions and application instructions. From the specified character to the NULL code (00H) that indicates the end of the character string are the target string data. (1) When the specified character is NULL code The NULL code is stored by using one word.
  • Page 53: Time Data

    4.4.6 Time data Time data are used in time type operation instructions of application functions. Specify time data in the T#10d20h30m40s567ms form. For example. the following adds ‘1 Day, 2 Hours, 3 Minutes, and 4 Seconds’ to ‘10 Days, 20 Hours, 30 Minutes, 40 Seconds, and 567 Milliseconds’.
  • Page 54: Arrays

    4.4.7 Arrays An array represents a consecutive aggregation of same data type labels. Arrays can be defined by the elementary data types or structures. GX Works2 Version1 Operating Manual (Structured Project)) The maximum number of arrays differs depending on the data types. One-dimensional array Two-dimensional array Label name...
  • Page 55 [Structured ladder] [ST] FOR Index1:=0 TO 4 BY 1 DO INC(TRUE,Var_D0[Index1]); END_FOR; (3) Maximum number of array elements The maximum number of array elements differs depending on data types as shown below. Table 4.4.7-2 Maximum number of array Data type Maximum number Bit, word (signed), word (unsigned)/16-bit string, timer, counter, and retentive timer 32768...
  • Page 56: Structures

    4.4.8 Structures A structure is an aggregation of different data type labels. Structures can be used in all POUs. To use structures, first create the configuration of structure, and define a structure label name for the created structure as a new data type GX Works2 Version1 Operating Manual (Structured Project)) To use each element of structure, append an element name after the structure label name with '.' as a delimiter in between.
  • Page 57: Device And Address

    Device and Address This section explains the method for expressing programmable controller CPU devices. The following two types of format are available. • Device: This format consists of a device name and a device number. • Address: A format defined in IEC61131-3. In this format, a device name starts with %. 4.5.1 Device Device is a format that uses a device name and a device number.
  • Page 58: Address

    4.5.2 Address Address is a format defined in IEC61131-3. The following table shows details of format that conforms to IEC61131-3. Table 4.5.2-1 Address definition specifications 1st character: 3rd character and later: Start 2nd character: data size Number position classification Input (Omitted) Numerics used for detailed Number...
  • Page 59: Correspondence Between Devices And Addresses

    4.5.3 Correspondence between devices and addresses This section explains the correspondence between devices and addresses. (1) Correspondence between devices and addresses The following table shows the correspondence between devices and addresses. (a) QCPU (Q mode)/LCPU Table 4.5.3-1 Correspondence between devices and addresses (1/2) Example of correspondence between Expressing method Device...
  • Page 60 Table 4.5.3-1 Correspondence between devices and addresses (2/2) Example of correspondence between Expressing method device and address Device Device Address Device Address Step relay %MX2.n S127 %MX2.127 SFC transition device %MX18.n %MX18.3 SFC block device %MX17.n %MX17.3 Link input Jx\Xn %IX16.x.n J1\X1FFF %IX16.1.8191...
  • Page 61 (2) Digit specification for bit devices The following table shows the correspondence between devices and addresses when a digit is specified for a bit device. Table 4.5.3-3 Correspondence of formats with digit specification Device Address %[Position of memory area][Data size]19.[Number of K[Number of digits][Device name][Device number] digits].[Classification].[Number] (Number of digits: 1 to 8)
  • Page 62: Index Setting

    Index Setting (1) Overview of the index setting (a) The index setting is an indirect setting that uses index registers. When the index setting is used in a sequence program, the device consists of ‘directly specified device number’ + ‘content of index register’. For example, when D2Z2 is specified and the value of Z2 is 3, D(2+3)=D5 is set as the target.
  • Page 63 2) Devices with restrictions on index registers Device Description Example TS0Z0 OUT_T Only Z0 or Z1 can be used for contacts or TC1Z1 coils of the timer. CS0Z1 OUT_C Only Z0 or Z1 can be used for contacts or coils of the counter. CC1Z0 (c) Devices that can be used for the index setting (for FXCPU) The following table shows the devices that can be used for the index setting.
  • Page 64 (d) The following figure shows the examples of index setting and their actual processing devices. (With the setting of Z0=20 and Z1=−5) Ladder example Actual processing device K1M33 Description K2X(50 + 14) = K2X64 K2X50Z0 Converts K20 to a hexadecimal number. K2X50Z0 K1M38Z1 K1M38Z1...
  • Page 65 (a) Specifying a range of index registers used for a 32-bit index setting 1) Values from 2147483648 to 2147483647 can be set to index registers. The following shows how the index is set. DMOV Stores 40000 to Z0 40000 Var_Z0 Stores the data of ZR {10+40000} = ZR40010 to D0 ZR10Z0...
  • Page 66 4) Usage range of index registers The following table shows the usage range of index registers when setting indexes in 32-bit range. Since the specified index register (Zn) and next index register (Zn+1) are used for index setting in 32-bit range, make sure not to overlap index registers being used.
  • Page 67 (b) Specifying a 32-bit index setting using 'ZZ' 1) A 32-bit index can be specified to the index register by specifying an index using 'ZZ', for instance, 'ZR0ZZ4'. The following figure shows the 32-bit index setting using 'ZZ'. DMOVP Set 100000 to Z4 and Z5. K100000 MOVP Set 32-bit (Z4, Z5) index to ZR.
  • Page 68 5) The following figure shows the examples of 32-bit index setting using 'ZZ' and their actual processing devices. Ladder example Actual processing device DMOV ZR101000 K100000 Description ZR1000ZZ0 ZR(1000+100000) ZR101000 D30Z2 D(30-20) K-20 ZR1000ZZ0 D30Z2 Figure 4.6-5 Ladder examples and actual processing devices 6) Functions that can use 'ZZ' 32-bit index settings using 'ZZ' can be used in the following functions.
  • Page 69 (4) Applying index settings to extended data registers (D) and extended link registers (W) (for Universal model QCPU (excluding Q00UJCPU), and LCPU) As an index setting can be applied to internal user devices, data registers (D) and link registers (W), the device specification by the index setting can be used within the range of extended data registers (D) and extended link registers (W).
  • Page 70 2) Index settings that cross file registers (ZR), extended data registers (D), and extended link registers (W) Even when an index setting that crosses file registers (ZR), extended data registers (D), and extended link registers (W) is applied, an error does not occur.
  • Page 71 (b) An index setting is applicable to both start I/O numbers of the intelligent function module and buffer memory addresses for intelligent function module devices U10Z1\G0Z2 If Z1=2 and Z2=8, then U(10+2)\G(0+8)=U12\G8 (c) An index setting is applicable to both network numbers and device numbers for link direct devices J1Z1\K4X0Z2 If Z1=2 and Z2=8,...
  • Page 72 (6) Precautions (a) Applying the index setting within the FOR to NEXT instruction loop The pulses can be output by using edge relays (V) within the FOR to NEXT instruction loop. Note that the pulses cannot be output by the PLS, PLF or pulse ( P) instruction.
  • Page 73 (b) Applying the index setting in the CALL instruction The pulse can be output by using edge relays (V) with the CALL instruction. Note that the pulse cannot be output by the PLS, PLF or pulse ( P) instruction. [When using an edge relay] [When not using an edge relay] (M0Z1 pulse is output normally.) (M0Z1 pulse is not output normally.)
  • Page 74: Libraries

    Libraries A library is an aggregation of data including POUs, global labels, and structures organized in a single file to be utilized in multiple projects. The followings are the advantages of using libraries. • Data in library files can be utilized in multiple projects by installing them to each project. •...
  • Page 75: User Libraries

    4.7.1 User libraries A user library is a library for storing created structures, global labels, POUs, and other data that can be used in other projects. (1) Composition of a user library The following table shows data that can be registered in a user library. Table 4.7.1-1 Composition of a user library Name Description...
  • Page 76: Precautions On Assigning A Name

    Precautions on Assigning a Name This section explains the conditions for assigning a name to a label, function block instance or structure label. • Conditions (1) Specify a name within 32 characters. (2) Do not use reserved words. For reserved words, refer to the following section. Appendix 2 Character Strings that cannot be Used in Label Names and Data Names (3) Use alphanumeric and underscores (_).
  • Page 77: Writing Programs

    WRITING PROGRAMS ST Language ..........5-2 Structured Ladder Language .
  • Page 78: St Language

    ST Language The ST language is a text language with a similar grammatical structure to the C language. Controls such as conditional judgement and repetition process written in syntaxes can be described. This language is suitable for programming complicated processes that cannot be easily described by a graphic language (structured ladder language).
  • Page 79: Operators In St Language

    5.1.2 Operators in ST language The following table shows the operators used in the ST language and their priorities. Table 5.1.2-1 Operators in the ST language Operator Description Example Priority Parenthesized expression (1+2)*(3+4) Highest Function ( ) Function (Parameter list) ADD_E(bo01, in01, in02, in03) Exponentiation re01:= 2.0 ** 4.4...
  • Page 80: Syntaxes In St Language

    5.1.3 Syntaxes in ST language The following table shows the syntaxes that can be used in the ST language. Table 5.1.3-1 Syntaxes in the ST language Type of syntax Description Assignment syntax Assignment syntax IF THEN conditional syntax, IF ELSE conditional syntax, and IF ELSIF conditional syntax Conditional syntax CASE conditional syntax FOR DO syntax...
  • Page 81 (2) IF THEN conditional syntax (a) Format IF <Boolean expression> THEN <Syntax ...>; END_IF; (b) Description The syntax is executed when the value of Boolean expression (conditional formula) is TRUE. The syntax is not executed if the value of Boolean expression is FALSE. Any expression that returns TRUE or FALSE as the result of the Boolean operation with a single bit type variable status, or a complicated expression that includes many variables can be used for the Boolean expression.
  • Page 82 (4) IF ...ELSIF conditional syntax (a) Format IF <Boolean expression 1> THEN <Syntax 1 ...>; ELSIF <Boolean expression 2> THEN <Syntax 2 ...>; ELSIF <Boolean expression 3> THEN <Syntax 3 ...>; END_IF; (b) Description Syntax 1 is executed when the value of Boolean expression (conditional formula) 1 is TRUE.
  • Page 83 (5) CASE conditional syntax (a) Format CASE <Integer expression> OF <Integer selection 1> : <Syntax 1 ...>; <Integer selection 2> : <Syntax 2 ...>; · · · <Integer selection n> : <Syntax n ...>; ELSE <Syntax n+1 ...>; END_CASE; (b) Description The result of the CASE conditional expression is returned as an integer value.
  • Page 84 (7) WHILE...DO syntax (a) Format WHILE <Boolean expression> DO <Syntax ...>; END_WHILE; (b) Description The WHILE...DO syntax executes one or more syntaxes while the value of Boolean expression (conditional formula) is TRUE. The Boolean expression is evaluated before the execution of the syntax. If the value of Boolean expression is FALSE, the syntax in the WHILE...DO syntax is not executed.
  • Page 85: Calling Functions In St Language

    (9) RETURN syntax (a) Format RETURN; (b) Description The RETURN syntax is used to end a program in a middle of the process. When the RETURN syntax is used in a program, the process jumps from the RETURN syntax execution step to the last line of the program, ignoring all the remaining steps after the RETURN syntax.
  • Page 86: Calling Function Blocks In St Language

    1) Calling a function with one input variable (Example: ABS) Output1 := ABS(Input1); 2) Calling a function with three input variables (Example: MAX) Output1 := MAX(Input1, Input2, Input3); 5.1.5 Calling function blocks in ST language The following description is used to call a function block in the ST language. Instance name(Input variable1:= Variable1, ...
  • Page 87: Structured Ladder Language

    Structured Ladder Language The structured ladder language is a graphic language for writing programs using ladder symbols such as contacts, coils, functions, and function blocks. Write programs on the assumption that the power is supplied from the baseline at the left edge of the editor to the connected ladders.
  • Page 88: Ladder Symbols In Structured Ladder Language

    5.2.2 Ladder symbols in structured ladder language The following table shows the ladder symbols that can be used in the structured ladder language. For details, refer to the following manual. MELSEC-Q/L Structured Programming Manual (Common Instructions) Table 5.2.2-1 Ladder symbols in the structured ladder language (1/2) Element Ladder symbol Description...
  • Page 89 Table 5.2.2-1 Ladder symbols in the structured ladder language (2/2) Element Network element Description Pointer branch instruction Jump Unconditionally executes the program at the specified pointer number in the same program file. Indicates the end of a subroutine program. Returns the step to the Return next step after the instruction which called the subroutine program.
  • Page 90 MEMO 5-14...
  • Page 91: Appendix

    APPENDIX Appendix 1 Correspondence between Generic Data Types and Devices ..App-2 Appendix 2 Character Strings that cannot be Used in Label Names and Data Names . . App-6 Appendix 3 Recreating Ladder Programs ....... . . App-8 App-1...
  • Page 92: Appendix 1 Correspondence Between Generic Data Types And Devices App

    Appendix 1 Correspondence between Generic Data Types and Devices The following table shows the correspondence between generic data types and devices. Table App. 1-1 Correspondence between generic data types and devices Device Classification Type Device name Device symbol Input Output Internal relay Latch relay Annunciator...
  • Page 93 Generic data type ANY_SIMPLE ANY_NUM ANY_BIT ANY_INT ANY_REAL Double Array Structure Word Double Single- Double- Time String word Word (unsigned)/ word precision precision ANY16 ANY32 (unsigned)/ (signed) 16-bit string (signed) real real 32-bit string − − − − − − −...
  • Page 94 Device Classification Type Device name Device symbol Link input Jn\X Link output Jn\Y Bit device Link relay Jn\B Link direct device Link special relay Jn\SB Link register Jn\W Word device Link special register Jn\SW Intelligent function module Word device Intelligent function module device Un\G device Index register...
  • Page 95 Generic data type ANY_SIMPLE ANY_NUM ANY_BIT ANY_INT ANY_REAL Double Array Structure Word Double Single- Double- Time String word Word (unsigned)/ word precision precision ANY16 ANY32 (unsigned)/ (signed) 16-bit string (signed) real real 32-bit string − − − − − − −...
  • Page 96 Appendix 2 Character Strings that cannot be Used in Label Names and Data Names Character strings used for application function names, common instruction names, special instruction names, and instruction words are called reserved words. These reserved words cannot be used for label names or data names. If the character string defined as a reserved word is used for a label name or data name, an error occurs during registration or compilation.
  • Page 97: Appendix 2 Character Strings That Cannot Be Used In Label Names And Data Names App

    Table App. 2-1 Character strings that cannot be used for label names and data names (2/2) Category Character string Standard function block Function block names in application functions such as CTD, CTU name Symbol /, \, *, ?, <, >, ¦, ", :, [, ] , ;, , , =, +, %, ', ~, @, {, }, !, #, $, & Date and time literal DATE, DATE_AND_TIME, DT, TIME, TIME_OF_DAY, TOD ACTION, END_ACTION, CONFIGURATION, END_CONFIGURATION, CONSTANT, F_EDGE, R_EDGE, AT, PROGRAM,...
  • Page 98: Appendix 3 Recreating Ladder Programs App

    Appendix 3 Recreating Ladder Programs This section provides an example of creating a structured program same as the program created in the ladder programming language using GX Works2. Appendix 3.1 Procedure for creating a structured program The following explains the basic procedure for creating a structured program based on the program created in the ladder programming language.
  • Page 99: Appendix 3.2 Example Of Creating A Structured Program

    Appendix 3.2 Example of creating a structured program This section shows an example of creating a sequence program same as the program created in GX Developer using GX Works2. The following examples explain the method for creating a structured program same as the data receive program for a Q-compatible serial communication module, using the structured ladder and ST languages.
  • Page 100 (2) Setting labels Set global labels and local labels. • Setting examples of global labels • Setting examples of local labels *1: Devices of local labels are automatically assigned within the range specified in the device/label automatic-assign setting in GX Works2. To assign the same devices as those in the original ladder program, set them as global labels.
  • Page 101 (3) Creating a structured program The following examples show how a structured program is created based on the original program. • Original program (Programming language: ladder) • Structured program (Programming language: structured ladder) Appendix 3 Recreating Ladder Programs App-11 Appendix 3.2 Example of creating a structured program...
  • Page 102 • Original program (Programming language: ladder) • Structured program (Programming language: ST) *1: When using multiple contacts for execution conditions, enclose them by '( )' to be programmed in a group. Appendix 3 Recreating Ladder Programs App-12 Appendix 3.2 Example of creating a structured program...
  • Page 103 INDEX Index-1...
  • Page 104 [Numerics] 32-bit index setting ..........4-42 operators ..............5-3 output variables ..........4-10,4-16 address ............4-36,4-37 array ..............4-32 POU................. 4-5 precautions on assigning label names ....4-54 priority..............4-4 Bit data ..............4-22 program ..............4-5 program blocks............4-6 program components ........
  • Page 105 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 106 Microsoft, Windows are registered trademarks of Microsoft Corporation in the United States and other countries. Ethernet is a trademark of Xerox Corporation. All other company names and product names used in this manual are trademarks or registered trademarks of their respective companies.

This manual is also suitable for:

Melsec-l seriesMelsec-f series

Table of Contents