Download Print this page

Mitsubishi Electric MELSEC Q Series Programming Manual

Structured text.
Hide thumbs

Advertisement

Programming Manual
(Structured Text)

Advertisement

   Related Manuals for Mitsubishi Electric MELSEC Q Series

   Summary of Contents for Mitsubishi Electric MELSEC Q Series

  • Page 1

    Programming Manual (Structured Text)

  • Page 3: Safety Precautions

     SAFETY PRECAUTIONS  (Always read these precautions before use) Before using the MELSEC-Q series or MELSEC-L series PLC, 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

     CONDITIONS OF USE FOR THE PRODUCT  (1) Mitsubishi programmable controller ("the PRODUCT") shall be used in conditions; i) where any problem, fault or failure occurring in the PRODUCT, if any, shall not lead to any major or serious accident; and ii) where the backup and fail-safe function are systematically or automatically provided outside of the PRODUCT for the case of any problem, fault or failure occurring in the PRODUCT.

  • Page 5: Revisions

    REVISIONS * The manual number is given on the bottom left of the back cover. Print Date * Manual Number Revision Feb., 2003 SH (NA) 080366E-A First printing Jul., 2003 SH (NA) 080366E-B Correction Section 6.7.1, Section 6.7.2, Section 6.7.3, Section 6.9.1, Section 6.9.2, Section 6.9.3, Section 6.9.4, Section 6.9.5, Section 6.9.6, Chapter 7 Jun., 2004 SH (NA) 080366E-C...

  • Page 6

    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 7: Table Of Contents

    INTRODUCTION Thank you for choosing the Mitsubishi MELSOFT series Integrated FA software. Read this manual and make sure you understand the functions and performance of MELSEC series sequencer thoroughly in advance to ensure correct use. CONTENTS SAFETY PRECAUTIONS ..........................A- 1 CONDITIONS OF USE FOR THE PRODUCT .....................

  • Page 8

    4.3 Control Syntaxes ............................4- 6 4.3.1 Control syntax list ..........................4- 6 4.3.2 Conditional statements ........................4- 7 4.3.3 Repeat statement ..........................4-15 4.3.4 Other control syntaxes ........................4-20 4.3.5 Precautions for use of control syntaxes ................... 4-22 4.4 Call of Function Block ..........................4-29 4.5 Comment ..............................

  • Page 9

    5.5.17 Increment ....................INC_M ......5-21 5.5.18 Decrement ....................DEC_M ......5-21 5.5.19 32-bit BIN increment ................DINC_M ......5-22 5.5.20 32-bit BIN decrement ................DDEC_M ...... 5-22 5.6 Data Conversion ............................5-23 5.6.1 BIN BCD conversion ................BCD_M ......5-23 5.6.2 32-bit BIN BCD conversion ..............

  • Page 10

    5.10.10 Block data logical sum ................BKOR_M ...... 5-43 5.10.11 Exclusive OR (2 devices) ..............WXOR_M ..... 5-44 5.10.12 Exclusive OR (3 devices) ..............WXOR_3_M ....5-44 5.10.13 32-bit data exclusive OR (2 devices) ............ DXOR_M ...... 5-45 5.10.14 32-bit data exclusive OR (3 devices) ............ DXOR_3_M ....5-45 5.10.15 Block data exclusive OR ...............

  • Page 11

    5.14.15 32-bit data maximum value retrieval ............ DMAX_M ...... 5-66 5.14.16 Data minimum value retrieval ............... MIN_M ......5-66 5.14.17 32-bit data minimum value retrieval ............. DMIN_M ....... 5-67 5.14.18 Data sort ....................SORT_M ...... 5-67 5.14.19 32-bit data sort ..................DSORT_M ....5-68 5.14.20 Total value calculation ................

  • Page 12

    5.18.4 Floating-point SIN operation ..............ASIN_E_MD ....5-89 5.18.5 Floating-point COS operation ............... ACOS_E_MD ....5-90 5.18.6 Floating-point TAN operation ..............ATAN_E_MD ....5-90 5.18.7 Floating-point angle radian ..............RAD_E_MD....5-91 5.18.8 Floating-point radian angle conversion ..........DEG_E_MD ....5-91 5.18.9 Floating-point square root ...............

  • Page 13

    6.1.2 Boolean type (BOOL) integer type (INT) conversion ....... BOOL_TO_INT (_E) ..6- 4 6.1.3 Boolean type (BOOL) character string type (STRING) conversion ..BOOL_TO_STR (_E) ... 6- 5 6.1.4 Double precision integer type (DINT) Boolean type (BOOL) conversion ..DINT_TO_BOOL (_E) . 6- 6 6.1.5 Double precision integer type (DINT) integer type (INT) conversion ..

  • Page 14

    6.6.4 Left rotation ....................ROL (_E) ...... 6-42 6.7 Bit Type Boolean Functions ........................6-43 6.7.1 Logical product ..................AND_E ......6-43 6.7.2 Logical sum ....................OR_E ......6-44 6.7.3 Exclusive logical sum ................XOR_E ......6-45 6.7.4 Logical NOT ....................NOT (_E) ...... 6-46 6.8 Selection Functions ..........................

  • Page 15: About Manuals

    About Manuals The manuals related to this product are shown below. Refer to the following table when ordering required manuals. Relevant manuals Manual Number Manual Name (Model Code) GX Developer Version 8 Operating Manual (Startup) SH-080372E Explains the system configuration, installation method and startup method of GX Developer. (13JU40) (Sold separately) GX Developer Version 8 Operating Manual...

  • Page 16: How To Use This Manual

    How to Use This Manual This Manual ... Use this manual to perform structured text (hereafter abbreviated to ST) programming with GX Developer. It is suitable for the users who have the knowledge and programming experience of PLC ladder programs and for the users who have the knowledge and programming experience of high-level languages such as the C language.

  • Page 17: Abbreviations And Generic Terms In This Manual

    Abbreviations and Generic Terms in This Manual In this manual, the following generic terms and abbreviations are used to represent the GX Developer software package and PLC CPU modules. The module mode name is given when the applicable model name must be pointed out explicitly. Generic Terms /Abbreviation Description/Applicable Module Generic product name of the product types SWnD5C-GPPW-E,...

  • Page 18: Overview

    1 OVERVIEW 1 OVERVIEW 1.1 What Is the ST Language? The ST language is defined in the International Standard IEC61131-3 that stipulates the logic description system in open controllers. The ST language supports operators, control syntaxes and functions to permit the following descriptions.

  • Page 19

    1 OVERVIEW (3) Ease of describing operation processing Capable of briefly describing easy-to-read operation processing that is difficult to describe in lists or ladders, the ST language has a high level of program readability and is suitable for the fields where complex arithmetic operations, comparison operations, etc.

  • Page 20: Features Of St Program In Melsec-q/l Series

    1 OVERVIEW 1.2 Features of ST Program in MELSEC-Q/L Series ST programs are described in ST language. Using GX Developer to perform ST programming enables efficient programming to be performed in excellent operation environment. The following provides the main features of ST programs in the MELSEC-Q/L series. (1) Design efficiency improved by defining processing as parts With often used processing defined as parts in the form of function blocks (FB) in ST language, they can be used in necessary areas of each program.

  • Page 21: St Program Creating Procedure

    1 OVERVIEW 1.3 ST Program Creating Procedure The following flowchart indicates the general procedure of ST programming. In the following example, parts were created with the function block function and a main program was then created in ST language. For details, refer to the GX Developer Operating Manual Creation of new project (Structured Text).

  • Page 22: System Configuration

    2 SYSTEM CONFIGURATION 2 SYSTEM CONFIGURATION 2.1 System Configuration This section explains the system configuration for use of ST programs. 2.1.1 Applicable CPUs ST programs are applicable to the following CPU modules. Basic Model High Performance Universal model Process CPU Redundant CPU LCPU QCPU...

  • Page 23

    2 SYSTEM CONFIGURATION (2) Applicable devices The device names that can be used in ST programs are as indicated below. The number of device points can be changed in parameter setting. Refer to Section "3.3.3 Devices" for details of the device representation methods. Classification Type Device...

  • Page 24

    2 SYSTEM CONFIGURATION (3) Devices applicable to ST programs only In ST programs, the contacts, coils and present values of the timers and counters are represented and used as individual devices. The device representations and types of the contacts, coils and present values of the timers and counters are as indicated below.

  • Page 25: Handling Of Characters And Numeric Values In St Programs

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3.1 Usable Characters The ST language is a programming language described in text format. It can be described as in document editing using a general text editor, but the grammar and usable characters and symbols have been defined.

  • Page 26

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS (2) Character types The characters used in ST programs can be classified as indicated below. Classification Description Example Character string defined as desired by the user. Label name It includes a function block Switch_A name, array name, structure name, etc.

  • Page 27: Data Handling

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3.2 Data Handling In ST programs, the types of used data have been defined. Sections 3.2 and 3.3 indicate the data types and their representation methods in ST programs. 3.2.1 Data types The following data types can be used in ST programs.

  • Page 28: About Any Type

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3.2.2 About ANY type Use the ANY type when multiple data types are permitted for the argument, return value, etc. of a function. The ANY type is a data type that handles any data type and is available in different types indicated in the following table.

  • Page 29: Array And Structure

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3.2.3 Array and structure In ST programs, arrays and structures can be used as data. Arrays and structures are data having a structure that can be handled as one block in a program when their elements are defined with local or global labels before use.

  • Page 30

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS Precaution for use of the specification numbers of the array elements When an array has n elements, the specification numbers of the array elements are 0 to n-1. Hence, if n or more is specified, an error will occur at the time of conversion.

  • Page 31

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS (2) Structure A structure is a data type defined by combining the data of any types. Each element can be referred to individually by describing the element name after the variable (label) name defined for the structure type, with a period (.) placed between them.

  • Page 32: Data Representation Methods

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3.3 Data Representation Methods Constants, labels and devices can be used as data in ST programs. Representation Item Description Example Constant Numeric value or character string data written directly to 123, “ABC”...

  • Page 33

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS [K, H representation] Value Range IEC Data Type K-32768 to K32767 INT, ANY16 K-2147483648 to K2147483647 DINT, ANY32 ANY_BIT (word) K0 to K32767 K0 to K2147483647 ANY_BIT (double word) H0 to HFFFF INT, ANY16, ANY_BIT (word) H0 to HFFFFFFFF SINT, ANY32, ANY_BIT (double word)

  • Page 34

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS Precaution for use of the H, 2#, 8# and 16#-specified numeric values in word label and word device operation expressions When the value handled in operation is in the range H8000 to HFFFF, the operation result available by ST program conversion differs from the operation result available by the assignment of a value to a device in the PLC CPU.

  • Page 35: Labels

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3.3.2 Labels In ST programs, labels can be used with data. When labels are used in an ST program, label declaration must be made on the local variable setting screen or global variable setting screen before use. (For the label and structure label declaration methods, refer to the "GX Developer Operating Manual".) Label representation examples in ST programs are as follows.

  • Page 36

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS REFERENCE Label declaration procedure Make label declaration on the local variable setting screen or global variable setting screen. The local variable setting screen can be opened by performing the following operation.

  • Page 37

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS Precaution for use of the pointer type, timer type, counter type and retentive timer type labels The pointer type, timer type, counter type or retentive timer type label can be declared, but if it is used in an ST program as a label, a conversion error will occur and the label cannot be used.

  • Page 38: Devices

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS 3.3.3 Devices (1) How to use devices In an ST program, devices of QCPU (Q mode)/LCPU can be used by directly describing them without labels being used. Devices can be used in the left and right members of an expression and the argument, return value, etc.

  • Page 39

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS (a) Index modification Index modification is indirect address specification using the index register. When the index register is used, the device number is (directly specified device number) + (index register contents). [Description example] (* The target D device number is changed for the numeric value in Z2 (* When 1 is in Z2, the target device number changes from D(0+1) to D1.

  • Page 40

    3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS REMARK Data type when digit specification is used ... When digit specification is used, the data types are as follows. Example: When X0 is used Integer type (INT): K1X0, K2X0, K3X0, K4X0 Double precision integer type (DINT): K5X0, K6X0, K7X0, K8X0 Precaution 1 for use of digit specification A conversion error will occur if the data type differs between the right member...

  • Page 41: St Program Expressions

    4 ST PROGRAM EXPRESSIONS 4 ST PROGRAM EXPRESSIONS 4.1 Assignment Statement An assignment statement has a function to assign the result of an expression in the right member to a label or device in the left member. In the assignment statement, the result of the expression in the right member must be equal to the data type in the left member.

  • Page 42: Operators

    4 ST PROGRAM EXPRESSIONS 4.2 Operators This section gives a list of operators usable in ST programs and their examples of use. 4.2.1 Operator list The following table lists the operators used in ST programs and indicates the priorities at the time of operation execution. Operator Description Priority...

  • Page 43

    4 ST PROGRAM EXPRESSIONS Precaution 1 for use of operator A conversion error will occur if the applicable data in the right member of an operator is not the same in data type as the applicable data in the left member. Precaution 2 for use of operator The number of used operators that can be described in a single expression is up to 1024.

  • Page 44: Examples Of Using The Operators

    4 ST PROGRAM EXPRESSIONS 4.2.2 Examples of using the operators The following gives the examples of using the operators in ST programs. (1) Operation of integer type (INT) (a) When actual devices are used [Example of use] D0 : = D1 * (D2 + K3) / K100; <<Operation order>>...

  • Page 45

    4 ST PROGRAM EXPRESSIONS (2) Operation of Boolean type (BOOL) (a) When actual devices are used [Example of use] M0 : = X0 AND X1 AND (D1 = 100); <<Operation order>> 1) Only when the result of X0 AND X1 is ON and D is 100, M0 turns ON. (b) When labels are used ...

  • Page 46: Control Syntaxes

    4 ST PROGRAM EXPRESSIONS 4.3 Control Syntaxes Conditional statements and repeat statements are available for ST programs to perform comparison and repetition. Conditional statement: When a certain condition is satisfied, the selected statement is executed. Repeat statement: One or more statements are executed repeatedly according to the state of a certain variable or condition.

  • Page 47: Conditional Statements

    4 ST PROGRAM EXPRESSIONS 4.3.2 Conditional statements (1) IF THEN conditional statement [Format] IF <Boolean expression> THEN <Statement ... > END_IF; [Explanation] The statement is executed when the Boolean expression (conditional expression) is TRUE. If the Boolean expression is FALSE, the statement is not executed.

  • Page 48

    4 ST PROGRAM EXPRESSIONS 2) When label w_Str is specified as character string type IF w_Str = "ABC" THEN (* If w_Str is "ABC" D0 : = 0; (* 0 is assigned to D0. END_IF; 3) When label w_Str is specified as character string type IF w_Str = 'ABC' THEN (* If w_Str is 'ABC' D0 : = 0;...

  • Page 49

    4 ST PROGRAM EXPRESSIONS (2) IF ... ELSE conditional statement [Format] IF <Boolean expression> THEN <Statement1 ... > ELSE <Statement2 ... > END_IF; [Explanation] Statement 1 is executed when the Boolean expression (conditional expression) is TRUE. Statement 2 is executed if the value of the Boolean expression is FALSE. Conditional FALSE expression...

  • Page 50

    4 ST PROGRAM EXPRESSIONS (3) IF ... ELSIF conditional statement [Format] IF <Boolean expression 1> THEN <Statement 1 ... > ELSIF <Boolean expression 2> THEN <Statement 2 ... > ELSIF <Boolean expression 3> THEN <Statement 3 ... > END_IF; [Explanation] Statement 1 is executed when Boolean expression (conditional expression) 1 is TRUE.

  • Page 51

    4 ST PROGRAM EXPRESSIONS [Description example] (a) When actual devices are used in Boolean expressions IF D0 < 100 THEN (* If D0 is less than 100 D1 : = 0; (* 0 is assigned to D1. ELSIF D0 <= 200 THEN (* If D0 is less than or equal to 200 D1 : = 1;...

  • Page 52

    4 ST PROGRAM EXPRESSIONS (4) CASE conditional statement [Format] CASE <Integer expression> OF <Integer selection 1> : <Statement 1> <Integer selection 2> : <Statement 2> <Integer selection n> : <Statement n> ELSE <Statement n+1 ...> END_CASE; Specifying method that can be used for <Integer selection *> in CASE conditional statement One value, multiple values, or a value range can be specified for <Integer selection *>...

  • Page 53

    4 ST PROGRAM EXPRESSIONS TRUE = Selection 1? FALSE Statement 1 TRUE = Selection 2? FALSE Statement 2 TRUE = Selection n? Statement n+1 Statement n [Description example] (a) When actual device is used in integer expression CASE D0 OF D1 : = 0;...

  • Page 54

    4 ST PROGRAM EXPRESSIONS (c) When function is used in integer expression CASE DINT_TO_INT (dData) OF (* If DINT_TO_INT (dData) is 1 D1 : = 0; (* 0 is assigned to D1. 2, 3: (* If DINT_TO_INT (dData) is 2 or 3 D1 : = 1;...

  • Page 55: Repeat Statement

    4 ST PROGRAM EXPRESSIONS 4.3.3 Repeat statement (1) FOR...DO syntax [Format] FOR <Repeat variable initialization> TO <Last value expression> BY <Incremental expression> DO < Statement ...> END_FOR; Repeat variable initialization: The data used as a repeat variable is initialized. Last value expression, incremental expression: The initialized repeat variable is incremented or decremented according to the incremental expression, and repetitive processing is performed...

  • Page 56

    4 ST PROGRAM EXPRESSIONS Precaution for use of repeat variable The double precision integer type (DINT) and integer type (INT) can be used for a repeat variable, but structure elements and array elements cannot be used. Also, match the type used for the repeat variable with the types of the <last value expression>...

  • Page 57

    4 ST PROGRAM EXPRESSIONS (2) WHILE...DO syntax [Format] WHILE <Boolean expression> D0 <Statement ...> END_WHILE; [Explanation] The WHILE ... DO syntax executes one or more statements while the Boolean expression (conditional expression) is TRUE. The Boolean expression is judged before execution of the statement. If the Boolean expression is FALSE, the statement in DO ...

  • Page 58

    4 ST PROGRAM EXPRESSIONS (3) REPEAT...UNTIL syntax [Format] REPEAT <Statement ...> UNTIL <Boolean expression> END_REPEAT; [Explanation] The REPEAT ... UNTIL syntax executes one or more statements while the Boolean expression (conditional expression) is FALSE. The Boolean expression is judged after execution of the statement. If the value is TRUE, the statement in REPEAT ...

  • Page 59

    4 ST PROGRAM EXPRESSIONS (c) When function is used in Boolean expression REPEAT D1 : = D1 + 1; (* Until BOOL_TO_DINT(M0)*) (* than 100 UNTIL BOOL_TO_DINT(M0) < 100 (* becomes less (* D1 is incremented by 1 END_REPEAT; Precaution 1 for use of repeat statements When using a repeat statement, be careful not to result in endless loop processing.

  • Page 60: Other Control Syntaxes

    4 ST PROGRAM EXPRESSIONS 4.3.4 Other control syntaxes (1) RETURN syntax [Format] RETURN; [Explanation] The RETURN syntax is used to terminate a program in a function block or an ST program. When the RETURN syntax is used in a program, the processing after the RETURN syntax are all ignored, and a jump occurs from the place where RETURN is executed to the last line of the ST program or the program in the function block.

  • Page 61

    4 ST PROGRAM EXPRESSIONS (2) EXIT syntax [Format] EXIT; [Explanation] The EXIT syntax can be used in the repeat statement of an ST program and terminates a repeat loop midway. When the EXIT syntax is reached during execution of a repeat loop, the repeat loop processing after the EXIT syntax is not executed.

  • Page 62: Precautions For Use Of Control Syntaxes

    4 ST PROGRAM EXPRESSIONS 4.3.5 Precautions for use of control syntaxes This section explains the number of used steps, operation processing time and instructions for use of the control syntaxes in an ST program. (1) Number of used steps and operation processing time for use of control syntaxes The number of used steps and operation processing time for use of the control syntaxes will be explained.

  • Page 63

    4 ST PROGRAM EXPRESSIONS (b) CASE conditional statement Unit ( µ s) Operation Processing Operation Processing Number of Steps Time (Q25H) Time (Q00J) CASE D0 OF 1, 2: D0 : = 100; ST program 5.004 36.1 3..10: D1 : = D1 + 1; END_CASE;...

  • Page 64

    4 ST PROGRAM EXPRESSIONS (d) WHILE...DO statements Unit ( µ s) WHILE...DO statement 1 Operation Processing Operation Processing Number of Steps Time (Q25H) Time (Q00J) WHILE X0 DO 3.034 D0 : = 100; ST program Repeated until X0 21.9 END_ WHILE; becomes TRUE.

  • Page 65

    4 ST PROGRAM EXPRESSIONS (e) REPEAT...UNTIL statements Unit ( µ s) REPEAT...UNTIL statement 1 Operation Processing Operation Processing Number of Steps Time (Q25H) Time (Q00J) REPEAT 1.534 D0 : = 100; ST program Repeated until X0 10.9 UNTIL X0 becomes TRUE. END_ REPEAT;...

  • Page 66

    4 ST PROGRAM EXPRESSIONS (f) EXIT statement Unit ( µ s) Operation Processing Operation Processing Number of Steps Time (Q25H) Time (Q00J) ST program List program As above As above As above As above [Remarks] Using the JMP instruction, execution moves to the pointer immediately after repeat processing termination. If the statement is described in a list, the operation is the same as in the ST program.

  • Page 67

    4 ST PROGRAM EXPRESSIONS (2) Precautions for use of bit devices The following explains the precautions to be taken when a program is created using an IF/CASE conditional statement in an ST program. Once the Boolean expression (conditional expression) is satisfied in the IF condition statement, when a bit device is turned ON in the IF condition statement, that bit device becomes always ON.

  • Page 68

    4 ST PROGRAM EXPRESSIONS (3) Precautions for use of timers and counters The following explains the precautions to be taken when a program is created using an IF/CASE conditional statement in an ST program. In the IF condition statement, the Boolean expression (conditional expression) differs from the execution condition of the timer/counter instruction.

  • Page 69: Call Of Function Block

    4 ST PROGRAM EXPRESSIONS 4.4 Call of Function Block In an ST program, a function blocks (FB) can be used. This section explains the method of using a user-created FB in an ST program. (For the FB creating method, refer to the "GX Developer Version 8 Operating Manual (Function Block)".

  • Page 70

    4 ST PROGRAM EXPRESSIONS REFERENCE To make label declaration for the input, I/O and output variables of FB ... GX Developer start [Open project] Click the FB tab Add new FB Double-click Header icon FB label setting screen The following example shows the FB input/output variable label setting made on the FB label setting screen.

  • Page 71

    4 ST PROGRAM EXPRESSIONS Precaution for acquiring the FB output Execute FB output acquirement after an FB call. If it is executed before an FB call, an error will occur. Example: FB name: FB1 Input variable : I_Test Output variable: O_Test D1 : = FB1.O_Test;...

  • Page 72: Comment

    4 ST PROGRAM EXPRESSIONS 4.5 Comment In an ST program, comments can be input. An area enclosed by "(*" and "*)" is handled as a comment. If a comment is placed within a comment, an error will occur. [Description example] Example 1: (* The pump is activated.

  • Page 73

    4 ST PROGRAM EXPRESSIONS MEMO 4 - 33 4 - 33...

  • Page 74: Melsec Functions

    5 MELSEC FUNCTIONS 5 MELSEC FUNCTIONS How the functions are described This manual describes the function definitions, arguments, return values and using examples of the MELSEC functions. The MELSEC functions are created on the basis of the MELSEC common commands. For the applicable CPU types, basic operations, detailed functions and applicable devices of the functions and the errors that may occur during execution of the functions, refer to the "MELSEC-Q/L Programming Manual (Common Instructions)".

  • Page 75

    5 MELSEC FUNCTIONS The following indicates the correspondences between the MELSEC command in the "MELSEC-Q/L Programming Manual (Common Instructions)" and the MELSEC function in this manual. MELSEC-Q/L Programming Manual (Common Instructions) [MELSEC instruction] 6.1.6 BIN block data comparisons (BKCMP , BKCMP High Basic Process...

  • Page 76

    5 MELSEC FUNCTIONS 1) Applicable CPU types CPU types that can use the instructions are indicated. 2) Applicable devices • The correspondences between the arguments of the MELSEC function and MELSEC command are as follows. (The arguments of the same argument names correspond to each other.) Precaution for use of the arguments of the MELSEC and IEC functions When the argument is of ANY32 type, the data type that can be specified is the...

  • Page 77: Output

    5 MELSEC FUNCTIONS 5.1 Output 5.1.1 Output to device OUT_M The execution condition is output to the specified device. Function definition BOOL OUT_M (BOOL EN, BOOL D); Argument Name IN/OUT Description Execution condition Target to be turned ON/OFF Return Value Description Execution condition BOOL...

  • Page 78: High-speed Timer

    5 MELSEC FUNCTIONS 5.1.3 High-speed timer TIMER_H_M When the coil of the timer (high-speed timer, high-speed retentive timer) turns ON, the timer calculates up to the set value, and when the timer times out (calculation value ( set value), the contact is put in the following status. N/O contact: Conduction N/C contact: Non-conduction Function definition BOOL TIMER_H_M (BOOL EN, BOOL TCoil, ANY16 TValue);...

  • Page 79: Set Of Device

    5 MELSEC FUNCTIONS 5.1.5 Set of device SET_M When the execution condition is satisfied, the specified device is operated as described below. Bit device: The coil/contact is turned ON. When bit of word device is specified: The specified bit is turned to 1. Function definition BOOL SET_M (BOOL EN, BOOL D);...

  • Page 80: Conversion Of Direct Output Into Pulse

    5 MELSEC FUNCTIONS 5.1.7 Conversion of direct output into pulse DELTA_M When the execution condition is satisfied, the specified direct access output (DY) is output as a pulse. Function definition BOOL DELTA_M (BOOL EN, BOOL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be output as pulse (DY device)

  • Page 81: 1-bit Shift

    5 MELSEC FUNCTIONS 5.2 1-Bit Shift 5.2.1 1-bit shift of device SFT_M When the execution condition is satisfied, the specified device is operated as described below. In the case of bit device: The ON/OFF status of the device number preceding the specified device number is shifted to the specified device number, and the preceding device number is turned OFF.

  • Page 82: Termination

    5 MELSEC FUNCTIONS 5.3 Termination 5.3.1 Stop STOP_M When the execution condition is satisfied, output Y is reset and the CPU operation is stopped. (This operation is the same as performed when the RUN/STOP DIP switch is moved to the STOP position.) Function definition BOOL STOP_M (BOOL EN);...

  • Page 83: Comparison Operation

    5 MELSEC FUNCTIONS 5.4 Comparison Operation 5.4.1 Block data comparison (=) BKCMP_EQ_M n points of BIN 16-bit data (word unit), starting at the specified devices, are compared in terms of "=". Function definition BOOL BKCMP_EQ_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 n, BOOL D); Argument Name IN/OUT Description...

  • Page 84: Block Data Comparison (>)

    5 MELSEC FUNCTIONS 5.4.3 Block data comparison (>) BKCMP_GT_M n points of BIN 16-bit data (word unit), starting at the specified devices, are compared in terms of ">". Function definition BOOL BKCMP_GT_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 n, BOOL D); Argument Name IN/OUT Description...

  • Page 85: Block Data Comparison (<)

    5 MELSEC FUNCTIONS 5.4.5 Block data comparison (<) BKCMP_LT_M n points of BIN 16-bit data (word unit), starting at the specified devices, are compared in terms of "<". Function definition BOOL BKCMP_LT_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 n, BOOL D); Argument Name IN/OUT Description...

  • Page 86: Arithmetic Operation

    5 MELSEC FUNCTIONS 5.5 Arithmetic Operation 5.5.1 Addition of BCD 4-digit data (2 devices) BPLUS_M The specified two BCD 4-digit data are added. Function definition BOOL BPLUS_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Addend data (BCD 4-digit data) IN/OUT...

  • Page 87: Subtraction Of Bcd 4-digit Data (2 Devices)

    5 MELSEC FUNCTIONS 5.5.3 Subtraction of BCD 4-digit data (2 devices) BMINUS_M Subtraction is performed between the specified two BCD 4-digit data. Function definition BOOL BMINUS_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Subtrahend data (BCD 4-digit data) IN/OUT...

  • Page 88: Addition Of Bcd 8-digit Data (2 Devices)

    5 MELSEC FUNCTIONS 5.5.5 Addition of BCD 8-digit data (2 devices) DBPLUS_M The specified two BCD 8-digit data are added. Function definition BOOL DBPLUS_M (BOOL EN, ANY16 S1, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Addend data (BCD 8-digit data) IN/OUT...

  • Page 89: Subtraction Of Bcd 8-digit Data (2 Devices)

    5 MELSEC FUNCTIONS 5.5.7 Subtraction of BCD 8-digit data (2 devices) DBMINUS_M Subtraction is performed between the specified two BCD 8-digit data. Function definition BOOL DBMINUS_M (BOOL EN, ANY32 S1, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Subtrahend data (BCD 8-digit data) IN/OUT...

  • Page 90: Multiplication Of Bcd 4-digit Data

    5 MELSEC FUNCTIONS 5.5.9 Multiplication of BCD 4-digit data BMULTI_M The specified two BCD 4-digit data are multiplied. Function definition BOOL BMULTI_M (BOOL EN, ANY16 S1, ANY16 S2, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Multiplicand data (BCD 4-digit data) Multiplier data (BCD 4-digit data)

  • Page 91: Multiplication Of Bcd 8-digit Data

    5 MELSEC FUNCTIONS 5.5.11 Multiplication of BCD 8-digit data DBMULTI_M The specified two BCD 8-digit data are multiplied. Function definition BOOL DBMULTI_M (BOOL EN, ANY32 S1, ANY32 S2, ANY16(4) D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Multiplicand data (BCD 8-digit data) Multiplier data (BCD 8-digit data)

  • Page 92: Character String Data Connection (2 Devices)

    5 MELSEC FUNCTIONS 5.5.13 Character string data connection (2 devices) STRING_PLUS_M The specified character string data are connected. Function definition BOOL STRING_PLUS_M (BOOL EN, STRING S1, STRING D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to connect (character string data) Data to be connected, connection result (character string...

  • Page 93: Bin Block Addition

    5 MELSEC FUNCTIONS 5.5.15 BIN block addition BKPLUS_M n points of BIN 16-bit data, starting at the specified devices, are added. Function definition BOOL BKPLUS_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Augend data (BIN 16-bit data) Addend data (BIN 16-bit data)

  • Page 94: Increment

    5 MELSEC FUNCTIONS 5.5.17 Increment INC_M The specified BIN 16-bit data is incremented (by 1). Function definition BOOL INC_M (BOOL EN, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) IN/OUT Increment data, incrementing result (BIN 16-bit data) Return Value Description BOOL...

  • Page 95: 32-bit Bin Increment

    5 MELSEC FUNCTIONS 5.5.19 32-bit BIN increment DINC_M The specified BIN 32-bit data is incremented (by 1). Function definition BOOL DINC_M (BOOL EN, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) IN/OUT Increment data, incrementing result (BIN 32-bit data) Return Value...

  • Page 96: Data Conversion

    5 MELSEC FUNCTIONS 5.6 Data Conversion 5.6.1 BIN BCD conversion BCD_M The specified BIN 16-bit data (0 to 9999) is converted into BCD 4-digit data. Function definition BOOL BCD_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (BIN 16-bit data) Conversion result (BCD 4-digit data)

  • Page 97: Bcd Bin Conversion

    5 MELSEC FUNCTIONS 5.6.3 BCD BIN conversion BIN_M The specified BCD 4-digit data (0 to 9999) is converted into BIN 16-bit data. Function definition BOOL BIN _M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (BCD 4-digit data) Conversion result (BIN 16-bit data)

  • Page 98: Floating-point Bin Conversion

    5 MELSEC FUNCTIONS 5.6.5 Floating-point BIN conversion INT_E_MD The specified real number data is converted into BIN 16-bit data. Function definition BOOL INT_E_MD (BOOL EN, REAL S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (real number data) Conversion result (BIN 16-bit data)

  • Page 99: Bin Floating-point Conversion

    5 MELSEC FUNCTIONS 5.6.7 BIN floating-point conversion FLT_M The specified BIN 16-bit data is converted into real number data. Function definition BOOL FLT_M (BOOL EN, ANY16 S1, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (BIN 16-bit data) Conversion result (real number data)

  • Page 100: 16-bit Bin 32-bit Bin Conversion

    5 MELSEC FUNCTIONS 5.6.9 16-bit BIN 32-bit BIN conversion DBL_M The specified BIN 16-bit data is converted into signed BIN 32-bit data. Function definition BOOL DBL_M (BOOL EN, ANY16 S1, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (BIN 16-bit data) Conversion result (BIN 32-bit data)

  • Page 101: Bin Gray Code Conversion

    5 MELSEC FUNCTIONS 5.6.11 BIN gray code conversion GRY_M The specified BIN 16-bit data is converted into gray code 16-bit data. Function definition BOOL GRY_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (BIN 16-bit data) Conversion result (gray code 16-bit data)

  • Page 102: Gray Code Bin Conversion

    5 MELSEC FUNCTIONS 5.6.13 Gray code BIN conversion GBIN_M The specified gray code 16-bit data is converted into BIN 16-bit data. Function definition BOOL GBIN_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (gray code 16-bit data) Conversion result (BIN 16-bit data)

  • Page 103: 2' Complement Of 16-bit Bin

    5 MELSEC FUNCTIONS 5.6.15 2' complement of 16-bit BIN NEG_M The sign of the specified BIN 16-bit data is inverted. (2's complement) Function definition BOOL NEG_M (BOOL EN, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data whose sign will be inverted, sign inversion result IN/OUT...

  • Page 104: 2' Complement Of Floating-point

    5 MELSEC FUNCTIONS 5.6.17 2' complement of floating-point ENEG_M The sign of the specified real number data is inverted. (2's complement) Function definition BOOL ENEG_M (BOOL EN, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data whose sign will be inverted, sign inversion result IN/OUT...

  • Page 105: Block Bcd Bin Conversion

    5 MELSEC FUNCTIONS 5.6.19 Block BCD BIN conversion BKBIN_M n points of BCD 4-digit data (0 to 9999), starting at the specified device, is converted into BIN 16-bit data. Function definition BOOL BKBIN_M (BOOL EN, ANY16 S1, ANY16 n, ANY16 D); Argument Name IN/OUT Description...

  • Page 106: Data Transfer

    5 MELSEC FUNCTIONS 5.7 Data Transfer 5.7.1 16-bit data NOT transfer CML_M The specified BIN 16-bit data are inverted bit by bit. Function definition BOOL CML_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data whose bits will be inverted (BIN 16-bit data) Inversion result transfer destination (BIN 16-bit data)

  • Page 107: Block Transfer

    5 MELSEC FUNCTIONS 5.7.3 Block transfer BMOV_M n points of BIN 16-bit data, starting at the specified device, are batch-transferred. Function definition BOOL BMOV_M (BOOL EN, ANY16 S1, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be transferred (BIN 16-bit data) Number of data to be transferred (BIN 16-bit data)

  • Page 108: 16-bit Data Exchange

    5 MELSEC FUNCTIONS 5.7.5 16-bit data exchange XCH_M The specified two BIN 16-bit data are exchanged. Function definition BOOL XCH_M (BOOL EN, ANY16 D1, ANY16 D2); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) IN/OUT Data to be exchanged, exchange result (BIN 16-bit data) IN/OUT...

  • Page 109: Block Data Exchange

    5 MELSEC FUNCTIONS 5.7.7 Block data exchange BXCH_M n points of BIN 16-bit data, starting at the specified devices, are exchanged. Function definition BOOL BXCH_M (BOOL EN, ANY16 n, ANY16 D1, ANY16 D2); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Number of data to be exchanged (BIN 16-bit data) Data to be exchanged, exchange result (BIN 16-bit...

  • Page 110: Program Execution Control

    5 MELSEC FUNCTIONS 5.8 Program Execution Control 5.8.1 Interrupt disable DI_M If the interrupt factor of an interrupt program occurs, the execution of the interrupt program is disabled until EI_M is executed. Function definition BOOL DI_M (BOOL EN); Argument Name IN/OUT Description Execution condition...

  • Page 111: I/o Refresh

    5 MELSEC FUNCTIONS 5.9 I/O Refresh 5.9.1 I/O refresh RFS_M n points of I/O devices, starting at the specified device, are refreshed. Function definition BOOL RFS_M (BOOL EN, BOOL S1, ANY16 n); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Devices to be refreshed (bit data) Number of data to be refreshed (BIN 16-bit data)

  • Page 112: Logical Operation Commands

    5 MELSEC FUNCTIONS 5.10 Logical Operation Commands 5.10.1 Logical product (2 devices) WAND_M The specified two BIN 16-bit data are ANDed bit by bit. Function definition BOOL WAND_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to AND (BIN 16-bit data) IN/OUT...

  • Page 113: 32-bit Data Logical Product (2 Devices)

    5 MELSEC FUNCTIONS 5.10.3 32-bit data logical product (2 devices) DAND_M The specified two BIN 32-bit data are ANDed bit by bit. Function definition BOOL DAND_M (BOOL EN, ANY32 S1, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to AND (BIN 32-bit data) IN/OUT...

  • Page 114: Block Data Logical Product

    5 MELSEC FUNCTIONS 5.10.5 Block data logical product BKAND_M n points of 16-bit data, starting at the specified two devices, are ANDed bit by bit. Function definition BOOL BKAND_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when...

  • Page 115: Logical Sum (3 Devices)

    5 MELSEC FUNCTIONS 5.10.7 Logical sum (3 devices) WOR_3_M The specified two BIN 16-bit data are ORed bit by bit. Function definition BOOL WOR_3_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 D1); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be ORed (BIN 16-bit data) Data to OR (BIN 16-bit data)

  • Page 116: 32-bit Data Logical Sum (3 Devices)

    5 MELSEC FUNCTIONS 5.10.9 32-bit data logical sum (3 devices) DOR_3_M The specified two BIN 32-bit data are ORed bit by bit. Function definition BOOL DOR_3_M (BOOL EN, ANY32 S1, ANY32 S2, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be ORed (BIN 32-bit data) Data to OR (BIN 32-bit data)

  • Page 117: Exclusive Or (2 Devices)

    5 MELSEC FUNCTIONS 5.10.11 Exclusive OR (2 devices) WXOR_M The specified two BIN 16-bit data are EXCLUSIVE ORed bit by bit. Function definition BOOL WXOR_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to EXCLUSIVE OR (BIN 16-bit data) Data to be EXCLUSIVE ORed, operation result (BIN...

  • Page 118: 32-bit Data Exclusive Or (2 Devices)

    5 MELSEC FUNCTIONS 5.10.13 32-bit data exclusive OR (2 devices) DXOR_M The specified two BIN 32-bit data are EXCLUSIVE ORed bit by bit. Function definition BOOL DXOR_M (BOOL EN, ANY32 S1, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to EXCLUSIVE OR (BIN 32-bit data) Data to be EXCLUSIVE ORed, operation result (BIN...

  • Page 119: Block Data Exclusive Or

    5 MELSEC FUNCTIONS 5.10.15 Block data exclusive OR BKXOR_M n points of 16-bit data, starting at the specified two devices, are EXCLUSIVE ORed bit by bit. Function definition BOOL BKXOR_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 n, ANY16 D); Argument Name IN/OUT Description...

  • Page 120: Not Exclusive Or (3 Devices)

    5 MELSEC FUNCTIONS 5.10.17 NOT exclusive OR (3 devices) WXNR_3_M The specified two BIN 16-bit data are NOT EXCLUSIVE ORed bit by bit. Function definition BOOL WXNR_3_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be NOT EXCLUSIVE ORed (BIN 16-bit data) Data to NOT EXCLUSIVE OR (BIN 16-bit data)

  • Page 121: 32-bit Data Not Exclusive Or (3 Devices)

    5 MELSEC FUNCTIONS 5.10.19 32-bit data NOT exclusive OR (3 devices) DXNR_3_M The specified two BIN 32-bit data are NOT EXCLUSIVE ORed bit by bit. Function definition BOOL DXNR_3_M (BOOL EN, ANY32 S1, ANY32 S2, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE)

  • Page 122: Rotation

    5 MELSEC FUNCTIONS 5.11 Rotation 5.11.1 Right rotation (carry flag not included) ROR_M The specified BIN 16-bit data are rotated n bits to the right, without the carry flag being included. Function definition BOOL ROR_M (BOOL EN, ANY16 n, ANY16 D); Argument Name IN/OUT Description...

  • Page 123: Left Rotation (carry Flag Not Included)

    5 MELSEC FUNCTIONS 5.11.3 Left rotation (carry flag not included) ROL_M The specified BIN 16-bit data are rotated n bits to the left, without the carry flag being included. Function definition BOOL ROL_M (BOOL EN, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when...

  • Page 124: 32-bit Data Right Rotation (carry Flag Not Included)

    5 MELSEC FUNCTIONS 5.11.5 32-bit data right rotation (carry flag not included) DROR_M The specified BIN 32-bit data are rotated n bits to the right, without the carry flag being included. Function definition BOOL DROR_M (BOOL EN, ANY16 n, ANY32 D); Argument Name IN/OUT Description...

  • Page 125: 32-bit Data Left Rotation (carry Flag Not Included)

    5 MELSEC FUNCTIONS 5.11.7 32-bit data left rotation (carry flag not included) DROL_M The specified BIN 32-bit data are rotated n bits to the left, without the carry flag being included. Function definition BOOL DROL_M (BOOL EN, ANY16 n, ANY32 D); Argument Name IN/OUT Description...

  • Page 126: Shift

    5 MELSEC FUNCTIONS 5.12 Shift 5.12.1 n-bit right shift SFR_M The specified BIN 16-bit data are shifted n bits to the right. Function definition BOOL SFR_M (BOOL EN, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Number of shifts (0 to 15) (BIN 16-bit data) IN/OUT...

  • Page 127: N-bit Data 1-bit Right Shift

    5 MELSEC FUNCTIONS 5.12.3 n-bit data 1-bit right shift BSFR_M n points of bit data, starting at the specified device, are shifted one bit to the right. Function definition BOOL BSFR_M (BOOL EN, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE)

  • Page 128: 1-word Right Shift

    5 MELSEC FUNCTIONS 5.12.5 1-word right shift DSFR_M n points of 16-bit data, starting at the specified device, are shifted one word to the right. Function definition BOOL DSFR_M (BOOL EN, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Number of devices to be shifted (BIN 16-bit data) IN/OUT...

  • Page 129: Bit Processing

    5 MELSEC FUNCTIONS 5.13 Bit Processing 5.13.1 Bit set of word device BSET_M Bit n of the specified word device is set. Function definition BOOL_BSET_M (BOOL EN, ANY16 n, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Bit number to be set (BIN 16-bit data) IN/OUT...

  • Page 130: Bit Test Of Word Device

    5 MELSEC FUNCTIONS 5.13.3 Bit test of word device TEST_MD The bit status in the specified position of the specified word device is written to the specified bit device. Function definition BOOL TEST_MD (BOOL EN, ANY16 S1, ANY 16 S2, BOOL D); Argument Name IN/OUT Description...

  • Page 131: Bit Device Batch Reset

    5 MELSEC FUNCTIONS 5.13.5 Bit device batch reset BKRST_M n points, starting at the specified bit device, are reset. Function definition BOOL BKRST_M (BOOL EN, BOOL S1, ANY16 n); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Head of data to be reset (bit data) Number of bits to be reset (BIN 16-bit data)

  • Page 132: Data Processing

    5 MELSEC FUNCTIONS 5.14 Data Processing 5.14.1 Data search SER_M n points of data, starting at the specified BIN 16-bit data, are searched for the specified BIN 16-bit data. Function definition BOOL SER_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 n, ANY16(2) D); Argument Name IN/OUT Description...

  • Page 133: Bit Check

    5 MELSEC FUNCTIONS 5.14.3 Bit check SUM_M The number of bits having 1 in the specified BIN 16-bit data is counted. Function definition BOOL SUM_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be counted (BIN 16-bit data) Count result (BIN 16-bit data)

  • Page 134: Decode

    5 MELSEC FUNCTIONS 5.14.5 Decode DECO_M The lower n bits of the specified data are decoded. Function definition BOOL DECO_M (BOOL EN, ANY_SIMPLE S1, ANY16 n, ANY_SIMPLE D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be decoded Valid bit length (1 to 8) *0: No processing (BIN 16-bit data)

  • Page 135: 7-segment Decode

    5 MELSEC FUNCTIONS 5.14.7 7-segment decode SEG_M The lower 4 bits (0 to F) of the specified data are decoded into 7-segment display data. Function definition BOOL SEG_M (BOOL EN, ANY16 S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be decoded Decode result (BIN 16-bit data)

  • Page 136: 4-bit Connection Of 16-bit Data

    5 MELSEC FUNCTIONS 5.14.9 4-bit connection of 16-bit data UNI_M The lower 4 bits of n points of BIN 16-bit data, starting at the specified device, are connected to the specified device. Function definition BOOL UNI_M (BOOL EN, ANY16 S1, ANY16 n, ANY16 D); Argument Name IN/OUT Description...

  • Page 137: Bit Connection Of Any Data

    5 MELSEC FUNCTIONS 5.14.11 Bit connection of any data NUNI_M The bits of the data stored in and after the specified device are connected in units of the specified bits. Function definition BOOL NUNI_M (BOOL EN, ANY16 S1, ANY16 S2, ANY16 D); Argument Name IN/OUT Description...

  • Page 138: Byte Unit Data Connection

    5 MELSEC FUNCTIONS 5.14.13 Byte unit data connection BTOW_MD The lower 8 bits of n points of BIN 16-bit data in and after the specified device are connected in word units. Function definition BOOL BTOW_MD (BOOL EN, ANY16 S1, ANY16 n, ANY16 D); Argument Name IN/OUT Description...

  • Page 139: 32-bit Data Maximum Value Retrieval

    5 MELSEC FUNCTIONS 5.14.15 32-bit data maximum value retrieval DMAX_M The maximum value is retrieved from n points of BIN 32-bit data, starting at the specified device. Function definition BOOL DMAX_M (BOOL EN, ANY32 S1, ANY16 n, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the...

  • Page 140: 32-bit Data Minimum Value Retrieval

    5 MELSEC FUNCTIONS 5.14.17 32-bit data minimum value retrieval DMIN_M The minimum value is retrieved from n points of BIN 32-bit data, starting at the specified device. Function definition BOOL DMIN_M (BOOL EN, ANY32 S1, ANY16 n, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the...

  • Page 141: 32-bit Data Sort

    5 MELSEC FUNCTIONS 5.14.19 32-bit data sort DSORT_M n points of BIN 32-bit data, starting at the specified device, are sorted in ascending or descending order. Function definition BOOL DSORT_M (BOOL EN, ANY32 S1, ANY16 n, ANY16 S2, BOOL D1, ANY16 D2); Argument Name IN/OUT Description...

  • Page 142: 32-bit Total Value Calculation

    5 MELSEC FUNCTIONS 5.14.21 32-bit total value calculation DWSUM_M n points of BIN 32-bit data, starting at the specified device, are all added. Function definition BOOL DWSUM_M (BOOL EN, ANY32 S1, ANY16 n, ANY16(4) D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data from which total value will be calculated (BIN 32-bit data)

  • Page 143: Structuring

    5 MELSEC FUNCTIONS 5.15 Structuring 5.15.1 Refresh COM_M The I/O refresh and general data processing of the intelligent function module are performed. Function definition BOOL COM_M (BOOL EN); Argument Name IN/OUT Description Execution condition (Only value TRUE indicating that the result is always valid or normally ON device SM400 can be specified.) Return Value Description...

  • Page 144: Buffer Memory Access

    5 MELSEC FUNCTIONS 5.16 Buffer Memory Access 5.16.1 Intelligent function module 1-word data read FROM_M The specified points of data are read from the specified address and later of the buffer memory in the specified intelligent function module or special function module. Function definition BOOL FROM_M (BOOL EN, ANY16 n1, ANY16 n2, ANY16 n3, ANY16 D);...

  • Page 145: Intelligent Function Module 1-word Data Write

    5 MELSEC FUNCTIONS 5.16.3 Intelligent function module 1-word data write TO_M n3 points of data, starting at the specified device, are written to the specified address and later of the buffer memory in the specified intelligent function module or special function module. Function definition BOOL TO_M (BOOL EN, ANY16 S1, ANY16 n1, ANY16 n2, ANY16 n3);...

  • Page 146: Character String Processing

    5 MELSEC FUNCTIONS 5.17 Character string processing 5.17.1 BIN decimal ASCII conversion BINDA_S_MD The numeric value in each digit of the specified BIN 16-bit data represented in decimal is converted into ASCII code data. Function definition BOOL BINDA_S_MD (BOOL EN, ANY16 S1, STRING(8) D); Argument Name IN/OUT Description...

  • Page 147: Hexadecimal Ascii Bin Conversion

    5 MELSEC FUNCTIONS 5.17.3 BIN hexadecimal ASCII conversion BINHA_S_MD The numeric value in each digit of the specified BIN 16-bit data represented in hexadecimal is converted into ASCII code data. Function definition BOOL BINHA_S_MD (BOOL EN, ANY 16S1, STRING(6) D); Argument Name IN/OUT Description...

  • Page 148

    5 MELSEC FUNCTIONS 5.17.5 BCD 4-digit decimal ASCII conversion BCDDA_S_MD The numeric value in each digit of the specified BCD 4-digit data is converted into ASCII code. Function definition BOOL BCDDA_S_MD (BOOL EN, ANY16 S1, STRING(6) D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE)

  • Page 149

    5 MELSEC FUNCTIONS 5.17.7 Decimal ASCII BIN conversion DABIN_S_MD The specified decimal ASCII code data is converted into BIN 16-bit data. Function definition BOOL DABIN_S_MD (BOOL EN, STRING (6) S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (decimal ASCII code data) Conversion result (BIN 16-bit data)

  • Page 150: Hexadecimal Ascii 32-bit Bin Conversion

    5 MELSEC FUNCTIONS 5.17.9 Hexadecimal ASCII BIN conversion HABIN_S_MD The specified hexadecimal ASCII code data is converted into BIN 16-bit data. Function definition BOOL HABIN_S_MD (BOOL EN, STRING(4) S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (hexadecimal ASCII code data) Conversion result (BIN 16-bit data)

  • Page 151: Decimal Ascii Bcd 4-digit Conversion

    5 MELSEC FUNCTIONS 5.17.11 Decimal ASCII BCD 4-digit conversion DABCD_S_MD The specified decimal ASCII code data is converted into BCD 4-digit data. Function definition BOOL DABCD_S_MD (BOOL EN, STRING(4) S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted (decimal ASCII code data) Conversion result (BCD 4-digit data)

  • Page 152: Device Comment Data Read

    5 MELSEC FUNCTIONS 5.17.13 Device comment data read COMRD_S_MD The comment of the specified device is read as ASCII code data. Function definition BOOL COMRD_S_MD (BOOL EN, ANY_SIMPLE S1, STRING (32) D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data from which comment will be read Comment read result (ASCII code data)

  • Page 153: Bin

    5 MELSEC FUNCTIONS 5.17.15 BIN character string conversion STR_S_MD The specified BIN 16-bit data is converted into a character string with a decimal point added in the specified position. Function definition BOOL STR_S_MD (BOOL EN, ANY32 S1, ANY16 S2, STRING(9) D); Argument Name IN/OUT Description...

  • Page 154: Character String 32-bit Bin Conversion

    5 MELSEC FUNCTIONS 5.17.17 Character string BIN conversion VAL_S_MD The specified character string is converted into BIN 16-bit data, and its number of digits and BIN 16-bit data are obtained. Function definition BOOL VAL_S_MD (BOOL EN, STRING (8) S1, ANY32 D1, ANY16 D2); Argument IN/OUT Description...

  • Page 155: Floating-point Character String Conversion

    5 MELSEC FUNCTIONS 5.17.19 Floating-point character string conversion ESTR_M The specified real number data is converted into a character string according to the specified display instruction. Function definition BOOL ESTR_M (BOOL EN, REAL S1, ANY16 (3) S2, STRING (24) D); Argument Name IN/OUT Description...

  • Page 156: Bin Ascii Conversion

    5 MELSEC FUNCTIONS 5.17.21 BIN ASCII conversion ASC_S_MD The specified BIN 16-bit data is converted into the hexadecimal ASCII data of the specified number of characters. Function definition BOOL ASC_S_MD (BOOL EN, ANY16 S1, ANY16 n, STRING D); Argument Name IN/OUT Description Execution condition (Function is executed only when the...

  • Page 157: Fetch From Character String Right Side

    5 MELSEC FUNCTIONS 5.17.23 Fetch from character string right side RIGHT_M n characters of data, starting at the right of the specified character string data (end of the character string), are acquired. Function definition BOOL RIGHT_M (BOOL EN, STRING S1, ANY16 n, STRING D); Argument Name IN/OUT Description...

  • Page 158: Any Data Fetch In Character String

    5 MELSEC FUNCTIONS 5.17.25 Any data fetch in character string MIDR_M S2[1] characters of data, starting at S2[0] of the specified character data, are acquired. Function definition BOOL MIDR_M (BOOL EN, STRING S1, ANY16(2) S2 , STRING D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is...

  • Page 159: Character String Search

    5 MELSEC FUNCTIONS 5.17.27 Character string search INSTR_M A searched for the specified character string data is performed, starting at the "n"th character from the left of the specified character string data. Function definition BOOL INSTR_M (BOOL EN, STRING S1, STRING S2, ANY16 n, ANY16 D); Argument Name IN/OUT Description...

  • Page 160: Bcd Format Data Floating-point

    5 MELSEC FUNCTIONS 5.17.29 BCD format data floating-point EREXP_M The specified BCD type floating-point format data is converted into real number data based on the specified fraction part digits. Function definition BOOL EREXP_M (BOOL EN, ANY16 S1, ANY16 S2, REAL D); Argument Name IN/OUT Description...

  • Page 161: Special Functions

    5 MELSEC FUNCTIONS 5.18 Special Functions 5.18.1 Floating-point SIN operation SIN_E_MD The SIN (sine) value of the specified angle is operated. Function definition BOOL SIN_E_MD (BOOL EN, REAL S1, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Angle data to be SIN (sine) operated (real number data) Remarks: Set the specified angle in radian unit (angle...

  • Page 162: Floating-point Tan Operation

    5 MELSEC FUNCTIONS 5.18.3 Floating-point TAN operation TAN_E_MD The TAN (tangent) value of the specified angle is operated. Function definition BOOL TAN_E_MD (BOOL EN, REAL S1, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Angle data to be TAN (tangent) operated (real number data) Remarks: Set the specified angle in radian unit (angle...

  • Page 163: Floating-point Cos Operation

    5 MELSEC FUNCTIONS 5.18.5 Floating-point COS operation ACOS_E_MD The COS (arccosine) operation of the specified COS value is performed. Function definition BOOL ACOS_E_MD (BOOL EN, REAL S1, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be operated, COS value (-1.0 to 1.0) (real number data) Operation result (angle data in radian unit) (real number data)

  • Page 164

    5 MELSEC FUNCTIONS 5.18.7 Floating-point angle radian RAD_E_MD The unit of magnitude of the specified angle is converted from the degree unit to the radian unit. Function definition BOOL RAD_E_MD (BOOL EN, REAL S1, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be converted, angle data in degree unit (real...

  • Page 165: Floating-point Square Root

    5 MELSEC FUNCTIONS 5.18.9 Floating-point square root SQR_E_MD The square root of the specified value is operated. Function definition BOOL SQR_E_MD (BOOL EN, REAL S1, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be operated (only positive value can be specified) (real number data) Operation result (real number data)

  • Page 166: Floating-point Natural Logarithm Operation

    5 MELSEC FUNCTIONS 5.18.11 Floating-point natural logarithm operation LOG_E_MD The base e logarithm (natural logarithm) of the specified value is operated. Function definition BOOL LOG_E_MD (BOOL EN, REAL S1, REAL D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be operated (only positive value can be specified) (real number data)

  • Page 167: Sequence Change

    5 MELSEC FUNCTIONS 5.18.13 Sequence change SRND_M The random number sequence is changed according to the specified 16-bit BIN data. Function definition BOOL SRND_M (BOOL EN, ANY16 S1); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Random number sequence change result (BIN 16-bit data)

  • Page 168: Bcd 8-digit Square Root

    5 MELSEC FUNCTIONS 5.18.15 BCD 8-digit square root BDSQR_MD The square root of the specified BCD 8-digit data is operated. Function definition BOOL BDSQR_MD (BOOL EN, ANY32 S1, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) BCD 8-digit data to be operated (BIN 32-bit data) Operation result (BIN 32-bit data)

  • Page 169: Bcd Type Cos Operation

    5 MELSEC FUNCTIONS 5.18.17 BCD type COS operation BCOS_MD The BCD 4-digit data of the specified angle is COS (cosine) operated. Function definition BOOL BCOS_MD (BOOL EN, ANY16 S1, ANY16(3) D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data to be operated (BCD 4-digit data) D [0] Sign (positive: 0, negative: 1)

  • Page 170: Bcd Type Sin Operation

    5 MELSEC FUNCTIONS 5.18.19 BCD type SIN operation BASIN_MD The SIN (arcsine) value of the specified BCD value is operated. Function definition BOOL BASIN_MD (BOOL EN, ANY16(3) S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S [0] Sign (positive: 0, negative: 1) Operation result...

  • Page 171: Bcd Type Tan Operation

    5 MELSEC FUNCTIONS 5.18.21 BCD type TAN operation BATAN_MD The TAN (arctangent) value of the specified BCD value is operated. Function definition BOOL BATAN_MD (BOOL EN, ANY16(3) S1, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Head number of S [0] Sign (positive: 0, negative: 1)

  • Page 172: Data Control

    5 MELSEC FUNCTIONS 5.19 Data Control 5.19.1 Upper/lower limit control LIMIT_MD The output value is controlled depending on whether the specified BIN 16-bit data is within the upper/lower limit value range or not. Function definition BOOL LIMIT_MD (BOOL EN, ANY16 S1, ANY16 S2, ANY16 S3, ANY16 D); Argument Name IN/OUT Description...

  • Page 173: 32-bit Data Upper/lower Limit Control

    5 MELSEC FUNCTIONS 5.19.2 32-bit data upper/lower limit control DLIMIT_MD The output value is controlled depending on whether the specified BIN 32-bit data is within the upper/lower limit value range or not. Function definition BOOL DLIMIT_MD (BOOL EN, ANY32 S1, ANY32 S2, ANY32 S3, ANY32 D); Argument Name IN/OUT Description...

  • Page 174: Dead Band Control

    5 MELSEC FUNCTIONS 5.19.3 Dead band control BAND_MD The output value is controlled depending on whether the specified BIN 16-bit data is within the upper/lower limit range of the specified dead band or not. Function definition BOOL BAND_MD (BOOL EN, ANY16 S1, ANY16 S2, ANY16 S3, ANY16 D); Argument Name IN/OUT Description...

  • Page 175: 32-bit Data Dead Band Control

    5 MELSEC FUNCTIONS 5.19.4 32-bit data dead band control DBAND_MD The output value is controlled depending on whether the specified BIN 32-bit data is within the upper/lower limit range of the specified dead band or not. Function definition BOOL DBAND_MD (BOOL EN, ANY32 S1, ANY32 S2, ANY32 S3, ANY32 D); Argument Name IN/OUT Description...

  • Page 176: Bit Zone Control

    5 MELSEC FUNCTIONS 5.19.5 Bit zone control ZONE_MD The output value is zone-controlled with a bias value added to the specified BIN 16-bit data. Function definition BOOL ZONE_MD (BOOL EN, ANY16 S1, ANY16 S2, ANY16 S3, ANY16 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the...

  • Page 177: 32-bit Data Bit Zone Control

    5 MELSEC FUNCTIONS 5.19.6 32-bit data bit zone control DZONE_MD The output value is zone-controlled with a bias value added to the specified BIN 32-bit data. Function definition BOOL DZONE_MD (BOOL EN, ANY32 S1, ANY32 S2, ANY32 S3, ANY32 D); Argument Name IN/OUT Description...

  • Page 178: File Register Block No. Switching

    5 MELSEC FUNCTIONS 5.19.7 File register block No. switching RSET_MD The block No. of the file registers used in a program is changed into the specified block No. Function definition BOOL RSET_MD (BOOL EN, ANY16 S1); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) New block No.

  • Page 179: Set Of Comment File

    5 MELSEC FUNCTIONS 5.19.9 Set of comment file QCDSET_M The file name of the comment file used in a program is changed into the specified file name. Function definition BOOL QDRSET_M (BOOL EN, STRING S1); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) "Drive No.: File name"...

  • Page 180: Clock

    5 MELSEC FUNCTIONS 5.20 Clock 5.20.1 Read of clock data DATERD_MD The "year, month, day, hour, minute, second, day of week" is read from the clock element of the QCPU/LCPU. They are stored into the specified destination as BIN values. Function definition BOOL DATERD_MD (BOOL EN, ANY16(7) S);...

  • Page 181: Write Of Clock Data

    5 MELSEC FUNCTIONS 5.20.2 Write of clock data DATEWR_MD The clock data "year, month, day, hour, minute, second, day of week" are written to the clock element of the QCPU/LCPU. Function definition BOOL DATEWR_MD (BOOL EN, ANY16(7) S); Argument Name IN/OUT Description Execution condition (Function is executed only when the...

  • Page 182: Addition Of Clock Data

    5 MELSEC FUNCTIONS 5.20.3 Addition of clock data DATEPLUS_M The specified time data is added to the specified time-of-day data. Function definition BOOL DATEPLUS_M (BOOL EN, ANY16(3) S1, ANY16(3) S2, ANY16(3) D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S1 [0] Hour (0 to 23) Time-of-day data to...

  • Page 183: Subtraction Of Clock Data

    5 MELSEC FUNCTIONS 5.20.4 Subtraction of clock data DATEMINUS_M The specified time data is subtracted from the specified time-of-day data. Function definition BOOL DATEMINUS_M (BOOL EN, ANY16(3) S1, ANY16(3) S2, ANY16(3) D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Time-of-day data from S1 [0] Hour (0 to 23)

  • Page 184: Clock Data Format Conversion (hour, Minute, Second Second)

    5 MELSEC FUNCTIONS 5.20.5 Clock data format conversion (hour, minute, second second) SECOND_M The specified time data is converted into second. Function definition BOOL SECOND_M (BOOL EN, ANY16(3) S, ANY32 D); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S [0] Hour (0 to 23)

  • Page 185: Program Control

    5 MELSEC FUNCTIONS 5.21 Program Control 5.21.1 Program standby PSTOP_M The program of the specified file name is put in a standby status. Function definition BOOL PSTOP_M (BOOL EN, STRING S1); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) File name of program to be put in standby status (character string data)

  • Page 186: Program Scan Execution Registration

    5 MELSEC FUNCTIONS 5.21.3 Program scan execution registration PSCAN_M The program of the specified file name is put in a scan execution status. Function definition BOOL PSCAN_M (BOOL EN, STRING S1); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) File name of program to be put in scan execution status (character string data)

  • Page 187: Others

    5 MELSEC FUNCTIONS 5.22 Others 5.22.1 WDT reset WDT_M The watchdog timer is reset in a sequence program. Function definition BOOL WDT _M (BOOL EN); Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Return Value Description BOOL...

  • Page 188: Iec Functions

    6 IEC FUNCTIONS 6 IEC FUNCTIONS How the functions are described This manual describes the function definitions, arguments, return values and using examples of the IEC functions. The IEC functions are created by combining the MELSEC common instructions. For the applicable devices of the IEC functions, the errors that may occur during execution of the functions, and the applicable CPU types, refer to the "MELSEC-Q/L Programming Manual (Common Instructions)".

  • Page 189

    6 IEC FUNCTIONS The following indicates the correspondences between the MELSEC instruction in the "MELSEC-Q/L Programming Manual (Common Instructions)" and the IEC function in this manual. MELSEC-Q/L Programming Manual (Common Instructions) [MELSEC instruction] 6.3.3 Conversion from BIN 16 and 32-bit data to floating decimal point (Single precision) (FLT(P),DFLT(P)) Ver.

  • Page 190: Type Conversion Functions

    6 IEC FUNCTIONS 6.1 Type Conversion Functions 6.1.1 Boolean type (BOOL) double precision integer type (DINT) conversion BOOL_TO_DINT BOOL_TO_DINT_E The specified Boolean type (BOOL) data is converted into double precision integer type (DINT) data. Function definition DINT BOOL_TO_DINT( BOOL S1 ); Argument Argument Name IN/OUT...

  • Page 191

    6 IEC FUNCTIONS 6.1.2 Boolean type (BOOL) integer type (INT) conversion BOOL_TO_INT BOOL_TO_INT_E Boolean type (BOOL) data is converted into integer type (INT) data. Function definition INT BOOL_TO_INT ( BOOL S1 ); Argument Argument Name IN/OUT Description Data to be converted (bit data) Return value Return Value Description...

  • Page 192

    6 IEC FUNCTIONS 6.1.3 Boolean type (BOOL) character string type (STRING) conversion BOOL_TO_STR BOOL_TO_STR_E Boolean type (BOOL) data is converted into character string type (STRING) data. Function definition STRING(2) BOOL_TO_STR ( BOOL S1 ); Argument Argument Name IN/OUT Description Data to be converted (bit data) Return value Return Value Description...

  • Page 193: Double Precision Integer Type (dint) Boolean Type (bool) Conversion

    6 IEC FUNCTIONS 6.1.4 Double precision integer type (DINT) Boolean type (BOOL) conversion DINT_TO_BOOL DINT_TO_BOOL_E Double precision integer type (DINT) data is converted into Boolean type (BOOL) data. Function definition BOOL DINT_TO_BOOL ( DINT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 32-bit data) Return value...

  • Page 194

    6 IEC FUNCTIONS 6.1.5 Double precision integer type (DINT) integer type (INT) conversion DINT_TO_INT DINT_TO_INT_E Double precision integer type (DINT) data is converted into integer type (INT) data. Function definition INT DINT_TO_INT ( DINT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 32-bit data) Return value...

  • Page 195: Double Precision Integer Type (dint) Real Number Type (real) Conversion

    6 IEC FUNCTIONS 6.1.6 Double precision integer type (DINT) real number type (REAL) conversion DINT_TO_REAL DINT_TO_REAL_E Double precision integer type (DINT) data is converted into real number type (REAL) data. Function definition REAL DINT_TO_REAL ( DINT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 32-bit data)

  • Page 196: Double Precision Integer Type (dint) Character String Type

    6 IEC FUNCTIONS 6.1.7 Double precision integer type (DINT) character string type (STRING) conversion DINT_TO_STR DINT_TO_STR_E Double precision integer type (DINT) data is converted into character string type (STRING) data. Function definition STRING(12) DINT_TO_STR ( DINT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 32-bit data)

  • Page 197

    6 IEC FUNCTIONS 6.1.8 Integer type (INT) Boolean type (BOOL) conversion INT_TO_BOOL INT_TO_BOOL_E Integer type (INT) data is converted into Boolean type (BOOL) data. Function definition BOOL INT_TO_BOOL ( INT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 16-bit data) Return value Return Value Description...

  • Page 198

    6 IEC FUNCTIONS 6.1.9 Integer type (INT) double precision integer type (DINT) conversion INT_TO_DINT INT_TO_DINT_E Integer type (INT) data is converted into double precision integer type (DINT) data. Function definition DINT INT_TO_DINT ( INT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 16-bit data) Return value...

  • Page 199: Integer Type (int) Real Number Type (real) Conversion

    6 IEC FUNCTIONS 6.1.10 Integer type (INT) real number type (REAL) conversion INT_TO_REAL INT_TO_REAL_E Integer type (INT) data is converted into real number type (REAL) data. Function definition REAL INT_TO_REAL ( INT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 16-bit data) Return value Return Value Description...

  • Page 200: Integer Type (int) Character String Type (string) Conversion

    6 IEC FUNCTIONS 6.1.11 Integer type (INT) character string type (STRING) conversion INT_TO_STR INT_TO_STR_E Integer type (INT) data is converted into character string type (STRING) data. Function definition STRING(8) INT_TO_STR ( INT S1 ); Argument Argument Name IN/OUT Description Data to be converted (BIN 16-bit data) Return value Return Value Description...

  • Page 201: Real Number Type (real) Double Precision Integer Type (dint) Conversion

    6 IEC FUNCTIONS 6.1.12 Real number type (REAL) double precision integer type (DINT) conversion REAL_TO_DINT REAL_TO_DINT_E The specified real number type (REAL) data is converted into double precision integer type (DINT) data. Function definition DINT REAL_TO_DINT( REAL S1 ); Argument Argument Name IN/OUT Description...

  • Page 202: Real Number Type (real) Integer Type (int) Conversion

    6 IEC FUNCTIONS 6.1.13 Real number type (REAL) integer type (INT) conversion REAL_TO_INT REAL_TO_INT_E Real number type (REAL) data is converted into integer type (INT) data. Function definition INT REAL_TO_INT ( REAL S1 ); Argument Argument Name IN/OUT Description Data to be converted (real number data) Return value Return Value Description...

  • Page 203: Real Number Type (real) Character String Type (string) Conversion

    6 IEC FUNCTIONS 6.1.14 Real number type (REAL) character string type (STRING) conversion REAL_TO_STR REAL_TO_STR_E Real number type (REAL) data is converted into character string type data. Function definition STRING(14) REAL_TO_STR ( REAL S1); Argument Argument Name IN/OUT Description Data to be converted (real number data) Return value Return Value Description...

  • Page 204: Character String Type (string) Boolean Type (bool) Conversion

    6 IEC FUNCTIONS 6.1.15 Character string type (STRING) Boolean type (BOOL) conversion STR_TO_BOOL STR_TO_BOOL_E Character string type (STRING) data is converted into Boolean type (BOOL) data. Function definition BOOL STR_TO_BOOL ( STRING(2) S1 ); Argument Argument Name IN/OUT Description Data to be converted (character string data) Return value Return Value Description...

  • Page 205: Character String Type (string) Double Precision Integer Type (dint) Conversion

    6 IEC FUNCTIONS 6.1.16 Character string type (STRING) double precision integer type (DINT) conversion STR_TO_DINT STR_TO_DINT_E Character string type (STRING) data is converted into double precision integer type (DINT) data. Function definition DINT STR_TO_DINT ( STRING(12) S1 ); Argument Argument Name IN/OUT Description Data to be converted (character string data)

  • Page 206: Character String Type (string) Integer Type (int) Conversion

    6 IEC FUNCTIONS 6.1.17 Character string type (STRING) integer type (INT) conversion STR_TO_INT STR_TO_INT_E Character string type (STRING) data is converted into integer type (INT) data. Function definition INT STR_TO_INT ( STRING(6) S1 ); Argument Argument Name IN/OUT Description Data to be converted (character string data) Return value Return Value Description...

  • Page 207: Character String Type (string) Real Number Type

    6 IEC FUNCTIONS 6.1.18 Character string type (STRING) real number type (REAL) conversion STR_TO_REAL STR_TO_REAL_E Character string type (STRING) data is converted into real number type (REAL) data. Function definition REAL STR_TO_REAL ( STRING(24) S1 ); Argument Argument Name IN/OUT Description Data to be converted (character string data) Return value...

  • Page 208: Numerical Functions (general Functions)

    6 IEC FUNCTIONS 6.2 Numerical Functions (General Functions) 6.2.1 Absolute value ABS_E The absolute value of the specified data is operated. Function definition ANY_NUM ABS ( ANY_NUM S1 ); Argument Argument Name IN/OUT Description Data whose absolute value will be found Return value Return Value Description...

  • Page 209: Square Root

    6 IEC FUNCTIONS 6.2.2 Square root SQRT SQRT_E The square root of the specified data is operated. Function definition REAL SQRT ( REAL S1 ); Argument Argument Name IN/OUT Description Data whose square root will be found Return value Return Value Description REAL Square root operation result (real number data)

  • Page 210: Numeric Functions (logarithm Functions)

    6 IEC FUNCTIONS 6.3 Numeric Functions (Logarithm Functions) 6.3.1 Natural logarithm LN_E The natural logarithm of the specified data is operated. Function definition REAL LN( REAL S1 ); Argument Argument Name IN/OUT Description Data whose natural logarithm will be found (real number data) Return value Return Value Description...

  • Page 211: Natural Exponent

    6 IEC FUNCTIONS 6.3.2 Natural exponent EXP_E The natural exponent of the specified data is operated. Function definition REAL EXP( REAL S1 ); Argument Argument Name IN/OUT Description Data whose natural exponent will be found (real number data) Return value Return Value Description REAL...

  • Page 212: Numerical Functions (trigonometric Functions)

    6 IEC FUNCTIONS 6.4 Numerical Functions (Trigonometric Functions) 6.4.1 Floating-point SIN operation SIN_E The SIN (sine) value of the specified angle is operated. Function definition REAL SIN( REAL S1 ); Argument Argument Name IN/OUT Description Angle data to be SIN (sine) operated (real number data) Remarks: Set the specified angle in radian unit (angle / 180).

  • Page 213: Floating-point Cos Operation

    6 IEC FUNCTIONS 6.4.2 Floating-point COS operation COS_E The COS (cosine) value of the specified angle is operated. Function definition REAL COS( REAL S1 ); Argument Argument Name IN/OUT Description Angle data to be COS (cosine) operated (real number data) Remarks: Set the specified angle in radian unit (angle / 180).

  • Page 214: Floating-point Tan Operation

    6 IEC FUNCTIONS 6.4.3 Floating-point TAN operation TAN_E The TAN (tangent) value of the specified angle is operated. Function definition REAL TAN( REAL S1 ); Argument Argument Name IN/OUT Description Angle data to be TAN (tangent) operated (real number data) Remarks: Set the specified angle in radian unit (angle / 180).

  • Page 215: Floating-point Sin Operation

    6 IEC FUNCTIONS 6.4.4 Floating-point SIN operation ASIN ASIN_E The SIN (arcsine) of the specified SIN value is operated. Function definition REAL ASIN( REAL S1 ); Argument Argument Name IN/OUT Description SIN value to be SIN (arcsine) operated (-1.0 to 1.0) (real number data) Return value Return Value Description...

  • Page 216: Floating-point Cos Operation

    6 IEC FUNCTIONS 6.4.5 Floating-point COS operation ACOS ACOS_E The COS (arccosine) of the specified COS value is operated. Function definition REAL ACOS( REAL S1 ); Argument Argument Name IN/OUT Description COS value to be COS (arccosine) operated (-1.0 to 1.0) (real number data) Return value Return Value...

  • Page 217: Floating-point Tan Operation

    6 IEC FUNCTIONS 6.4.6 Floating-point TAN operation ATAN ATAN_E The TAN (arctangent) of the specified TAN value is operated. Function definition REAL ATAN( REAL S1 ); Argument Argument Name IN/OUT Description TAN value to be TAN (arctangent) operated (real number data) Return value Return Value Description...

  • Page 218: Arithmetic Operation Functions

    6 IEC FUNCTIONS 6.5 Arithmetic Operation Functions 6.5.1 Addition ADD_E The specified multiple data are added. Function definition BOOL ADD_E( BOOL EN, ANY_NUM S1, ANY_NUM S2,..,ANY_NUM Sn, ANY_NUM D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S1 to Sn Data to be added Addition operation result...

  • Page 219: Multiplication

    6 IEC FUNCTIONS 6.5.2 Multiplication MUL_E The specified multiple data are multiplied. Function definition BOOL MUL_E( BOOL EN, ANY_NUM S1, ANY_NUM S2,..,ANY_NUM Sn, ANY_NUM D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S1 to Sn Data to be multiplied Multiplication operation result...

  • Page 220: Subtraction

    6 IEC FUNCTIONS 6.5.3 Subtraction SUB_E Subtraction is performed between the specified data. Function definition BOOL SUB_E( BOOL EN, ANY_NUM S1, ANY_NUM S2, ANY_NUM D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Minuend data Subtrahend data Subtraction operation result...

  • Page 221: Division

    6 IEC FUNCTIONS 6.5.4 Division DIV_E Division is performed between the specified data. Function definition BOOL DIV_E( BOOL EN, ANY_NUM S1, ANY_NUM S2, ANY_NUM D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Dividend data Divisor data Division operation result...

  • Page 222: Modulus Operation

    6 IEC FUNCTIONS 6.5.5 Modulus operation MOD_E Division is performed between the specified data, and its remainder is operated. Function definition BOOL MOD_E( BOOL EN, ANY_INT S1, ANY_INT S2, ANY_INT D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Dividend data Divisor data Modulus operation result...

  • Page 223: Natural Exponential

    6 IEC FUNCTIONS 6.5.6 Natural exponential EXPT EXPT_E Natural exponential is operated from the specified data used as a base and data used as an exponent. Function definition REAL EXPT ( REAL S1, ANY_NUM S2 ); Argument Argument Name IN/OUT Description Data used as base Data used as exponent...

  • Page 224

    6 IEC FUNCTIONS Function definition BOOL EXPT_E( BOOL EN, REAL S1, ANY_NUM S2, REAL D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Data used as base Data used as exponent Operation result Remarks: The operation result is the angle data in radian unit.

  • Page 225: Assignment

    6 IEC FUNCTIONS 6.5.7 Assignment MOVE MOVE_E The specified data is assigned to the specified storage destination. Function definition ANY MOVE ( ANY S1 ); Argument Argument Name IN/OUT Description Data to be assigned Return value Return Value Description Assignment result data Example of use Argument Type ST Program...

  • Page 226: Bit Shift Functions

    6 IEC FUNCTIONS 6.6 Bit Shift Functions 6.6.1 Bit left shift SHL_E The specified data is shifted n bits to the left. Function definition ANY_BIT SHL ( ANY_BIT S1, ANY_BIT n ); Argument Argument Name IN/OUT Description Data to be shifted Number of bits to be shifted Remarks: Only a constant can be specified as the number of bits to be shifted.

  • Page 227: Bit Right Shift

    6 IEC FUNCTIONS 6.6.2 Bit right shift SHR_E The specified data is shifted n bits to the right. Function definition ANY_BIT SHR ( ANY_BIT S1, ANY_BIT n ); Argument Argument Name IN/OUT Description Data to be shifted Number of bits to be shifted Remarks: Only a constant can be specified as the number of bits to be shifted.

  • Page 228: Right Rotation

    6 IEC FUNCTIONS 6.6.3 Right rotation ROR_E Data is rotated n bits to the right in a circle. Function definition ANY_BIT ROR ( ANY_BIT S1, ANY_BIT n ); Argument Argument Name IN/OUT Description Data to be rotated Number of bits to be rotated Remarks: Only a constant can be specified as the number of bits to be rotated.

  • Page 229: Left Rotation

    6 IEC FUNCTIONS 6.6.4 Left rotation ROL_E Data is rotated n bits to the left in a circle. Function definition ANY_BIT ROL ( ANY_BIT S1, ANY_BIT n ); Argument Argument Name IN/OUT Description Data to be rotated Number of bits to be rotated Remarks: Only a constant can be specified as the number of bits to be rotated.

  • Page 230: Bit Type Boolean Functions

    6 IEC FUNCTIONS 6.7 Bit Type Boolean Functions 6.7.1 Logical product AND_E The logical product of the specified multiple data is operated. Function definition BOOL AND_E( BOOL EN, ANY_BIT S1, ANY_BIT S2,…., ANY_BIT Sn, ANY_BIT D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE)

  • Page 231: Logical Sum

    6 IEC FUNCTIONS 6.7.2 Logical sum OR_E The logical sum of the specified multiple data is operated. Function definition BOOL OR_E( BOOL EN, ANY_BIT S1, ANY_BIT S2,…., ANY_BIT Sn, ANY_BIT D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S1 to Sn Data to be ORed OR operation result...

  • Page 232: Exclusive Logical Sum

    6 IEC FUNCTIONS 6.7.3 Exclusive logical sum XOR_E The exclusive logical sum of the specified multiple data is operated. Function definition BOOL XOR_E( BOOL EN, ANY_BIT S1, ANY_BIT S2,…., ANY_BIT Sn, ANY_BIT D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S1 to Sn Data to be EXCLUSIVE ORed EXCLUSIVE OR operation result...

  • Page 233: Logical Not

    6 IEC FUNCTIONS 6.7.4 Logical NOT NOT_E The logical NOT of the specified data is operated. Function definition ANY_BIT NOT( ANY_BIT S1 ); Argument Argument Name IN/OUT Description Data to be logical NOT operated Return value Return Value Description ANY_BIT Logical NOT operation result Remarks: Example of use...

  • Page 234: Selection Functions

    6 IEC FUNCTIONS 6.8 Selection Functions 6.8.1 Binary selection SEL_E One data is selected from among the specified two data according to the selection condition. Function definition ANY SEL( BOOL S1, ANY S2, ANY S3 ); Argument Argument Name IN/OUT Description Selection condition Data to be selected when S1 is FALSE...

  • Page 235

    6 IEC FUNCTIONS Function definition BOOL SEL_E( BOOL EN, BOOL S1, ANY S2, ANY S3, ANY D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Selection condition Data to be selected when S1 is FALSE Data to be selected when S1 is TRUE Selection result When S1 is FALSE ..

  • Page 236: Maximum Value

    6 IEC FUNCTIONS 6.8.2 Maximum value MAX_E The specified data are searched for the maximum value. Function definition ANY_SIMPLE MAX( ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn ); Argument Argument Name IN/OUT Description S1 to Sn Search target data Return value Return Value Description ANY_SIMPLE...

  • Page 237

    6 IEC FUNCTIONS Function definition BOOL MAX_E( BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn, ANY_SIMPLE D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S1 to Sn Search target data Search result Return value Return Value...

  • Page 238: Minimum Value

    6 IEC FUNCTIONS 6.8.3 Minimum value MIN_E The specified data are searched for the minimum value. Function definition ANY_SIMPLE MIN( ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn ); Argument Argument Name IN/OUT Description S1 to Sn Search target data Return value Return Value Description ANY_SIMPLE...

  • Page 239

    6 IEC FUNCTIONS Function definition BOOL MIN_E (BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2, ANY_SIMPLE S2,…., ANY_SIMPLE Sn, ANY_SIMPLE D1); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) S1 to Sn Search target data Search result Return value Return Value...

  • Page 240: Limiter

    6 IEC FUNCTIONS 6.8.4 Limiter LIMIT LIMIT_E The output value is controlled depending on whether the specified data is within the upper/lower limit value (minimum/maximum output limit value) range or not. Function definition ANY_SIMPLE LIMIT( ANY_SIMPLE MIN, ANY_SIMPLE S1, ANY_SIMPLE MAX ); Argument Argument Name IN/OUT...

  • Page 241

    6 IEC FUNCTIONS Function definition BOOL LIMIT_E( BOOL EN, ANY_SIMPLE MIN, ANY_SIMPLE S1, ANY_SIMPLE MAX, ANY_SIMPLE D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Minimum output limit value Input value Maximum output limit value Output value When MIN (lower limit value) >...

  • Page 242: Multiplexer

    6 IEC FUNCTIONS 6.8.5 Multiplexer MUX_E One data is selected from among the specified data according to the specified selection condition. Function definition ANY MUX ( INT n, ANY S1, ANY S2,….,ANY Sn ); Argument Argument Name IN/OUT Description Selection condition S1 to Sn Selection target data Return value...

  • Page 243

    6 IEC FUNCTIONS Function definition BOOL MUX_E( BOOL EN, INT n, ANY S1, ANY S2,….,ANY Sn, ANY D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE) Selection condition S1 to Sn Selection target data Selection result When n = 1, D1 = S1...

  • Page 244: Comparison Functions

    6 IEC FUNCTIONS 6.9 Comparison Functions 6.9.1 Greater than right member ( > ) GT_E In all the specified data, whether the relationship of > (greater than) is satisfied or not is acquired. Function definition BOOL GT_E( BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn, BOOL D1 );...

  • Page 245

    6 IEC FUNCTIONS Argument Type ST Program Conversion Result Used Instruction BOOL GT_E( M0 , M100, M101, M100 LD,ANI,ANB,OUT, M102, M103, bBit1 ); AND,SET,RST M101 M101 M102 M102 M103 M8191 M8191 bBit1 M8191 bBit1 STRING GT_E( M0 , Str1, Str2 , Str3, LD$>...

  • Page 246: Greater Than Or Equal To Right Member ( >= )

    6 IEC FUNCTIONS 6.9.2 Greater than or equal to right member ( >= ) GE_E In all the specified data, whether the relationship of (greater than or equal to) is satisfied or not is acquired. Function definition BOOL GE_E( BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn, BOOL D1 );...

  • Page 247

    6 IEC FUNCTIONS Argument Type ST Program Conversion Result Used Instruction BOOL GE_E( M0 , M100, M101, M100 LD,ORI,ANB,OUT M102, M103, bBit1 ); AND,SET,ANI,RST M101 M101 M102 M102 M103 M8191 M8191 bBit1 M8191 bBit1 STRING GE_E( M0 , Str1, Str2 , Str3, LD$>= Str1 Str2 LD$>=, AND$>=,...

  • Page 248: Equal ( = )

    6 IEC FUNCTIONS 6.9.3 Equal ( = ) EQ_E In all the specified data, whether the relationship of = (equal) is satisfied or not is acquired. Function definition BOOL EQ_E( BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn, BOOL D1 ); Argument Argument Name IN/OUT...

  • Page 249

    6 IEC FUNCTIONS Argument Type ST Program Conversion Result Used Instruction BOOL b_result := EQ_E( b_select, LD,AND,LDI,ANI, X10, X11, X12, M20 ); ORB,ANB,SET,RST M8191 b_select M8191 b_select M8191 b_select b_result STRING b_result := EQ_E( b_select, LD$= s_ary1 s_ary2 LD$=,OUT,LD,AND, s_ary1, s_ary2, b_data1 ); SET,ANI,RST M8191 b_select...

  • Page 250: Less Than Or Equal To Right Member ( <= )

    6 IEC FUNCTIONS 6.9.4 Less than or equal to right member ( <= ) LE_E In all the specified data, whether the relationship of (less than or equal to) is satisfied or not is acquired. Function definition BOOL LE_E( BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn, BOOL D1 );...

  • Page 251

    6 IEC FUNCTIONS Argument Type ST Program Conversion Result Used Instruction DINT b_result := LE_E( b_select, LDD<= di_data1 di_data2 LDD<=, ANDD<=, di_data1, di_data2, di_data3, OUT,LD,AND,SET, ANDD<= di_data2 di_data3 b_data1 ); ANI,RST M8191 b_select M8191 b_data1 b_select M8191 b_data1 b_select b_result BOOL b_result := LE_E( b_select, LDI,OR,ANB,OUT,...

  • Page 252: Less Than Right Member ( < )

    6 IEC FUNCTIONS 6.9.5 Less than right member ( < ) LT_E In all the specified data, whether the relationship of < (less than) is satisfied or not is acquired. Function definition BOOL LT_E( BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2,…., ANY_SIMPLE Sn, BOOL D1 );...

  • Page 253

    6 IEC FUNCTIONS Argument Type ST Program Conversion Result Used Instruction DINT b_result := LT_E( b_select, LDD< di_data1 di_data2 LDD<, ANDD<,OUT, di_data1, di_data2, di_data3, ANDD< di_data2 di_data3 LD,AND,SET,ANI, b_data1 ); M8191 b_select M8191 b_data1 b_select M8191 b_data1 b_select b_result BOOL b_result := LT_E( b_select, LDI,AND,ANB,OUT, X10, X11, X12, M20 );...

  • Page 254: Unequal ( <> )

    6 IEC FUNCTIONS 6.9.6 Unequal ( <> ) NE_E In all the specified data, whether the relationship of (unequal) is satisfied or not is acquired. Function definition BOOL NE_E( BOOL EN, ANY_SIMPLE S1, ANY_SIMPLE S2, BOOL D1 ); Argument Argument Name IN/OUT Description Execution condition (Function is executed only when the result is TRUE)

  • Page 255

    6 IEC FUNCTIONS Argument Type ST Program Conversion Result Used Instruction BOOL b_result := NE_E( b_select, LD,ANI,LDI,AND, X10, X11, M20 ); ORB,OUT,SET,RST M8191 b_select M8191 b_select M8191 b_select b_result STRING b_result := NE_E( b_select, LD$<> s_ary1 s_ary2 LD$<>,OUT,LD,AND, s_ary1, s_ary2, b_data1 ); SET,ANI,RST M8191 b_select...

  • Page 256: Character String Functions

    6 IEC FUNCTIONS 6.10 Character String Functions 6.10.1 Character string length acquisition LEN_E The character string length of the specified character string data is acquired. Function definition INT LEN ( STRING S1 ); Argument Argument Name IN/OUT Description Data whose character string length will be acquired (character string data) Return value Return Value...

  • Page 257: Acquisition From Start Position Of Character String

    6 IEC FUNCTIONS 6.10.2 Acquisition from start position of character string LEFT LEFT_E The specified n characters of character string is acquired, starting at the left of the specified character string (head of the character string). Function definition STRING LEFT ( STRING S1, INT n ); Argument Argument Name IN/OUT...

  • Page 258: Acquisition From End Of Character String

    6 IEC FUNCTIONS 6.10.3 Acquisition from end of character string RIGHT RIGHT_E The specified n characters of character string is acquired, starting at the right of the specified character string (end of the character string). Function definition STRING RIGHT ( STRING S1, INT n ); Argument Argument Name IN/OUT...

  • Page 259: Acquisition From Specified Position Of Character String

    6 IEC FUNCTIONS 6.10.4 Acquisition from specified position of character string MID_E The specified n characters of character string data is acquired, starting at the specified position from the left of the specified character string (head of the character string). Function definition STRING MID( STRING S1, INT n, INT POS );...

  • Page 260: Concatenation Of Character Strings

    6 IEC FUNCTIONS 6.10.5 Concatenation of character strings CONCAT CONCAT_E All the specified character strings are concatenated. Function definition STRING CONCAT( STRING S1, STRING S2,….,STRING Sn ); Argument Argument Name IN/OUT Description S1 to Sn Data to be concatenated (character string data) Return value Return Value Description...

  • Page 261: Insertion Of Character String Into Specified Position

    6 IEC FUNCTIONS 6.10.6 Insertion of character string into specified position INSERT INSERT_E The character string data is inserted into the specified position and later of the specified character string data. Function definition STRING INSERT( STRING S1, STRING S2, INT POS ); Argument Argument Name IN/OUT...

  • Page 262: Deletion Of Character String From Specified Position

    6 IEC FUNCTIONS 6.10.7 Deletion of character string from specified position DELETE DELETE_E n characters of character string is deleted from the specified position and later of the specified character string. Function definition STRING DELETE( STRING S1, INT n, INT POS ); Argument Argument Name IN/OUT...

  • Page 263: Replacement Of Character String From Specified Position

    6 IEC FUNCTIONS 6.10.8 Replacement of character string from specified position REPLACE REPLACE_E n characters of character string data starting at the specified position of the specified character string data is replaced by the specified character string. Function definition STRING REPLACE( STRING S1, STRING S2, INT n, INT POS ); Argument Argument Name IN/OUT...

  • Page 264: Search For Character String From Specified Position

    6 IEC FUNCTIONS 6.10.9 Search for character string from specified position FIND FIND_E The specified character string is searched for the specified character string. Function definition INT FIND( STRING S1, STRING S2 ); Argument Argument Name IN/OUT Description Character string to be searched (character string data) Character string to be searched for (character string data) Return value Return Value...

  • Page 265

    7 ERROR LIST 7 ERROR LIST This chapter explains the errors that may occur during conversion of a created ST program. For the execution errors that may occur when the ST program is written to the CPU module, refer to the "MELSEC-Q/L Programming Manual (Common Instructions)", "QCPU User's Manual (Hardware Design, Maintenance and Inspection)"...

  • Page 266

    7 ERROR LIST Error Message Cause Corrective Action The description of the device is illegal. As illegal descriptions, there are the following examples. Description of a device is Correct the description of Example 1: D0.10 := TRUE; wrong. (C1014) the device. The bit No.

  • Page 267: Error List

    7 ERROR LIST Error Message Cause Corrective Action The unsupported data type was used, or the constant was described wrongly. As illegal descriptions, there are the following examples. The used data type is not Example 1: W_TMP := TIME#1100_0101; supported. Description of a constant is Example 2: W_TMP := T#0;...

  • Page 268

    7 ERROR LIST Error Message Cause Corrective Action Other than a constant was used in the argument for which a constant should be specified. There are the following program examples that will It is used except a constant result in an error. for the %d argument.

  • Page 269

    7 ERROR LIST Error Message Cause Corrective Action Describe ";" at the end of The statement is not ended by ";". the statement. '*1' missing. (C8006) Describe "END FOR" in the "END FOR" is not described in the FOR syntax. (END FOR FOR syntax.

  • Page 270

    7 ERROR LIST Error Message Cause Corrective Action The FB call argument does not match in type with the specified value or variable. There are the following examples that will result in the above error. Example 1: Input variable (word type): IN1 Diverted FB name: FB1 FB1(IN1 := TRUE);...

  • Page 271

    7 ERROR LIST Error Message Cause Corrective Action The same argument is used two or more times for an FB call. Input '*1' was multiply Do not use the same Example 1: I/O variable (bit type) : INOUT1 assigned. (C8016) argument more than once Diverted FB name: FB1 (Argument name enters *1.)

  • Page 272

    7 ERROR LIST Error Message Cause Corrective Action The element name of the structure is wrong or the variable name of the FB is wrong. Example 1: Structure element name: mem1 Diverted structure name: InsSDT1 Member '*1' of '*2' is InsSDT1.mem2 := 100;...

  • Page 273

    7 ERROR LIST Error Message Cause Corrective Action The variable to which a constant, input variable or other value cannot be assigned is specified in the location where the value is assigned. The variable which cannot Example 1: Label (constant type): cnt substitute a value for the *1 cnt := D10;...

  • Page 274

    7 ERROR LIST Error Message Cause Corrective Action The format type does not match in the control syntax. Example 1: Double word type: DwLBL FOR DwLBL := W1 TO W2 BY W3 DO W5 := W6; END_FOR; The data types of the repeat variable and last value expression/incremental expression do not match.

  • Page 275

    7 ERROR LIST Error Message Cause Corrective Action "DO" is not described in the FOR syntax. Describe "DO" in the FOR Example 1: FOR D1 := D2 TO D3 BY D4 syntax. Describe "UNTIL" in the The keyword '*1' is "UNTIL"...

  • Page 276

    7 ERROR LIST Error Message Cause Corrective Action There are too many nesting levels or conditions in the control syntax, or the program of the control syntax is too long. Example 1: IF D0 = 0 THEN IF D1 = 0 THEN •...

  • Page 277

    7 ERROR LIST Error Message Cause Corrective Action 0 is used as the divisor. Correct the portion where 0 Example 1: D0 := 10/0; Division by zero. (C9065) is used as the divisor. Example 2: D1 := W1/K0; Change the character When operation could not be performed by directly string function that resulted The return value of function...

  • Page 278

    7 ERROR LIST Error Message Cause Corrective Action An error is in a conversion Check the contents of the The program is correct in ST grammar but an error result. (F0028)"*1" list displayed in the error occurs due to device specifications, etc. (Illegal conversion result is message, and correct the Example 1: TS0 := TRUE;...

  • Page 279

    7 ERROR LIST Error Message Cause Corrective Action With the CONCAT(_E) Use different variables in The same variable is used in the argument and function, the argument and the argument and return return value of the CONCAT(_E) function. the same variable as a value of the CONCAT(_E) Example 1: Character string label: Str1 •...

  • Page 280

    7 ERROR LIST Error Message Cause Corrective Action A total of 1025 or more functions or operators are used in a single statement. When functions or Example 1: D0 := 1+1+1+1+ • • • +1+1; operators are used in a There is too much function 1025 or more operators "+"...

  • Page 281

    7 ERROR LIST Error Message Cause Corrective Action The illegal data type was used for the argument of the MELSEC function. Example 1: RST_M(M0, ddev1); The double word type was specified in the second argument of function RST_M. The illegal type is used at Example 2: DECO_M(M0, Real1, K8, Real2);...

  • Page 282: Appendices

    APPENDICES APPENDICES Appendix 1 Character Strings that cannot be Used as Labels and FB Names This section indicates the character strings that cannot be used as label and FB names during ST programming. The character strings used in the device names, instruction names or function names cannot be used as labels and FB names.

  • Page 283: Appendix 1 Character Strings That Cannot Be Used As Labels And Fb Names

    APPENDICES Character strings that cannot be used as labels and FB names T, TASK, THEN, TIME, TIME_OF_DAY, TIME_TO_STRING, TO, TOD, TOF, TON, TP, TR, TRAN, TRANA, TRANC, TRANCA, TRANCO, TRANCOC, TRANCOCJ, TRUNC_DINT (INT, SINT), TRANJ, TRANL, TRANO, TRANOA, TRANOC, TRANOCA, TRANOCJ, TRANOJ, TRANSITION, TRUE, TYPE U, UDINT, UDINT_TO_BOOL (BYTE, DINT, DWORD, INT, REAL, SINT, STRING, UINT, UNTIL, USINT, WORD), UINT, UINT_TO_BOOL (BYTE, DINT, DWORD, INT, REAL, SINT, STRING, UDINT, USINT, WORD), ULINT, UNTIL, USINT, USINT_TO_BOOL (BYTE, DINT, DWORD, INT, REAL, SINT, STRING,...

  • Page 284: Appendix 2 St Instruction Table For Gx Developer And Gx Works2

    APPENDICES Appendix 2 ST instruction table for GX Developer and GX Works2 Instructions that can be used in ST programs of GX Developer may not be able to be used in GX Works2. As a result, an error may occur when a project that includes an ST program and is saved in GX Works2 format is read and compiled with GX Developer.

  • Page 285

    APPENDICES GX Works2 GX Developer GX Works2 GX Developer GX Works2 GX Developer STOP STOP_M WAND WAND_M WXNR WXNR_M SUM_M WDT_M WXOR WXOR_M SWAP SWAP_MD WOR_M XCH_M TEST TEST_MD WSUM WSUM_M ZONE ZONE_MD UNI_M WTOB WTOB_MD App - 4 App - 4...

  • Page 286

    INDEX 32-bit data logical product (2 devices) 1-bit shift of device (SFT_M)......5- 8 (DAND_M)............5-40 1-word left shift (DSFL_M) ......5-55 32-bit data logical product (3 devices) 1-word right shift (DSFR_M) ......5-55 (DAND_3_M) ..........5-40 16-bit BIN 32-bit BIN conversion 32-bit data logical sum (2 devices) (DBL_M) ............

  • Page 287

    Acquisition from end of character string BCD format data floating-point (RIGHT(_E)) ..........6-71 (EREXP_M)............5-87 Acquisition from specified position of BCD type COS operation (BCOS_MD) ..5-96 character string (MID(_E)) ......6-72 BCD type COS-1 operation (BACOS_MD)...5-97 Acquisition from start position of BCD type SIN operation (BSIN_MD) ....5-95 character string (LEFT(_E)) ......

  • Page 288

    BOOL_TO_DINT(_E) (Boolean type (BOOL) BKCMP_EQ_M double precision integer type (Block data comparison (=))......5-10 (DINT) conversion) .........6- 3 BKCMP_GT_M BOOL_TO_INT(_E) (Boolean type (Block data comparison (>)......5-11 (BOOL) integer type (INT) conversion) ..6- 4 BKCMP_LE_M BOOL_TO_STR(_E) (Boolean type (Block data comparison (<=)) ....... 5-11 (BOOL) character string type BKCMP_LT_M (STRING) conversion) ........6- 5...

  • Page 289

    Character string length detection Data maximum value retrieval (MAX_M) ..5-65 (LEN_S_MD) ..........5-79 Data minimum value retrieval (MIN_M) ..5-66 Character string search (INSTR_M) ..... 5-86 Data search (SER_M) ........5-59 Character string type (STRING) Data sort S (SORT_M) ........5-67 Boolean type (BOOL) conversion DATEMINUS_M (STR_TO_BOOL(_E))........

  • Page 290

    DECO_M (Decode) ........5-61 DMAX_M Decode (DECO_M) ........5-61 (32-bit data maximum value retrieval)...5-66 Decrement (DEC_M) ........5-21 DMIN_M DEG_E_MD (32-bit data minimum value retrieval)....5-67 (Floating-point radian angle conversion).. 5-91 DNEG_M DELETE(_E) (Deletion of character (2' complement of 32-bit BIN)......5-30 string from specified position) .......

  • Page 291

    DXNR_M (32-bit data NOT Floating-point character string conversion exclusive OR (2 devices)) ......5-47 (ESTR_M) ............5-82 DXOR_3_M Floating-point COS operation (COS(_E)) ..6-26 (32-bit data exclusive OR (3 devices)) ..5-45 Floating-point COS-1 operation DXOR_M (ACOS_E_MD) ..........5-90 (32-bit data exclusive OR (2 devices)) ..5-45 Floating-point COS-1 operation DZONE_MD (ACOS(_E))............6-29...

  • Page 292

    Intelligent function module 1-word data write HABIN_S_MD (Hexadecimal ASCII (TO_M) ............5-72 conversion) ............ 5-77 Intelligent function module 2-word data read BIN conversion) ..5-83 HEX_S_MD (ASCII (DFRO_M)............5-71 Hexadecimal ASCII 32-bit BIN conversion Intelligent function module 2-word data write (DHABIN_S_MD) .......... 5-77 (DTO_M) ............5-72 Hexadecimal ASCII BIN conversion...

  • Page 293

    Maximum value (MAX(_E))......6-49 PLOW_M (Program low-speed execution MID(_E) (Acquisition from specified registration) ..........5-113 position of character string)......6-72 POFF_M MIDR_M (Program output OFF standby) ....5-112 (Any data fetch in character string)....5-85 Program low-speed execution registration MIDW_M (Any data replacement in (PLOW_M) ...........5-113 character string) ..........

  • Page 294

    RFS_M (I/O refresh)........5-38 Stop (STOP_M) ..........5- 9 Right rotation (ROR(_E)) ......6-41 STOP_M (Stop) ..........5- 9 Right rotation (carry flag included) STR_S_MD character string conversion) .....5-80 (RCR_M) ............5-49 (BIN Right rotation (carry flag not included) STR_TO_BOOL(_E) (ROR_M) ............5-49 (Character string type (STRING) RIGHT_M Boolean type (BOOL) conversion) ....6-17...

  • Page 295

    Total value calculation (WSUM_M) ....5-68 Unequal ( <> ) (NE_E) ........6-67 UNI_M (4-bit connection of 16-bit data) ..5-63 Upper/lower limit control (LIMIT_MD)... 5-99 VAL_S_MD (Character string BIN conversion).... 5-81 WAND_3_M (Logical product (3 devices))......5-39 WAND_M (Logical product (2 devices)) ..5-39 WDT reset (WDT_M) ........

  • Page 296

    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 298

    SH(NA)-080366E-J(1410)KWIX MODEL: QCPU-P-ST-E MODEL CODE: 13JF68 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.

This manual also for:

Melsec l series

Comments to this Manuals

Symbols: 0
Latest comments: