Mitsubishi MELSEC-Q Series Programming Manual
Mitsubishi MELSEC-Q Series Programming Manual

Mitsubishi MELSEC-Q Series Programming Manual

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

Advertisement

QCPU
Structured Programming Manual
(Common Instructions)
Mitsubishi
Programmable Controller

Advertisement

Table of Contents
loading

Summary of Contents for Mitsubishi MELSEC-Q Series

  • Page 1 QCPU Structured Programming Manual (Common Instructions) Mitsubishi Programmable Controller...
  • Page 3: Safety Precautions

    SAFETY PRECAUTIONS (Always read these instructions before using this product.) Before using the MELSEC-Q series programmable controller, 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: Revisions

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

    INTRODUCTION Thank you for purchasing the Mitsubishi MELSEC-Q series programmable controller. Before using the product, thoroughly read this manual to develop full familiarity with the programming specifications to ensure correct use. Please forward this manual to the end user. CONTENTS SAFETY PRECAUTIONS ..........................A - 1...
  • Page 6 2.5.9 Display instructions........................2 - 27 2.5.10 Debug/error diagnostics instructions ................... 2 - 27 2.5.11 String processing instructions...................... 2 - 28 2.5.12 Special function instructions ......................2 - 31 2.5.13 Data control instructions ......................2 - 33 2.5.14 Switch instructions ........................2 - 34 2.5.15 Clock instructions.........................
  • Page 7 5. SEQUENCE INSTRUCTIONS 5 - 1 to 5 - 54 5.1 Contact Instructions 5 - 2 5.1.1 Operation start, series connection, parallel connection ..............5 - 2 5.1.2 Pulse operation start, pulse series connection, pulse parallel connection........5 - 4 5.2 Bond Instructions 5 - 6 5.2.1 Ladder block series connection and parallel connection ...............
  • Page 8 6.2.10 Floating-point data addition and subtraction (double precision) ..........6 - 45 6.2.11 Floating-point data multiplication and division (single precision) ..........6 - 48 6.2.12 Floating-point data multiplication and division (double precision)..........6 - 51 6.2.13 Block data addition and subtraction..................... 6 - 54 6.2.14 Character string data concatenation....................
  • Page 9 6.8.6 Ramp signal..........................6 - 166 6.8.7 Pulse density measurement ...................... 6 - 169 6.8.8 Fixed cycle pulse output ......................6 - 171 6.8.9 Pulse width modulation......................6 - 173 6.8.10 Matrix input ..........................6 - 175 7. APPLICATION INSTRUCTIONS 7 - 1 to 7 - 368 7.1 Logical Operation Instructions 7 - 2...
  • Page 10 7.7 Data Table Operation Instructions 7 - 113 7.7.1 Writing data to data table......................7 - 113 7.7.2 Reading oldest data from data table..................7 - 116 7.7.3 Reading newest data from data table ..................7 - 119 7.7.4 Deleting/inserting data from/to data table .................. 7 - 122 7.8 Buffer Memory Access Instructions 7 - 125 7.8.1 Reading 1-/2-word data from intelligent function module ............
  • Page 11 7.12.15Radian to degree conversion on floating-point data (single precision) ........7 - 258 7.12.16Radian to degree conversion on floating-point data (double precision)........7 - 260 7.12.17Square root operation on floating-point data (single precision) ..........7 - 262 7.12.18Square root operation on floating-point data (double precision) ..........7 - 264 7.12.19Exponential operation on floating-point data (single precision) ..........
  • Page 12 8. QCPU INSTRUCTIONS 8 - 1 to 8 - 68 8.1 Reading Module Information 8 - 2 8.2 Trace Set/Reset 8 - 6 8.3 Writing Data to Specified File 8 - 9 8.4 Reading Data from Specified File 8 - 20 8.5 Writing Data to Standard ROM 8 - 33 8.6 Reading Data from Standard ROM...
  • Page 13: Manuals

    MANUALS Related manuals are separately issued according to the purpose of their functions in GX Works2. Related manuals The manuals related to this product are shown below. Refer to the following tables when ordering required manuals. (1) Structured programming Manual number Manual name (Model code) QCPU Structured Programming Manual (Fundamentals)
  • Page 14 MEMO A-12...
  • Page 15: Overview

    OVERVIEW Purpose of This Manual ......... . 1-2 Generic Terms and Abbreviations in This Manual .
  • Page 16: Purpose Of This Manual

    Purpose of This Manual This manual explains the common instructions used for creating structured programs. Manuals for reference are listed in the following table according to their purpose. For information such as the contents and number of each manual, refer to the list of 'Related manuals'.
  • Page 17 (2) Programming User's Manual for intelligent function QCPU(Q mode)/QnACPU module/ QCPU Structured Programming Manual Programming Manual Reference Manual for network module Purpose Common Special Application Common PID Control − Fundamentals Instructions Instructions Functions Instructions Instructions Learning the types and details of common instructions, descriptions of...
  • Page 18: Generic Terms And Abbreviations In This Manual

    Generic Terms and Abbreviations in This Manual This manual uses the generic terms and abbreviations listed in the following table to discuss the software packages and programmable controller CPUs. Corresponding module models are also listed if needed. Generic term and Description abbreviation GX Works2...
  • Page 19: Instruction Tables

    INSTRUCTION TABLES Types of Instructions..........2-2 How to Read Instruction Tables .
  • Page 20: Types Of Instructions

    Types of Instructions Instructions for CPU modules are classified into sequence instructions, basic instructions, and application instructions. Table 2.1 shows the types of instructions. Table 2.1 Types of instructions Type of instruction Description Reference Contact instruction Operation start, series connection, parallel connection Bond instruction Ladder block connection, operation result pulse, operation result store/read Output instruction...
  • Page 21: How To Read Instruction Tables

    How to Read Instruction Tables Instruction tables in Sections 2.3 to 2.6 are summarized in the following form. Table 2.2 How to read Instruction tables Executing Category Instruction name Argument Processing details Page condition Execution Category Function name Argument Processing details Page condition 16-bit data...
  • Page 22 5) Details of executing conditions of each instruction are as follows: Symbol Executing condition Indicates a non-conditional executing instruction that is always executed disregarding the ON/OFF status of No symbol the precondition of the instruction. When the precondition is OFF, the instruction performs ‘OFF’ processing. Indicates an 'executed while ON' type instruction that is executed only while the precondition is ON.
  • Page 23: Sequence Instructions

    Sequence Instructions 2.3.1 Contact instructions Table 2.3 Contact instructions Executing Category Instruction name Argument Processing details Page condition • Starts a logical operation. − (Starts a logical operation with normally open contact) • Starts a logical NOT operation. − (Starts a logical operation with normally closed contact) •...
  • Page 24: Bond Instructions

    2.3.2 Bond instructions Table 2.4 Bond instructions Executing Category Instruction name Argument Processing details Page condition • Performs a logical AND operation between − logical blocks (Series connection between logical blocks) • Performs a logical OR operation between − logical blocks (Parallel connection between logical blocks) •...
  • Page 25: Shift Instructions

    2.3.4 Shift instructions Table 2.6 Shift instructions Executing Category Instruction name Argument Processing details Page condition • 1-bit shift of a device 5-44 Shift 2.3.5 Master control instructions Table 2.7 Master control instructions Executing Category Instruction name Argument Processing details Page condition •...
  • Page 26: Basic Instructions

    Basic instructions 2.4.1 Comparison operation instructions Table 2.10 Comparison operation instructions Executing Category Instruction name Argument Processing details Page condition • Conduction state when AND= • Non-conduction state when LD<> • Conduction state when AND<> • Non-conduction state when OR<> LD<= •...
  • Page 27: Basic Instructions

    Table 2.10 Comparison operation instructions (continued) Executing Category Instruction name Argument Processing details Page condition • Conduction state when LDD= ANDD= • Non-conduction state when ORD= • Conduction state when LDD<> ANDD<> • Non-conduction state when ORD<> • Conduction state when LDD<= ANDD<= •...
  • Page 28 Table 2.10 Comparison operation instructions (continued) Executing Category Instruction name Argument Processing details Page condition • Conduction state when LDED= ANDED= • Non-conduction state when ORED= • Conduction state when LDED<> ANDED<> • Non-conduction state when ORED<> • Conduction state when LDED<= ANDED<= •...
  • Page 29 Table 2.10 Comparison operation instructions (continued) Executing Category Instruction name Argument Processing details Page condition • Compares the character string of with LD$= the character string of character by character. AND$= • Conduction state when (Character string of )=(Character string of •...
  • Page 30 Table 2.10 Comparison operation instructions (continued) Executing Category Instruction name Argument Processing details Page condition BKCMP= , n, BKCMP<> , n, BKCMP<= , n, BKCMP< , n, BKCMP>= , n, • Compares the data n points from with BIN block BKCMP>...
  • Page 31: Arithmetic Operation Instructions

    2.4.2 Arithmetic operation instructions Table 2.11 Arithmetic operation instructions Executing Category Instruction name Argument Processing details Page condition 16-bit BIN • data addition 6-22 − • subtraction 32-bit BIN • ( data addition 6-24 • ( )−( subtraction 16-bit BIN •...
  • Page 32 Table 2.11 Arithmetic operation instructions (continued) Executing Category Instruction name Argument Processing details Page condition Floating- • ( point data addition and 6-42 subtraction • ( )−( (single precision) Floating- • ( point data addition and 6-45 subtraction • ( )−( (double precision)
  • Page 33: Data Conversion Instructions

    2.4.3 Data conversion instructions Table 2.12 Data conversion instructions Executing Category Instruction name Argument Processing details Page condition BCD conversion BCD data BIN (0 to 9999) 6-65 conversion BCD conversion DBCD ( +1, ) ( +1, ) BIN (0 to 99999999) BIN conversion BCD (0 to 9999) BIN data...
  • Page 34 Table 2.12 Data conversion instructions (continued) Executing Category Instruction name Argument Processing details Page condition Conversion to Gray code data BIN data to BIN (-32768 to 32767) Gray code 6-87 Conversion to Gray code data data ( +1, ) ( +1, ) conversion DGRY BIN (-2147483648 to...
  • Page 35: Data Transfer Instructions

    2.4.4 Data transfer instructions Table 2.13 Data transfer instructions Executing Category Instruction name Argument Processing details Page condition 16-bit data transfer 6-107 32-bit data DMOV ( +1, ) ( +1, ) transfer Floating- point data ( +1, ) ( +1, ) 6-110 transfer EMOV...
  • Page 36: Program Branch Instructions

    2.4.5 Program branch instructions Table 2.14 Program branch instructions Executing Category Instruction name Argument Processing details Page condition • Jumps to when the input condition is satisfied. 6-137 • Jumps to from the next scan after the Jump input condition is satisfied. •...
  • Page 37: Other Convenient Instructions

    2.4.8 Other convenient instructions Table 2.17 Other convenient instructions Executing Category Instruction name Argument Processing details Page condition Down UDCNT1 6-152 , n, Current Cn value 1 2 3 4 6 7 6 5 3 2 1 0 -1 -2 -3 -2 -1 0 Up/down Cn contact point counter...
  • Page 38: Application Instructions

    Application Instructions 2.5.1 Logical operation instructions Table 2.18 Logical operation instructions Executing Category Instruction name Argument Processing details Page condition WAND DAND ( +1, ) ( +1, ) ( +1, ) Logical BKAND , n, ( +1, ) ( +1, ) ( +1, ) Logical 7-12...
  • Page 39: Rotation Instructions

    2.5.2 Rotation instructions Table 2.19 Rotation instructions Executing Category Instruction name Argument Processing details Page condition SM700 Rotates n bits to the right. Carry flag Right 7-27 rotation SM700 Rotates n bits to the right. Carry flag SM700 Carry flag Rotates n bits to the left.
  • Page 40: Shift Instructions

    2.5.3 Shift instructions Table 2.20 Shift instructions Executing Category Instruction name Argument Processing details Page condition Carry flag b0 SM700 0 to 0 7-41 n-bit shift Carry flag SM700 0 to 0 BSFR Carry flag SM700 7-44 1-bit shift BSFL Carry flag SM700 DSFR...
  • Page 41: Bit Processing Instructions

    2.5.4 Bit processing instructions Table 2.21 Bit processing instructions Executing Category Instruction name Argument Processing details Page condition BSET Bit set/ 7-50 reset BRST TEST Bit specified for 7-53 Bit test DTEST Bit specified for Bit device Reset 7-56 batch BKRST reset 2.5 Application Instructions...
  • Page 42: Data Processing Instructions

    2.5.5 Data processing instructions Table 2.22 Data processing instructions Executing Category Instruction name Argument Processing details Page condition , n, : Match number ( +1) : Number of matches Data search 7-58 32 bits DSER , n, : Match number ( +1) : Number of matches : Number of 1s...
  • Page 43 Table 2.22 Data processing instructions (continued) Executing Category Instruction name Argument Processing details Page condition • Searches the data n points from the device specified for in units of 16 bits , n, and stores the maximum value to the device specified for 7-85 •...
  • Page 44: Structured Instructions

    2.5.6 Structured instructions Table 2.23 Structured instructions Executing Category Instruction name Argument Processing details Page condition • Executes the operation n times within 7-100 − NEXT instruction loop. NEXT • Forcibly terminates the execution of the Repeat instruction loop and 7-103 BREAK NEXT...
  • Page 45: Buffer Memory Access Instructions

    2.5.8 Buffer memory access instructions Table 2.25 Buffer memory access instructions Executing Category Instruction name Argument Processing details Page condition • Reads data in units of 16 bits from the FROM n1, n2, n3, intelligent function module. 7-125 Data read •...
  • Page 46: String Processing Instructions

    2.5.11 String processing instructions Table 2.28 String processing instructions Executing Category Instruction name Argument Processing details Page condition • Converts 1 word of BIN data specified to 5 digits of decimal ASCII data BINDA BIN data and stores the result to the word device specified for decimal 7-151...
  • Page 47: Application Instructions

    Table 2.28 String processing instructions (continued) Executing Category Instruction name Argument Processing details Page condition • Stores the length (number of Character characters) of character string data 7-180 string length stored in the device specified for detection the device specified for •...
  • Page 48 Table 2.28 String processing instructions (continued) Executing Category Instruction name Argument Processing details Page condition • Stores n characters from the end of the character string data specified for RIGHT , n, the device specified for 7-212 • Stores n characters from the start of the LEFT character string data specified for , n,...
  • Page 49: Special Function Instructions

    2.5.12 Special function instructions Table 2.29 Special function instructions Executing Category Instruction name Argument Processing details Page condition 7-228 Sin ( +1, ) ( +1, ) 7-232 Cos ( +1, ) ( +1, ) Trigonometric functions 7-236 Tan ( +1, ) ( +1, ) (single- precision...
  • Page 50 Executing Category Instruction name Argument Processing details Page condition • Generates random numbers in the Random range from 0 to number less than 32767 number and stores it to the device specified for generation 7-277 • Updates the random number series Random according to the content of 16-bit BIN number...
  • Page 51: Data Control Instructions

    2.5.13 Data control instructions Table 2.30 Data control instructions Executing Category Instruction name Argument Processing details Page condition • When stores the value of • When LIMIT stores the value of • When stores the value of • When ( Upper/ stores the values of ( ) to...
  • Page 52: Switch Instructions

    2.5.14 Switch instructions Table 2.31 Switch instructions Executing Category Instruction name Argument Processing details Page condition • Changes the block number of the Block number RSET extension file register to the number 7-312 specified for switch • Sets the file name used as a file QDRSET 7-315 register.
  • Page 53: Program Control Instructions

    2.5.16 Program control instructions Table 2.33 Program control instructions Executing Category Instruction name Argument Processing details Page condition • Sets the specified program in the PSTOP 7-337 standby status. • Turns OFF the coil of the OUT POFF instruction of the specified program and 7-339 sets the program in the standby status.
  • Page 54: Other Instructions

    2.5.17 Other instructions Table 2.34 Other instructions Executing Category Instruction name Argument Processing details Page condition − WDT reset • Resets WDT in the sequence program. 7-347 n1 scans n2 scans Timing clock DUTY 7-349 n1, n2, SM420 to SM424, SM430 to SM434 •...
  • Page 55: Qcpu Instructions

    2.5.18 QCPU instructions Table 2.35 QCPU instructions Executing Category Instruction name Argument Processing details Page condition • Stores the module information of the number of points specified for (n2) from Module UNIRD n1, n2, information read the start I/O number specified for (n1) to and the following devices.
  • Page 56: Multiple Cpu High Speed Transmission Dedicated Instructions

    Executing Category Instruction name Argument Processing details Page condition • Reads devices from the CPU shared FROM memory of another station CPU module n1, n2, n3, Data read from to the host station. other CPU 8-61 • Reads devices from the CPU shared shared memory DFRO memory of another station CPU module to...
  • Page 57 CONFIGURATION OF INSTRUCTIONS Configuration of Instructions........3-2 Labels .
  • Page 58: Configuration Of Instructions

    Configuration of Instructions Most of the instructions available for CPU modules can be divided into an instruction name and arguments. The application of an instruction name and arguments are as follows: • Instruction name····· Indicates the function of the instruction. •...
  • Page 59 (3) Number of devices and number of transfers (n) (a) The number of devices and number of transfers used in an instruction that uses multiple devices are specified for n. Example: Block data transfer instruction BMOV Specifies the number of transfers used by a BMOV instruction (b) A value in the range of 0 to 32767 can be set for the number of devices and number of transfers.
  • Page 60: Labels

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

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

    Data Types Data types of labels include the elementary data types and the generic data types. Generic data type is the data type of labels covering some elementary data types. The data type name starts with 'ANY'. The following shows the list of elementary data types and generic data types. Table 3.3-1 Elementary data types Data type Description...
  • Page 63 Table 3.3-2 Generic data types ANY_SIMPLE Array Structure ANY_NUM ANY_BIT String Word (unsigned)/ ANY_REAL ANY_INT 16-bit string Word Single-precision Double word real (signed) (unsigned)/ The higher 'ANY' data types include sub-level data types. 32-bit string Double-precision Double word The highest 'ANY' data type includes all data types. real (signed) ANY16...
  • Page 64: Method For Specifying Data

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

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

    3.4.3 Double word (32 bits) data Double word data are 32-bit numeric value data used in basic instructions and application instructions. The following shows the two types of double word data that can be handled in CPU modules. • Decimal constants ....-2147483648 to 2147483647 •...
  • Page 68 (c) When the destination is a word device For the word device at the destination side, 0s are stored to bits starting from the digit specified at the source. (Data_s:K1X0, Data_d:D0) Ladder example Processing Instruction that processes 32-bit data K1X0 X3 X2 X1 X0 0s are stored DMOV...
  • Page 69 (2) Using word devices Devices used in lower 16 bits are specified for a word device. 'Specified device number' and 'specified device number +1' are used for instructions that process 32-bit data. Transfers 32-bit data DMOV Two points (32 bits) of D0 and D1 are the target word devices 3.4.4 Single-precision real/double-precision real data...
  • Page 70 (2) Double-precision real (double-precision floating-point data) Devices used in lower 16 bits are specified for instructions that use real number data. Real number data are stored in 64 bits of 'specified device number' and 'specified device number + 3'. Transfers real number data EDMOV Var_R100 Var_D0...
  • Page 71: 3.4.4 Single-Precision Real/Double-Precision Real Data

    1. Floating-point data in a CPU module can be monitored by the monitoring function of a peripheral. 2. To express 0 in floating-point data, set all of the following bits to 0. (a) Single-precision floating-point data: b0 to b31 (b) Double-precision floating-point data: b0 to b63 3.
  • Page 72: String Data

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

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

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

    Device and Address This section explains the method for expressing programmable controller CPU devices. The following two types of format are available. • Device: This format consists of a device name and a device number. • Address: A format defined in IEC61131-3. In this format, a device name starts with %. 3.5.1 Device Device is a format that uses a device name and a device...
  • Page 77 ● Data size Data size is a class indicating the size of data. The following shows the format rules corresponding to the device format. • Bit device : X (bit) • Word device : W (word), D (double word), L (long word) ●...
  • Page 78: En And Eno

    EN and ENO Instructions with EN allow control of instruction execution. An input variable EN inputs the condition for executing a instruction. An output variable ENO outputs execution status. The following table shows the status of ENO and the operation result according to the status of Table 3.6-1 Status of ENO and the operation result according to the status of EN Operation result TRUE (No operation error)
  • Page 79: Index Setting

    Index Setting (1) Overview of the index setting (a) The index setting is an indirect setting that uses index registers. When the index setting is used in a sequence program, the device consists of ‘directly specified device number’ + ‘content of index register’. For example, when D2Z2 is specified and the value of Z2 is 3, D(2+3)=D5 is set as the target.
  • Page 80 Remark There are no usage restrictions on index register numbers for current values of the timer and counter. OUT_T Set value of timer (Index setting is not applicable) SM400 TN0Z4 K4Y30 Current value of timer OUT_C CC100 Set value of counter (Index setting is not applicable) SM400 CN100Z6...
  • Page 81 (3) 32-bit index setting (for Universal model QCPU only) Either of the following two methods can be selected to specify index registers used for a 32- bit index setting. • Specify a range of index registers used for a 32-bit index setting. •...
  • Page 82 3) Devices that can be used for index settings Only the following devices can be used for index settings. Device Description Serial number access file register Extended data register Extended link register 4) Usage range of index registers The following table shows the usage range of index registers when setting indexes in 32-bit range.
  • Page 83 2) Specification method When specifying a 32-bit index setting using 'ZZ', select "Use ZZ" in the "Indexing Setting for ZR Device" setting of the PLC parameter in GX Works2. Figure 3.7-4 Index setting for ZR device on the parameter setting screen 3) Devices that can be used for the index setting Only the following devices can be used for the index setting.
  • Page 84 5) The following figure shows the examples of 32-bit index setting using 'ZZ' and their actual processing devices. Ladder example Actual processing device Description ZR1000Z0…ZR(1000+100000)=ZR101000 D30Z2    D(30-20)  D10 Figure 3.7-4 Ladder examples and actual processing devices 6) Functions that can use 'ZZ' 32-bit index settings using 'ZZ' can be used in the following functions of GX Works2.
  • Page 85 (4) Applying index settings to extended data registers (D) and extended link registers (W) (for Universal model QCPU) As an index setting can be applied to internal user devices, data registers (D) and link registers (W), the device specification by the index setting can be used within the range of extended data registers (D) and extended link registers (W).
  • Page 86 2) Index settings that cross file registers (ZR), extended data registers (D), and extended link registers (W) Even when an index setting that crosses file registers (ZR), extended data registers (D), and extended link registers (W) is applied, an error does not occur.
  • Page 87 (b) An index setting is applicable to both I/O numbers and buffer memory numbers for intelligent function module devices U10Z1\G0Z2 If Z1=2 and Z2=8, then U(10+2)\G(0+8)=U12\G8 (c) An index setting is applicable to both network numbers and device numbers for link direct devices J1Z1\K4X0Z2 If Z1=2 and Z2=8,...
  • Page 88 (6) Precautions (a) Applying the index setting within the FOR to NEXT instruction loop The pulses can be output by using edge relays (V) within the FOR to NEXT instruction loop. Note that the pulses cannot be output by the PLS, PLF or pulse ( P) instruction.
  • Page 89 (b) Applying the index setting in the CALL instruction The pulse can be output by using edge relays (V) with the CALL instruction. Note that the pulse cannot be output by the PLS, PLF or pulse ( P) instruction. [When using an edge relay] [When not using an edge relay] (M0Z1 pulse is output normally.) (M0Z1 pulse is not output normally.)
  • Page 90: Precautions On Programming

    Precautions on Programming The following cases cause an operation error during the execution of basic instructions and application instructions in a CPU module. • Errors described on each page of instruction explanation are occurred. • No intelligent function module is mounted at the specified I/O number position when an intelligent function module device is used.
  • Page 91 2) For Universal model QCPU The device range is checked. When the data exceed the corresponding device range, an operation error occurs. For example, when data registers are assigned in 12k points, an error occurs if the data exceed D12287. DMOV D12287 This specifies D12287 and D12288 as the...
  • Page 92 2) For Universal model QCPU The device range is checked. When the data exceed the corresponding device range, an operation error occurs. For example, when data registers are assigned in 12k points, an error occurs if the data exceed D12287. BMOV D12287 This specifies D12287 and D12288 as the...
  • Page 93 However, when the index setting is applied in the CPU module other than the Universal model QCPU, and if the start number of the device exceeds the device range, an error does not occur and the data accesses to another devices. When the data are accessed as following in the Universal model QCPU, an error occurs.
  • Page 94 Remark For the method for changing the assignment of internal user devices, refer to the following manual. • QCPU User's Manual (Function Explanation, Program Fundamentals) (d) When the index setting is applied to direct access output (DY), the device range is checked.
  • Page 95: Executing Conditions For Instructions

    Executing Conditions for Instructions This section explains the four types of executing condition for sequence instructions, basic instructions, and application instructions executed in a CPU module. • Non-conditional execution ..Instructions executed regardless of ON/OFF status of the device. Example: LD= instruction •...
  • Page 96: Operation Of Out Instructions, Set/Rst Instructions, Or Pls/Plf Instructions Using Same Device

    3.10 Operation of OUT Instructions, SET/RST Instructions, or PLS/PLF Instructions Using Same Device This section explains the operation when the OUT instructions, SET/RST instructions, or PLS/ PLF instructions that use a same device are executed multiple times in one scan. (1) OUT instructions that use a same device Avoid executing the OUT instructions that use a same device multiple times during one scan.
  • Page 97 (2) SET/RST instructions that use a same device (a) The SET instruction turns ON the specified device when the execution command is ON, while it performs no operation when the execution command is OFF. Thus, if the SET instructions that use a same device are executed multiple times during one scan, the specified device is turned ON when any of the execution commands is turned ON.
  • Page 98 (3) PLS instructions that use a same device The PLS instruction turns ON the specified device when the execution command turns from OFF to ON. When the status is other than turning from OFF to ON, (OFF to OFF, ON to ON or ON to OFF), the PLS instruction turns OFF the specified device.
  • Page 99 • The timings of turning from OFF to ON between X0 and X1 are same EN ENO EN ENO EN ENO EN ENO M0 turns OFF because X1 status is M0 turns ON because X1 other than OFF goes ON (OFF ON).
  • Page 100 [Timing chart] • The ON/OFF timing differs between X0 and X1 (The specified device is not turned ON for one scan) EN ENO EN ENO EN ENO EN ENO M0 turns OFF because X1 status is M0 turns OFF because X1 other than ON OFF.
  • Page 101: Precautions On Using File Registers

    3.11 Precautions on Using File Registers This section explains the precautions on using file registers in the QCPU. (1) Setting file registers to be used To use file registers, they need to be set in the PLC parameter or the QDRSET instruction. If the file registers are not set, normal operations cannot be performed in the instructions that use the file registers.
  • Page 102 (3) Specifying the file register number exceeding the registered number (a) For CPUs other than Universal model QCPU An error does not occur when data are written/read to/from the file register numbers that are greater than the registered number of points. Note that the data cannot be written/read correctly to/from file registers.
  • Page 103 (5) Settings and restrictions when specifying file registers to refresh devices (a) Setting refresh devices Refresh devices can be set by the following settings. • Refresh settings of CC-Link IE controller network module • Refresh settings of MELSECNET/H • Refresh settings of CC-Link •...
  • Page 104 (6) Precautions on using file registers in the flash memory This section explains the precautions on the flash memory that can use file registers in the QCPU. (a) The following flash memory can be used for the QCPU. • QCPU: Flash card (b) File registers in a flash memory can be only read in sequence programs.
  • Page 105: How To Read Instructions

    HOW TO READ INSTRUCTIONS...
  • Page 106 Chapter 5 to 9 provide detailed explanation on each instruction in the layout as shown below. Indicates a section number and an outline of an instruction. Indicates an instruction to be explained.
  • Page 107 Indicates the CPU modules that can use the instruction. Icon Description Universal model High Performance model QCPU QCPU High The normal icon indicates that the CPU module Universal Performance can use the corresponding instructions. The icon with symbol indicates that the CPU High module can use the corresponding instructions Performance...
  • Page 108 *1 : Can be used for the Universal model QCPU only. *2 : The time type is used in time type operation instructions of application function. For details of application functions, refer to the following manual. QCPU Structured Programming Manual (Application Functions) Generic data type Description Can use all elementary data types.
  • Page 109: Sequence Instructions

    SEQUENCE INSTRUCTIONS Contact Instructions ..........5-2 Bond Instructions .
  • Page 110: Contact Instructions

    LD, LDI, AND, ANI, OR, ORI Contact Instructions 5.1.1 Operation start, series connection, parallel connection LD, LDI, AND, ANI, OR, ORI High Performance Universal Bit device number/bit specification for word devices ( X1/D0.1 X1/D0.1 X2/D0.2 X2/D0.2 X3/D0.3 X3/D0.3 : Devices used as contacts (Bit) Internal device Setting Others...
  • Page 111 LD, LDI, AND, ANI, OR, ORI AND, ANI (1) AND is the normally open series connection instruction, and ANI is the normally closed series connection instruction. They read the ON/OFF data of the specified bit device* perform an AND operation on that data and the operation result to that point, and take this value as the operation result.
  • Page 112: 5.1.2 Pulse Operation Start, Pulse Series Connection, Pulse Parallel Connection

    LDP, LDF, ANDP, ANDF, ORP, ORF 5.1.2 Pulse operation start, pulse series connection, pulse parallel connection LDP, LDF, ANDP, ANDF, ORP, ORF High Performance Universal LD(P)(F) AND(P)(F) OR(P)(F) indicates any of the following instructions. Structured ladder ANDP ANDF ENO:= (EN, s); Input argument, Executing condition :Bit...
  • Page 113 LDP, LDF, ANDP, ANDF, ORP, ORF (2) LDF is the falling pulse operation start instruction, and it is ON only at the falling pulse of the specified bit device (when it turns from ON to OFF). If a word device is specified, it is ON only when the specified bit changes from 1 to 0. ANDP, ANDF (1) ANDP is a rising pulse series connection instruction, and ANDF is a falling pulse series connection instruction.
  • Page 114: Bond Instructions

    ANB, ORB Bond Instructions 5.2.1 Ladder block series connection and parallel connection ANB, ORB High Performance Universal Block A Block B Block A Block B Use OR or ORI for a parallel connection of one contact. Internal device Setting R, ZR Constant Others data...
  • Page 115 ANB, ORB Operation Error No operation error occurs in the execution of the ANB and ORB instructions. Program Example The program using the ANB and ORB instructions. [Structured ladder] 5.2 Bond Instructions 5.2.1 Ladder block series connection and parallel connection...
  • Page 116: Operation Result Push/Read/Pop

    MPS, MRD, MPP 5.2.2 Operation result push/read/pop MPS, MRD, MPP High Performance Universal indicates any of the following instructions. Structured ladder ENO:= (EN); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data Word...
  • Page 117 MPS, MRD, MPP 1. The following shows the ladders using and without using the MPS, MRD, and MPP instructions. Ladder without using the MPS, MRD, and MPP Ladder using the MPS, MRD, and MPP instructions instructions 2. The MPS and MPP instructions must be used the same number of times. If the number of times these instructions are used differs from each other, the ladder is not displayed correctly in the ladder mode on the peripheral.
  • Page 118 MPS, MRD, MPP (2) The program using the MPS and MPP instructions successively. [Structured ladder] [ST] OUT(MPS(X1E AND M81) AND M96,Y35); OUT(MRD(TRUE) AND M97,Y36); OUT(MRD(TRUE) AND M98,Y37); OUT(MPP(TRUE),Y38); 5.2 Bond Instructions 5-10 5.2.2 Operation result push/read/pop...
  • Page 119: Operation Result Inversion

    5.2.3 Operation result inversion High Performance Universal indicates the following instruction. Structured ladder ENO:= (EN); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data Word Word − − Function Inverts the operation result immediately prior to the INV instruction. Operation result immediately prior to the Operation result following the execution of INV instruction...
  • Page 120 Program Example The program which inverts the X0 ON/OFF data, and outputs from Y10. [Structured ladder] [ST] OUT(INV(X0),Y10); [Timing chart] The INV instruction operates based on the results of calculation made until the INV instruction is given. Accordingly, use it in the same position as that of AND. The INV instruction cannot be used at the LD and OR positions.
  • Page 121: Pulse Conversion Of Operation Result

    MEP, MEF 5.2.4 Pulse conversion of operation result MEP, MEF High Performance Universal indicates any of the following instructions. Structured ladder ENO:= (EN); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data Word...
  • Page 122 MEP, MEF Program Example The program which performs pulse conversion to the operation results of X0 and X1 [Structured ladder] [ST] IF X0 AND X1 THEN MEP(TRUE); SET(TRUE,M0); END_IF; 1. The MEP and MEF instructions will occasionally not function properly when pulse conversion is conducted for a contact that has been indexed by a subroutine program or FOR to NEXT instruction loop.
  • Page 123: Pulse Conversion Of Edge Relay Operation Result

    EGP, EGF 5.2.5 Pulse conversion of edge relay operation result EGP, EGF High Performance Universal EGP: Executing condition EGF: Executing condition indicates any of the following instructions. Structured ladder ENO:= (EN ,d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Edge relay number that stores the operation result...
  • Page 124 EGP, EGF (3) The EGF instruction is used when conducting pulse operations for indexed programs in subroutine programs and FOR to NEXT instruction loop. (4) The EGF instruction can be used like AND. Operation Error No operation error occurs in the execution of the EGP and EGF instructions. Program Example The program using the EGP instruction.
  • Page 125 EGP, EGF 1. Since the EGP and EGF instructions are executed according to the operation results performed immediately before the EGP and EGF instructions, these instructions must be used at the same position as AND. (Refer to Section 5.1.1.) The EGP and EGF instructions cannot be used at the LD or OR position. 2.
  • Page 126: Output Instructions

    Output Instructions 5.3.1 Out instruction (excluding timers, counters and annunciators) High Performance Universal indicates the following instruction. Structured ladder ENO:= (EN, d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Device number to be turned ON or OFF :ANY_SIMPLE Internal device Setting...
  • Page 127 Operation Error No operation error occurs in the execution of the OUT instruction. Program Example (1) When using bit devices [Structured ladder] [ST] OUT(X5,Y33); IF X6 THEN OUT(TRUE,Y34); OUT(TRUE,Y35); END_IF; (2) When bits are specified for a word device [Structured ladder] [ST] OUT(X5,D0.5);...
  • Page 128: Timer

    OUT_T, OUTH_T 5.3.2 Timer OUT_T, OUTH_T High Performance Universal OUT_T OUTH_T indicates any of the following instructions. Structured ladder OUT_T OUT_T OUTH_T ENO:= (EN, TCoil, TValue); OUT_T TCoil TValue Input argument, Executing condition :Bit TCoil: Timer number :Bit TValue: Timer set value :ANY16 Output argument, ENO:...
  • Page 129 OUT_T, OUTH_T (2) The contact responds as follows when the operation result up to the OUT(H)_T instruction is a change from ON to OFF. Prior to time up After time up Current value of Normally Type of timer Timer coil Normally open Normally open Normally...
  • Page 130 OUT_T, OUTH_T Caution (1) When creating a program in which the operation of the timer contact triggers the operation of other timer, create the program for the timer that operates later first. In any of the following cases, all timers turn ON at the same scan if the program is created in the order the timers operate.
  • Page 131 OUT_T, OUTH_T Program Example (1) In the following program, Y10 and Y14 are turned ON, 10 seconds after X0 has turned ON. [Structured ladder] [ST] OUT_T(X0,TC1,100); OUT(TS1,Y10); OUT(TS1,Y14); *2: The setting value of the low-speed timer indicates its default time limit (100ms). (2) In the following program, the BCD data of X10 to X1F are set as the timer's setting value.
  • Page 132: Counter

    OUT_C 5.3.3 Counter OUT_C High Performance Universal OUT_C indicates the following instruction. OUT_C Structured ladder OUT_C ENO:= (EN, CCoil, CValue); OUT_C CCoil CValue Input argument, Executing condition :Bit CCoil: Counter number :Bit CValue: Counter set value :ANY16 Output argument, ENO: Execution result :Bit Internal device...
  • Page 133 OUT_C (5) Index setting for the counter coil and contact can use only Z0 and Z1. Counter setting value has no limitation for index setting. (6) When using counter devices in a program, it is necessary to separate the usage of devices into following classification depending on the position of use.
  • Page 134 OUT_C (2) In the following program, the setting value for C10 is set at 10 when X0 turns ON, and at 20 when X1 turns ON. [Structured ladder] Stores 10 to D0 when X0 turns ON. Stores 20 to D0 when X1 turns ON.
  • Page 135: Annunciator Output

    5.3.4 Annunciator output High Performance Universal indicates the following instruction. Structured ladder ENO:= (EN, d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Annunciator number to be turned ON :ANY_SIMPLE Internal device Setting R, ZR Constant Others data Word Word...
  • Page 136 Operation Error No operation error occurs in the execution of the OUT instruction. Remark 1. For details of annunciators, refer to the following manual. • QCPU User's Manual (Functions Explanation, Program Fundamentals) 2. The table below shows which CPU module features either the LED display device on front of the CPU module or "USER"...
  • Page 137: Setting Devices (Excluding Annunciators)

    5.3.5 Setting devices (excluding annunciators) High Performance Universal indicates the following instruction. Structured ladder ENO:= (EN, d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Bit device number or bit specification for word devices to be :Bit turned ON Internal device Setting...
  • Page 138 Operation Error No operation error occurs in the execution of the SET instruction. Program Example (1) In the following program, Y8B is set (ON) when X8 turns ON, and Y8B is reset (OFF) when X9 turns ON. [Structured ladder] [ST] SET(X8,Y8B);...
  • Page 139: Resetting Devices (Excluding Annunciators)

    5.3.6 Resetting devices (excluding annunciators) High Performance Universal indicates the following instruction. Structured ladder ENO:= (EN, d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Bit device number or bit specification for word devices to be :ANY_SIMPLE reset Word device number to be reset Internal device...
  • Page 140 Operation Error No operation error occurs in the execution of the RST instruction. Program Example (1) In the following program, the value of the data register is set to 0. [Structured ladder] Stores the data from X10 to X1F to Var_D8 when X0 turns ON.
  • Page 141 (2) In the following program, the 100ms retentive timer and counter are reset. [Structured ladder] When ST225 is set as retentive timer, it turns ON when X4's ON time reaches 30 minutes. Counts the number of times ST225 turned ON. Resets the coil, contact, and current value of ST255 when the contact of ST255 turns ON.
  • Page 142 SET, RST 5.3.7 Setting and resetting annunciators SET, RST High Performance Universal Executing condition indicates any of the following instructions. Structured ladder ENO:= (EN, d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Annunciator number to be set :Bit Annunciator number to be reset :Bit...
  • Page 143: 5.3.7 Setting And Resetting Annunciators

    SET, RST (1) The annunciator specified for is turned OFF when the execution command is turned ON. (2) The annunciator numbers (F numbers) of annunciators that have turned OFF are deleted from the special registers (SD64 to SD79), and the value of SD63 is decremented by 1. Remark 1.
  • Page 144 SET, RST Program Example In the following program, the annunciator F11 is turned ON when X1 turns ON, and the value 11 is stored to the special register (SD64 to SD79). Further, the annunciator F11 is reset when X2 turns ON, and the value 11 is deleted from the special registers (SD64 to SD79). [Structured ladder] [ST] SET(X1,F11);...
  • Page 145: Rising Pulse And Falling Pulse Outputs

    PLS, PLF 5.3.8 Rising pulse and falling pulse outputs PLS, PLF High Performance Universal PLS: Executing condition PLF: Executing condition indicates any of the following instructions. Structured ladder ENO:= (EN, d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Device to be set as pulse output :Bit...
  • Page 146 PLS, PLF (2) If the RUN/STOP key switch is changed from RUN to STOP after the execution of the PLS instruction, the PLS instruction will not be executed again even if the switch is set back to RUN. Operating the Operating the EN ENO RUN/STOP...
  • Page 147 PLS, PLF Program Example (1) In the following program, the PLS instruction is executed when X9 turns ON. [Structured ladder] [ST] PLS(X9,M9); [Timing chart] X9 OFF M9 OFF 1 scan (2) In the following program, the PLF instruction is executed when X9 turns OFF. [Structured ladder] [ST] PLF(X9,M9);...
  • Page 148: Bit Device Output Inversion

    5.3.9 Bit device output inversion High Performance Universal Executing condition indicates the following instruction. Structured ladder ENO:= (EN, s); Input argument, Executing condition :Bit Device number whose status to be inverted :Bit Output argument, ENO: Execution result :Bit Internal device Setting Others R, ZR...
  • Page 149 Program Example (1) In the following program, the output of Y10 is inverted when X9 turns ON. [Structured ladder] [ST] FF(X9,Y10); [Timing chart] (2) In the following program, b10 (bit 10) of D10 is inverted when X0 turns ON. [Structured ladder] [ST] FF(X0,D10.A);...
  • Page 150: Pulse Conversion Of Direct Output

    DELTA 5.3.10 Pulse conversion of direct output DELTA High Performance Universal DELTA(P) P: Executing condition indicates any of the following instructions. Structured ladder DELTA DELTAP DELTA ENO:= (EN, d); DELTA Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Bit to be set as pulse output :Bit...
  • Page 151 DELTA (2) The DELTAP instruction is used by commands for rising pulse execution for an intelligent function module. Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. •...
  • Page 152: Shift Instructions

    Shift Instructions 5.4.1 Bit device shift High Performance Universal SFT(P) P: Executing condition indicates any of the following Instructions. Structured ladder SFTP ENO:= (EN, d); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Device number to be shifted :Bit Internal device Setting...
  • Page 153 (c) When the SFT and SFTP instructions are to be used consecutively, the program starts from the device with the larger number. Shift range Shift input M15 M14 X02 ON After the 1st shift input After the 2nd shift input X02 ON After the 3rd shift input After the 4th shift input...
  • Page 154 Program Example In the following program, the devices from Y57 to Y5B are shifted when X8 turns ON. [Structured ladder] [ST] IF LDP(TRUE,X8) THEN SFT(TRUE,Y5B); SFT(TRUE,Y5A); SFT(TRUE,Y59); SFT(TRUE,Y58); LDP(TRUE,X7); OUT(TRUE,Y57); END_IF; [Timing chart] 5.4 Shift Instructions 5-46 5.4.1 Bit device shift...
  • Page 155: Master Control Instructions

    MC, MCR Master Control Instructions 5.5.1 Setting and resetting master control MC, MCR High Performance Universal indicates any of the following instructions. Structured ladder ENO:= (EN, n*, d); Structured ladder ENO:= (EN, n*); Input argument, Executing condition :Bit Nesting (N0 to N14) :ANY16 Output argument, ENO:...
  • Page 156 MC, MCR EN ENO X1 X3 M7 X6 X4 EN ENO (1) If the execution command of the MC instruction is ON when master control is started, the result of the operation from the MC instruction to the MCR instruction will be exactly as the instruction (ladder) shows.
  • Page 157 MC, MCR (1) This is the instruction for recovery from the master control, and indicates the end of the master control range of operation. (2) Do not place contacts before the MCR instruction. (3) Use the MC instruction and MCR instruction of the same nesting number as a set. However, when the MCR instructions are nested in one place, all master controls can be terminated with the lowest nesting number.
  • Page 158: 5.5.1 Setting And Resetting Master Control

    MC, MCR Cautions when using nesting architecture (1) Nesting can be used up to 15 times (N0 to N14) When using nesting, nests should be inserted from the lower to higher nesting number with the MC instruction, and from the higher to the lower order with the MCR instruction. If this order is reversed, there will be no nesting architecture, and the CPU module will not be capable of performing correct operations.
  • Page 159: End Instructions

    FEND End Instructions 5.6.1 Ending main routine program FEND High Performance Universal FEND indicates the following instruction. Structured ladder FEND FEND ENO:= (EN); FEND Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data...
  • Page 160 FEND (3) Even sequence programs following the FEND instruction can be displayed in ladder display at a peripheral. (Peripherals continue to display ladders until encountering END.) CALL Operation Main routine performed Jump caused program Main routine when the CJ by the CJ instruction program instruction is not executed...
  • Page 161: Other Instructions

    STOP Other Instructions 5.7.1 Sequence program stop STOP High Performance Universal STOP indicates the following instruction. Structured ladder STOP STOP ENO:= (EN); STOP Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data Word...
  • Page 162 STOP Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The STOP instruction was executed before the execution of the RET instruction and after the execution of the CALL instruction.
  • Page 163: Basic Instructions

    BASIC INSTRUCTIONS Comparison Operation Instructions ....... . . 6-2 Arithmetic Operation Instructions ........6-22 Data Conversion Instructions .
  • Page 164: Comparison Operation Instructions

    <>, <=, <, >=, > Comparison Operation Instructions 6.1.1 16-bit BIN data comparison <>, <=, <, >=, > High Universal Performance (<>) <> (<=) <= (<) < (>=) >= > (>) indicates any of the following instructions. Structured ladder AND= LD<>...
  • Page 165 <>, <=, <, >=, > (2) The results of the comparison operations for each instruction are as follows. Instruction Instruction Condition Comparison result Condition Comparison result symbol in symbol in <> <> <= <= > Non-conduction Conduction state state < <...
  • Page 166 <>, <=, <, >=, > (4) In the following program, the value in Var_D0 is compared with the value in Var_D3, and Y33 turns ON when the value in Var_D3 is equal or greater than the value in Var_D00 or when both M3 and M8 are ON.
  • Page 167 D<>, D<=, D<, D>=, D> 6.1.2 32-bit BIN data comparison D<>, D<=, D<, D>=, D> High Universal Performance ANDD (<>) D<> (<=) D<= (<) D< (>=) D>= D> (>) indicates any of the following instructions. Structured ladder LDD= ANDD= ORD= LDD= LDD<>...
  • Page 168: 6.1.2 32-Bit Bin Data Comparison

    D<>, D<=, D<, D>=, D> (2) The results of the comparison operations for each instruction are as follows. Instruction Instruction Condition Comparison result Condition Comparison result symbol in symbol in D<> D<> D<= D<= > Non-conduction Conduction state state D< D<...
  • Page 169 D<>, D<=, D<, D>=, D> (3) In the following program, the BIN value of −80000 is compared with the value in Var_D3 when M3 is ON, and Y33 turns ON when the value in Var_D3 is less than −80000, or when M8 is ON.
  • Page 170: Floating-Point Data Comparison (Single Precision)

    E<>, E<=, E<, E>=, E> 6.1.3 Floating-point data comparison (single precision) E<>, E<=, E<, E>=, E> High Universal Performance (E=) (E<>) E<> (E<=) E<= (E<) E< (E>=) E>= E> (E>) indicates any of the following instructions. Structured ladder LDE= ANDE= ORE= LDE= LDE<>...
  • Page 171 E<>, E<=, E<, E>=, E> (2) The results of the comparison operations for each instruction are as follows. Instruction Instruction Condition Comparison result Condition Comparison result symbol in symbol in E<> E<> E<= E<= > Non-conduction Conduction state state E< E<...
  • Page 172 E<>, E<=, E<, E>=, E> (2) In the following program, the floating-point real number 1.23 is compared with the value in Var_D3 when M3 is ON, and Y33 turns ON when the value in Var_D3 is other than 1.23. [Structured ladder] (3) In the following program, the value in Var_D0 is compared with the value in Var_D3 when M3 is ON, and Y33 turns ON when the value in Var_D3 is equal to or smaller than the value in Var_D0 or when M8 is ON.
  • Page 173 ED=, ED<>, ED<=, ED<, ED>=, ED> 6.1.4 Floating-point data comparison (double precision) ED=, ED<>, ED<=, ED<, ED>=, ED> High Universal Performance (ED=) (ED<>) ED<> (ED<=) ED<= (ED<) ED< (ED>=) ED>= ED> (ED>) indicates any of the following instructions. Structured ladder LDED= ANDED= ORED=...
  • Page 174 ED=, ED<>, ED<=, ED<, ED>=, ED> Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The specified value is not within the following range. (Error code: 4140) -1022 1024...
  • Page 175: Floating-Point Data Comparison (Double Precision)

    ED=, ED<>, ED<=, ED<, ED>=, ED> Caution Since the maximum number of digits of real number that can be input by GX Works2 is 15 digits, the comparison with the real number whose number of significant figures is 16 or more cannot be made by the instruction shown in this section.
  • Page 176 $<>, $<=, $<, $>=, $> 6.1.5 Character string data comparison $<>, $<=, $<, $>=, $> High Universal Performance AND$ (<>) $<> (<=) $<= (<) $< (>=) $>= $> (>) indicates any of the following instructions. Structured ladder LD$= AND$= OR$= LD$= LD$<>...
  • Page 177: 6.1.5 Character String Data Comparison

    $<>, $<=, $<, $>=, $> (3) The character string data of for the comparison refers to the data up to 00 (a) If all character string data are matched, the comparison result will be matched. "ABCDE" "ABCDE" Comparison result Comparison result Instruction symbol in Instruction symbol in Conduction state...
  • Page 178 $<>, $<=, $<, $>=, $> (d) If the character string data specified for are of different lengths, the data with the longer character string will be larger. "1234567" "123456" Comparison result Comparison result Instruction symbol in Instruction symbol in Non-conduction state $<...
  • Page 179 $<>, $<=, $<, $>=, $> Program Example (1) In the following program, the character string data stored in Var_D0 and the following devices are compared with the character string data stored in Var_D10 and the following devices, and Y33 turns ON when they are matched. [Structured ladder] (2) In the following program, the character string "ABCDEF"...
  • Page 180 BKCMP=, BKCMP<>, BKCMP<=, BKCMP<, BKCMP>=, BKCMP> 6.1.6 BIN block data comparison BKCMP=, BKCMP<>, BKCMP<=, BKCMP<, BKCMP>=, BKCMP> High Universal Performance BKCMP (=)(P) BKCMP= (<>) BKCMP<> (<=) BKCMP<= (<) BKCMP< (>=) BKCMP>= P: Executing condition (>) indicates any of the following Structured ladder instructions.
  • Page 181 BKCMP=, BKCMP<>, BKCMP<=, BKCMP<, BKCMP>=, BKCMP> (b) If the comparison condition has not been met, the corresponding device of turns OFF. Operation results 1234 (BIN) 5321 (BIN) 5678 (BIN) 3399 (BIN) 5000 (BIN) 5678 (BIN) + (n 2) + (n 2) 7777 (BIN) 6543...
  • Page 182: 6.1.6 Bin Block Data Comparison

    BKCMP=, BKCMP<>, BKCMP<=, BKCMP<, BKCMP>=, BKCMP> Program Example (1) In the following program, the data stored in D100 to D103 is compared with the data stored in R0 to R3 when X20 turns ON, and the result is stored to M10 and the following devices. [Structured ladder] [Operation] D100...
  • Page 183 BKCMP=, BKCMP<>, BKCMP<=, BKCMP<, BKCMP>=, BKCMP> (3) In the following program, the data in D10 to D12 are compared with the data in D30 to D32 when X20 turns ON, and the result is stored to M100 and the following devices. The character string "ALL ON"...
  • Page 184: Arithmetic Operation Instructions

    +, - Arithmetic Operation Instructions 6.2.1 16-bit BIN data addition and subtraction +, - High Universal Performance +(P) P: Executing condition -(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Data to be added or subtracted, or start number of the device : ANY16 that stores data to be added or subtracted Start number of the device that stores addition or subtraction...
  • Page 185 +, - (3) The judgment of whether the value is positive or negative is made by the most significant bit (b15). • 0: Positive • 1: Negative (4) The following is the result when an underflow or overflow is generated by the operation. The carry flag in this case does not turn ON.
  • Page 186: 32-Bit Bin Data Addition And Subtraction

    D+, D- 6.2.2 32-bit BIN data addition and subtraction D+, D- High Universal Performance D+(P) P: Executing condition D-(P) indicates any of the following Structured ladder instructions. Not supported Input argument, Executing condition : Bit Data to be added or subtracted : ANY32 Addition or subtraction data : ANY32...
  • Page 187 D+, D- (4) The following is the result when an underflow or overflow is generated by the operation. The carry flag in this case does not turn ON. 2147483647 2147483647 Since bit 31 value is "1", (7FFFFFFF (00000002 (80000001 result of operation takes a negative value. 2147483648 2147483646 Since bit 31 value is "0",...
  • Page 188 D+, D- (2) In the following program, the value in Var_D2 is subtracted from the value in Var_D0 when X0B turns ON, and the result is stored to Var_D10. [Structured ladder] 6.2 Arithmetic Operation Instructions 6-26 6.2.2 32-bit BIN data addition and subtraction...
  • Page 189: 16-Bit Bin Data Multiplication And Division

    *, / 6.2.3 16-bit BIN data multiplication and division *, / High Universal Performance *(P) P: Executing condition /(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Multiplicand or dividend data, or start number of the device : ANY16 that stores multiplicand or dividend data Multiplier or divisor data, or start number of the device that...
  • Page 190 *, / /(P) (1) Divides 16-bit BIN data specified for and 16-bit BIN data specified for , and stores the result to the variable specified for Quotient Remainder 5678 (BIN) 1234 (BIN) 4 (BIN) 742 (BIN) (2) Quotient and remainder of the division result are stored in 32-bit data. Quotient: Stored to [0] (16 bits).
  • Page 191 *, / (3) In the following program, the value in Var_D0 is divided by 3.14 when X3 turns ON, and the result is stored to Var_D1. [Structured ladder] 6.2 Arithmetic Operation Instructions 6-29 6.2.3 16-bit BIN data multiplication and division...
  • Page 192: 32-Bit Bin Data Multiplication And Division

    D*, D/ 6.2.4 32-bit BIN data multiplication and division D*, D/ High Universal Performance D*(P) P: Executing condition D/(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Multiplicand or dividend data : ANY32 Multiplier or divisor data : ANY32 Output argument,...
  • Page 193 D*, D/ D/(P) (1) Divides the 32-bit BIN data specified for by the 32-bit BIN data specified for , and stores the result to the variable specified for Quotient Remainder d [0] d [1] b31 b16 b31 b16 b31 b16 567890 (BIN) 123456 (BIN) 4 (BIN)
  • Page 194 D*, D/ (2) In the following program, the value in Var_D0 is multiplied by 314 when X3 turns ON, and the result is stored to Var_D2. [Structured ladder] 6.2 Arithmetic Operation Instructions 6-32 6.2.4 32-bit BIN data multiplication and division...
  • Page 195: 4-Digit Bcd Data Addition And Subtraction

    B+, B- 6.2.5 4-digit BCD data addition and subtraction B+, B- High Universal Performance B+(P) P: Executing condition B-(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Data to be added or subtracted, or start number of the device : ANY16 that stores data to be added or subtracted Start number of the device that stores addition or subtraction...
  • Page 196 B+, B- B-(P) (1) Subtracts the 4-digit BCD data specified for and the 4-digit BCD data specified for and stores the result of the subtraction to the variable specified for Digits exceeding the specified number of digits are assumed to be 0. (2) Values can be specified between 0 and 9999 (4-digit BCD) for (3) The following is the result when an underflow is generated by the subtraction operation.
  • Page 197: 8-Digit Bcd Data Addition And Subtraction

    DB+, DB- 6.2.6 8-digit BCD data addition and subtraction DB+, DB- High Universal Performance DB+(P) P: Executing condition DB-(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Data to be added or subtracted : ANY32 Addition or subtraction data : ANY32...
  • Page 198 DB+, DB- DB-(P) (1) Subtracts the 8-digit BCD data specified for and the 8-digit BCD data specified for and stores the result of the subtraction to the variable specified for (Upper 4 digits) (Lower 4 digits) (Upper 4 digits) (Lower 4 digits) (Upper 4 digits) (Lower 4 digits) −...
  • Page 199: 4-Digit Bcd Data Multiplication And Division

    B*, B/ 6.2.7 4-digit BCD data multiplication and division B*, B/ High Universal Performance B*(P) P: Executing condition B/(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Multiplicand or dividend data, or start number of the device : ANY16 that stores multiplicand or dividend data Multiplier or divisor data, or start number of the device that...
  • Page 200 B*, B/ B/(P) (1) Divides BCD data specified for by BCD data specified for , and stores the result to the variable specified for Quotient Remainder Digits exceeding the specified number of digits are assumed to be 0. (2) Quotient and remainder of the division result are stored in 32-bit data. Quotient (4-digit BCD): Stored to [0] (16 bits).
  • Page 201 DB*, DB/ 6.2.8 8-digit BCD data multiplication and division DB*, DB/ High Universal Performance DB*(P) P: Executing condition DB/(P) indicates any of the following instructions. Structured ladder DB*P DB/P Not supported Input argument, Executing condition : Bit Multiplicand or dividend data : ANY32 Multiplier or divisor data : ANY32...
  • Page 202 DB*, DB/ DB/(P) (1) Divides 8-digit BCD data specified for by 8-digit BCD data specified for , and stores the result to the variable specified for ÷ Digits exceeding the specified number of digits are assumed to be 0. Quotient (Upper 4 digits) (Lower 4 digits) Remainder...
  • Page 203: 6.2.8 8-Digit Bcd Data Multiplication And Division

    DB*, DB/ (2) In the following program, the BCD value in Var_D0 is divided by the BCD value in Var_D8 when X0B turns ON, and the result is stored to Var_D765. [Structured ladder] [Operation] Var_D0 Var_D8 Dividend Divisor Var_D765[0] Var_D765[1] (Upper 4 digits) (Lower 4 digits) (Upper 4 digits)
  • Page 204 E+, E- 6.2.9 Floating-point data addition and subtraction (single precision) E+, E- High Universal Performance E+(P) P: Executing condition E-(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Data to be added or subtracted : Single-precision real Addition or subtraction data : Single-precision real...
  • Page 205 E+, E- E-(P) (1) Subtracts the floating-point real number specified for and the floating-point real number specified for , and stores the result to the variable specified for Floating-point Floating-point Floating-point real number real number real number (2) Values which can be specified for , and which can be stored, are as follows.
  • Page 206: Floating-Point Data Addition And Subtraction (Single Precision)

    E+, E- (2) In the following program, the floating-point real number Var_D20 is subtracted from the floating-point real number Var_D10, and the result is stored to Var_D30. [Structured ladder] [Operation] Var_D10 Var_D20 Var_D30 97365.203 76059.797 21305.406 6.2 Arithmetic Operation Instructions 6-44 6.2.9 Floating-point data addition and subtraction (single precision)
  • Page 207 ED+, ED- 6.2.10 Floating-point data addition and subtraction (double precision) ED+, ED- High Universal Performance ED+(P) P: Executing condition ED-(P) indicates any of the following instructions. Structured ladder ED+P ED-P Not supported Input argument, Executing condition : Bit Data to be added or subtracted : Double-precision real Addition or subtraction data : Double-precision real...
  • Page 208 ED+, ED- ED-(P) (1) Subtracts the 64-bit floating-point real number specified for from the 64-bit floating-point real number specified for , and stores the result to − 64-bit floating-point 64-bit floating-point 64-bit floating-point real number real number real number (2) Values which can be specified for , and which can be stored, are as follows: -1022 1024...
  • Page 209: Floating-Point Data Addition And Subtraction (Double Precision)

    ED+, ED- (2) In the following program, the 64-bit floating-point real number Var_D20 is subtracted from the 64-bit floating-point real number Var_D10, and the result is stored to Var_D30. [Structured ladder] [Operation] Var_D10 Var_D20 Var_D30 97365.203 76059.797 21305.406 6.2 Arithmetic Operation Instructions 6-47 6.2.10 Floating-point data addition and subtraction (double precision)
  • Page 210 E*, E/ 6.2.11 Floating-point data multiplication and division (single precision) E*, E/ High Universal Performance E*(P) P: Executing condition E/(P) indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Multiplicand or dividend data : Single-precision real Multiplier or divisor data : Single-precision real...
  • Page 211 E*, E/ E/(P) (1) Divides the floating-point real number specified for by the floating-point real number specified for and stores the operation result to the variable specified for Floating-point real Floating-point real Floating-point real number number number (2) Values which can be specified for , and can be stored, are as follows.
  • Page 212: Floating-Point Data Multiplication And Division (Single Precision)

    E*, E/ (2) In the following program, the floating-point real number in Var_D10 is divided by the floating- point real number in Var_D20, and the result is stored to Var_D30. [Structured ladder] [Operation] Var_D10 Var_D20 Var_D30 97365.203 76059.797 21305.406 6.2 Arithmetic Operation Instructions 6-50 6.2.11 Floating-point data multiplication and division (single precision)
  • Page 213 ED*, ED/ 6.2.12 Floating-point data multiplication and division (double precision) ED*, ED/ High Universal Performance ED*(P) P: Executing condition ED/(P) indicates any of the following instructions. Structured ladder ED*P ED/P Not supported Input argument, Executing condition : Bit Multiplicand or dividend data : Double-precision real Multiplier or divisor data : Double-precision real...
  • Page 214 ED*, ED/ ED/(P) (1) Divides the 64-bit floating-point real number specified for by the 64-bit floating-point real number specified for , and stores the result to 64-bit floating-point 64-bit floating-point 64-bit floating-point real number real number real number (2) Values which can be specified for , and can be stored, are as follows.
  • Page 215: Floating-Point Data Multiplication And Division (Double Precision)

    ED*, ED/ (2) In the following program, the 64-bit floating-point real number in Var_D10 is divided by the 64-bit floating-point real number in Var_D20, and the result is stored to Var_D30. [Structured ladder] [Operation] Var_D10 Var_D20 Var_D30 5217.39 9.73521 5359.041 6.2 Arithmetic Operation Instructions 6-53 6.2.12 Floating-point data multiplication and division (double precision)
  • Page 216 BK+, BK- 6.2.13 Block data addition and subtraction BK+, BK- High Universal Performance BK+(P) P: Executing condition BK-(P) indicates any of the following Structured ladder instructions. BK+P BK-P Not supported Input argument, Executing condition : Bit Start number of the device that stores data to be added or : ANY16 subtracted Start number of the device that stores addition or subtraction...
  • Page 217: 6.2.13 Block Data Addition And Subtraction

    BK+, BK- (2) Block addition is performed in units of 16 bits. (3) The constant can be specified between 32768 and 32767 (BIN 16 bits) for 5555 (BIN) 1234 (BIN) 8888 (BIN) 4567 (BIN) 2321 (BIN) 2000 (BIN) 4321 (BIN) 1234 (BIN) 3087...
  • Page 218 BK+, BK- Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device.
  • Page 219 6.2.14 Character string data concatenation High Universal Performance $+(P) P: Executing condition indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Connection data : String Data to be connected : String Output argument, ENO: Execution result : Bit...
  • Page 220 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The entire character strings cannot be stored to the variable specified for (Error code: 4101) •...
  • Page 221: 16-Bit Bin Data Increment And Decrement

    INC, DEC 6.2.15 16-bit BIN data increment and decrement INC, DEC High Universal Performance INC(P) P: Executing condition DEC(P) indicates any of the following instructions. Structured ladder INCP DECP ENO:= (EN, d); Input argument, Executing condition : Bit Output argument, ENO: Execution result : Bit...
  • Page 222 INC, DEC Operation Error No operation error occurs in the execution of the INC(P) and DEC(P) instructions. Program Example (1) In the following program, the current values from the counter C0 to C20 are output to Y30 to Y3F in BCD data each time X8 turns ON. (When current value is less than 9999) [Structured ladder] Outputs the current value of C (0+21) to Y30 to Y3F...
  • Page 223 INC, DEC (2) The following is a down-counter program. [Structured ladder] Transfers 100 to D8 when X7 turns ON. When M38 is OFF, decrements the value in D8 each time X8 turns from OFF to ON. M38 turns ON when the value in D8 reaches 0.
  • Page 224: 32-Bit Bin Data Increment And Decrement

    DINC, DDEC 6.2.16 32-bit BIN data increment and decrement DINC, DDEC High Universal Performance DINC(P) P: Executing condition DDEC(P) indicates any of the following instructions. Structured ladder DINC DINCP DINC DDEC DDECP ENO:= (EN, d); DINC Input argument, Executing condition : Bit Output argument, ENO:...
  • Page 225 DINC, DDEC Operation Error No operation error occurs in the execution of the DINC(P) and DDEC(P) instructions. Program Example (1) In the following program, 1 is added to the data in Var_D0 when X0 turns ON. [Structured ladder] [ST] DINCP(X0,Var_D0); (2) In the following program, 1 is added to the data set in Var_D0 when X0 turns ON, and the result is stored to Var_D3.
  • Page 226 DINC, DDEC (4) In the following program, 1 is subtracted from the data set in Var_D0 when X0 turns ON, and the result is stored to Var_D3. [Structured ladder] [ST] IF X0 THEN DMOVP(TRUE,Var_D0,Var_D3); DDECP(TRUE,Var_D3); END_IF; 6.2 Arithmetic Operation Instructions 6-64 6.2.16 32-bit BIN data increment and decrement...
  • Page 227: Data Conversion Instructions

    BCD, DBCD Data Conversion Instructions 6.3.1 BIN data to 4-/8-digit BCD data conversion BCD, DBCD High Universal Performance BCD(P) P: Executing condition DBCD(P) indicates any of the following instructions. Structured ladder BCDP DBCD DBCDP ENO:= (EN, s, d); Input argument, Executing condition : Bit BIN data...
  • Page 228 BCD, DBCD DBCD(P) Converts BIN data (0 to 99999999) in the device specified for to BCD data, and stores the result to the device specified for BIN 99999999 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 BCD conversion Must always be "0"...
  • Page 229: 6.3.1 Bin Data To 4-/8-Digit Bcd Data Conversion

    BCD, DBCD (2) In the following program, 32-bit data from D0 to D1 are output to devices from Y40 to Y67. Programmable controller output module Y67 to Y64 Y63 to Y60 Y5F to Y5C Y5B to Y58 Y57 to Y54 Y53 to Y50 Y4F to Y4C Y4B to Y48...
  • Page 230 BIN, DBIN 6.3.2 4-/8-digit BCD data to BIN data conversion BIN, DBIN High Universal Performance BIN(P) P: Executing condition DBIN(P) indicates any of the following instructions. Structured ladder BINP DBIN DBINP ENO:= (EN, s, d); Input argument, Executing condition : Bit BCD data : ANY16/32 Output argument,...
  • Page 231 BIN, DBIN DBIN(P) Converts the BCD data (0 to 99999999) in the device specified for to the BIN data, and stores the result to the device specified for BCD 99999999 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 Million’s Hundred Thousand’s...
  • Page 232: 6.3.2 4-/8-Digit Bcd Data To Bin Data Conversion

    BIN, DBIN (2) In the following program, the BCD data in X10 to X37 are converted to BIN data when X8 turns ON, and the result is stored to Var_D0. (Addition of the BCD data in X20 to X37 converted to BIN data and the BCD data in X10 to X1F converted to BIN data.) BCD digital switch Input power supply...
  • Page 233 FLT, DFLT 6.3.3 16-/32-bit BIN data to floating-point data conversion (single precision) FLT, DFLT High Universal Performance FLT(P) P: Executing condition DFLT(P) indicates any of the following instructions. Structured ladder FLTP DFLT DFLTP ENO:= (EN, s, d); Input argument, Executing condition : Bit Integer data to be converted to floating-point data : ANY16/32...
  • Page 234 FLT, DFLT DFLT(P) (1) Converts 32-bit BIN data specified for to the floating-point real number, and stores the result to the device specified for Upper 16 bits Lower 16 bits BIN 32 bits Floating-point real number (2) BIN values between 2147483648 and 2147483647 can be specified for (3) Due to the fact that floating-point real numbers are processed by 32-bit single precision, the number of significant figures is 24 bits if the display is binary and approximately 7 digits if the...
  • Page 235: 32-Bit Bin Data To Floating-Point Data Conversion (Single Precision)

    FLT, DFLT Program Example (1) In the following program, the 16-bit BIN value in Var_D20 is converted to the floating-point real number, and the result is stored to Var_D0. [Structured ladder] [ST] FLTP(SM400,Var_D20,Var_D0); [Operation] Integer Var_D20 Var_D0 conversion 15923 15923 BIN value Floating-point type real number...
  • Page 236: 32-Bit Bin Data To Floating-Point Data Conversion (Double Precision)

    FLTD, DFLTD 6.3.4 16-/32-bit BIN data to floating-point data conversion (double precision) FLTD, DFLTD High Universal Performance FLTD(P) P: Executing condition DFLTD(P) indicates any of the following instructions. Structured ladder FLTD FLTDP FLTD DFLTD DFLTDP ENO:= (EN, s, d); FLTD Input argument, Executing condition : Bit...
  • Page 237 FLTD, DFLTD DFLTD(P) (1) Converts 32-bit BIN data specified for to a 64-bit floating-point real number, and stores the result to Upper 16 bits Lower 16 bits BIN 32 bits 64-bit floating-point real number (2) BIN values between 2147483648 and 2147483647 can be specified for + 1.
  • Page 238 FLTD, DFLTD (2) In the following program, the 32-bit BIN value in Var_D20 is converted to the 64-bit floating- point real number, and the result is stored to Var_D0. [Structured ladder] [ST] DFLTDP(SM400,Var_D20L,Var_D0); [Operation] Real number Var_D20 Var_D0 conversion 16543521 16543521 BIN value 64-bit floating-point...
  • Page 239 INT, DINT 6.3.5 Floating-point data to 16-/32-bit BIN data conversion (single precision) INT, DINT High Universal Performance INT(P) P: Executing condition DINT(P) indicates any of the following instructions. Structured ladder INTP DINT DINTP ENO:= (EN, s, d); Input argument, Executing condition : Bit Floating-point data to be converted to BIN value : ANY32, single-precision real...
  • Page 240 INT, DINT DINT(P) (1) Converts the floating-point real number specified for to 32-bit BIN data, and stores the result to the device specified for Upper 16 bits Lower 16 bits BIN 32 bits Floating-point real number (2) Floating-point real numbers between 2147483648 and 2147483647 can be specified for (3) The integer value stored in is stored as BIN 32 bits.
  • Page 241: Floating-Point Data To 16-/32-Bit Bin Data Conversion (Single Precision)

    INT, DINT [ST] INTP(SM400,Var_D20,Var_D0); [Operation] Integer Var_D20 Var_D0 conversion  25915.6796   25916 Floating-point real BIN value number Integer Var_D20 conversion 33562.3211 An operation error occurs Floating-point real since the value of setting data number is smaller than -32768. (2) In the following program, the floating-point real number in Var_D20 is converted to the 32-bit BIN value, and the result is stored to Var_D0.
  • Page 242: Floating-Point Data To 16-Bit/32-Bit Bin Data Conversion (Double Precision)

    INTD, DINTD 6.3.6 Floating-point data to 16-bit/32-bit BIN data conversion (double precision) INTD, DINTD High Universal Performance INTD(P) P: Executing condition DINTD(P) indicates any of the following instructions. Structured ladder INTD INTDP INTD DINTD DINTDP ENO:= (EN, s, d); INTD Input argument, Executing condition : Bit...
  • Page 243 INTD, DINTD DINTD(P) (1) Converts the 64-bit floating-point real number specified for to 32-bit BIN data, and stores the result to Upper 16 bits Lower 16 bits 64-bit floating-point BIN 32 bits real number (2) 64-bit floating-point real numbers between 2147483648.0 and 2147483647.0 can be specified for + 3,...
  • Page 244 INTD, DINTD Program Example (1) In the following program, the 64-bit floating-point real number in Var_D20 is converted to the 16-bit BIN value, and the result is stored to Var_D0. [Structured ladder] [ST] INTDP(SM400,Var_D20,Var_D0); [Operation] Integer Var_D20 Var_D0 conversion 25915.6796 25916 BIN value 64-bit floating-point...
  • Page 245: 16-Bit Bin Data To 32-Bit Bin Data Conversion

    6.3.7 16-bit BIN data to 32-bit BIN data conversion High Universal Performance DBL(P) P: Executing condition indicates any of the following instructions. Structured ladder DBLP ENO:= (EN, s, d); Input argument, Executing condition : Bit 16-bit BIN data, or start number of the device that stores 16-bit : ANY16 BIN data Output argument,...
  • Page 246 Program Example In the following program, the 16-bit BIN value in Var_D100 is converted to the 32-bit BIN value when X20 turns ON, and the result is stored to Var_R100. [Structured ladder] [ST] DBLP(X20,Var_D100,Var_R100); [Operation] Var_D100 Var_R100 FB2E FFFFFB2E ( 1234) ( 1234) 6.3 Data Conversion Instructions 6-84...
  • Page 247: 32-Bit Bin Data To 16-Bit Bin Data Conversion

    WORD 6.3.8 32-bit BIN data to 16-bit BIN data conversion WORD High Universal Performance WORD(P) P: Executing condition indicates any of the following instructions. Structured ladder WORD WORDP WORD ENO:= (EN, s, d); WORD Input argument, Executing condition : Bit 32-bit BIN data : ANY32 Output argument,...
  • Page 248 WORD Program Example In the following program, the 32-bit BIN value in Var_R100 is converted to the 16-bit BIN value when X20 turns ON, and the result is stored to Var_D100. [Structured ladder] [ST] WORDP(X20,Var_R100,Var_D100); [Operation] Var_R100 Var_D100 FFFF8253 8253 ( 32173) ( 32173) 6.3 Data Conversion Instructions...
  • Page 249: 16-/32-Bit Bin Data To Gray Code Conversion

    GRY, DGRY 6.3.9 16-/32-bit BIN data to Gray code conversion GRY, DGRY High Universal Performance GRY(P) P: Executing condition DGRY(P) indicates any of the following instructions. Structured ladder GRYP DGRY DGRYP ENO:= (EN, s, d); Input argument, Executing condition : Bit BIN data : ANY16/32 Output argument,...
  • Page 250 GRY, DGRY DGRY(P) Converts 32-bit BIN data in the device specified for to Gray code, and stores the result to the device specified for Negative values cannot be specified for (Upper 16 bits) (Lower 16 bits) 305419896 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 Gray code 305419896 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1 0 1 0 0 0 1 0 0 Operation Error...
  • Page 251: Gray Code To 16-/32-Bit Bin Data Conversion

    GBIN, DGBIN 6.3.10 Gray code to 16-/32-bit BIN data conversion GBIN, DGBIN High Universal Performance GBIN(P) P: Executing condition DGBIN(P) indicates any of the following instructions. Structured ladder GBIN GBINP GBIN DGBIN DGBINP ENO:= (EN, s, d); GBIN Input argument, Executing condition : Bit Gray code data...
  • Page 252 GBIN, DGBIN DGBIN(P) Converts Gray code data in the device specified for to 32-bit BIN data and stores the result to the device specified for Values between 0 and 2147483647 can be specified for (Upper 16 bits) (Lower 16 bits) Gray code 305419896 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1 0 1 0 0 0 1 0 0 305419896...
  • Page 253 NEG, DNEG 6.3.11 Two’s complement of 16-/32-bit BIN data (sign inversion) NEG, DNEG High Universal Performance NEG(P) P: Executing condition DNEG(P) indicates any of the following instructions. Structured ladder NEGP DNEG DNEGP ENO:= (EN, d); Input argument, Executing condition : Bit Output argument, ENO: Execution result...
  • Page 254: Two's Complement Of 16-/32-Bit Bin Data (Sign Inversion)

    NEG, DNEG DNEG(P) (1) Inverts the sign of the 32-bit device specified for and stores the result to the device specified for 32 bit Before execution -218460 Sign conversion - After 218460 execution (2) This instruction is used when inverting positive and negative signs. Operation Error No operation error occurs in the execution of the NEG(P) and DNEG(P) instructions.
  • Page 255: Sign Inversion Of Floating-Point Data (Single Precision)

    ENEG 6.3.12 Sign inversion of floating-point data (single precision) ENEG High Universal Performance ENEG(P) P: Executing condition indicates any of the following instructions. Structured ladder ENEG ENEGP ENEG ENO:= (EN, d); ENEG Input argument, Executing condition : Bit Output argument, ENO: Execution result : Bit...
  • Page 256 ENEG Program Example In the following program, the sign of the floating-point real number in Var_D100 is inverted when X20 turns ON, and the result is stored to Var_D100. [Structured ladder] [ST] ENEGP(X20,Var_D100); [Operation] Var_D100 Var_D100 1.2345 1.2345 6.3 Data Conversion Instructions 6-94 6.3.12 Sign inversion of floating-point data (single precision)
  • Page 257: Sign Inversion Of Floating-Point Data (Double Precision)

    EDNEG 6.3.13 Sign inversion of floating-point data (double precision) EDNEG High Universal Performance EDNEG(P) P: Executing condition indicates any of the following instructions. Structured ladder EDNEG EDNEGP EDNEG ENO:= (EN, d); EDNEG Input argument, Executing condition : Bit Output argument, ENO: Execution result : Bit...
  • Page 258 EDNEG Program Example In the following program, the sign of the 64-bit floating-point real number in Var_D0 is inverted when X20 turns ON, and the result is stored to Var_D0. [Structured ladder] [ST] ENEGP(X20,Var_D0); [Operation] Var_D100 Var_D100 1.2345 1.2345 6.3 Data Conversion Instructions 6-96 6.3.13 Sign inversion of floating-point data (double precision)
  • Page 259 BKBCD 6.3.14 16-bit BIN block data to 4-digit BCD block data conversion BKBCD High Universal Performance BKBCD(P) P: Executing condition indicates any of the following instructions. Structured ladder BKBCD BKBCDP BKBCD ENO:= (EN, s, n, d); BKBCD Input argument, Executing condition : Bit Start number of the device that stores BIN data : ANY16...
  • Page 260: 6.3.14 16-Bit Bin Block Data To 4-Digit Bcd Block Data Conversion

    BKBCD Function (1) Converts the BIN data (0 to 9999) n points from the device specified for to the BCD data, and stores the results to the device specified for and the following devices. Must always be "0". BIN 1234 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0 BIN 5678 0 0 1 0 1 1 0 0 0 1 0 1 1 1 0...
  • Page 261 BKBCD Program Example In the following program, the BIN values in D100 to D102 are converted to the BCD values when X20 turns ON, and the results are stored to D200 and the following devices. [Structured ladder] [ST] Var_D0:=3; BKBCDP(X20,D100,Var_D0,D200); [Operation] D100 BIN 5432 0 0 0 1 0 1 0 1 0 0 1 1 1 0 0 0...
  • Page 262 BKBIN 6.3.15 4-digit BCD block data to 16-bit BIN block data conversion BKBIN High Universal Performance BKBIN(P) P: Executing condition indicates any of the following instructions. Structured ladder BKBIN BKBINP BKBIN ENO:= (EN, s, n, d); BKBIN Input argument, Executing condition : Bit Start number of the device that stores BCD data : ANY16...
  • Page 263 BKBIN Function (1) Converts the BCD data (0 to 9999) n points from the device specified for to the BIN data, and stores the results to the device specified for and the following devices. BCD 1234 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 BCD 5678 BCD 1545...
  • Page 264: 6.3.15 4-Digit Bcd Block Data To 16-Bit Bin Block Data Conversion

    BKBIN Program Example In the following program, the BCD values in D100 to D102 are converted to the BIN values when X20 turns ON, and the results are stored to D200 and the following devices. [Structured ladder] [ST] Var_D0:=3; BKBINP(X20,D100,Var_D0,D200); [Operation] D100 BCD 8080 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0...
  • Page 265: Single-Precision To Double-Precision Conversion

    ECON 6.3.16 Single-precision to double-precision conversion ECON High Performance Universal ECON(P) P: Executing condition indicates any of the following instructions. Structured ladder ECON ECONP ECON ENO:= (EN, s, d); ECON Input Executing condition :Bit argument, Conversion source data :Single-precision real Output ENO: Execution result...
  • Page 266 ECON Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 267: Double-Precision To Single-Precision Conversion

    EDCON 6.3.17 Double-precision to single-precision conversion EDCON High Performance Universal EDCON(P) P: Executing condition indicates any of the following instructions. Structured ladder EDCON EDCONP EDCON ENO:= (EN, s, d); EDCON Input Executing condition :Bit argument, Conversion source data :Double-precision real Output ENO: Execution result...
  • Page 268 EDCON Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 269: Data Transfer Instructions

    MOV, DMOV Data Transfer Instructions 6.4.1 16-/32-bit data transfer MOV, DMOV High Universal Performance MOV(P) P: Executing condition DMOV(P) indicates any of the following instructions. Structured ladder MOVP DMOV DMOVP ENO:= (EN, s, d); Input argument, Executing condition : Bit Data to be transferred : ANY16/32 Output argument,...
  • Page 270 MOV, DMOV DMOV(P) Transfers the 32-bit data in the device specified for to the device specified for Before transfer Transfer After transfer Operation Error No operation error occurs in the execution of the MOV(P) and DMOV(P) instruction. Program Example (1) In the following program, the input data in the devices from X0 to XB are transferred to Var_D8.
  • Page 271 MOV, DMOV (4) In the following program, the data in the devices from X0 to X1F are transferred to Var_D0. [Structured ladder] [ST] DMOVP(SM400,K8X0,Var_D0); 6.4 Data Transfer Instructions 6-109 6.4.1 16-/32-bit data transfer...
  • Page 272: Floating-Point Data Transfer (Single Precision)

    EMOV(P) 6.4.2 Floating-point data transfer (single precision) EMOV(P) High Universal Performance EMOV(P) P: Executing condition indicates any of the following instructions. Structured ladder EMOV EMOVP EMOV ENO:= (EN, s, d); EMOV Input argument, Executing condition : Bit Data to be transferred : Single-precision real Output argument, ENO:...
  • Page 273 EMOV(P) Program Example (1) In the following program, the real number in Var_D10 is transferred to Var_D0. [Structured ladder] [ST] EMOVP(SM400,Var_D10,Var_D0); [Operation] Var_D10 Var_D0 36.475 36.475 (2) In the following program, the real number 1.23 is transferred to Var_D10 when X8 turns [Structured ladder] [ST] EMOVP(X8,−1.23,Var_D10);...
  • Page 274: Floating-Point Data Transfer (Double Precision)

    EDMOV 6.4.3 Floating-point data transfer (double precision) EDMOV High Universal Performance EDMOV(P) P: Executing condition indicates any of the following instructions. Structured ladder EDMOV EDMOVP EDMOV ENO:= (EN, s, d); EDMOV Input argument, Executing condition : Bit Data to be transferred : Double-precision real Output argument, ENO:...
  • Page 275 EDMOV Program Example (1) In the following program, the 64-bit floating-point real number in Var_D10 is transferred to Var_D0. [Structured ladder] [ST] EDMOVP(SM400,Var_D10,Var_D0); [Operation] Var_D10 Var_D0 36.475 36.475 (2) In the following program, the real number 1.23 is transferred to Var_D10 when X8 turns [Structured ladder] [ST] EDMOVP(X8,−1.23,Var_D10);...
  • Page 276 $MOV 6.4.4 Character string data transfer $MOV High Universal Performance $MOV(P) P: Executing condition indicates any of the following instructions. Structured ladder $MOV $MOVP $MOV Not supported Input argument, Executing condition : Bit Character string data to be transferred (Maximum string : String length: 16 characters for QnA/Q4AR;...
  • Page 277: 6.4.4 Character String Data Transfer

    $MOV (2) Processing will be performed without error even in cases where the range for the devices storing the character string data to be transferred ( +n) overlaps with the range of the devices which will store the character string data after it has been transferred ( +n).
  • Page 278 $MOV (2) In the following program, the character string "ABCD" is transferred to Var_D20 when X0 turns ON. [Structured ladder] 6.4 Data Transfer Instructions 6-116 6.4.4 Character string data transfer...
  • Page 279: 32-Bit Data Negation Transfer

    CML, DCML 6.4.5 16-/32-bit data negation transfer CML, DCML High Universal Performance CML(P) P: Executing condition DCML(P) indicates any of the following instructions. Structured ladder CMLP DCML DCMLP ENO:= (EN, s, d); Input argument, Executing condition : Bit Data to be inverted : ANY16/32 Output argument, ENO:...
  • Page 280 CML, DCML DCML(P) Inverts 32-bit data specified for bit by bit, and transfers the result to the device specified for Before execution Inverse After execution Operation Error No operation error occurs in the execution of the CML(P) and DCML(P) instruction. Program Example (1) In the following program, the data in the devices from X0 to X7 are inverted, and the results are transferred to Var_D0.
  • Page 281 CML, DCML (2) In the following program, the data in the devices from M16 to M23 are inverted, and the results are transferred to the devices from Y40 to Y47. [Structured ladder] [ST] CML(SM402,K2M16,K3Y40); [Operation] If the number of bits of is smaller than the number of bits of These bits are all regarded as 0.
  • Page 282 CML, DCML (4) In the following program, the data in the devices from X0 to X1F are inverted, and the results are transferred to Var_D0. [Structured ladder] [ST] DCML(SM402,K8X0,Var_D0); [Operation] If the number of bits of is smaller than the number of bits of X8 X7 These bits are all regarded as 0.
  • Page 283 CML, DCML (6) In the following program, the data in Var_D0 are inverted when X3 turns ON, and the result is transferred to Var_D16. [Structured ladder] [ST] DCMLP(X3,Var_D0,Var_D16); [Operation] 0 1 0 0 1 1 1 Var_D0 Var_ D16 1 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1 6.4 Data Transfer Instructions 6-121...
  • Page 284 BMOV 6.4.6 16-bit block data transfer BMOV High Universal Performance BMOV(P) P: Executing condition indicates any of the following instructions. Structured ladder BMOV BMOVP BMOV ENO:= (EN, s, n, d); BMOV Input argument, Executing condition : Bit Start number of the device that stores data to be transferred : ANY16 Number of transfers : ANY16...
  • Page 285 BMOV (2) Transfers can be accomplished even in cases where there is an overlap between the source and destination device. In the case of transmission to the smaller device number, transmission is from ; for transmission to the larger device number, transmission is from + (n 1).
  • Page 286: 6.4.6 16-Bit Block Data Transfer

    BMOV (6) Selecting the execution of the device range check Whether to disable or enable the device range check at the execution of the BMOV instruction can be selected by the device range check disable flag (SM237). (Only when the subset condition is satisfied) The device range check for the devices (n-1) and...
  • Page 287 BMOV (2) In the following program, the data in the devices from X20 to X2F are transferred to the devices from D100 to D103 in units of 4 points. [Structured ladder] [ST] BMOVP(SM402,K1X20,4,D100); [Operation] Before execution 0 1 1 1 0 1 1 0 0 1 0 0 After execution (destination of transfer)
  • Page 288 FMOV 6.4.7 Identical 16-bit block data transfer FMOV High Universal Performance FMOV(P) P: Executing condition indicates any of the following instructions. Structured ladder FMOV FMOVP FMOV ENO:= (EN, s, n, d); FMOV Input argument, Executing condition : Bit Data to be transferred, or start number of the device that : ANY16 stores data to be transferred Number of transfers...
  • Page 289 FMOV (2) In cases where specifies a word device and a bit device, the number of bits specified by digit specification for the bit device will be the target bits for the word device. If K1Y30 has been specified for , the lower 4 bits of the word device specified for will become the target.
  • Page 290: 6.4.7 Identical 16-Bit Block Data Transfer

    FMOV Program Example (1) In the following program, the lower 4-bit data in D0 are transferred to the devices from Y10 to Y23 in units of 4 bits when X0A turns ON. [Structured ladder] [ST] FMOVP(X0A,D0,5,K1Y10); [Operation] b2 b1 1 0 1 1 1 0 0 1 1 0 1 1 Y13 to Y10...
  • Page 291: 32-Bit Data Exchange

    XCH, DXCH 6.4.8 16-/32-bit data exchange XCH, DXCH High Universal Performance XCH(P) P: Executing condition DXCH(P) indicates any of the following instructions. Structured ladder XCHP DXCH DXCHP ENO:= (EN, d1, d2); Input argument, Executing condition : Bit Output argument, ENO: Execution result : Bit Data to be exchanged...
  • Page 292 XCH, DXCH DXCH(P) Exchanges the 32-bit data between Before execution 1 1 1 0 0 0 0 1 1 1 1 1 1 1 After execution 1 1 1 1 1 1 1 1 1 1 0 0 0 0 Operation Error No operation error occurs in the execution of the XCH(P) and DXCH(P) instruction.
  • Page 293 XCH, DXCH (3) In the following program, the data in Var_D0 and the data in the devices from M16 to M47 are exchanged when X10 turns ON. [Structured ladder] [ST] DXCHP(X10,Var_D0,K8M16); (4) In the following program, the data in Var_D0 and the data in Var_D9 are exchanged when M0 turns ON.
  • Page 294 BXCH 6.4.9 16-bit block data exchange BXCH High Universal Performance BXCH(P) P: Executing condition indicates any of the following instructions. Structured ladder BXCH BXCHP BXCH ENO:= (EN, n, d1, d2); BXCH Input argument, Executing condition : Bit Number of exchanges : ANY16 Output argument, ENO:...
  • Page 295: 6.4.9 16-Bit Block Data Exchange

    BXCH Function Exchanges the 16-bit data n points from the device specified for and the 16-bit data n points from the device specified for 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1...
  • Page 296 BXCH Program Example In the following program, the data 3 points from D200 and the data 3 points from R0 are exchanged when X1C turns ON. [Structured ladder] [ST] BXCHP(X1C,3,D200,R0); [Operation] D200 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 D201 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0...
  • Page 297: Upper And Lower Bytes Exchange

    SWAP 6.4.10 Upper and lower bytes exchange SWAP High Universal Performance SWAP(P) P: Executing condition indicates any of the following instructions. Structured ladder SWAP SWAPP SWAP ENO:= (EN, s); SWAP Input argument, Executing condition : Bit Start number of the device that stores data to be exchanged : ANY16 Output argument, ENO:...
  • Page 298 SWAP Program Example In the following program, the higher 8 bits and the lower 8 bits in R10 are exchanged when X10 turns ON. [Structured ladder] [ST] SWAPP(X10,Var_R10); [Operation] Var_R10 0 0 0 0 1 1 1 1 1 1 1 1 Var_R10 6.4 Data Transfer Instructions 6-136...
  • Page 299: Program Branch Instructions

    CJ, SCJ, JMP Program Branch Instructions 6.5.1 Pointer branch instructions CJ, SCJ, JMP High Universal Performance indicates any of the following instructions. Structured ladder Not supported Input argument, Executing condition : Bit Network label of the jump destination : ANY16 Output argument, ENO: Execution result...
  • Page 300 CJ, SCJ, JMP (1) Executes the program of the specified network label within the same POU from the next scan after the execution command turns from OFF to ON. (2) Executes the program in the next step when the execution command is OFF or turns from ON to OFF.
  • Page 301 CJ, SCJ, JMP Operation Error No operation error occurs in the execution of the CJ, SCJ, and JMP instructions. Program Example (1) The following program jumps to Label3 when X9 turns ON. [Structured ladder] (2) The following program jumps to Label3 from the next scan after X9 is turned ON. [Structured ladder] 6.5 Program Branch Instructions 6-139...
  • Page 302: Jump To End

    GOEND 6.5.2 Jump to END GOEND High Universal Performance GOEND indicates the following instruction. GOEND Structured ladder ENO:= (EN); GOEND GOEND Input argument, Executing condition : Bit Output argument, ENO: Execution result : Bit Internal device Setting R, ZR Constant Others data Word...
  • Page 303 GOEND Program Example The following program jumps to the END when the value of Var_D0 is a negative number. [Structured ladder] [ST] GOEND(Var_D0<0); 6.5 Program Branch Instructions 6-141 6.5.2 Jump to END...
  • Page 304: Program Execution Control Instructions

    DI, EI, IMASK Program Execution Control Instructions 6.6.1 Interrupt disable/enable instructions, interrupt program mask DI, EI, IMASK High Universal Performance IMASK indicates any of the following instructions. Structured ladder ENO:= (EN); IMASK ENO:= (EN, s); IMASK Input argument, Executing condition : Bit Interrupt mask data (when using the IMASK instruction) : Array of ANY16 (0..15)
  • Page 305: 6.6.1 Interrupt Disable/Enable Instructions, Interrupt Program Mask

    DI, EI, IMASK Releases the disable interrupt status of the DI instruction, and enables the execution of the interrupt program with the interrupt pointer number which is allowed by the IMASK instruction and the fixed cycle execution type program. When the IMASK instruction is not executed, I32 to I47 are disabled. Sequence program Even when the interrupt factor is occurred in the DI to EI instruction loop, the interrupt program is set on hold until...
  • Page 306 DI, EI, IMASK 1. For information on interrupt conditions, refer to the following manual. • QCPU User's Manual (Functions Explanation, Program Fundamentals) 2. The DI status (interrupt disabled) is active during the execution of an interrupt program. Do not insert the EI instructions in interrupt programs to attempt the execution of multiple interrupts, with interrupt programs running inside interrupt programs.
  • Page 307 DI, EI, IMASK Program Example In the following program, the interrupt programs with the interrupt pointer number I1 and I3 are set in the enable execution status while X0 is ON. [Structured ladder] Task_01 [Always] ... interrupt enable program The FEND instruction is not required. Task_Interrupt No.
  • Page 308 DI, EI, IMASK [ST] Task_01 [Always] ... interrupt enable program IF X0=FALSE THEN DI(TRUE); IF X0 THEN MOVP(TRUE,H0A,Var_D10[0]); MOVP(TRUE,0,Var_D10[1]); MOVP(TRUE,0,Var_D10[2]); END_IF; IMASK(TRUE,Var_D10); EI(TRUE); OUT(M0=FALSE,Y20); END_IF; Task_Interrupt No. 1 [Event] ... I1 interrupt enable program MOVP(M10,10,Var_D100); Task_Interrupt No. 3 [Event] ... I3 interrupt enable program IF M11 THEN Var_D200 := Var_D100 + Var_D200;...
  • Page 309: Recovery From Interrupt Programs

    IRET 6.6.2 Recovery from interrupt programs IRET High Universal Performance IRET indicates the following instruction. Structured ladder IRET IRET ENO:= (EN); IRET Input argument, Executing condition : Bit Output argument, ENO: Execution result : Bit Internal device Setting R, ZR Constant Others data...
  • Page 310 IRET Program Example In the following program, 1 is added to Var_D0 if M0 is ON when the interrupt of No.3 occurs. [Structured ladder] Task_01 [Always] ... interrupt enable program The FEND instruction is not required for interrupt programs. Task_Interrupt No. 3 [Event] ... interrupt enable program The IRET instruction is not required for interrupt programs.
  • Page 311 IRET For interrupt programs, create multiple tasks to register interrupt enable programs and interrupt programs. Interrupt enable program ..............Interrupt program Task_Interrupt No. 3 [Always] to [Event] ... Change to a interrupt program. [Property setting] Enter the device I3. 6.6 Program Execution Control Instructions 6-149 6.6.2 Recovery from interrupt programs...
  • Page 312: I/O Refresh Instructions 6.7.1 I/O Refresh

    I/O Refresh Instructions 6.7.1 I/O refresh High Universal Performance RFS(P) P: Executing condition indicates any of the following instructions. Structured ladder RFSP ENO:= (EN, s, n); Input argument, Executing condition : Bit Start number of the device that executes the refresh function : Bit Number of refreshes : ANY16 Output argument,...
  • Page 313 (3) Use direct access inputs (DX) or direct access outputs (DY) to refresh inputs (X) or outputs (Y) in units of 1 point. [Program based on the RFS instruction] Refreshes X0. Refreshes Y20. [Program based on direct access input and direct access output] Direct access input Direct access output Operation Error...
  • Page 314: Other Convenient Instructions

    UDCNT1 Other Convenient Instructions 6.8.1 Single-phase input up/down counter UDCNT1 High Universal Performance UDCNT1 indicates the following instruction. UDCNT1 Structured ladder UDCNT1 ENO:= (EN,s, n, d); UDCNT1 Input argument, Executing condition : Bit s+0:Input number for the counter input : Array of bit (0..1) s+1:For setting the up/down counter •...
  • Page 315 UDCNT1 (3) Count processing is conducted as described below. • When the count is going up, the counter contact specified for turns ON when the current value becomes identical with the setting value specified for n. However, the current value count will continue even when the contact of the counter specified for turns ON.
  • Page 316 UDCNT1 Program Example In the following program, the number of turns from OFF to ON in Var_X0 are counted using C0 (up/down counter) after X20 has turned ON. [Structured ladder] [ST] UDCNT1(X20,Var_X0,5,C0); [Operation] Var_X0 Down C0 current value 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0 1 2 3 2 1 0 - - - - - C0 contact 6.8 Other Convenient Instructions...
  • Page 317: Two-Phase Input Up/Down Counter

    UDCNT2 6.8.2 Two-phase input up/down counter UDCNT2 High Universal Performance UDCNT2 indicates the following instruction. UDCNT2 Structured ladder UDCNT2 ENO:= (EN,s, n, d); UDCNT2 Input argument, Executing condition : Bit s+0:Input number for the counter input (A-phase pulse) : Array of bit (0..1) s+1:Input number for the counter input (B-phase pulse) Set value : ANY16...
  • Page 318 UDCNT2 (3) Count processing is conducted as described below. • When the count is going up, the counter contact specified for turns ON when the current value becomes identical with the setting value specified for n. However, the current value count will continue even when the contact of the counter specified for turns ON.
  • Page 319 UDCNT2 Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The device specified for exceeds the corresponding device range. (For Universal model QCPU only) (Error code: 4101) Program Example In the following program, the status of Var_X0 and Var_X0+1 are counted by C0 (up/down...
  • Page 320: Teaching Timer

    TTMR 6.8.3 Teaching timer TTMR High Universal Performance TTMR indicates the following instruction. TTMR Structured ladder TTMR ENO:= (EN, n, d); TTMR Input argument, Executing condition : Bit Multiplier of the measurement value : ANY16 Output argument, ENO: Execution result : Bit d+0:Measurement value storage device : Array of ANY16 (0..1)
  • Page 321 TTMR 1. Time measurements are conducted when the TTMR instruction is executed. Using the JMP or similar instruction to jump the TTMR instruction will make it impossible to get an accurate measurement. 2. Do not change the multiplier specified for n while the TTMR instruction is being executed.
  • Page 322: Special Function Timer

    STMR 6.8.4 Special function timer STMR High Universal Performance STMR indicates the following instruction. STMR Structured ladder STMR ENO:= (EN,s, n, d); STMR Input argument, Executing condition : Bit Timer number : ANY16 Set value : ANY16 Output argument, ENO: Execution result : Bit d[0]:Off-delay timer output...
  • Page 323 STMR • ON-delay and OFF-delay timer output ( Turns ON at the falling pulse of the timer coil, and after the falling pulse command of the STMR instruction, turns OFF when the amount of time specified for n has passed. (2) The timer coil specified for turns ON at the rising pulse and falling pulse command of the STMR instruction, and starts measurement of the current value.
  • Page 324 STMR Program Example In the following program, Y0 and Y1 are turned ON and OFF every second (flicker) when X20 turns ON. (Uses 100ms timer) [Structured ladder] [ST] STMR(X20 AND NOT(Var_M0[3]),T0,10,Var_M0); OUT(Var_M0[1],Y0); OUT(Var_M0[2],Y1); [Timing chart] Var_M0[1],Y0 Var_M0[2],Y1 Var_M0[3] 1 sec 1 sec 6.8 Other Convenient Instructions 6-162...
  • Page 325 ROTC 6.8.5 Rotary table shortest direction control ROTC High Universal Performance ROTC indicates the following instruction. Structured ladder ROTC ROTC ENO:= (EN, s, n1, n2, d); ROTC Input argument, Executing condition : Bit s+0:For measuring the number of table rotations : Array of ANY16 (0..2) s+1:Call station number s+2:Call item number...
  • Page 326 ROTC (3) The system uses [0] as a counter to instruct it as to what item is at which number counting from station number 0. Do not rewrite the sequence program data. Accurate controls will not be possible in cases where users have rewritten the data. (4) The value of n2 should be less than the number of table divisions that were specified for n1.
  • Page 327: 6.8.5 Rotary Table Shortest Direction Control

    ROTC Program Example In the following program, item at section Var_D0[2] on a 10-division rotary table is taken in and out at section Var_D0[1], and the rotation direction and the control speed of the motor are determined by two sections ahead and behind of the item when the table is rotated at low speed. [Structured ladder] [ST] OUT(X20,Var_M0[0]);...
  • Page 328: Ramp Signal

    RAMP 6.8.6 Ramp signal RAMP High Universal Performance RAMP indicates the following instruction. Structured ladder RAMP RAMP ENO:= (EN, n1, n2, ,n3, d1, d2); RAMP Input argument, Executing condition : Bit Initial value : ANY16 Final value : ANY16 Number of transitions : ANY16 Output argument, ENO:...
  • Page 329 RAMP Example 0 is varied to 350 in seven scans as shown below. Value stored in + 0 (Present value) Value specified by n2 (350) Value specified by n1 (0) Value stored in (Number of execution times) Number of shifts (7) specified by n3 When the calculated one variation is indivisible, compensation is made to achieve the value specified for n2 by the number of shifts specified for n3.
  • Page 330 RAMP [ST] IF X0 THEN SET(TRUE,Var_M0[1]); RAMP(TRUE,10,100,6,Var_D0,Var_M0); END_IF; [Timing chart] Var_D0[0] Var_D0[1] 1 scan 1 scan 1 scan 1 scan 1 scan Var_M0[0] Var_M0[1] 6.8 Other Convenient Instructions 6-168 6.8.6 Ramp signal...
  • Page 331: Pulse Density Measurement

    6.8.7 Pulse density measurement High Universal Performance indicates the following instruction. Structured ladder ENO:= (EN, s, n, d); Input argument, Executing condition : Bit Pulse input : Bit Measurement time (unit: ms) : ANY16 Output argument, ENO: Execution result : Bit Start number of the device that stores the measurement result : ANY16 Internal device Setting...
  • Page 332 (2) When the measurement directed by the SPD instruction has been completed, the measurement is executed again from 0. Turn OFF the execution command to stop the measurement directed by the SPD instruction. 1. With the SPD instruction, the argument device data are registered in the work area of the CPU module and counting operation is processed as a system interrupt.
  • Page 333: Fixed Cycle Pulse Output

    PLSY 6.8.8 Fixed cycle pulse output PLSY High Universal Performance PLSY indicates the following instruction. PLSY Structured ladder PLSY ENO:= (EN, n1, n2, d); PLSY Input argument, Executing condition : Bit Frequency, or device number that stores frequency : ANY16 Output counts, or device number that stores output counts : ANY16 Output argument,...
  • Page 334 PLSY 1. With the PLSY instruction, the argument device data are registered in the work area of the CPU module and counting operation is processed as a system interrupt. (The device data registered in the work area is cleared by turning the execution command OFF, or turning the STOP/RUN switch from STOP to RUN.) For this reason, the pulses that can be counted must have longer ON and OFF times than the interrupt interval of the CPU module.
  • Page 335: Pulse Width Modulation

    6.8.9 Pulse width modulation High Universal Performance indicates the following instruction. Structured ladder ENO:= (EN, n1, n2, d); Input argument, Executing condition : Bit ON-time, or device number that stores ON-times : ANY16 Cycle, or device number that stores cycles : ANY16 Output argument, ENO:...
  • Page 336 Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The device specified for exceeds the corresponding device range. (For Universal model QCPU only) (Error code: 4101) 1.
  • Page 337: Matrix Input

    6.8.10 Matrix input High Universal Performance indicates the following instruction. Structured ladder ENO:= (EN,s, n, d1, d2); Input argument, Executing condition : Bit Start device for data input : Bit Number of input rows : ANY16 Output argument, ENO: Execution result : Bit Start device for data output : Bit...
  • Page 338 (7) For n, a value in the range from 2 to 8 can be assigned. (8) No processing is performed in any of the following cases. • The device number specified for , or is not a multiple of 16. •...
  • Page 339 Caution (1) Note that the MTR instruction directly operates on actual input and output. The output that had been turned ON by the MTR instruction does not turn OFF when the MTR command turns OFF. Turn OFF the specified output in the sequence program.
  • Page 340 MEMO 6-178...
  • Page 341 APPLICATION INSTRUCTIONS Logical Operation Instructions ........7-2 Rotation Instructions .
  • Page 342: Logical Operation Instructions

    Logical Operation Instructions (1) The logical operation instructions perform logical OR, logical AND or other logical operations in unit of 1 bit. Example Formula for Operation Description Operation Logical AND A bit is set to 1 only when both input A A / B (AND) and input B are 1, otherwise set to 0...
  • Page 343 WAND, DAND 7.1.1 Logical AND operation on 16-/32-bit data WAND, DAND High Universal Performance WAND(P) P: Executing condition DAND(P) indicates any of the following instructions. Structured ladder WAND WANDP WAND DAND DANDP ENO:= (EN, s1, s2, d); WAND Input argument, Executing condition :Bit Data on which the logical AND operation is performed...
  • Page 344 WAND, DAND DAND(P) (1) Performs a logical AND operation on each bit of the 32-bit data for the device specified for and the 32-bit data for the device specified for , and stores the results to the device specified for (2) For bit devices, the operation is performed regarding the bit devices after the point of specified digit as 0.
  • Page 345: 7.1.1 Logical And Operation On 16-/32-Bit Data

    WAND, DAND (2) In the following program, the logical AND operation is performed on the data in Var_D10 and Var_D20 when X1C turns ON, and the results are stored to the devices from M0 to M11. [Structured ladder] [ST] WANDP(X1C,Var_D10,Var_D20,K3M0); [Operation] Var_D10 Var_D20...
  • Page 346 BKAND 7.1.2 Logical AND operation on block data BKAND High Universal Performance BKAND(P) P: Executing condition indicates any of the following Structured ladder instructions. BKAND BKAND BKANDP ENO:= (EN, s1, s2 , n, d); BKAND Input argument, Executing condition :Bit Start number of the device that stores data on which the logical :ANY16 AND operation is performed...
  • Page 347: 7.1.2 Logical And Operation On Block Data

    BKAND Function (1) Performs a logical AND operation on the data n points from the device specified for , and the data n points from the device specified for , and stores the results to the device specified for and the following devices. 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0...
  • Page 348 BKAND Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device.
  • Page 349: Logical Or Operation On 16-/32-Bit Data

    WOR, DOR 7.1.3 Logical OR operation on 16-/32-bit data WOR, DOR High Universal Performance WOR (P) P: Executing condition DOR (P) indicates any of the following instructions. Structured ladder WORP WOR_3_M DORP ENO:= (EN, s1, s2, d); ENO:= WOR_3_M (EN, s1, s2, d1); Input argument, Executing condition :Bit...
  • Page 350 WOR, DOR DOR(P) (1) Performs a logical OR operation on each bit of the 32-bit data of the device specified for and the 32-bit data of the device specified for , and stores the results to the device specified for (2) For bit devices, the operation is performed regarding the bit devices after the point of specified digit as 0.
  • Page 351 WOR, DOR (2) In the following program, the logical OR operation is performed on the 32-bit data in Var_D0, and the 24-bit data from X20 to X37 when M8 turns ON, and the results are stored to Var_D23. [Structured ladder] [ST] DORP(M8,Var_D0,K6X20,Var_D23);...
  • Page 352 BKOR 7.1.4 Logical OR operation on block data BKOR High Universal Performance BKOR(P) P: Executing condition indicates any of the following Structured ladder instructions. BKOR BKOR BKORP ENO:= (EN, s1, s2, n, d); BKOR Input argument, Executing condition :Bit Start number of the device that stores data on which the logical :ANY16 OR operation is performed Logical OR operation data, or start number of the device that...
  • Page 353: 7.1.4 Logical Or Operation On Block Data

    BKOR Function (1) Performs a logical OR operation on the data n points from the device specified for , and the data n points from the device specified for , and stores the results to the device specified for and the following devices. 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0...
  • Page 354 BKOR Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device.
  • Page 355 WXOR, DXOR 7.1.5 Exclusive OR operation on 16-/32-bit data WXOR, DXOR High Universal Performance WXOR(P) P: Executing condition DXOR(P) indicates any of the following instructions. Structured ladder WXOR WXORP WXOR DXOR DXORP ENO:= (EN, s1, s2, d); WXOR Input argument, Executing condition :Bit Data on which the exclusive OR operation is performed...
  • Page 356 WXOR, DXOR DXOR(P) (1) Performs an exclusive OR operation on each bit of the 32-bit data of the device specified for and the 32-bit data of the device specified for , and stores the results to the device specified for (2) For bit devices, the operation is performed regarding the bit devices after the point of specified digit as 0.
  • Page 357: 7.1.5 Exclusive Or Operation On 16-/32-Bit Data

    WXOR, DXOR (2) In the following program, the exclusive OR operation is performed on the data in Var_D20 and the data in Var_D30 when X10 turns ON, and the results are stored to Var_D40. [Structured ladder] [ST] DXORP(X10,Var_D20,Var_D30,Var_D40); [Operation] Var_D20 Var_D30 Var_D40 7.1 Logical Operation Instructions...
  • Page 358 BKXOR 7.1.6 Exclusive OR operation on block data BKXOR High Universal Performance BKXOR(P) P: Executing condition indicates any of the following Structured ladder instructions. BKXOR BKXOR BKXORP ENO:= (EN, s1, s2, n, d); BKXOR Input argument, Executing condition :Bit Start number of the device that stores data on which the :ANY16 exclusive OR operation is performed Exclusive OR operation data, or start number of the device...
  • Page 359: 7.1.6 Exclusive Or Operation On Block Data

    BKXOR Function (1) Performs an exclusive OR operation on the data n points from the device specified for and the data n points from the device specified for , and stores the results to the device specified for and the following devices. 0 0 1 1 0 0 1 1 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0...
  • Page 360 BKXOR Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device.
  • Page 361 WXNR, DXNR 7.1.7 Exclusive NOR operation on 16-/32-bit data WXNR, DXNR High Universal Performance WXNR(P) P: Executing condition DXNR(P) indicates any of the following instructions. Structured ladder WXNR WXNRP WXNR DXNR DXNRP ENO:= (EN, s1, s2, d); WXNR Input argument, Executing condition :Bit Data on which the exclusive NOR operation is performed...
  • Page 362 WXNR, DXNR DXNR(P) (1) Performs an exclusive NOR operation on the 32-bit data of the device specified for the 32-bit data of the device specified for , and stores the results to the device specified for (2) For bit devices, the operation is performed regarding the bit devices after the point of specified digit as 0.
  • Page 363: 7.1.7 Exclusive Nor Operation On 16-/32-Bit Data

    WXNR, DXNR (2) In the following program, the exclusive NOR operation is performed on the 32-bit data in Var_D20 and the data in Var_D10 when X10 turns ON, and the results are stored to Var_D40. [Structured ladder] [ST] DXNRP(X10,Var_D20,Var_D10,Var_D40); [Operation] Var_D20 Var_D10 Var_D40...
  • Page 364 BKXNR 7.1.8 Exclusive NOR operation on block data BKXNR High Universal Performance BKXNR(P) P: Executing condition indicates any of the following Structured ladder instructions. BKXNR BKXNR BKXNRP ENO:= (EN, s1, s2, n, d); BKXNR Input argument, Executing condition :Bit Start number of the device that stores data on which the :ANY16 exclusive NOR operation is performed Exclusive NOR operation data, or start number of the device...
  • Page 365: 7.1.8 Exclusive Nor Operation On Block Data

    BKXNR Function (1) Performs an exclusive NOR operation on the data n points from the device specified for and the data n points from the device specified for , and stores the results to the device specified for and the following devices. 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0...
  • Page 366 BKXNR Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device.
  • Page 367: Rotation Instructions

    ROR, RCR Rotation Instructions 7.2.1 Right rotation of 16-bit data ROR, RCR High Universal Performance ROR(P) P: Executing condition RCR(P) indicates any of the following instructions. Structured ladder RORP RCRP ENO:= (EN, n, d); Input argument, Executing condition :Bit Number of rotations (0 to 15) :ANY16 Output argument, ENO:...
  • Page 368 ROR, RCR Function ROR(P) (1) Rotates 16-bit data of the device specified for , not including the carry flag, n bits to the right. The carry flag is ON or OFF depending on the status prior to the execution of the ROR instruction.
  • Page 369 ROR, RCR (2) When a bit device is specified for , a rotation is performed within the device range set by digit specification. The number of bits that rotate is the remainder of n divided by ‘number of points by digit specification’.
  • Page 370: 7.2.1 Right Rotation Of 16-Bit Data

    ROR, RCR Operation Error No operation error occurs in the execution of the ROR(P) and RCR(P) instructions. Program Example (1) In the following program, the data in Var_D0 are rotated, not including the carry flag, 3 bits to the right, when X0C turns ON. [Structured ladder] [ST] RORP(X0C,3,Var_D0);...
  • Page 371: Left Rotation Of 16-Bit Data

    ROL, RCL 7.2.2 Left rotation of 16-bit data ROL, RCL High Universal Performance ROL(P) P: Executing condition RCL(P) indicates any of the following instructions. Structured ladder ROLP RCLP ENO:= (EN, n, d); Input argument, Executing condition :Bit Number of rotations (0 to 15) :ANY16 Output argument, ENO:...
  • Page 372 ROL, RCL Function ROL(P) (1) Rotates 16-bit data of the device specified for , not including the carry flag, n bits to the left. The carry flag turns ON or OFF depending on its status prior to the execution of the ROL instruction.
  • Page 373 ROL, RCL RCL(P) (1) Rotates 16-bit data of the device specified for , including the carry flag, n bits to the left. The carry flag turns ON or OFF depending on its status prior to the execution of the RCL instruction.
  • Page 374 ROL, RCL Operation Error No operation error occurs in the execution of the ROL(P) and RCL(P) instructions. Program Example (1) In the following program, the data in Var_D0 are rotated, not including the carry flag, 3 bits to the left, when X0C turns ON. [Structured ladder] [ST] ROLP(X0C,3,Var_D0);...
  • Page 375 DROR, DRCR 7.2.3 Right rotation of 32-bit data DROR, DRCR High Universal Performance DROR(P) P: Executing condition DRCR(P) indicates any of the following instructions. Structured ladder DROR DRORP DROR DRCR DRCRP ENO:= (EN, n, d); DROR Input argument, Executing condition :Bit Number of rotations (0 to 31) :ANY16...
  • Page 376 DROR, DRCR (3) Specify any of 0 to 31 for n. If the value specified for n is 32 or higher, the remainder of n divided by 32 is used for rotation. For example, when n 34, the remainder of 34 / 32 1 is 2, thus the data are rotated 2 bits to the right.
  • Page 377: 7.2.3 Right Rotation Of 32-Bit Data

    DROR, DRCR Program Example (1) In the following program, the data of Var_D0 are rotated, not including the carry flag, 4 bits to the right, when X0C turns ON. [Structured ladder] [ST] DRORP(X0C,4,Var_D0); [Operation] Carry flag (SM700) b28 b27 b24 b23 b20 b19 b12b11 b8 b7 b4 b3...
  • Page 378: Left Rotation Of 32-Bit Data

    DROL, DRCL 7.2.4 Left rotation of 32-bit data DROL, DRCL High Universal Performance DROL(P) P: Executing condition DRCL(P) indicates any of the following instructions. Structured ladder DROL DROLP DROL DRCL DRCLP ENO:= (EN, n, d); DROL Input argument, Executing condition :Bit Number of rotations (0 to 31) :ANY16...
  • Page 379 DROL, DRCL (3) Specify any of 0 to 31 for n. If the value specified for n is 32 or higher, the remainder of n divided by 32 is used for rotation. For example, when n 34, the remainder of 34/32 1 is 2, thus the data are rotated 2 bits to the left.
  • Page 380 DROL, DRCL (2) In the following program, the data in Var_D0 are rotated, including the carry flag, 4 bits to the left, when X0C turns ON. [Structured ladder] [ST] DRCLP(X0C,4,Var_D0); [Operation] Carry flag (SM700) b28b27 b24 b23 b20b19 b12 b11 b8 b7 b4 b3 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0...
  • Page 381 SFR, SFL Shift Instructions 7.3.1 n-bit right/left shift of 16-bit data SFR, SFL High Universal Performance SFR(P) P: Executing condition SFL(P) indicates any of the following instructions. Structured ladder SFRP SFLP ENO:= (EN, n, d); Input argument, Executing condition :Bit Number of shifts (0 to 15) :ANY16 Output argument,...
  • Page 382: Shift Instructions 7.3.1 N-Bit Right/Left Shift Of 16-Bit Data

    SFR, SFL (2) When a bit device is specified for , a right shift is performed within the device range of points by digit specification. Y14 Y13 When n = 4: Carry flag (SM700) Y14 Y13 Become 0 The number of bits that shift is the remainder of n divided by ‘number of points by digit specification’.
  • Page 383 SFR, SFL Program Example (1) In the following program, the data in Var_D0 are shifted to the right by the number of bits specified for Var_D100 when X20 turns ON. [Structured ladder] [ST] Var_D0:=3; SFRP(X20,Var_D0,Var_D100); [Operation] b14 b13b12 b11b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 Var_D0 Var_D100 Carry flag...
  • Page 384: 1-Bit Right/Left Shift Of N-Bit Data

    BSFR, BSFL 7.3.2 1-bit right/left shift of n-bit data BSFR, BSFL High Universal Performance BSFR(P) P: Executing condition BSFL(P) indicates any of the following instructions. Structured ladder BSFR BSFRP BSFR BSFL BSFLP ENO:= (EN, n, d); BSFR Input argument, Executing condition :Bit Number of devices to be shifted :ANY16...
  • Page 385 BSFR, BSFL BSFL(P) (1) Shifts the data n points from the device specified for to the left by 1 bit. +(n-2) +(n-3) +(n-1) Carry flag +(n-1) +(n-2) +(n-3) (SM700) Becomes 0 (2) The device specified for becomes 0. Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 386 BSFR, BSFL (2) In the following program, the data in the devices from Y60 to Y6F are shifted to the left when X4 turns ON. [Structured ladder] [ST] BSFLP(X4,16,Y60); [Operation] Y6EY6DY6CY6BY6AY69 Y66Y65Y64Y63Y62Y61 Carry flag (SM700) Y6EY6DY6CY6BY6AY69 Y66Y65Y64Y63Y62Y61 Becomes 0 7.3 Shift Instructions 7-46 7.3.2 1-bit right/left shift of n-bit data...
  • Page 387: 1-Word Right/Left Shift Of N-Word Data

    DSFR, DSFL 7.3.3 1-word right/left shift of n-word data DSFR, DSFL High Universal Performance DSFR(P) P: Executing condition DSFL(P) indicates any of the following instructions. Structured ladder DSFR DSFRP DSFR DSFL DSFLP ENO:= (EN, n, d); DSFR Input argument, Executing condition :Bit Number of devices to be shifted :ANY16...
  • Page 388 DSFR, DSFL DSFL(P) (1) Shifts data n points from device specified for to the left by 1 word. +(n-1) +(n-2) +(n-3) +(n-2) +(n-1) Becomes 0 (2) The device specified for becomes 0. Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 389 DSFR, DSFL (2) In the following program, the data from D683 to D689 are shifted to the left when X0B turns [Structured ladder] [ST] DSFLP(X0B,7,D683); [Operation] Specification range for the DSFLP instruction D689 D688 D687 D686 D685 D684 D683 -100 -336 3802 -32765 5003 D689...
  • Page 390: Bit Processing Instructions

    BSET, BRST Bit Processing Instructions 7.4.1 Bit set and reset of word devices BSET, BRST High Universal Performance BSET(P) P: Executing condition BRST(P) indicates any of the following instructions. Structured ladder BSET BSETP BSET BRST BRSTP ENO:= (EN, n, d); BSET Input argument, Executing condition...
  • Page 391 BSET, BRST BRST(P) (1) Resets (to 0) the nth bit of the word device specified for (2) If n exceeds 15, bit set/reset is performed with the lower 4 bits of the data. BRSTP EN ENO Before execution 1 1 0 0 1 0 1 1 0 0 1 1 1 0 1 1 After execution 1 1 0 0 0 0 1 1 0 0 1 1 1 0 1 1 0 is set.
  • Page 392 BSET, BRST Remark Bit set or reset of word devices can also be performed by bit specification for word devices. For details on bit specification for word devices, refer to the following manual. • QCPU User's Manual (Functions Explanation, Program Fundamentals) The processing of the program example (1) would be performed as shown below if bit specification for word devices had been used.
  • Page 393: Bit Test

    TEST, DTEST 7.4.2 Bit test TEST, DTEST High Universal Performance TEST(P) P: Executing condition DTEST(P) indicates any of the following instructions. Structured ladder TEST TESTP TEST DTEST DTESTP ENO:= (EN, s1, s2, d); TEST Input argument, Executing condition :Bit Bit data to be extracted :ANY16/32 Position of bit data to be extracted :ANY16...
  • Page 394 TEST, DTEST (3) The position specified for specifies the position of each bit in a 1-word data block (0 to 15). When 16 or higher value is specified for , the target is the bit data at the position indicated by the remainder of n divided by 16. For example, when n 18, the remainder of 18/16 1 is 2, thus the target is the data of b2.
  • Page 395 TEST, DTEST [ST] TESTP(SM400,Var_D0,10,Var_M0); [Operation] Var_D0 1 0 1 1 0 0 1 1 0 1 1 0 1 0 1 0 Turns Var_M0 OFF since b10 is 0. Var_D0 0 0 1 0 0 1 1 1 1 0 1 0 0 0 0 1 Turns Var_M0 ON since b10 is 1.
  • Page 396: Batch Reset Of Bit Devices

    BKRST 7.4.3 Batch reset of bit devices BKRST High Universal Performance BKRST(P) P: Executing condition indicates any of the following instructions. Structured ladder BKRST BKRSTP BKRST ENO:= (EN, s, n); BKRST Input argument, Executing condition :Bit Start number of the device to be reset :Bit Number of devices to be reset :ANY16...
  • Page 397 BKRST Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device. (Error code: 4101) Program Example (1) In the following program, the devices from M0 to M7 are turned OFF when X0 turns ON.
  • Page 398: Data Processing Instructions

    SER, DSER Data Processing Instructions 7.5.1 16-/32-bit data search SER, DSER High Universal Performance SER(P) P: Executing condition DSER(P) indicates any of the following Structured ladder instructions. SERP DSER DSERP ENO:= (EN, s1, s2, n, d); Input argument, Executing condition :Bit Search data :ANY16/32...
  • Page 399 SER, DSER Function SER(P) (1) Searches n points from the 16-bit data of the device specified for , regarding 16-bit data of the device specified for as a keyword. Then, the number of matches with the keyword is stored to the device specified for [1], and the relative value from to the first matched device number is stored to the device specified for...
  • Page 400 SER, DSER DSER(P) (1) Searches n points from the device specified for in units of 32 bits (2 n points in units of 16 bits) regarding 32-bit data of the device specified for as a keyword. Then, the number of matches with the keyword is stored to the device specified for [1], and the relative value from to the first matched device number is stored to the device specified for...
  • Page 401 SER, DSER Program Example (1) In the following program, the devices from D100 to D105 are searched by the data in Var_D0 when X20 turns ON, and the results are stored to Var_W0. [Structured ladder] [ST] Var_D0:=123; SERP(X20,Var_D0,D100,6,Var_W0); [Operation] Search data Data to be searched D100 Var_D0...
  • Page 402: 16-/32-Bit Data Bit Check

    SUM, DSUM 7.5.2 16-/32-bit data bit check SUM, DSUM High Universal Performance SUM(P) P: Executing condition DSUM(P) indicates any of the following instructions. Structured ladder SUMP DSUM DSUMP ENO:= (EN, s, d); Input argument, Executing condition :Bit Data whose total number of bits set to 1 is counted :ANY16/32 Output argument, ENO:...
  • Page 403 SUM, DSUM DSUM(P) From the 32-bit data in the device specified for , stores the total number of bits where 1 is set, to the device specified for b16 b15 1 0 0 1 1 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 1 1 1 1 0 1 1 0 Total number of bits where 1 is set 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0...
  • Page 404 SUM, DSUM (2) In the following program, the number of bits which are turned ON in Var_D100 are stored to Var_D0 when X10 turns ON. [Structured ladder] [ST] DSUMP(X10,Var_D100,Var_D0); [Operation] 0 1 0 1 0 0 0 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 Var_D100 Stores the total number of bits where 1 is set to D0.
  • Page 405: Decoding From 8 To 256 Bits

    DECO 7.5.3 Decoding from 8 to 256 bits DECO High Universal Performance DECO(P) P: Executing condition indicates any of the following instructions. Structured ladder DECO DECOP DECO ENO:= (EN, s, n, d); DECO Input argument, Executing condition :Bit Decoding data :ANY_SIMPLE Valid bit length (1 to 8), no processing on 0 :ANY16...
  • Page 406 DECO Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of n is outside the range of 0 to 8. (Error code: 4100) •...
  • Page 407: Encoding From 256 To 8 Bits

    ENCO 7.5.4 Encoding from 256 to 8 bits ENCO High Universal Performance ENCO(P) P: Executing condition indicates any of the following instructions. Structured ladder ENCO ENCOP ENCO ENO:= (EN, s, n, d); ENCO Input argument, Executing condition :Bit Encoding data :ANY_SIMPLE Valid bit length (1 to 8), no processing on 0 :ANY16...
  • Page 408 ENCO Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of n is outside the range of 0 to 8. (Error code: 4100) •...
  • Page 409: 7-Segment Decode

    7.5.5 7-segment decode High Universal Performance SEG(P) P: Executing condition indicates any of the following instructions. Structured ladder SEGP ENO:= (EN, s, d); Input argument, Executing condition :Bit Decoding data, or start number of the device that stores :ANY16 decoding data Output argument, ENO: Execution result...
  • Page 410 Operation Error No operation error occurs in the execution of the SEG(P) instruction. 7-segment decode display Configuration of 7 Display data Hexade segments Bit pattern cimal 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Start number of bit device...
  • Page 411 Program Example In the following program, the data from XC to XF are converted to 7-segment display data and the results are output to the devices from Y38 to Y3F when X0 turns ON. [Structured ladder] [ST] SEGP(X0,K1X0C,K2Y38); [Timing chart] Y38 to Y3F *1: The data Y38 to Y3F will not change until the next data are output.
  • Page 412: 4-Bit Separation Of 16-Bit Data

    7.5.6 4-bit separation of 16-bit data High Universal Performance DIS(P) P: Executing condition indicates any of the following instructions. Structured ladder DISP ENO:= (EN, s, n, d); Input argument, Executing condition :Bit Start number of the device that stores data to be separated :ANY16 Number of separations (1 to 4), no processing on 0 :ANY16...
  • Page 413 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device. (Error code: 4101) •...
  • Page 414: 4-Bit Connection Of 16-Bit Data

    7.5.7 4-bit connection of 16-bit data High Universal Performance UNI(P) P: Executing condition indicates any of the following instructions. Structured ladder UNIP ENO:= (EN, s, n, d); Input argument, Executing condition :Bit Start number of the device that stores data to be connected :ANY16 Number of connections (1 to 4), no processing on 0 :ANY16...
  • Page 415 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device. (Error code: 4101) •...
  • Page 416: Separation And Connection Of Random Data

    NDIS, NUNI 7.5.8 Separation and connection of random data NDIS, NUNI High Universal Performance NDIS(P) P: Executing condition NUNI(P) indicates any of the following instructions. Structured ladder NDIS NDISP NDIS NUNI NUNIP ENO:= (EN, s1, s2, d); NDIS Input argument, Executing condition :Bit Start number of the device that stores data to be separated or...
  • Page 417 NDIS, NUNI Function NDIS(P) (1) Separates each bit of data stored in the device number specified for and the following devices in blocks whose numbers of bits are specified for , and stores the data to the device number specified for and the following devices.
  • Page 418 NDIS, NUNI NUNI(P) (1) Connects each bit of data stored in the device number specified for and the following devices in blocks whose numbers of bits are specified for , and stores them to the device number specified for and the following devices. Specification of the number of connected bits Specification of the end of setting b15b14b13...
  • Page 419 NDIS, NUNI Program Example (1) In the following program, the data of 4, 3, and 6 bits respectively from the lower bits of Var_D0 are separated, and they are stored to the devices from D10 to D12. [Structured ladder] [ST] IF SM400 THEN MOVP(TRUE,4,D20);...
  • Page 420 NDIS, NUNI (2) In the following program, the lower 4 bits of data in D10, the lower 3 bits of data in D11, and the lower 6 bits of data in D12 are connected, and they are stored to Var_D0. [Structured ladder] [ST] IF SM400 THEN...
  • Page 421: Separation And Connection Of Data In Units Of Bytes

    WTOB, BTOW 7.5.9 Separation and connection of data in units of bytes WTOB, BTOW High Universal Performance WTOB(P) P: Executing condition BTOW(P) indicates any of the following instructions. Structured ladder WTOB WTOBP WTOB BTOW BTOWP ENO:= (EN, s, n, d); WTOB Input argument, Executing condition...
  • Page 422 WTOB, BTOW Function WTOB(P) (1) Separates n bytes of the 16-bit data stored in the device specified for and the following devices, and stores them to the device specified for and the following devices. b8b7 b8 b7 Upper byte Lower byte Data of lower byte Upper byte Lower byte...
  • Page 423 WTOB, BTOW BTOW(P) (1) Connects the lower 8 bits of the 16-bit data in n words stored in the device specified for and the following devices in units of 1-word and stores it to the device specified for the following devices. The upper 8 bits of n-word data stored in the device specified for and the following devices will be ignored.
  • Page 424 WTOB, BTOW Program Example (1) In the following program, the data from D10 to D12 are separated in units of bytes when X0 turns ON, and they are stored to the devices from D20 to D25. [Structured ladder] [ST] WTOBP(X0,D10,6,D20); [Operation] 6 bytes (2) In the following program, the lower 8-bit data from D20 to D25 are connected when X0 turns...
  • Page 425: Maximum Value Search Of 16-/32-Bit Data

    MAX, DMAX 7.5.10 Maximum value search of 16-/32-bit data MAX, DMAX High Universal Performance MAX(P) P: Executing condition DMAX(P) indicates any of the following instructions. Structured ladder MAXP DMAX DMAXP ENO:= (EN, s, n, d); Input argument, Executing condition :Bit Start number of the device in which the maximum value is :ANY16/32 searched...
  • Page 426 MAX, DMAX DMAX(P) (1) Searches for the maximum value in the n points of 32-bit BIN data, from the device specified , and stores the searched maximum value to the device specified for Searches from the device specified for and counted from , stores the location of device number which is stored in the maximum value of the first search to +2 and stores the...
  • Page 427 MAX, DMAX [Operation] D100 D150 4321 (BIN) 5000 (BIN) -679 (BIN) D101 D151 5432 (BIN) 4000 (BIN) 1432 (BIN) D102 D152 4444 (BIN) 4000 (BIN) 444 (BIN) D103 D153 5000 (BIN) 6000 (BIN) -1000 (BIN) D200 Maximum value 1432 D201 Location D202 Quantity...
  • Page 428: Minimum Value Search Of 16-/32-Bit Data

    MIN, DMIN 7.5.11 Minimum value search of 16-/32-bit data MIN, DMIN High Universal Performance MIN(P) P: Executing condition DMIN(P) indicates any of the following instructions. Structured ladder MINP DMIN DMINP ENO:= (EN, s, n, d); Input argument, Executing condition :Bit Start number of the device in which the minimum value is :ANY16/32 searched...
  • Page 429 MIN, DMIN DMIN(P) (1) Searches for the minimum value in the n points of 32-bit BIN data, from the device specified , and stores searched minimum value to the devices specified for Searches from the device specified for and counted from , stores the location of the device number which is stored in the minimum value of the first search to +2 and stores...
  • Page 430 MIN, DMIN [Operation] 5542 (BIN) 5500 (BIN) 11042 (BIN) D100 D150 5857 (BIN) D101 4000 (BIN) 9857 (BIN) D151 4590 (BIN) D102 4500 (BIN) 9090 (BIN) D152 4450 (BIN) D103 6000 (BIN) 10450 (BIN) D153 D200 9090 Minimum value D201 Location D202 Quantity...
  • Page 431: Sorting 16-/32-Bit Data

    SORT, DSORT 7.5.12 Sorting 16-/32-bit data SORT, DSORT High Universal Performance SORT DSORT indicates any of the following Structured ladder instructions. SORT SORT DSORT ENO:= (EN, s1, n, s2, d1, d2); SORT Input argument, Executing condition :Bit Table to be sorted :ANY16/32 Number of data to be compared in one sort execution :ANY16...
  • Page 432 SORT, DSORT Function SORT (1) Sorts 16-bit BIN data n points from in ascending or descending order. Sort order is specified by the ON or OFF status of SM703. • When SM703 is OFF : Sorts in ascending order • When SM703 is ON : Sorts in descending order -124 Data before sort When SM703 = OFF...
  • Page 433 SORT, DSORT DSORT (1) Sorts 32-bit BIN data n points from in ascending or descending order. Sort order is specified by the ON or OFF status of SM703. • When SM703 is OFF : Sorts in ascending order • When SM703 is ON : Sorts in descending order +1 , -1000...
  • Page 434 SORT, DSORT Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • For the SORT instruction, the range of n points from exceeds the corresponding device range.
  • Page 435 SORT, DSORT (2) In the following program, the 32-bit BIN data 20 points from Var_D0 are sorted in the ascending or descending order when X10 turns ON. [Structured ladder] [ST] OUT(X0,SM703); DSORT(X10,Var_D0,1,5,M0,D100); [Operation] Data after sort Var_D0 -99999 Data before sort -1111 X0→OFF Var_D0...
  • Page 436: Total Calculation Of 16-Bit Data

    WSUM 7.5.13 Total calculation of 16-bit data WSUM High Universal Performance WSUM(P) P: Executing condition indicates any of the following instructions. Structured ladder WSUM WSUMP WSUM ENO:= (EN, s, n, d); WSUM Input argument, Executing condition :Bit Start number of the device that stores data whose total value is :ANY16 evaluated Number of data...
  • Page 437 WSUM Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device. (Error code: 4101) Program Example In the following program, the 16-bit BIN data from D10 to D14 are added when X1C turns ON,...
  • Page 438: Total Calculation Of 32-Bit Data

    DWSUM 7.5.14 Total calculation of 32-bit data DWSUM High Universal Performance DWSUM(P) P: Executing condition indicates any of the following instructions. Structured ladder DWSUM DWSUMP DWSUM ENO:= (EN, s, n, d); DWSUM Input argument, Executing condition :Bit Data whose total value is evaluated :ANY32 Number of data :ANY16...
  • Page 439 DWSUM Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of n points from the device specified for exceeds the corresponding device.
  • Page 440: Structured Instructions

    FOR, NEXT Structured Instructions 7.6.1 FOR to NEXT instruction loop FOR, NEXT High Universal Performance NEXT indicates any of the following instructions. Structured ladder NEXT Not supported Structured ladder Not supported NEXT Input argument, Executing condition :Bit Number of repeats of the FOR to NEXT instruction loop (1 to :ANY16 32767) Output argument,...
  • Page 441 FOR, NEXT (4) Up to 16 nesting levels are applicable for the FOR instruction. EN ENO EN ENO EN ENO FOR instructions can be nested up to 16 deep. NEXT EN ENO NEXT EN ENO NEXT EN ENO Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 442 FOR, NEXT Program Example In the following program, the FOR to NEXT instruction loop is executed when X8 is OFF, and not executed when X8 is ON. [Structured ladder] Remark 1. To force an end to the repetitious execution of the FOR to NEXT instruction loop, insert the BREAK instruction.
  • Page 443: Forced Termination Of For To Next Instruction Loop

    BREAK 7.6.2 Forced termination of FOR to NEXT instruction loop BREAK High Universal Performance BREAK(P) P: Executing condition indicates any of the following instructions. Structured ladder BREAK BREAKP BREAK Not supported Input argument, Executing condition :Bit Pointer number of branch destination when the repeat process :ANY16 is forcibly terminated Output argument,...
  • Page 444 BREAK (2) The remaining number of the FOR to NEXT instruction loops is stored to at the time of forced termination. Note that the remaining number includes the operation when the BREAK(P) instruction is executed. (3) The BREAK(P) instruction can be used only in the FOR to NEXT instruction loop. (4) The BREAK(P) instruction can be used only when there is only one level of nesting.
  • Page 445 BREAK Program Example In the following program, the forced termination is executed on the processes in the FOR to NEXT instruction loop when the value of Var_D0 reaches 30 (when the FOR to NEXT instruction loop has been executed 30 times). [Structured ladder] Remark The value 71 is stored to Var_D1 when the BREAK(P) instruction is executed.
  • Page 446: Subroutine Program Call

    CALL 7.6.3 Subroutine program call CALL High Universal Performance CALL(P) P: Executing condition indicates any of the following instructions. Structured ladder CALL CALLP CALL Not supported Input argument, Executing condition :Bit Start pointer number of the subroutine program :ANY16 Output argument, ENO: Execution result :Bit...
  • Page 447 CALL (2) Up to 16 nesting levels are applicable for the CALL(P) instruction. CALL CALL CALL FEND (3) Devices which are turned ON within subroutine programs will be latched even if the subroutine program is not executed. Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 448: Return From Subroutine Program

    7.6.4 Return from subroutine program High Universal Performance indicates the following instruction. Structured ladder ENO:= (EN); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data Word Word − − Function (1) Indicates the end of the subroutine program.
  • Page 449 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The FEND, GOEND or STOP instruction is executed after the execution of the CALL(P) instruction, and prior to the execution of the RET instruction.
  • Page 450: Refresh Instruction

    7.6.5 Refresh instruction High Universal Performance For the COM instruction of the following CPU modules, refer to Section 8.13. • High Performance model QCPU with the serial number 04012 or higher • Universal model QCPU indicates the following instruction. Structured ladder ENO:= (EN);...
  • Page 451 (2) The processing of the COM instruction differs depending on whether the special relay SM775 is ON or OFF. • When SM775 is OFF: Performs auto refresh and communication with a peripheral * • When SM775 is ON: Performs communication with peripheral only * *1: The following processes are performed in communication with peripheral.
  • Page 452 1) When the COM instruction is used at the host station, it is possible to increase the number of data communication repetitions with the remote I/O station unconditionally, as shown in (b) above, and thus to speed up data communications. 2) In cases where the remote station scan time is longer than the scan time of the host station, the COM instruction used at the remote station side can avoid the occurrence of timing failure in which the data cannot be fetched, as shown in (a).
  • Page 453: Data Table Operation Instructions

    FIFW Data Table Operation Instructions 7.7.1 Writing data to data table FIFW High Universal Performance FIFW(P) P: Executing condition indicates any of the following instructions. Structured ladder FIFW FIFWP FIFW ENO:= (EN, s, d); FIFW Input argument, Executing condition :Bit Write data to the table, or device number that stores data :ANY16 Output argument,...
  • Page 454 FIFW (2) When the FIFW(P) instruction is executed for the first time, any values specified for should be cleared. (3) The number of data blocks to be written in the data table and the data table range should be managed by a user. [Refer to Program Example (2)] Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the...
  • Page 455 FIFW (2) In the following program, the data from X20 to X2F are stored to the data table from D38 to D44 when X1B turns ON, and if there are more than 6 data blocks to be stored, Y60 is turned ON and the FIFW(P) instruction is disabled.
  • Page 456: Reading Oldest Data From Data Table

    FIFR 7.7.2 Reading oldest data from data table FIFR High Universal Performance FIFR(P) P: Executing condition indicates any of the following instructions. Structured ladder FIFR FIFRP FIFR ENO:= (EN, s, d); FIFR Input argument, Executing condition :Bit Start number of the device that stores read data from the table:ANY16 Output argument, ENO: Execution result...
  • Page 457 FIFR Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The FIFR(P) instruction is executed when the value of is 0. (Error code: 4100) •...
  • Page 458 FIFR (2) In the following program, the data in Var_D0 are stored to the data table D38 to D43 when X1C turns ON, and when the number of stored data reaches 5, the last-stored data in D39 of the data table are stored to Var_R0. [Structured ladder] [ST] FIFWP(X1C,Var_D0,D38);...
  • Page 459: Reading Newest Data From Data Table

    FPOP 7.7.3 Reading newest data from data table FPOP High Universal Performance FPOP(P) P: Executing condition indicates any of the following instructions. Structured ladder FPOP FPOPP FPOP ENO:= (EN, s, d); FPOP Input argument, Executing condition :Bit Start number of the device that stores read data from the table:ANY16 Output argument, ENO: Execution result...
  • Page 460 FPOP Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The FPOP(P) instruction is executed when the value of is 0. (Error code: 4100) •...
  • Page 461 FPOP (2) In the following program, the data in Var_D0 are stored to the data table D38 to D43 when X1C turns ON, and when the number of stored data reaches 5, and X1D turns ON, the last- stored data in the data table are stored to Var_R0. [Structured ladder] [ST] FIFWP(X1C,Var_D0,D38);...
  • Page 462: Deleting/Inserting Data From/To Data Table

    FDEL, FINS 7.7.4 Deleting/inserting data from/to data table FDEL, FINS High Universal Performance FDEL(P) P: Executing condition FINS(P) indicates any of the following instructions. Structured ladder FDEL FDELP FDEL FINS FINSP ENO:= (EN, s, n, d); FDEL Input argument, Executing condition :Bit Start device number which stores insert data :ANY16...
  • Page 463 FDEL, FINS FINS(P) (1) Inserts the 16-bit data specified for in the nth block of the data table specified for After the execution of the FINS(P) instruction, the data in the table following the inserted block are all dropped one position. Data table Data table Number of stored...
  • Page 464 FDEL, FINS Program Example (1) In the following program, the second data from the table R0 to R7 are deleted when X10 turns ON, and the deleted data are stored to Var_D0. [Structured ladder] [ST] FDELP(X10,Var_D0,2,R0); [Operation] Data table Data table X10:ON -123 -123...
  • Page 465: Buffer Memory Access Instructions

    FROM, DFRO Buffer Memory Access Instructions 7.8.1 Reading 1-/2-word data from intelligent function module FROM, DFRO High Universal Performance FROM(P) P: Executing condition DFRO(P) indicates any of the following Structured ladder instructions. FROM FROM FROMP DFRO DFROP ENO:= (EN, n1, n2, n3, d); FROM Input argument, Executing condition...
  • Page 466 FROM, DFRO DFRO(P) (1) Reads the data in (n3 2) words from the buffer memory address specified for n2 of the intelligent function module specified for n1, and stores the data to the device specified for and the following devices. Intelligent function module buffer memory CPU module...
  • Page 467 FROM, DFRO Program Example (1) In the following program, the CH1 digital value of the A68AD mounted with I/O numbers 040 to 05F is read to Var_D0 when X0 turned ON. (Reads 1 word of data from address 10 of the buffer memory.) [Structured ladder] [ST]...
  • Page 468: Writing 1-/2-Word Data To Intelligent Function Module

    TO, DTO 7.8.2 Writing 1-/2-word data to intelligent function module TO, DTO High Universal Performance TO(P) P: Executing condition DTO(P) indicates any of the following Structured ladder instructions. DTOP ENO:= (EN, s, n1, n2, n3); Input argument, Executing condition :Bit Data to be written :ANY16/32 Start I/O number of the intelligent function module...
  • Page 469 TO, DTO When a constant is specified for , writes the same data (value specified for ) to the area of n3 words following the specified buffer memory. ( can be specified in the following range: -32768 to 32767 or 0H to FFFF Intelligent function module buffer memory CPU module...
  • Page 470 TO, DTO Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • There has been no exchange of signals with the intelligent function module at the execution of the instruction.
  • Page 471 TO, DTO Remark 1. The value of n1 is specified by the upper 3 digits of hexadecimal 4-digit representation of the start I/O number of the slot in which the intelligent function module is mounted. X0000 X0010 X0020 X0030 0040 Y0050 Y0070 Y0080 X000 F...
  • Page 472: Display Instructions

    Display Instructions 7.9.1 Printing ASCII code High Universal Performance indicates the following instruction. Structured ladder ENO:= (EN, s, d); Input argument, Executing condition :Bit ASCII code :ANY16/string Output argument, ENO: Execution result :Bit Start number of the output module that outputs ASCII code :Bit data Internal device...
  • Page 473 (a) If SM701 is ON, characters 8 points (16 characters) from the device specified for will be the target of the operation. Device where ASCII code data are stored Upper 8 bits Lower 8 bits Output Y b8 b7 Start of output ASCII code data output Printer or display device...
  • Page 474 (3) Output signals from the output module are transmitted at the rate of 30ms per character. For this reason, the time required to complete the transmission of the specified number of characters (n) will be 30ms n (ms). At 10ms interrupt intervals, the PR instruction executes data output, strobe signal ON, and strobe signal OFF.
  • Page 475 Program Example In the following program, the string data "ABCDEFGHIJKLMNOP" is converted to ASCII code data when X0 turns ON and the result is stored to Var_D0, and then the stored ASCII code data in Var_D0 are output to Y14 to Y1D when X3 turns ON. [Structured ladder] [ST] IF X0 THEN...
  • Page 476: Printing Comments

    7.9.2 Printing comments High Universal Performance indicates the following instruction. Structured ladder ENO:= (EN, s, d); Input argument, Executing condition :Bit Start number of the device whose comments are printed :ANY_SIMPLE Output argument, ENO: Execution result :Bit Start number of the output module that outputs comments :Bit Internal device Setting...
  • Page 477 Function (1) Outputs comment data (ASCII code data) in the device specified for to output module specified for The number of characters output differs according to the ON or OFF status of SM701. • When SM701 is OFF : Comments in 32 characters •...
  • Page 478 (2) Output signals from the output module are transmitted at the rate of 30ms per character. For this reason, the time required to complete the transmission of the number of specified characters will be 30ms n (ms). At 10ms interrupt intervals, the PRC instruction executes data output, strobe signal ON, and strobe signal OFF.
  • Page 479 Operation Error In the following case, an operation error occurs and the error flag is turned ON. • The PRC instruction is executed while comments are written during online change. (Error code: 4100) Program Example In the following program, the comment data in Y60 are output to Y30 to Y39 when X0 turns ON. [Structured ladder] [ST] PRC(X0 AND NOT(Y39),Y60,Y30);...
  • Page 480: Resetting Error Display Or Annunciator

    LEDR 7.9.3 Resetting error display or annunciator LEDR High Universal Performance LEDR indicates the following instruction. LEDR Structured ladder LEDR ENO:= (EN); LEDR Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data Word...
  • Page 481 LEDR (2) Operations when annunciators (F) are ON. (a) For CPU module with no LED display on the front The following operations are performed when the LEDR instruction is executed. 1) "USER" LED flickers, and is turned OFF. 2) The annunciators (F) stored in SD62 and SD64 are reset, and the F numbers of SD65 to SD79 are moved up.
  • Page 482 LEDR Remark 1. The defaults for the error item numbers set in special registers SD207 to SD209 and order of priority are given in the table below. Factor number Priority Meaning Remarks (Hexadecimal) Power off AC DOWN Redundant base unit power supply voltage SINGLE PS.
  • Page 483: Debug/Error Diagnostics Instructions

    CHKST, CHK 7.10 Debug/Error Diagnostics Instructions 7.10.1 Special format error check CHKST, CHK High Universal Performance CHKST indicates any of the following instructions. Structured ladder CHKST CHKST ENO:= (EN); CHKST Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting...
  • Page 484 CHKST, CHK (1) The CHK instruction is the instruction used for the bidirectional operation as shown below to confirm the nature of the system error. (a) When the CHK instruction is executed, an error diagnostic check is performed with the specified check conditions, and if a failure is detected, SM80 is turned ON, and the failure number is stored to SD80 as a BCD value.
  • Page 485 CHKST, CHK (2) Depending on the specified contact, the CHK instruction undergoes processing identical to that shown for the ladder below. CHKST EN ENO EN ENO (Detection by both advance and retraction edge sensors Max. 150 contacts during advance operation of the conveyor) EN ENO Coil No.
  • Page 486 CHKST, CHK (7) Place LD and AND instructions prior to the CHK instruction to establish a check condition. Check conditions cannot be set using other contact instructions. If a check condition has been set with the LDI or ANI instruction, the processing for the check condition they specify will not be performed.
  • Page 487: Changing Check Format Of The Chk Instruction

    CHKCIR, CHKEND 7.10.2 Changing check format of the CHK instruction CHKCIR, CHKEND High Universal Performance CHKCIR CHKEND indicates any of the following instructions. Structured ladder CHKCIR CHKEND CHKCIR ENO:= (EN); CHKCIR Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting...
  • Page 488 CHKCIR, CHKEND (a) The device numbers indicated at check conditions (X2 and X8 in the figure below) are index setting values for each device number (with the exception of annunciators (F)) described in the ladder patterns. Example X10 in the in the figure below would be as follows.
  • Page 489 CHKCIR, CHKEND 2) If SM710 is ON, checks are performed on contact numbers 1 through the end in order of coil number. [Specified ladder between CHKCIR and CHKEND instructions] [Order of check in CPU module] X12 X14 Y42 X8 CHKST EN ENO X18 X1A Y48 XE...
  • Page 490 CHKCIR, CHKEND (3) Coil numbers for ladders specified within the CHKCIR to CHKEND instruction loop are assigned with coil numbers from 1 to 9, from top to bottom. SM400 CHKCIR Coil No. 1 Coil No. 2 Coil No. 8 Coil No. 9 SM400 CHKEND (4) The CHKCIR and CHKEND instructions can be written at any step in the program desired.
  • Page 491: String Processing Instructions

    BINDA, DBINDA 7.11 String Processing Instructions 7.11.1 16-/32-bit BIN data to decimal ASCII data conversion BINDA, DBINDA High Universal Performance BINDA(P) P: Executing condition DBINDA(P) indicates any of the following instructions. Structured ladder BINDA BINDAP BINDA DBINDA DBINDAP ENO:= (EN, s, d); BINDA Input argument, Executing condition...
  • Page 492 BINDA, DBINDA Function BINDA(P) (1) Converts each digit number of decimal notation of the 16-bit BIN data specified for ASCII code data, and stores the results to the device specified for and the following devices. b8 b7 ASCII code for ten-thousands place Sign ASCII code for hundreds place ASCII code for thousands place...
  • Page 493 BINDA, DBINDA DBINDA(P) (1) Converts each digit number of decimal notation of the 32-bit BIN data specified for ASCII code data, and stores the results to the device specified for and the following devices. b8b7 ASCII code for billions place Sign ASCII code for ten-millions place ASCII code for hundred-millions place...
  • Page 494 BINDA, DBINDA Program Example (1) In the following program, the 16-bit BIN data in Var_W0 are converted to the decimal ASCII code data, and the results are output to Y40 to Y48 by the PR instruction. (Global label Var_D0 is assigned to device D0.) [Structured ladder] [ST] IF SM400 THEN...
  • Page 495 BINDA, DBINDA (2) In the following program, the 32-bit BIN data in Var_W10 are converted to the decimal ASCII code data, and the results are output to Y40 to Y48 by the PR instruction. (Global label Var_D0 is assigned to device D0.) [Structured ladder] [ST] IF SM400 THEN...
  • Page 496: 16-/32-Bit Bin Data To Hexadecimal Ascii Data Conversion

    BINHA, DBINHA 7.11.2 16-/32-bit BIN data to hexadecimal ASCII data conversion BINHA, DBINHA High Universal Performance BINHA(P) P: Executing condition DBINHA(P) indicates any of the following instructions. Structured ladder BINHA BINHAP DBINHA DBINHAP BINHA ENO:= (EN, s, d); BINHA Input argument, Executing condition :Bit BIN data to be converted to ASCII code data...
  • Page 497 BINHA, DBINHA Function BINHA(P) (1) Converts each digit number of hexadecimal notation of the 16-bit BIN data specified for ASCII code data, and stores the results to the device specified for and the following devices. b8b7 ASCII code for the 3rd digit ASCII code for the 4th digit ASCII code for the 1st digit ASCII code for the 2nd digit...
  • Page 498 BINHA, DBINHA DBINHA(P) (1) Converts each digit number of hexadecimal notation of the 32-bit BIN data specified for ASCII code data, and stores the results to the device specified for and the following devices. b8b7 ASCII code for the 7th digit ASCII code for the 8th digit ASCII code for the 5th digit ASCII code for the 6th digit...
  • Page 499 BINHA, DBINHA Program Example (1) In the following program, the 16-bit BIN data in Var_W0 are converted to the hexadecimal ASCII code data, and the results are output to Y40 to Y48 by the PR instruction. (Global label Var_D0 is assigned to device D0.) [Structured ladder] [ST] IF SM400 THEN...
  • Page 500 BINHA, DBINHA (2) In the following program, the 32-bit BIN data in Var_W10 are converted to the hexadecimal ASCII code data, and the results are output to Y40 to Y48 by the PR instruction. (Global label Var_D0 is assigned to device D0.) [Structured ladder] [ST] IF SM400 THEN...
  • Page 501: 8-Digit Bcd Data To Decimal Ascii Data Conversion

    BCDDA, DBCDDA 7.11.3 4-/8-digit BCD data to decimal ASCII data conversion BCDDA, DBCDDA High Universal Performance BCDDA(P) P: Executing condition DBCDDA(P) indicates any of the following instructions. Structured ladder BCDDA BCDDAP DBCDDA DBCDDAP BCDDA ENO:= (EN, s, d); BCDDA Input argument, Executing condition BCD data to be converted to ASCII code data :ANY16 / 32...
  • Page 502 BCDDA, DBCDDA Function BCDDA(P) (1) Converts each digit number of hexadecimal notation of the 4-digit BCD data specified for to ASCII code data, and stores the results to the device specified for and the following devices. b8 b7 ASCII code for hundred’s place ASCII code for thousand’s place ASCII code for unit’s place ASCII code for ten’s place...
  • Page 503 BCDDA, DBCDDA DBCDDA(P) (1) Converts each digit number of hexadecimal notation of the 8-digit BCD data specified for to ASCII code data, and stores the results to the device specified for and the following devices. b8b7 ASCII code for million’s place ASCII code for ten-million’s place ASCII code for ten-thousand’s place ASCII code for hundred-thousand’...
  • Page 504 BCDDA, DBCDDA Program Example (1) In the following program, the 4-digit BCD data in Var_W0 are converted to the decimal ASCII code data, and the results are output to Y40 to Y48 by the PR instruction. (Global label Var_D0 is assigned to device D0.) [Structured ladder] [ST] IF SM400 THEN...
  • Page 505 BCDDA, DBCDDA (2) In the following program, the 8-digit BCD data in Var_W10 are converted to the decimal ASCII code data, and the results are output to Y40 to Y48 by the PR instruction. (Global label Var_D0 is assigned to device D0.) [Structured ladder] [ST] IF SM400 THEN...
  • Page 506: Decimal Ascii Data To 16-/32-Bit Bin Data Conversion

    DABIN, DDABIN 7.11.4 Decimal ASCII data to 16-/32-bit BIN data conversion DABIN, DDABIN High Universal Performance DABIN(P) P: Executing condition DDABIN(P) indicates any of the following instructions. Structured ladder DABIN DABINP DABIN DDABIN DDABINP ENO:= (EN, s, d); DABIN Input argument, Executing condition :Bit ASCII data to be converted to BIN value...
  • Page 507 DABIN, DDABIN Function DABIN(P) (1) Converts decimal ASCII data stored in the device specified for and the following devices to 16-bit BIN data, and stores the results to the device specified for b8b7 ASCII code for ten-thousand’s place Sign data ASCII code for hundred’s place ASCII code for thousand’s place ASCII code for unit’s place...
  • Page 508 DABIN, DDABIN (3) The sign 20 will be stored if the BIN value is positive, and the sign 2D will be stored if it is negative. (If other than 20 or 2D is set, it will be processed as positive data.) (4) ASCII code can be set for each position within the range from 30 to 39 (5) If the ASCII code set for each position is 20...
  • Page 509 DABIN, DDABIN (2) In the following program, the 10-digit decimal ASCII data and the signs set in Var_D20 are converted to BIN value, and the result is stored to Var_D10. [Structured ladder] [ST] DDABINP(SM400,Var_D20,Var_D10); [Operation] b8b7 (space) (space) Var_D20[0] (space) (space) Var_D20[1] Var_D10...
  • Page 510: Hexadecimal Ascii Data To 16-/32-Bit Bin Data Conversion

    HABIN, DHABIN 7.11.5 Hexadecimal ASCII data to 16-/32-bit BIN data conversion HABIN, DHABIN High Universal Performance HABIN(P) P: Executing condition DHABIN(P) indicates any of the following instructions. Structured ladder HABIN HABINP DHABIN DHABINP HABIN ENO:= (EN, s, d); HABIN Input argument, Executing condition :Bit ASCII data to be converted to BIN value...
  • Page 511 HABIN, DHABIN Function HABIN(P) (1) Converts hexadecimal ASCII data stored in the device specified for and the following devices to 16-bit BIN data, and stores the results to the device specified for b8b7 ASCII code for the 3rd digit ASCII code for the 4th digit ASCII code for the 1st digit ASCII code for the 2nd digit BIN 16 bits...
  • Page 512 HABIN, DHABIN Program Example (1) In the following program, the 4-digit hexadecimal ASCII data set in Var_D20 are converted to BIN value, and the results are stored to Var_D0. [Structured ladder] [ST] HABINP(SM400,Var_D20,Var_D0); [Operation] b8 b7 Var_D0 Var_D20 -22977 Regarded as A63F BIN value "A63F"...
  • Page 513: Decimal Ascii Data To 4-/8-Digit Bcd Data Conversion

    DABCD, DDABCD 7.11.6 Decimal ASCII data to 4-/8-digit BCD data conversion DABCD, DDABCD High Universal Performance DABCD(P) P: Executing condition DDABCD(P) indicates any of the following instructions. Structured ladder DABCD DABCDP DDABCD DDABCDP DABCD ENO:= (EN, s, d); DABCD Input argument, Executing condition :Bit ASCII data to be converted to BCD value...
  • Page 514 DABCD, DDABCD Function DABCD(P) (1) Converts decimal ASCII data stored in the device specified for and the following devices to 4-digit BCD data, and stores the results to the device specified for b8b7 ASCII code for hundred’s place ASCII code for thousand’s place ASCII code for unit’s place ASCII code for ten’s place Ten’s...
  • Page 515 DABCD, DDABCD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • There are characters within the data of that are outside the range of 0 to 9. (Error code: 4100) •...
  • Page 516: Reading Device Comment Data

    COMRD 7.11.7 Reading device comment data COMRD High Universal Performance COMRD(P) P: Executing condition indicates any of the following instructions. Structured ladder COMRD COMRDP COMRD ENO:= (EN, s, d); COMRD Input argument, Executing condition :Bit Comment to be read :ANY_SIMPLE Output argument, ENO: Execution result...
  • Page 517 COMRD Function (1) Reads the comment data in the device specified for , and stores it as ASCII code data to the device specified for and the following devices. b8b7 ASCII code for the 2nd character ASCII code for the 1st character ASCII code for the 4th character ASCII code for the 3rd character Comment at device number specified by s...
  • Page 518 COMRD Operation Error In any of the following cases, an operation error occurs and the error flag is turned ON. • The comment is not registered to the device specified for (Error code: 4100) • The COMRD(P) instruction is executed when writing a comment file during online change. (Error code: 4100) Program Example In the following program, the comment set in D100 is stored as ASCII code data in Var_W0 and...
  • Page 519 COMRD Caution (1) QCPU completes the processing after several scans. (2) The COMRD(P) or PRC instruction is not executed if the start signal (execution command) of the COMRD(P) or PRC instruction is turned ON before completion of the instruction (while SM720 is ON).
  • Page 520: Character String Length Detection

    7.11.8 Character string length detection High Universal Performance LEN(P) P: Executing condition indicates any of the following instructions. Structured ladder LENP ENO:= (EN, s, d); Input argument, Executing condition :Bit Character string :ANY16 :String Output argument, ENO: Execution result :Bit Device number that stores the detected character string length:ANY16 Internal device Setting...
  • Page 521 BCD values. [Structured ladder] [ST] IF SM400 THEN LENP(TRUE,D0,Var_D10); BCD(TRUE,Var_D10,K4Y40); END_IF; [Operation] b8 b7 Var_D10 BCD conversion 0 0 1 0 BCD value "MITSUBISHI" (Characters "ABC" that follow 00 are ignored) 7.11 String Processing Instructions 7-181 7.11.8 Character string length detection...
  • Page 522: 16-/32-Bit Bin Data To Character String Data Conversion

    STR, DSTR 7.11.9 16-/32-bit BIN data to character string data conversion STR, DSTR High Universal Performance STR(P) P: Executing condition DSTR(P) indicates any of the following instructions. Structured ladder STRP DSTR DSTRP ENO:= (EN,s1, s2, d); Input argument, Executing condition :Bit Number of digits for placing a decimal to the value to be :ANY32...
  • Page 523 STR, DSTR Function STR(P) (1) Adds a decimal point at the position specified for , to the 16-bit BIN data specified for converts the data to character string data, and stores the results to the device specified for and the following devices. b8b7 ASCII code for the Total number of digits...
  • Page 524 STR, DSTR (c) If the total number of digits for decimal fraction is greater than the number of BIN data digits, a zero will be added automatically and the number converted by shifting to the right, so that it would become 0. Total number of digits Number of digits in decimal fraction...
  • Page 525 STR, DSTR (5) After conversion, character string data are stored to the device numbers following indicated below. (a) The sign 20 (space) will be stored if the BIN value is positive, and the sign 2D (minus sign) will be stored if it is negative. (b) If the setting for the number of digits for decimal fraction is anything other than 0, 2E (.
  • Page 526 STR, DSTR Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The total number of digits specified for is outside of the ranges shown below. (Error code: 4100) When the STR(P) instruction is in use .....
  • Page 527 STR, DSTR Program Example (1) In the following program, the 16-bit BIN data stored in Var_D10 are converted to character string data in accordance with the digit specification of D0 and D1 when X0 turns ON, and stores the result to Var_D20. (Var_D0 is declared as a global variable assigned with D0 and D1.) [Structured ladder] [ST]...
  • Page 528 STR, DSTR (2) In the following program, the 32-bit BIN data stored in Var_D10 are converted to character string data in accordance with the digit specification of D0 and D1 when X0 turns ON, and stores the result to Var_D20. (Var_D0 is declared as a global variable assigned with D0 and D1.) [Structured ladder] [ST]...
  • Page 529: 10Character String Data To 16-/32-Bit Bin Data Conversion

    VAL, DVAL 7.11.10 Character string data to 16-/32-bit BIN data conversion VAL, DVAL High Universal Performance VAL(P) P: Executing condition DVAL(P) indicates any of the following instructions. Structured ladder VALP DVAL DVALP ENO:= (EN,s, d1, d2); Input argument, Executing condition :Bit Character string data to be converted to BIN data :Array of ANY16 (0..4)/(0..6)
  • Page 530 VAL, DVAL Function VAL(P) (1) Converts character string data stored in the device specified for and the following devices to 16-bit BIN data, and stores the number of digits and BIN data to For converting character string data to BIN data, all data from the device specified for the device where 00 is stored will be processed as character string data.
  • Page 531 VAL, DVAL (8) In cases where the character string specified for contains 20 (space) or 30 (0) between the sign and the first numeric value other than 0, these 20 and 30 are ignored in the conversion to BIN value. Total number of digits Total number of digits Number of digits...
  • Page 532 VAL, DVAL (8) In cases where the character string specified for contains 20 (space) or 30 (0) between the sign and the first numeric value other than 0, these 20 and 30 are ignored in the conversion to BIN value. Total number of digits Number of digits 6 5 4 3 .
  • Page 533 VAL, DVAL Program Example (1) In the following program, the character string data in Var_D20 are read as an integer value and converted to the BIN value when X0 turns ON, and the result is stored to Var_D0. [Structured ladder] [ST] VALP(X0,Var_D20,Var_D10,Var_D0);...
  • Page 534: 11Floating-Point Data To Character String Data Conversion

    ESTR 7.11.11 Floating-point data to character string data conversion ESTR High Universal Performance ESTR(P) P: Executing condition indicates any of the following instructions. Structured ladder ESTR ESTRP ESTR ENO:= (EN,s1, s2, d); ESTR Input argument, Executing condition :Bit Floating-point data to be converted :Single-precision real Display specification of numeric values to be converted :Array of ANY16 (0..2)
  • Page 535 ESTR (2) The post-conversion data differs depending on the display specification specified for 0: Floating-point format The converted data differs depending 1: Exponent format on the format selected at Total number of digits Setting is possible in the range from 2 to 24. Number of digits in decimal fraction When using floating-point format b8b7...
  • Page 536 ESTR (c) The converted character string data are stored to the devices following as indicated below. 1) The sign 20 (space) will be stored if the floating-point real number is positive, and the sign 2D (minus sign) will be stored if it is negative. 2) If the decimal fraction of a floating-point real number is out of the range of the digits for decimal fraction, the lower decimal values will be rounded off.
  • Page 537 ESTR When using exponent format b8b7 [0] Exponent format ASCII code for the (total number of digits -1) ASCII code for the sign Total number of digits th digit Number of digits in decimal fraction ASCII code for the ASCII code for decimal (total number of digits -2) point (.)(2E th digit...
  • Page 538 ESTR (c) The converted character string data are stored to the devices following as indicated below. 1) If the floating-point real number is positive in value, the sign before the integer part will be stored as ASCII code 20 (space), and if it is a negative value, the sign will be stored as 2D ( ).
  • Page 539 ESTR Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value is not within the range indicated below. (Error code: 4100) ±...
  • Page 540 ESTR Program Example (1) In the following program, the floating-point real number data in Var_R0 is converted in accordance with the conversion specification stored in Var_R10 when X0 turns ON, and the result is stored to Var_D0 and the following devices. [Structured ladder] [ST] ESTRP(X0,Var_R0,Var_R10,Var_D0);...
  • Page 541: 12Character String Data To Floating-Point Data Conversion

    EVAL 7.11.12 Character string data to floating-point data conversion EVAL High Universal Performance EVAL(P) P: Executing condition indicates any of the following instructions. Structured ladder EVAL EVALP EVAL ENO:= (EN, s, d); EVAL Input argument, Executing condition :Bit Character string data to be converted to floating-point real :String (24) number data Output argument,...
  • Page 542 EVAL (2) The specified character string data can be converted to floating-point real number data either in the floating-point format or the exponent format. b8b7 ASCII code for the 1st character ASCII code for the sign ASCII code for the 3rd character ASCII code for the 2nd character ASCII code for the 5th character ASCII code for the 4th character...
  • Page 543 EVAL (b) When using exponent format b8b7 (space) 1 . 350 34E 2 Floating-point real number s +7 . 3 5 0 3 4 1 2 E These digits are cut (4) In the floating-point format, if 2B (+) is specified for the sign or if the specification of sign is omitted, conversion is made assuming a positive value.
  • Page 544 EVAL Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The integer part or the decimal fraction contains a character other than the one in the range of 30 (0) to 39 (9).
  • Page 545 EVAL (2) In the following program, the character string data in Var_D10 and the following devices are converted to the floating-point real number data when X20 turns ON, and the result is stored to Var_D100. [Structured ladder] [ST] EVALP(X20,Var_D10,Var_D100); [Operation] b8b7 Var_D10 (space)
  • Page 546: 13Hexadecimal Bin Data To Ascii Data Conversion

    7.11.13 Hexadecimal BIN data to ASCII data conversion High Universal Performance ASC(P) P: Executing condition indicates any of the following instructions. Structured ladder ASCP ENO:= (EN,s, n, d); Input argument, Executing condition :Bit Start number of the device that stores BIN data to be :ANY16 converted to character string data Number of characters to be stored...
  • Page 547 Function (1) Converts the 16-bit BIN data stored in the device specified for and the following devices to ASCII data by treating the BIN data in hexadecimal representation. Then, stores the converted data to the device specified for and the following devices, for the number of characters specified for n.
  • Page 548 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The range of the number of characters specified for n following the device number specified for exceeds the corresponding device range.
  • Page 549: 14Ascii Data To Hexadecimal Bin Data Conversion

    7.11.14 ASCII data to hexadecimal BIN data conversion High Universal Performance HEX(P) P: Executing condition indicates any of the following instructions. Structured ladder HEXP ENO:= (EN,s, n, d); Input argument, Executing condition :Bit Character string data to be converted to BIN data :ANY16 String Number of characters to be stored...
  • Page 550 For example, if the number 9 has been specified for n, the operation will be as shown below. b8b7 When "9" is set for n Code "38 " remains unchanged since the specified number of characters is "9". (2) When the number of characters is specified for n, the range of characters specified for well as the device range specified for in which the BIN data will be stored are automatically decided.
  • Page 551 Program Example In the following program, the character string data in D0 to D4 are converted to the BIN data when X0 turns ON, and the results are stored to the devices from D10 to D14. [Structured ladder] [ST] HEXP(X0,D0,10,D10); [Operation] b8b7 7.11 String Processing Instructions...
  • Page 552: 15Extraction Of Character String Data From Right/Left

    RIGHT, LEFT 7.11.15 Extraction of character string data from right/left RIGHT, LEFT High Universal Performance RIGHT(P) P: Executing condition LEFT(P) indicates any of the following instructions. Structured ladder RIGHT RIGHTP RIGHT LEFT LEFTP ENO:= (EN,s, n, d); RIGHT Input argument, Executing condition :Bit Character string data...
  • Page 553 RIGHT, LEFT When n b8b7 b8b7 "12345" ASCII code for the 5th character "ABCDEF12345" (2) The NULL code (00 ) indicating the end of the character string is automatically appended at the end of the character string data. For the format of the character string data, refer to Section 3.4.5.
  • Page 554 RIGHT, LEFT Program Example (1) In the following program, the 4 characters of data from the rightmost of the character string data stored in Var_R0 and the following devices are extracted and stored to Var_D0 and the following devices when X0 turns ON. [Structured ladder] [ST] RIGHTP(X0,Var_R0,4,Var_D0);...
  • Page 555: 16Random Selection And Replacement In Character String Data

    MIDR, MIDW 7.11.16 Random selection and replacement in character string data MIDR, MIDW High Universal Performance MIDR(P) P: Executing condition MIDW(P) indicates any of the following instructions. Structured ladder MIDR MIDRP MIDR MIDW MIDWP ENO:= (EN,s1, s2, d); MIDR Input argument, Executing condition :Bit Character string data...
  • Page 556 MIDR, MIDW Function MIDR(P) (1) Extracts the character string data of [1] characters, from the position specified for [0], counted from the left end of the character string data specified for , and stores the extracted data to the device specified for and the following devices.
  • Page 557 MIDR, MIDW MIDW(P) (1) Extracts the character string data of [1] characters, from the left end of the character string data specified for , and stores the extracted data to the character string data specified for to the devices starting from the position specified for [0] from the left end.
  • Page 558 MIDR, MIDW (5) If the number of characters specified for [1] is 1, stores the data up to the final character specified for to the device specified for and the following devices. Before execution b8b7 b8b7 "012345" "ABCDEFGHIJK" After execution Position counted from the left end of character string data b8b7...
  • Page 559 MIDR, MIDW Program Example (1) In the following program, the 3rd character through the 6th character from the left of the character string data stored in Var_D10 and the following devices are extracted and stored to Var_D0 and the following devices when X0 turns ON. [Structured ladder] [ST] MIDRP(X0,Var_D10,Var_R0,Var_D0);...
  • Page 560: 17Character String Data Search

    INSTR 7.11.17 Character string data search INSTR High Universal Performance INSTR(P) P: Executing condition indicates any of the following Structured ladder instructions. INSTR INSTR INSTRP ENO:= (EN,s1, s2, n, d); INSTR Input argument, Executing condition :Bit Character string data to be searched :String Character string data in which character string data are :String...
  • Page 561 INSTR Function (1) Searches for the character string data specified for in the devices from the nth character from the left of the character string data specified for and stores the result to the device specified for As the result of search, the location of match, counted in the number of characters from the first character of the character string data specified for , is stored.
  • Page 562 INSTR Program Example (1) In the following program, the character string data stored in Var_D0 and the following devices are searched from the 5th character from the left of the character string data stored in Var_R0 and the following devices when X0 turns ON, and the result is stored to Var_D100.
  • Page 563: 18Floating-Point Data To Bcd Format Conversion

    EMOD 7.11.18 Floating-point data to BCD format conversion EMOD High Universal Performance EMOD(P) P: Executing condition indicates any of the following instructions. Structured ladder EMOD EMODP EMOD ENO:= (EN,s1, s2, d); EMOD Input argument, Executing condition :Bit Floating-point real number data :Single-precision real Decimal fraction data :ANY16...
  • Page 564 EMOD specifies the decimal fraction digits of the floating-point real number data as shown below. Values between 0 and 7 can be specified for 3.25427 0 . 03542768 3542770 1 . 5 4 3 2 1E + 2 1543210 (2) The 7th digit of the significant figure of BCD stored in +1 and +2 is rounded off to make a 6-digit number.
  • Page 565 EMOD Program Example In the following program, the floating-point real number data in Var_D0 is converted to BCD format according to the decimal fraction digits as specified for Var_R10 when X0 turns ON, and stores the results to D100 and the following devices. [Structured ladder] [ST] Var_D0:=−0.987654;...
  • Page 566: 19Bcd Format To Floating-Point Data Conversion

    EREXP 7.11.19 BCD format to floating-point data conversion EREXP High Universal Performance EREXP(P) P: Executing condition indicates any of the following instructions. Structured ladder EREXP EREXPP EREXP ENO:= (EN,s1, s2, d); EREXP Input argument, Executing condition :Bit Start number of the device that stores floating-point data in :ANY16 BCD format Decimal fraction data...
  • Page 567 EREXP (3) 0 to 38 can be set for the BCD exponent of (4) 0 to 7 can be set for the decimal fraction digits of (Sign) 5423 BCD type floating- H3215423 (BCD 7 digits) 0321 3 . 2 1 5 4 2 3 E+ 2 point format (Sign (exponent part)) (BCD exponent)
  • Page 568: Special Function Instructions

    7.12 Special Function Instructions 7.12.1 SIN operation on floating-point data (single precision) High Universal Performance SIN(P) P: Executing condition indicates any of the following instructions. Structured ladder SINP ENO:= (EN, s, d); Input argument, Executing condition :Bit Angle data on which the sine function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 569 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
  • Page 570: Sin Operation On Floating-Point Data (Double Precision)

    SIND 7.12.2 SIN operation on floating-point data (double precision) SIND High Universal Performance SIND(P) P: Executing condition indicates any of the following instructions. Structured ladder SIND SINDP SIND ENO:= (EN, s, d); SIND Input argument, Executing condition :Bit Angle data on which the sine function is evaluated :Double-precision real Output argument, ENO:...
  • Page 571 SIND Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 572: Cos Operation On Floating-Point Data (Single Precision)

    7.12.3 COS operation on floating-point data (single precision) High Universal Performance COS(P) P: Executing condition indicates any of the following instructions. Structured ladder COSP ENO:= (EN, s, d); Input argument, Executing condition :Bit Angle data on which the cosine function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 573 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
  • Page 574: Cos Operation On Floating-Point Data (Double Precision)

    COSD 7.12.4 COS operation on floating-point data (double precision) COSD High Universal Performance COSD(P) P: Executing condition indicates any of the following instructions. Structured ladder COSD COSDP COSD ENO:= (EN, s, d); COSD Input argument, Executing condition :Bit Angle data on which the cosine function is evaluated :Double-precision real Output argument, ENO:...
  • Page 575 COSD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 576: Tan Operation On Floating-Point Data (Single Precision)

    7.12.5 TAN operation on floating-point data (single precision) High Universal Performance TAN(P) P: Executing condition indicates any of the following instructions. Structured ladder TANP ENO:= (EN, s, d); Input argument, Executing condition :Bit Angle data on which the tangent function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 577 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • Operation results are outside of the range shown below. (Error code: 4100) -126 0, 2 |operation result|...
  • Page 578: Tan Operation On Floating-Point Data (Double Precision)

    TAND 7.12.6 TAN operation on floating-point data (double precision) TAND High Universal Performance TAND(P) P: Executing condition indicates any of the following instructions. Structured ladder TAND TANDP TAND ENO:= (EN, s, d); TAND Input argument, Executing condition :Bit Angle data on which the tangent function is evaluated :Double-precision real Output argument, ENO:...
  • Page 579 TAND Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified data is not within the following range. (Error code: 4140) -1022 1024...
  • Page 580: Sin -1

    ASIN 7.12.7 operation on floating-point data (single precision) ASIN High Universal Performance ASIN(P) P: Executing condition indicates any of the following instructions. Structured ladder ASIN ASINP ASIN ENO:= (EN, s, d); ASIN Input argument, Executing condition :Bit Sine values on which the arcsine function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 581 ASIN Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is outside the range of 1.0 to 1.0. (Error code: 4100) •...
  • Page 582: Sin Operation On Floating-Point Data (Single Precision)

    ASIN [ST] IF SM400 THEN ASIN(TRUE,Var_D0,Var_D10); DEG(TRUE,Var_D10,Var_D20); INT(TRUE,Var_D20,Var_D30); BCD(TRUE,Var_D30,K4Y40); END_IF; [Operation example when the value of 0.5 is set for Var_D0] Var_D0 Var_D10 conversion 0 . 5 0 . 5 2 3 5 9 8 8 Floating-point real Floating-point real ASIN number number...
  • Page 583: Sin Operation On Floating-Point Data (Double Precision)

    ASIND 7.12.8 operation on floating-point data (double precision) ASIND High Universal Performance ASIND(P) P: Executing condition indicates any of the following instructions. Structured ladder ASIND ASINDP ASIND ENO:= (EN, s, d); ASIND Input argument, Executing condition :Bit Sine values on which the arcsine function is evaluated :Double-precision real Output argument, ENO:...
  • Page 584 ASIND Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 585: Cos -1 Operation On Floating-Point Data (Single Precision)

    ACOS 7.12.9 operation on floating-point data (single precision) ACOS High Universal Performance ACOS(P) P: Executing condition indicates any of the following instructions. Structured ladder ACOS ACOSP ACOS ENO:= (EN, s, d); ACOS Input argument, Executing condition :Bit Cosine values on which the arccosine function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 586 ACOS Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is outside the range of 1.0 to 1.0. (Error code: 4100) •...
  • Page 587 ACOS [ST] IF SM400 THEN ACOS(TRUE,Var_D0,Var_D10); DEG(TRUE,Var_D10,Var_D20); INT(TRUE,Var_D20,Var_D30); BCD(TRUE,Var_D30,K4Y40); END_IF; [Operation example when the value of 0.5 is set for Var_D0] Var_D0 Var_D10 conversion 0 . 5 1 . 0 4 7 1 9 8 Floating-point real ACOS Floating-point real number number Angle conversion...
  • Page 588: Operation On Floating-Point Data (Double Precision)

    ACOSD 7.12.10 operation on floating-point data (double precision) ACOSD High Universal Performance ACOSD(P) P: Executing condition indicates any of the following instructions. Structured ladder ACOSD ACOSDP ACOSD ENO:= (EN, s, d); ACOSD Input argument, Executing condition :Bit Cosine values on which the arccosine function is evaluated :Double-precision real Output argument, ENO:...
  • Page 589 ACOSD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 590: Operation On Floating-Point Data (Single Precision)

    ATAN 7.12.11 operation on floating-point data (single precision) ATAN High Universal Performance ATAN(P) P: Executing condition indicates any of the following instructions. Structured ladder ATAN ATANP ATAN ENO:= (EN, s, d); ATAN Input argument, Executing condition :Bit Tangent values on which the arctangent function is evaluated :Single-precision real/ANY32 Output argument, ENO: Execution result...
  • Page 591 ATAN Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
  • Page 592: Operation On Floating-Point Data (Double Precision)

    ATAND 7.12.12 operation on floating-point data (double precision) ATAND High Universal Performance ATAND(P) P: Executing condition indicates any of the following instructions. Structured ladder ATAND ATANDP ATAND ENO:= (EN, s, d); ATAND Input argument, Executing condition :Bit Tangent values on which the arctangent function is evaluated :Double-precision real Output argument, ENO: Execution result...
  • Page 593 ATAND Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 594: 13Degree To Radian Conversion On Floating-Point Data (Single Precision)

    7.12.13 Degree to radian conversion on floating-point data (single precision) High Universal Performance RAD(P) P: Executing condition indicates any of the following instructions. Structured ladder RADP ENO:= (EN, s, d); Input argument, Executing condition :Bit Angle data whose unit is converted from degrees to radians :Single-precision real/ANY32 Output argument, ENO:...
  • Page 595 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
  • Page 596: 14Degree To Radian Conversion On Floating-Point Data (Double Precision)

    RADD 7.12.14 Degree to radian conversion on floating-point data (double precision) RADD High Universal Performance RADD(P) P: Executing condition indicates any of the following instructions. Structured ladder RADD RADDP RADD ENO:= (EN, s, d); RADD Input argument, Executing condition :Bit Angle data whose unit is converted from degrees to radians :Double-precision real Output argument,...
  • Page 597 RADD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 598: 15Radian To Degree Conversion On Floating-Point Data (Single Precision)

    7.12.15 Radian to degree conversion on floating-point data (single precision) High Universal Performance DEG(P) P: Executing condition indicates any of the following instructions. Structured ladder DEGP ENO:= (EN, s, d); Input argument, Executing condition :Bit Angle data whose unit is converted from radians to degrees :Single-precision real/ANY32 Output argument, ENO:...
  • Page 599 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
  • Page 600: 16Radian To Degree Conversion On Floating-Point Data (Double Precision)

    DEGD 7.12.16 Radian to degree conversion on floating-point data (double precision) DEGD High Universal Performance DEGD(P) P: Executing condition indicates any of the following instructions. Structured ladder DEGD DEGDP DEGD ENO:= (EN, s, d); DEGD Input argument, Executing condition :Bit Angle data whose unit is converted from radians to degrees :Double-precision real Output argument,...
  • Page 601 DEGD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 602: 17Square Root Operation On Floating-Point Data (Single Precision)

    7.12.17 Square root operation on floating-point data (single precision) High Universal Performance SQR(P) P: Executing condition indicates any of the following instructions. Structured ladder SQRP ENO:= (EN, s, d); Input argument, Executing condition :Bit Data on which the square root function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 603 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is a negative number. (Error code: 4100) •...
  • Page 604: 18Square Root Operation On Floating-Point Data (Double Precision)

    SQRD 7.12.18 Square root operation on floating-point data (double precision) SQRD High Universal Performance SQRD(P) P: Executing condition indicates any of the following instructions. Structured ladder SQRD SQRDP SQRD ENO:= (EN, s, d); SQRD Input argument, Executing condition :Bit Data on which the square root function is evaluated :Double-precision real Output argument, ENO:...
  • Page 605 SQRD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is a negative number. (Error code: 4100) •...
  • Page 606: 19Exponential Operation On Floating-Point Data (Single Precision)

    7.12.19 Exponential operation on floating-point data (single precision) High Universal Performance EXP(P) P: Executing condition indicates any of the following instructions. Structured ladder EXPP ENO:= (EN, s, d); Input argument, Executing condition :Bit Data on which the exponential function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 607 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • Operation result is not within the following range. (Error code: 4100) -126 | operation result | (For High Performance model QCPU)
  • Page 608 [Operation example when the value of 13 is specified for X20 to X27] Var_D20 Floating-point Var_D10 Var_D0 BIN conversion EXP operation conversion 4 4 2 4 1 3 . 4 BCD value BIN value Floating-point real Floating-point real number number *2: The operation result will be under 2129 if the BCD value of X20 to X27 is less than 89, from the calculation loge 2129 = 89.4.
  • Page 609: 20Exponential Operation On Floating-Point Data (Double Precision)

    EXPD 7.12.20 Exponential operation on floating-point data (double precision) EXPD High Universal Performance EXPD(P) P: Executing condition indicates any of the following instructions. Structured ladder EXPD EXPDP EXPD ENO:= (EN, s, d); EXPD Input argument, Executing condition :Bit Data on which the exponential function is evaluated :Double-precision real Output argument, ENO:...
  • Page 610 EXPD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value of the specified device is not within the following range. (Error code: 4140) -1022 1024...
  • Page 611 EXPD Conversion from natural logarithm to common logarithm In the CPU module, a natural logarithm operation is performed. To obtain a common logarithm value, enter a common logarithm value divided by 0.43429 in 7.12 Special Function Instructions 7-271 7.12.20 Exponential operation on floating-point data (double precision)
  • Page 612: 21Natural Logarithm Operation On Floating-Point Data (Single Precision)

    7.12.21 Natural logarithm operation on floating-point data (single precision) High Universal Performance LOG(P) P: Executing condition indicates any of the following instructions. Structured ladder LOGP ENO:= (EN, s, d); Input argument, Executing condition :Bit Data on which the natural logarithm function is evaluated :Single-precision real/ANY32 Output argument, ENO:...
  • Page 613 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is negative. (Error code: 4100) • The value specified for is 0.
  • Page 614 Conversion from natural logarithm to common logarithm In the CPU module, a natural logarithm operation is performed. To obtain the value of common logarithm, convert the value of natural logarithm with the following expression. X = 0.43429 7.12 Special Function Instructions 7-274 7.12.21 Natural logarithm operation on floating-point data (single precision)
  • Page 615: 22Natural Logarithm Operation On Floating-Point Data (Double Precision)

    LOGD 7.12.22 Natural logarithm operation on floating-point data (double precision) LOGD High Universal Performance LOGD(P) P: Executing condition indicates any of the following instructions. Structured ladder LOGD LOGDP LOGD ENO:= (EN, s, d); LOGD Input argument, Executing condition :Bit Data on which the natural logarithm function is evaluated :Double-precision real Output argument, ENO:...
  • Page 616 LOGD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is negative. (Error code: 4100) • The value specified for is 0.
  • Page 617: 23Random Number Generation And Series Update

    RND, SRND 7.12.23 Random number generation and series update RND, SRND High Universal Performance RND(P) P: Executing condition SRND(P) indicates any of the following instructions. Structured ladder RNDP SRND SRNDP ENO:= (EN, d); Structured ladder SRND ENO:= (EN, s); SRND Input argument, Executing condition :Bit...
  • Page 618 RND, SRND RND(P) Generates random numbers from 0 to 32767, and stores them to the device specified for SRND(P) Updates random number series according to the 16-bit BIN data stored in the device specified for Operation Error No operation error occurs in the execution of the RND(P) and SRND(P) instructions. Program Example (1) In the following program, the random number is stored to Var_D100 when X10 turns ON.
  • Page 619: 24Square Root Operation On 4-/8-Digit Bcd Data

    BSQR, BDSQR 7.12.24 Square root operation on 4-/8-digit BCD data BSQR, BDSQR High Universal Performance BSQR(P) P: Executing condition BDSQR(P) indicates any of the following instructions. Structured ladder BSQR BSQRP BSQR BDSQR BDSQRP ENO:= (EN, s, d); BSQR Input argument, Executing condition :Bit Data on which the square root function is evaluated...
  • Page 620 BSQR, BDSQR BDSQR(P) (1) Evaluates the square root function on the values specified for +1 and stores the results to the device specified for Integer part Decimal fraction 2-word data (2) BCD value of a maximum of 8 digits (0 to 99999999) can be specified for (3) The operation results of +1 are stored as their respective BCD values between 0 and 9999.
  • Page 621 BSQR, BDSQR Program Example (1) In the following program, the square root function is evaluated on 1325 in BCD value, and the integer part is output in BCD 4 digits to the devices from Y50 to Y5F, and the decimal fraction is output in BCD 4 digits to the devices from Y40 to Y4F.
  • Page 622 BSQR, BDSQR (2) In the following program, the square root function is evaluated on 74625813 in BCD value, and the integer part of the result is output in BCD 4 digits to the devices from Y50 to Y5F, and the decimal fraction is output in BCD 4 digits to the devices from Y40 to Y4F. [Structured ladder] Sets the data (BCD value) on which the square root function is evaluated.
  • Page 623: 25Sin Operation On Data In Bcd Format

    BSIN 7.12.25 SIN operation on data in BCD format BSIN High Universal Performance BSIN(P) P: Executing condition indicates any of the following instructions. Structured ladder BSIN BSINP BSIN ENO:= (EN, s, d); BSIN Input argument, Executing condition :Bit Data on which the sine function is evaluated, or start number :ANY16 of the device that stores data Output argument,...
  • Page 624 BSIN Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is not a BCD value. (Error code: 4100) •...
  • Page 625 BSIN [ST] IF SM400 THEN BINP(TRUE,K3X20,Var_D50); BINP(TRUE,H360,Var_D51); BCDP(TRUE,Var_D50 MOD Var_D51,Var_D10); BSIN(TRUE,Var_D10,Var_D20); MOV(TRUE,Var_D20[1],K1Y50); MOV(TRUE,Var_D20[2],K4Y40); END_IF; OUT(Var_D20[0]<>0,Y60); [Operation example when the value 590 is specified for X20 to X2B] Var_D10 [0] B/operation 5 9 0 0 0 0 1 BCD value BCD value (quotient) BSIN Var_D10 [1]...
  • Page 626: 26Cos Operation On Data In Bcd Format

    BCOS 7.12.26 COS operation on data in BCD format BCOS High Universal Performance BCOS(P) P: Executing condition indicates any of the following instructions. Structured ladder BCOS BCOSP BCOS ENO:= (EN, s, d); BCOS Input argument, Executing condition :Bit Data on which the cosine function is evaluated, or start :ANY16 number of the device that stores data Output argument,...
  • Page 627 BCOS Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is not a BCD value. (Error code: 4100) •...
  • Page 628 BCOS [ST] IF SM400 THEN BINP(TRUE,K3X20,Var_D50); BINP(TRUE,H360,Var_D51); BCDP(TRUE,Var_D50 MOD Var_D51,Var_D11); BCOS(TRUE,Var_D11,Var_D20); MOV(TRUE,Var_D20[1],K1Y50); MOV(TRUE,Var_D20[2],K4Y40); END_IF; OUT(Var_D20[0]<>0,Y60); [Operation example when the value 430 is specified for X20 to X2B] Var_D10 [0] B/operation 4 3 0 0 0 0 1 BCD value BCD value (quotient) BCOS Var_D10 [1]...
  • Page 629 BTAN 7.12.27 TAN operation on data in BCD format BTAN High Universal Performance BTAN(P) P: Executing condition indicates any of the following instructions. Structured ladder BTAN BTANP BTAN ENO:= (EN, s, d); BTAN Input argument, Executing condition :Bit Data on which the tangent function is evaluated, or start :ANY16 number of the device that stores data Output argument,...
  • Page 630 BTAN Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is not a BCD value. (Error code: 4100) •...
  • Page 631 BTAN [ST] IF SM400 THEN BINP(TRUE,K3X20,Var_D50); BINP(TRUE,H360,Var_D51); BCDP(TRUE,Var_D50 MOD Var_D51,Var_D10); OUT(Var_D10=H90 OR Var_D10=H270,M1); END_IF; IF NOT(M1) THEN BTAN(TRUE,Var_D10,Var_D20); MOV(TRUE,Var_D20[1],K1Y50); MOV(TRUE,Var_D20[2],K4Y40); END_IF; OUT(Var_D20[0]<>0,Y60); [Operation example when the value 390 is specified for X20 to X2B] Var_D10 [0] B/operation 3 9 0 0 0 0 1 BCD value BCD value...
  • Page 632: Operation On Data In Bcd Format

    BASIN 7.12.28 operation on data in BCD format BASIN High Universal Performance BASIN(P) P: Executing condition indicates any of the following instructions. Structured ladder BASIN BASINP BASIN ENO:= (EN, s, d); BASIN Input argument, Executing condition :Bit Data on which the arcsine function is evaluated :Array of ANY16 (0..2) Output argument, ENO:...
  • Page 633 BASIN Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is not a BCD value. (Error code: 4100) •...
  • Page 634 BASIN [ST] MOV(X0,1,D0); MOV(NOT(X0),0,D0); IF SM400 THEN MOV(TRUE,K1X30,D1); MOV(TRUE,K4X20,D2); END_IF; OUT((D1=1 AND D2<>0) OR D1>1,M0); BASIN(NOT(M0),Var_D0,K4Y40); [Operation example when the value 0.4753 is specified for X20 to X33] X0 OFF BCD value Transfer BASIN operation BCD value BCD value BASIN BCD value Transfer BCD value...
  • Page 635: Operation On Data In Bcd Format

    BACOS 7.12.29 operation on data in BCD format BACOS High Universal Performance BACOS(P) P: Executing condition indicates any of the following instructions. Structured ladder BACOS BACOSP BACOS ENO:= (EN, s, d); BACOS Input argument, Executing condition :Bit Data on which the arccosine function is evaluated :Array of ANY16 (0..2) Output argument, ENO:...
  • Page 636 BACOS Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is not a BCD value. (Error code: 4100) •...
  • Page 637 BACOS [ST] MOV(X0,1,D0); MOV(NOT(X0),0,D0); IF SM400 THEN MOV(TRUE,K1X30,D1); MOV(TRUE,K4X20,D2); END_IF; OUT((D1=1 AND D2<>0) OR D1>1,M0); BACOS(NOT(M0),Var_D0,K4Y40); [Operation example when the value 0.7650 is specified for X0 and X20 to X33] X0 ON BCD value Transfer BACOS operation BACOS BCD value BCD value BCD value Transfer...
  • Page 638: Operation On Data In Bcd Format

    BATAN 7.12.30 operation on data in BCD format BATAN High Universal Performance BATAN(P) P: Executing condition indicates any of the following instructions. Structured ladder BATAN BATANP BATAN ENO:= (EN, s, d); BATAN Input argument, Executing condition :Bit Data on which the arctangent function is evaluated :Array of ANY16 (0..2) Output argument, ENO:...
  • Page 639 BATAN Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value specified for is not a BCD value. (Error code: 4100) •...
  • Page 640: Data Control Instructions

    LIMIT, DLIMT 7.13 Data Control Instructions 7.13.1 Upper and lower limit controls of 16-/32-bit BIN data LIMIT, DLIMT High Universal Performance LIMIT(_P) P: Executing condition DLIMT(_P) indicates any of the following Structured ladder instructions. LIMIT LIMIT LIMITP DLIMIT DLIMITP ENO:= (EN,s1, s2, s3, d);...
  • Page 641 LIMIT, DLIMT Function LIMIT(P) (1) Controls the output value to be stored to the device specified for by checking the input value (BIN 16 bits) specified for is within the range of upper and lower limit values specified for Output value is controlled in the way shown below. Lower limit value Input value Lower limit value...
  • Page 642 LIMIT, DLIMT Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The lower limit value specified for is larger than the upper limit value specified for (Error code: 4100) Program Example (1) In the following program, the limit control from 500 to 5000 is performed on the data set in...
  • Page 643 LIMIT, DLIMT (2) In the following program, the limit control from 10000 to 1000000 is performed on the data set in BCD values from X20 to X3F when X0 turns ON, and the result is stored to Var_D10. [Structured ladder] [ST] IF X0 THEN DBINP(TRUE,K8X20,Var_D0);...
  • Page 644: Dead Band Control Of 16-/32-Bit Bin Data

    BAND, DBAND 7.13.2 Dead band control of 16-/32-bit BIN data BAND, DBAND High Universal Performance BAND(P) P: Executing condition DBAND(P) indicates any of the following Structured ladder instructions. BAND BAND BANDP DBAND DBANDP ENO:= (EN,s1, s2, s3, d); BAND Input argument, Executing condition :Bit Lower limit value of the dead band (No output band)
  • Page 645 BAND, DBAND Function BAND(P) (1) Controls the output value to be stored to the device specified for by checking the input value (BIN 16 bits) specified for is within the range of dead band upper and lower limit values specified for Output value is controlled in the way shown below.
  • Page 646 BAND, DBAND (3) The output value stored to is a signed 32-bit BIN value. Therefore, if the operation results exceed the range of 2147483648 to 2147483647, the following takes place. Dead band lower limit value ....1000 When : Input value ..........
  • Page 647 BAND, DBAND (2) In the following program, the dead band control applying the lower and upper limits from 10000 to 10000 is performed on the data set in BCD value at Var_D0 when X0 turns ON, and the result is stored to Var_D10. [Structured ladder] [ST] DBANDP(X0,−10000,10000,Var_D0,Var_D10);...
  • Page 648: Zone Control Of 16-/32-Bit Bin Data

    ZONE, DZONE 7.13.3 Zone control of 16-/32-bit BIN data ZONE, DZONE High Universal Performance ZONE(P) P: Executing condition DZONE(P) indicates any of the following Structured ladder instructions. ZONE ZONE ZONEP DZONE DZONEP ENO:= (EN, s1, s2, s3, d); ZONE Input argument, Executing condition :Bit Negative bias value that is added to the input value...
  • Page 649 ZONE, DZONE Function ZONE(P) (1) Adds a bias value specified for to an input value specified for , and stores the result to the device specified for Bias values are calculated in the way shown below. Input value Input value Negative bias value Output value •...
  • Page 650 ZONE, DZONE (2) Values between 2147483648 and 2147483647 can be specified for , and (3) The value stored to is a signed 32-bit BIN value. Therefore, if the operation results exceed the range of 2147483648 to 2147483647, the following takes place. Negative bias value ......
  • Page 651 ZONE, DZONE (2) In the following program, the zone control applying negative and positive bias values of 10000 to 10000 is performed on the data set for Var_D0 when X1 turns ON, and the result is stored to Var_D10. [Structured ladder] [ST] DZONEP(X1,−10000,10000,Var_D0,Var_D10);...
  • Page 652: Switch Instructions

    RSET 7.14 Switch Instructions 7.14.1 Switching file register block numbers RSET High Universal Performance RSET(P) P: Executing condition indicates any of the following instructions. Structured ladder RSET RSETP RSET ENO:= (EN, s); RSET Input argument, Executing condition :Bit Block number data to be switched, or device number that :ANY16 stores block number data Output argument,...
  • Page 653 RSET Example When switching block number from block No. 0 to block No. 1 Processing executed to file registers Setting of a block number Block Block Block File register Currently used after the used file execution of RSET register R32767 R32767 R32767 instruction...
  • Page 654 RSET Program Example In the following program, R0 of the block number 0 and the block number 1 are compared. [Structured ladder] [ST] IF SM400 THEN RSETP(TRUE,0); MOVP(TRUE,R0,Var_D0); RSETP(TRUE,1); MOVP(TRUE,R0,Var_D1); END_IF; OUT(Var_D0=Var_D1,Y40); OUT(Var_D0<Var_D1,Y41); OUT(Var_D0>Var_D1,Y42); [Operation] Drive No.1, ABC Drive No.1, DEF -3216 5001 9330...
  • Page 655: Setting File Register Files

    QDRSET 7.14.2 Setting file register files QDRSET High Universal Performance QDRSET(P) P: Executing condition indicates any of the following instructions. Structured ladder QDRSET QDRSETP QDRSET ENO:= (EN, s); QDRSET Input argument, Executing condition :Bit Character string data to be changed with the driver number file :String name of file register Output argument,...
  • Page 656 QDRSET Example When switching from Drive No. 1/File name B to Drive No. 3/File name A Processing executed to file registers Setting of a drive number and file name Drive 1 Drive 1 Drive 1 Drive 2 Drive 3 Drive 4 File name File name File name...
  • Page 657 QDRSET Program Example In the following program, R0 of the drive number 1 ABC and the drive number 1 DEF are compared. [Structured ladder] [ST] IF X0 THEN QDRSETP(TRUE,"1:ABC"); MOVP(TRUE,R0,Var_D0); QDRSETP(TRUE,"1:DEF"); MOVP(TRUE,R0,Var_D1); END_IF; OUT(Var_D0=Var_D1,Y40); OUT(Var_D0<Var_D1,Y41); OUT(Var_D0>Var_D1,Y42); [Operation] Drive No.1, ABC Drive No.1, DEF -3216 5001...
  • Page 658: Setting Files For Comments

    QCDSET 7.14.3 Setting files for comments QCDSET High Universal Performance QCDSET(P) P: Executing condition indicates any of the following instructions. Structured ladder QCDSET QCDSETP QCDSET ENO:= (EN, s); QCDSET Input argument, Executing condition :Bit Character string data to be changed with the driver number file :String name of comment file Output argument,...
  • Page 659 QCDSET Example When switching from Drive No. 1/File name B to Drive No. 3/File name A Processing executed to file registers Setting of a drive number and file name Drive 1 Drive 1 Drive 1 Drive 2 Drive 3 Drive 4 File name File name File name...
  • Page 660 QCDSET Program Example In the following program, the object file of the comments are switched to the file names ABC.QCD in the drive number 1 when X0 turns ON, and to the file names DEF.QCD in the drive number 3 when X1 turns ON. [Structured ladder] [ST] QCDSETP(X0,"1:ABC");...
  • Page 661: Clock Instructions

    DATERD 7.15 Clock Instructions 7.15.1 Reading clock data DATERD High Universal Performance DATERD(P) P: Executing condition indicates any of the following instructions. Structured ladder DATERD DATERDP DATERD ENO:= (EN, d); DATERD Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Clock data that are read :Array of ANY16 (0..6)
  • Page 662 DATERD (3) The day of week in +6 is stored as 0 to 6 to represent the days from Sunday to Saturday. Day of week Stored data (4) Compensation is made automatically for leap years. Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 663 DATERD [ST] IF SM400 THEN DATERD(TRUE,Var_D0); BCD(TRUE,Var_D0[0],K4Y70); BCD(TRUE,Var_D0[1],K2Y68); BCD(TRUE,Var_D0[2],K2Y60); BCD(TRUE,Var_D0[3],K2Y58); BCD(TRUE,Var_D0[4],K2Y50); BCD(TRUE,Var_D0[5],K2Y48); BCD(TRUE,Var_D0[6],K1Y44); END_IF; [Operation] (Year) Var_D0[0] 2005 Var_D0[1] (Month, Day) Clock data Var_D0[2] 2005, 12, 24, 12:57:39, Sunday Var_D0[3] Var_D0[4] (Hour, Minute) Var_D0[5] Var_D0[6] (Second, Day of week) 7.15 Clock Instructions 7-323 7.15.1 Reading clock data...
  • Page 664: Writing Clock Data

    DATEWR 7.15.2 Writing clock data DATEWR High Universal Performance DATEWR(P) P: Executing condition indicates any of the following instructions. Structured ladder DATEWR DATEWRP DATEWR ENO:= (EN, s); DATEWR Input argument, Executing condition :Bit Clock data to be written to clock element :Array of ANY16 (0..6) Output argument, ENO:...
  • Page 665 DATEWR +2 specifies the day in values from 1 to 31. +3 specifies the hour in values from 0 to 23 (using 24-hour clock, from 0 hours to 23 hundred hours). (Uses the 24-hour clock.) +4 specifies the minute in values from 0 to 59. +5 specifies the second in values from 0 to 59.
  • Page 666 DATEWR [ST] IF X40 THEN BIN(TRUE,K4X30,Var_D0[0]); BIN(TRUE,K2X28,Var_D0[1]); BIN(TRUE,K2X20,Var_D0[2]); BIN(TRUE,K2X18,Var_D0[3]); BIN(TRUE,K2X10,Var_D0[4]); BIN(TRUE,K2X8,Var_D0[5]); BIN(TRUE,K1X4,Var_D0[6]); DATEWR(TRUE,Var_D0); END_IF; [Operation] X38 X37 (Year) Var_D0[0] 2000 X28 X27 Var_D0[1] (Month, Day) Clock data Var_D0[2] Var_D0[3] 2000, 12, 24 12:57:39 Sunday X18 X17 Var_D0[4] (Hour, Minute) Var_D0[5] Var_D0[6] (Second) 7.15 Clock Instructions...
  • Page 667: Clock Data Addition

    DATE+ 7.15.3 Clock data addition DATE+ High Universal Performance DATE+(P) P: Executing condition indicates any of the following instructions. Structured ladder DATE+ DATE+P DATE+ Not supported Input argument, Executing condition :Bit Clock (time) data :Array of ANY16 (0..2) Time data to be added :Array of ANY16 (0..2) Output argument, ENO:...
  • Page 668 DATE+ (2) If the addition result of time exceeds 24 hours, 24 hours will be subtracted from the sum to make the final operation result. For example, if the time 20:20:20 were added to 14:20:30, the result would not be 34:40:50, but would instead be 10:40:50.
  • Page 669 DATE+ [Operation] • Clock data read by the DATERDP instruction. Clock element Var_D0[0] Year Var_D0[1] Month Var_D0[2] Var_D0[3] Hour Time data Var_D0[4] Minute Var_D0[5] Second Var_D0[6] Day of week • Addition by the DATE+ instruction. Var_D3[3] Var_D10[0] Var_D100[0] Hour: 10 Hour: 1 Hour: 11 Var_D3[4]...
  • Page 670: Clock Data Subtraction

    DATE- 7.15.4 Clock data subtraction DATE- High Universal Performance DATE-(P) P: Executing condition indicates any of the following instructions. Structured ladder DATE- DATE-P DATE- Not supported Input argument, Executing condition :Bit Clock (time) data :Array of ANY16 (0..2) Time data to be subtracted :Array of ANY16 (0..2) Output argument, ENO:...
  • Page 671 DATE- (2) If the operation results in a negative number, 24 will be added to the result to make a final operation result. For example, if the clock time 10:42:12 were subtracted from 4:50:32, the result would not 6:8:20, but rather would be 18:8:20. Hour: 4 Hour: 10 Hour: 18...
  • Page 672 DATE- [Operation] • Clock data read by the DATERDP instruction. Clock element Year Var_D100[0] Month Var_D100[1] Var_D100[2] Hour Var_D100[3] Minute Time data Var_D100[4] Var_D100[5] Second Var_D100[6] Day of week • Subtraction by the DATE- instruction (when 10 hours, 40 minutes, and 10 seconds have been specified for Var_D10).
  • Page 673: Time Data Conversion (Hour/Minute/Second Format To Seconds)

    SECOND 7.15.5 Time data conversion (hour/minute/second format to seconds) SECOND High Universal Performance SECOND(P) P: Executing condition indicates any of the following instructions. Structured ladder SECOND SECONDP SECOND ENO:= (EN, s, d); SECOND Input argument, Executing condition :Bit Clock data before the conversion :Array of ANY16 (0..2) Output argument, ENO:...
  • Page 674 SECOND Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value set for is outside of the setting range. (Error code: 4100) •...
  • Page 675: Time Data Conversion (Seconds To Hour/Minute/Second Format)

    HOUR 7.15.6 Time data conversion (seconds to hour/minute/second format) HOUR High Universal Performance HOUR(P) P: Executing condition indicates any of the following instructions. Structured ladder HOUR HOURP HOUR ENO:= (EN, s, d); HOUR Input argument, Executing condition :Bit Clock data before the conversion :ANY32 Output argument, ENO:...
  • Page 676 HOUR Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The value set for is outside of the setting range. (Error code: 4100) •...
  • Page 677: Program Control Instructions

    PSTOP 7.16 Program Control Instructions 7.16.1 Program standby PSTOP High Universal Performance PSTOP(P) P: Executing condition indicates any of the following instructions. Structured ladder PSTOP PSTOPP PSTOP ENO:= (EN, s); PSTOP Input argument, Executing condition :Bit Character string data of the file name whose program is set to :String the standby status Output argument,...
  • Page 678 PSTOP Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The program with the specified file name does not exist. (Error code: 2410) •...
  • Page 679: Program Output Off Standby

    POFF 7.16.2 Program output OFF standby POFF High Universal Performance POFF(P) P: Executing condition indicates any of the following instructions. Structured ladder POFF POFFP POFF ENO:= (EN, s); POFF Input argument, Executing condition :Bit File name whose program is set to the standby type by turning :String OFF the output Output argument,...
  • Page 680 POFF Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The program with the specified file name does not exist. (Error code: 2410) •...
  • Page 681: Registering Program As Scan Execution Type

    PSCAN 7.16.3 Registering program as scan execution type PSCAN High Universal Performance PSCAN(P) P: Executing condition indicates any of the following instructions. Structured ladder PSCAN PSCANP PSCAN ENO:= (EN, s); PSCAN Input argument, Executing condition :Bit File name whose program is set to the scan execution type :String Output argument, ENO:...
  • Page 682 PSCAN (5) It is not necessary to specify the extension (.QPG) with the file name. (Only .QPG files will be acted on.) Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 683: Registering Program As Low-Speed Execution Type

    PLOW 7.16.4 Registering program as low-speed execution type PLOW High Universal Performance PLOW(P) P: Executing condition indicates any of the following instructions. Structured ladder PLOW PLOWP PLOW ENO:= (EN, s); PLOW Input argument, Executing condition :Bit File name whose program is set to the low-speed execution :String type Output argument,...
  • Page 684 PLOW (5) It is not necessary to specify the extension (.QPG) with the file name. (Only .QPG files will be acted on.) Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 685: Checking Program Execution Status

    LDPCHK, ANDPCHK, ORPCHK 7.16.5 Checking program execution status LDPCHK, ANDPCHK, ORPCHK High Universal Performance LDPCHK ANDPCHK ORPCHK indicates any of the following instructions. Structured ladder LDPCHK ANDPCHK ORPCHK LDPCHK ENO:= (EN, s); LDPCHK Input argument, Executing condition :Bit File name of a program whose execution status is checked :String Output argument, ENO:...
  • Page 686 LDPCHK, ANDPCHK, ORPCHK Program Example In the following program, Y10 is turned ON when the program file "ABC.QPG" is in execution. [Structured ladder] [ST] OUT(LDPCHK(TRUE,"ABC"),Y10); Remark Non-execution indicates that the program execution type is a standby type. Execution indicates that the program execution type is a scan execution type (including during output OFF (during non-execution processing)), low-speed execution type or fixed scan execution type.
  • Page 687: Other Instructions

    7.17 Other Instructions 7.17.1 Resetting watchdog timer High Universal Performance WDT(P) P: Executing condition indicates any of the following instructions. Structured ladder WDTP ENO:= (EN); Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data...
  • Page 688 (5) Scan time values stored in the special register will not be cleared even if the WDT(P) instruction is executed. Accordingly, there are times when the value for the scan time for the special register is greater than the value of the watchdog timer set in the parameters. Operation Error No operation error occurs in the execution of the WDT(P) instruction.
  • Page 689: Timing Pulse Generation

    DUTY 7.17.2 Timing pulse generation DUTY High Universal Performance DUTY indicates the following instruction. DUTY Structured ladder DUTY ENO:= (EN,n1, n2, d); DUTY Input argument, Executing condition :Bit Number of scans to be turned ON :ANY16 Number of scans to be turned OFF :ANY16 Output argument, ENO:...
  • Page 690 DUTY (4) The data specified for n1, n2, and is registered to the system when the DUTY instruction is executed, and the timing pulse is turned ON and OFF by the END processing. Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 691: Time Check Instruction

    TIMCHK 7.17.3 Time check instruction TIMCHK High Universal Performance TIMCHK indicates the following instruction. TIMCHK Structured ladder TIMCHK ENO:= (EN,s1, s2, d); TIMCHK Input argument, Executing condition :Bit Device that stores the measured current value :ANY16 Device that stores the set value for measurement :ANY16 Output argument, ENO:...
  • Page 692 TIMCHK Operation Error In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The device that cannot be specified has been specified. (Error code: 4100) Program Example In the following program, the ON time of X0 is set to 5 seconds, the current value storage device is set to D0 and the device that will turn ON at time out is set to Y10.
  • Page 693: Reading 1 Byte Directly From File Register

    ZRRDB 7.17.4 Reading 1 byte directly from file register ZRRDB High Universal Performance ZRRDB(P) P: Executing condition indicates any of the following instructions. Structured ladder ZRRDB ZRRDBP ZRRDB ENO:= (EN, n, d); ZRRDB Input argument, Executing condition :Bit Serial byte number whose file register is read :ANY32 Output argument, ENO:...
  • Page 694 ZRRDB (2) File register numbers correspond to serial byte numbers are as indicated below. b8b7 Serial byte No. 1 Serial byte No. 0 Serial byte No. 3 Serial byte No. 2 Serial byte No. 5 Serial byte No. 4 Serial byte No. 5001 Serial byte No.
  • Page 695 ZRRDB [ST] IF X0 THEN ZRRDBP(TRUE,32000,Var_D100); ZRRDBP(TRUE,32007,Var_D101); END_IF; [Operation] b8 b7 b8 b7 Serial byte No. 32000 R16000 Var_D100 (Lower bits of R16000) R16001 Var_D101 R16002 Serial byte No. 32007 R16003 (Upper bits of R16003) 7.17 Other Instructions 7-355 7.17.4 Reading 1 byte directly from file register...
  • Page 696: Writing 1 Byte Directly To File Register

    ZRWRB 7.17.5 Writing 1 byte directly to file register ZRWRB High Universal Performance ZRWRB(P) P: Executing condition indicates any of the following instructions. Structured ladder ZRWRB ZRWRBP ZRWRB ENO:= (EN, n, s); ZRWRB Input argument, Executing condition :Bit Serial byte number whose file register is written :ANY32 Start number of the device that stores data to be written :ANY16...
  • Page 697 ZRWRB (2) File register numbers correspond to serial byte numbers are as indicated below. b8b7 Serial byte No. 1 Serial byte No. 0 Serial byte No. 3 Serial byte No. 2 Serial byte No. 5 Serial byte No. 4 Serial byte No. 5001 Serial byte No.
  • Page 698 ZRWRB [ST] IF X0 THEN ZRWRBP(TRUE,32000,Var_D100); ZRWRBP(TRUE,32007,Var_D101); END_IF; [Operation] b8 b7 b8 b7 Serial byte No. 32000 Var_D100 Ignored R16000 (Lower bits of R16000) R16001 R16002 b8 b7 Serial byte No. 32007 Var_D101 Ignored R16003 (Upper bits of R16003) b8 b7 R16000 R16001 R16002...
  • Page 699: Reading Indirect Address

    ADRSET 7.17.6 Reading indirect address ADRSET High Universal Performance ADRSET(P) P: Executing condition indicates any of the following instructions. Structured ladder ADRSET ADRSETP ADRSET ENO:= (EN, s, d); ADRSET Input argument, Executing condition :Bit Indirect address :ANY_SIMPLE Output argument, ENO: Execution result :Bit Indirect address of the device specified for s...
  • Page 700: Numeric Input From Keyboard

    7.17.7 Numeric input from keyboard High Universal Performance indicates the following instruction. Structured ladder ENO:= (EN, s, n, d1, d2); Input argument, Executing condition :Bit Device of (X) to which a numeral is input :Array of bit (0..8) Number of numeric digits to be input :ANY16 Output argument, ENO:...
  • Page 701 For example, in a case where the number of digits (n) has been set to 5, and the values "31", "33", "35", "37" and "39" have been input through X10 to X18 of the input module, the following will take place. Number of digits Input module of input data D0...
  • Page 702 (5) The digits for the numbers actually fetched to will be stored to the device specified for and the ASCII code data input to +1 and +2 are converted to hexadecimal BIN values, and stored. Execution command Condition contact for the execution of KEY instruction Strobe signal ( ASCII code input...
  • Page 703 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • The device specified for is not an input (X) device. (Error code: 4100) •...
  • Page 704 [ST] IF X0 AND NOT(M0) THEN SET(TRUE,M0); FMOVP(TRUE,0,3,D0); END_IF; IF M0 THEN MOVP(TRUE,5,D10); KEY(TRUE,Var_X20,D10,Var_D0,M10); END_IF; IF M10 THEN RST(TRUE,M0); RST(TRUE,M10); END_IF; [Operation] Input module b15 b12 b7 b4 Numeric keypad (Strobe signal) 7.17 Other Instructions 7-364 7.17.7 Numeric input from keyboard...
  • Page 705: Batch Save And Recovery Of Index Registers

    ZPUSH, ZPOP 7.17.8 Batch save and recovery of index registers ZPUSH, ZPOP High Universal Performance ZPUSH(P) P: Executing condition ZPOP(P) indicates any of the following instructions. Structured ladder ZPUSH ZPUSHP ZPOP ZPOPP ZPUSH ENO:= (EN, d); ZPUSH Input argument, Executing condition :Bit Output argument, ENO:...
  • Page 706 ZPUSH, ZPOP (4) The composition of the field used following is as shown below. • When using the High Performance model QCPU Number of saves 1st nesting (18 words for one nesting) Reserved by the system (2 words) 2nd nesting •...
  • Page 707 ZPUSH, ZPOP Program Example In the following program, the data of the index register which is prior to call the subroutine program are saved to D0 and the following devices, when using the index registers within the subroutine program following P0. [Structured ladder] [ST] ZPUSH(X0,D0);...
  • Page 708 MEMO 7-368...
  • Page 709 QCPU INSTRUCTIONS Reading Module Information ........8-2 Trace Set/Reset .
  • Page 710 UNIRD Reading Module Information UNIRD High Universal Performance UNIRD(P) P: Executing condition indicates any of the following instructions. Structured ladder UNIRD UNIRDP UNIRD ENO:= (EN, n1, n2, d); UNIRD Input argument, Executing condition :Bit Value obtained by dividing the start I/O number of the module :ANY16 information read source by 16 (0 to FFn) Number of read data (0 to 256)
  • Page 711 UNIRD Remark The value of n1 is specified by the higher 3 digits of the start I/O number of the slot from which the module information is read, when it is expressed in 4 digits in hexadecimal. X0000 X0010 X0020 X0030 0040 Y0050...
  • Page 712 UNIRD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. [High Performance model QCPU and Universal model QCPU] • When n1 is other than 0 to FF (Error code: 4100) •...
  • Page 713 UNIRD Readout result (When read to D0) ➀ 32-point intelligent function module for Q series b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 32-point module Intelligent function module No external power supply connected No blown-fuse error existing (Empty) No module error existing...
  • Page 714 TRACE, TRACER Trace Set/Reset TRACE, TRACER High Universal Performance TRACE TRACER indicates any of the following instructions. Structured ladder TRACE TRACER TRACE ENO:= (EN); TRACE Input argument, Executing condition :Bit Output argument, ENO: Execution result :Bit Internal device Setting R, ZR Constant Others data...
  • Page 715 TRACE, TRACER Function The sampling trace function collects the specified device data of a CPU module consecutively at the specified timing. With the sampling trace function, the traced results obtained through the specified number of trace operations will be stored to the sampling trace file of the memory card when SM800, SM801, and SM802 are turned ON.
  • Page 716 TRACE, TRACER TRACE (1) The TRACE instruction turns ON SM803, executes sampling by the number of times set for "After trigger number of times" in the Trace condition settings, latches the data and stops sampling trace. (2) The sampling is stopped if SM801 turns OFF during the trace execution. (3) After the TRACE instruction is executed and the trace is completed, SM805 turns ON.
  • Page 717 SP_FWRITE Writing Data to Specified File SP_FWRITE High Universal Performance SP_FWRITE indicates the following instruction. Structured ladder SP_FWRITE SP_FWRITE ENO:= (EN,s0,s1,s2,d0,d1); SP_FWRITE Input argument, Executing condition :Bit Drive specification :ANY16 File name :String Number of data to request writing :ANY16 Output argument, ENO: Execution result...
  • Page 718 SP_FWRITE Setting Description Setting range Set by Data type data Dummy –– –– User Drive specification Start number of the device that stores a file name. A file name is expressed as follows. Device Item Contents/Setting data Setting range Set by Specify the character string of a file name.
  • Page 719 SP_FWRITE Setting Description Setting range Set by Data type data When binary data write is specified for • Set the file position. 00000000 :Start of the file 00000001 to FFFFFFFE : From the specified position The unit for the value is determined by the data type specification.
  • Page 720 SP_FWRITE Caution (1) Only the ATA card drive (2) can be set for (drive specification). Note that when the Flash card is installed, the SP_FWRITE instruction cannot be used to perform writing. The SRAM card, standard RAM or standard ROM drive cannot be set. (2) For CSV setting, the data written are decimal values.
  • Page 721 SP_FWRITE (3) Be sure to use units of word to specify the number of request write data ( ), and the file position [4] and [5]. The following shows the method for writing binary data when number of request write data and file position are specified.
  • Page 722 SP_FWRITE (c) When the specified file does not exist, a new file is created and the data are additionally saved from the beginning of the file. The attributes of this new file are set using the archive attributes. (d) An error occurs when the saving space becomes full while data are additionally saved. In such a case, the data that are additionally saved successfully remains in the medium.
  • Page 723 SP_FWRITE When data are written after CSV format conversion and the specified number of columns is other than 0, the data are stored as table data with specified number of columns in a CSV format file. Example When data are written after CSV format conversion and the specified number of columns is other than 0.
  • Page 724 SP_FWRITE (g) When data are added by the High Performance model QCPU and Universal model QCPU of which the first 5 digits of the serial number are 01112 or higher. [Specify the file to which data will be written.] (If a file exists, delete it and create a new file again.) Execution type: CSV format File position: 0...
  • Page 725 SP_FWRITE Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. • Drive specified for drive specification device contains the medium other than the ATA card.
  • Page 726 SP_FWRITE Program Example (1) In the following program, 4 bytes of binary data (00 , 01 , 02 , and 03 ) are added to the file "ABCD.BIN" in the memory card inserted to drive 2 when X10 turns ON. •...
  • Page 727 SP_FWRITE [ST] IF X10 THEN MOVP(TRUE,H0100,Var_D0[0]); Var_D10:="ABCD"; MOVP(TRUE,2,Var_D20[0]); MOVP(TRUE,H100,Var_D20[1]); MOVP(TRUE,H302,Var_D20[2]); SP_FWRITE(TRUE,2,Var_D10,Var_D20[0],Var_D0,Var_M0); END_IF; • Assume that 8 points from are reserved for the control data devices. , CR LF Contents of the file to be written , CR LF Data to be read to the EXCEL file 8.3 Writing Data to Specified File 8-19...
  • Page 728 SP_FREAD Reading Data from Specified File SP_FREAD High Universal Performance SP_FREAD indicates the following instruction. Structured ladder SP_FREAD SP_FREAD ENO:= (EN,s0,s1,d0,d1,d2); SP_FREAD Input argument, Executing condition :Bit Drive specification :ANY16 File name :String Output argument, ENO: Execution result :Bit Control data :Array of ANY16 (0..7) Start number of the device that stores read data :ANY16...
  • Page 729 SP_FREAD Setting Description Setting range Set by Data type data Dummy –– –– User Drive specification Start number of the device that stores a file name. A file name is expressed as follows. Device Item Contents/Setting data Setting range Set by Specify the character string of a file name.
  • Page 730 SP_FREAD Setting Description Setting range Set by Data type data When binary data read is specified for • Set the file position. 00000000 : Start of the file 00000001 to FFFFFFFE :From the specified position The unit for the value is determined by the data type specification.
  • Page 731 SP_FREAD Setting Description Setting range Set by Data type data Bit device that turned ON at the completion of the processing. [1] is also turned ON at error completion.) Device Item Contents/Setting data Setting range Set by Indicates the completion of the processing. Completion ON: Completed ––...
  • Page 732 SP_FREAD (3) Be sure to use units of word to specify the number of request read data [2], file position [4], [5], and read data device size The following shows how each device data are read in binary data reading operation. Control data 0000 Execution/completion type...
  • Page 733 SP_FREAD (e) When the specified number of columns is 0, the data are read by ignoring the rows in CSV format file. Example When data are read after CSV format conversion and the specified number of columns is 0. Data created by EXCEL Main / sub item Measured value Length...
  • Page 734 SP_FREAD Such file cannot be created using EXCEL. This happens when CSV file is modified by a user. Example When the number of columns varies in each row when the data are read. Main / sub item Measured value Excess Length Temperature Elements outside the specified...
  • Page 735 SP_FREAD When data are read after CSV format conversion and the specified number of columns is other than 0, the data are read as the table with specified number of columns in CSV format file. The elements outside of the specified columns are ignored. Example When data are read after CSV format conversion and the specified number of columns is other than 0.
  • Page 736 SP_FREAD If the number of columns varies in each row, the elements outside of the specified columns are ignored and "0" is added to the places where elements do not exist. Example When the number of columns varies in each row when the data are read. Main / sub item Measured value Excess...
  • Page 737 SP_FREAD (g) With the High Performance model QCPU and Universal model QCPU whose first 5 digits of the serial number are "01112" or later, it is possible to divide read operation into multiple times. [Specify the row desired to start read.] Execution type: CSV format Start row: 2 Column specification: 4...
  • Page 738 SP_FREAD (h) When data are read after CSV format conversion, the numeric values that are out of range or the elements other than numeric values in the CSV format file to be read are converted to 0 When data are read after CSV format conversion, numeric values are read and converted as follows.
  • Page 739 SP_FREAD Program Example (1) In the following program, 4 bytes of binary data are read from the beginning of the file "ABCD.BIN" in the memory card inserted to drive 2 when X10 turns ON. • Assume that 8 points from Var_D0 are reserved for the control data devices. •...
  • Page 740 SP_FREAD (2) In the following program, the file "ABCD.CSV" is read to the PC card inserted to slot 0 as two-column table data in CSV format when X10 turns ON. • Assume that 8 points from Var_D0 are reserved for the control data devices. •...
  • Page 741 SP_DEVST Writing Data to Standard ROM SP_DEVST High Performance Universal SP_DEVST indicates the following instruction. SP_DEVST Structured ladder SP_DEVST ENO:= (EN, s1, s2, n, d); SP_DEVST Input argument, Executing condition :Bit Write offset of the device data storage file :ANY32 (Specified in unit of 16 bits per one point) Start number of the device to be written to the standard ROM :ANY16 Number of device points to be written...
  • Page 742 SP_DEVST Standard ROM Device data Start number of Write offset storage file device Write offset of the device data storage file Write 16 bits offset (2) Since the device data write position completion [0] in the standard ROM automatically turns ON at execution of the END instruction, which detects the completion of this instruction, and turns OFF with the END instruction of next scan, it is used as an execution completion flag of this instruction.
  • Page 743 SP_DEVST Program Example In the following program, 10 points of device data from D100 are written to the device data storage file in the standard ROM when M0 turns ON. [Structured ladder] [ST] SP_DEVST(M0,3,Var_D100,10,Var_M1); Caution (1) The value written to the standard ROM is the value at execution of this instruction. (2) The standard ROM data write count (SD687, SD688) increases by the execution of the SP_DEVST instruction.
  • Page 744 S_DEVLD Reading Data from Standard ROM S_DEVLD High Performance Universal S(P)_DEVLD P: Executing condition indicates any of the following instructions. Structured ladder S_DEVLD SP_DEVLD S_DEVLD ENO:= (EN, s, n, d); S_DEVLD Input argument, Executing condition :Bit Read offset of the device data storage file :ANY32 (Specified in unit of 16 bits per point) The number of read points...
  • Page 745 S_DEVLD Standard ROM Device data Start number of Read offset storage file device Read offset of the device data storage file Read 16 bits offset Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0.
  • Page 746 PLOADP Program Load from Memory Card PLOADP High Universal Performance PLOADP indicates the following instruction. PLOADP Structured ladder PLOADP ENO:= (EN, s, d); PLOADP Input argument, Executing condition :Bit :String Driver number file name that stores programs to be loaded Output argument, ENO: Execution result...
  • Page 747 PLOADP (2) The program added using the PLOADP instruction is assigned by the lowest number among the unused program numbers. (To assign a program number manually, store the program number to be assigned to SD720.) The following example shows when "MAIN6" is added by the PLOADP instruction. (a) When the program numbers have been set consecutively, the new program is added at the end of the preset program numbers.
  • Page 748 PLOADP (9) The PLC file settings of the loaded program are set as follows. (a) File usage for each program All the usage of file registers, device initial values, comments, and local devices of the program transferred by this instruction are set based on PLC file settings. However, an error will be returned if both of the conditions below are met when the program is transferred using this instruction.
  • Page 749 PLOADP Program Example In the following program, "ABCD.QPG" stored in the drive 4 is transferred to drive 0 and set the program in standby status when M0 turns ON. [Structured ladder] [ST] PLOADP(Var_M0,"4:ABCD",Var_M10); 8.7 Program Load from Memory Card 8-41...
  • Page 750 PUNLOADP Program Unload from Program Memory PUNLOADP High Universal Performance PUNLOADP indicates the following instruction. PUNLOADP Structured ladder PUNLOADP ENO:= (EN, s, d); PUNLOADP Input argument, Executing condition :Bit :String Program file name to be unloaded Output argument, ENO: Execution result :Bit Device to be turned ON for one scan at the instruction :Bit...
  • Page 751 PUNLOADP (3) An extension (.QPG) does not need to be specified for the file name. (4) The bit device specified for is turned ON during the END processing of the scan where this instruction is completed. The bit device is turned OFF at the next END processing. (5) The PLOADP, PUNLOADP, and PSWAPP instructions cannot be executed simultaneously.
  • Page 752 PUNLOADP Program Example In the following program, "ABCD.QPG" stored in the drive 0 is deleted from the memory when M0 turns from OFF to ON. [Structured ladder] [ST] PUNLOADP(M0,"ABCD",Var_M10); 8.8 Program Unload from Program Memory 8-44...
  • Page 753 PSWAPP Load and Unload PSWAPP High Universal Performance PSWAPP indicates the following instruction. PSWAPP Structured ladder PSWAPP ENO:= (EN, s1, s2, d); PSWAPP Input argument, Executing condition :Bit Program file name to be unloaded :String :String Driver number file name that stores programs to be loaded Output argument, ENO: Execution result...
  • Page 754 PSWAPP (2) The program to be transferred to the program memory by the PSWAPP instruction will have the program number of the program to be deleted from the program memory. (If there is an empty program number before the program to be deleted from the program memory, the program to be transferred to the program memory will not have the empty program number.) When program number 2 is "Empty", the program transferred to the program memory is...
  • Page 755 PSWAPP (9) The PLC file settings of the program on which the PSWAPP instruction has been executed are set as follows. (a) File usage for each program All the usage of file register, device initial value, comment, and local device of the program after the execution of the PSWAPP instruction are set based on PLC file settings.
  • Page 756 RBMOV 8.10 File Register High-Speed Block Transfer RBMOV High Universal Performance RBMOV(P) P: Executing condition indicates any of the following instructions. Structured ladder RBMOV RBMOVP RBMOV ENO:= (EN, s, n, d); RBMOV Input argument, Executing condition :Bit Start number of the device that stores data to be transferred :ANY16 Number of transfers :ANY16...
  • Page 757 RBMOV (2) The transfer is available even if there is an overlap between the source and destination devices. For the transmission to the smaller number of device, the data are transferred from . For the transmission to the larger number of device, the data are transferred from +(n-1).
  • Page 758 RBMOV Program Example (1) In the following program, the lower 4 bits of data in R66 to R69 are output to the devices from Y30 to Y3F in units of 4 points. [Structured ladder] [ST] RBMOVP(SM402,R66,4,K1Y30); Before execution After execution (source of transfer) (destination of transfer) 1 1 0 1...
  • Page 759 RBMOV The RBMOV(P) instruction is useful when batch transferring a large quantity of file register data with the QnHCPU. For the QnUD(E)(H)CPU, the processing speed is same as that of the BMOV instruction. The comparison of processing speed with the BMOV instruction is as follows. (1)Transferring data from file registers to internal devices or from internal devices to file registers Target memory...
  • Page 760 RBMOV 8.11 Writing Data to Host CPU Shared Memory The S(P)_TO or TO(P) instruction is used to write to the host CPU shared memory in the multiple CPU system. The following table indicates the usability of the S(P)_TO and TO(P) instructions. CPU module model S(P)_TO instruction TO(P) instruction...
  • Page 761 S_TO 8.11.1 Writing data to host CPU shared memory S_TO High Universal Performance *1: Function version B or later. S(P)_TO P: Executing condition indicates any of the following Structured ladder instructions. S_TO S_TO SP_TO ENO:= (EN, s1, s2, s3, s4, d); S_TO Input argument, Executing condition...
  • Page 762 S_TO Function (1) Writes words of device data from host CPU module to the CPU shared memory ○ address specified for and the following addresses of host CPU module. When writing is completed, the completion bit specified for turns ON. Host CPU CPU shared memory Device memory...
  • Page 763 S_TO Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. (1) When the specified value is outside of the following range. (Error code: 4101) •...
  • Page 764 S_TO Program Example In the following program, 10 points of data from Var_D0 are stored to the address 800 of the host CPU shared memory when X0 turns ON. [Structured ladder] [ST] SP_TO(X0,H3E0,H800,Var_D0,10,Var_M0); Remark is specified by the first 3 digits of the hexadecimal 4 digits which represent the start I/O number of the slot mounted to the CPU module.
  • Page 765 8.11.2 Writing data to host CPU shared memory High Universal Performance TO(P) P: Executing condition: indicates any of the following Structured ladder instructions. ENO:= (EN, s, n1, n2, n3); Input argument, Executing condition :Bit Write data, or start number of the device that stores write data :ANY16 Start I/O number of the host CPU :ANY16 Universal model QCPU: 3E0...
  • Page 766 Host CPU CPU shared memory Device memory of host CPU (n1) Writes n3 words of data When a constant is specified for , writes the same data (value specified for ) to the area of n3 words from the specified CPU shared memory. CPU shared memory of host CPU (n1) Constant...
  • Page 767 Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. (1) When the specified value is outside of the following range. (Error code: 4101) •...
  • Page 768 8.12 Reading Data from Other CPU Shared Memory Data can be read using the FROM(P) instruction of multiple CPU system from the following memories. • Buffer memory of intelligent function module • CPU shared memory of other CPU module • CPU shared memory of host CPU module (Can be executed in the Universal model QCPU) The following figure shows the processing performed when the FROM(P) instruction is executed in CPU No.
  • Page 769 FROM, DFRO 8.12.1 Reading data from other CPU shared memory FROM, DFRO High Universal Performance *1: Function version B or later. FROM(P) P: Executing condition DFRO(P) indicates any of the following Structured ladder instructions. FROM FROM FROMP DFRO DFROP ENO:= (EN, n1, n2, n3, d);...
  • Page 770 FROM, DFRO Function (1) Reads n3 words of data from the CPU shared memory address specified for n2 of the CPU module specified for n1, and stores the data to and the following devices. CPU shared memory of Device memory the specified CPU (n1) Reads n3 words...
  • Page 771 FROM, DFRO DFRO(P) (1) Reads (n3 2) words of data from the CPU shared memory address specified for n2 of the CPU module specified for n1, and stores the data to and the following devices. CPU shared memory of Device memory the specified CPU (n1) Reads words of data...
  • Page 772 FROM, DFRO Program Example In the following program, 10 points of data from the address 800 of the CPU shared memory of CPU No. 2 are stored to Var_D0 and the following devices when X0 turns ON. [Structured ladder] [ST] FROM(X0,H3E1,H800,10,Var_D0);...
  • Page 773 8.13 Selection of Refresh Instructions For the COM instruction of the following CPU modules, refer to Section 7.6.5. • High Performance model QCPU of serial number 04011 or lower High Performance Universal *1: First 5 digits of the serial number are 04012 or higher. indicates the following instruction.
  • Page 774 Remark The following processes are performed in communication with peripherals. • Monitoring process of other station • Read process of another intelligent function module buffer memory by the serial communication module (2) Turning OFF SM775 refreshes all refresh items except for I/O refresh. (3) When selecting refresh items (a) Select refresh items by SD778, and turn SM775 ON.
  • Page 775 Refresh between the multiple CPUs by the COM instruction is performed under the following conditions. • Receive operation from other CPUs : When b4 of SD778 (auto refresh of CPU shared memory) is 1. • Send operation from host CPU : When b15 of SD778 (execution/non- execution of communication with peripheral device) is 0...
  • Page 776 MEMO 8-68...
  • Page 777 MULTIPLE CPU HIGH SPEED TRANSMISSION DEDICATED INSTRUCTIONS Overview............9-2 Writing Device Data to Other CPUs .
  • Page 778 Overview The multiple CPU high speed transmission dedicated instruction is an instruction used to read and write device data between the multiple Universal model QCPUs. The following figure shows the operation when the data are read from the CPU No. 1 and written to the CPU No.
  • Page 779 (2) Devices that can be written/read Names of devices that can be written/read The following table shows the devices that can be written to/read from the other Universal model QCPUs using the multiple CPU high transmission dedicated instruction. Target device Classification Type Device name...
  • Page 780 By using the device specification method, data can be written/read within the device range of the host CPU. For example, when the data register of the host CPU is 12k points, and the data register of other CPU is 16k points, data of 12k points can be written/read from the start of the data register of the other CPU.
  • Page 781 (4) Managing the multiple CPU high speed transmission area (a) The multiple CPU high speed transmission area is managed in blocks and each block contains minimum of 16 words. The following table shows the number of blocks that can be used in each CPU and the number of blocks used for the instruction.
  • Page 782 (6) Multiple CPU high speed transmission dedicated instructions that can be executed simultaneously For the Universal model QCPU, the multiple CPU high speed transmission dedicated instructions can be executed simultaneously within the following range. Number of blocks that Total of blocks used by the can be used for each CPU simultaneously executed instructions By executing the multiple CPU high speed transmission dedicated instruction, if the number...
  • Page 783 (7) Interlocks when using the multiple CPU high speed transmission dedicated instruction (a) The special relays SM796 to SM799 (information of blocks used for the multiple CPU high speed transmission dedicated instruction) can be used as the interlocks for the multiple CPU high speed transmission dedicated instruction.
  • Page 784 (b) Program example when the special relays SM796 to SM799 are used as the interlocks In the following program, the D_DDWR instruction is executed to the CPU No. 2 at the rising pulse of X0, and to the CPU No. 3 at the rising pulse of X1. 9.1 Overview...
  • Page 785 (8) Program example when the multiple CPU high speed transmission dedicated instructions are executed from one CPU to another CPU between the multiple CPU modules When executing the multiple CPU high speed transmission dedicated instructions from one CPU to another CPU between the Universal model QCPUs, set the interlocks to avoid the instructions to be executed simultaneously.
  • Page 786 (9) Program example when data exceeding 100 words are written/read by the multiple CPU high speed transmission dedicated instruction Up to 100 words of data can be used for the multiple CPU high speed transmission dedicated instruction. In order to write/read data exceeding 100 words, execute the instruction multiple times.
  • Page 787 (b) Program example in which two or more D(P)_DDWR instructions are executed simultaneously In the following program, data in the devices ZR0 to ZR999 (1000 points) of the CPU No. 1 are written to the devices ZR0 to ZR999 of the CPU No.2 using the D_DDWR instruction.
  • Page 788 D_DDWR Writing Device Data to Other CPUs D_DDWR High Universal Performance D(P)_DDWR P: Executing condition indicates any of the following Structured ladder instructions. D_DDWR D_DDWR DP_DDWR ENO:= (EN, n*, s1, s2, d1, d2); D_DDWR Input argument, Start I/O number of the other CPU divided by 16 : ANY16 CPU No.
  • Page 789 D_DDWR Control Data Device Item Setting data Setting range Setting side Execution result of the instruction completion is stored. Completion status 0000(H) : No error (normal completion) System – Other than 0000(H) : Error code (error completion) Number of data to be written Set the number of data to be written in unit of word.
  • Page 790 D_DDWR (4) When empty blocks are not available in the multiple CPU high speed transmission area, the instruction completes with an error. This error completion is prevented by setting the number of blocks used for the instruction to the special registers (SD796 to SD799), and using the special relays (SM796 to SM799) as the interlocks.
  • Page 791 D_DDWR Program Example In the following program, 10 words of data from D0 in the host CPU are written to W10 and the following devices in the CPU No. 2 when X0 turns ON. [Structured ladder] The number of write data '10' is stored to the write data points storing device of control data D101 ( +1).
  • Page 792 D_DDRD Reading Device Data from Other CPUs D_DDRD High Universal Performance D(P)_DDRD P: Executing condition indicates any of the following Structured ladder instructions. D_DDRD D_DDRD DP_DDRD ENO:= (EN, n*, s1, s2, d1, d2); D_DDRD Input argument, Start I/O number of the other CPU divided by 16 : ANY16 CPU No.
  • Page 793 D_DDRD Control Data Device Item Setting data Setting range Setting side Execution result of the instruction completion is stored. Completion status 0000(H) : No error (normal completion) System – Other than 0000(H) : Error code (error completion) Number of data to be read Set the number of data to be read in unit of word.
  • Page 794 D_DDRD Operation Error In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON, and the corresponding error code is stored to SD0. (1) When the specified other CPU is wrong, or when the settings are not set correctly to use the multiple CPU high speed transmission instruction.
  • Page 795 D_DDRD Program Example In the following program, 10 words of data from D0 in the CPU No. 2 are read and stored to W10 and the following devices in the host CPU when X0 turns ON. [Structured ladder] The number of read data '10' is stored to the read data points storing device of control data D101 ( +1).
  • Page 796 MEMO 9-20...
  • Page 797 APPENDIX Appendix 1 Correspondence between Generic Data Types and Devices ..App-2 Appendix 2 Correspondence between Devices and Addresses ....App-6 App-1...
  • Page 798 Appendix 1 Correspondence between Generic Data Types and Devices The following table shows the correspondence between generic data types and devices. Table App. 1-1 Correspondence between generic data types and devices Device Classification Type Device name Device symbol Input Output Internal relay Latch relay Annunciator...
  • Page 799 Generic data type ANY_SIMPLE ANY_NUM ANY_BIT ANY_INT ANY_REAL Double Array Structure Word Double Single- Double- Time String word Word (unsigned)/ word precision precision ANY16 ANY32 (unsigned)/ (signed) 16-bit string (signed) real real 32-bit string − − − − − − −...
  • Page 800 Device Classification Type Device name Device symbol Link input Jn\X Link output Jn\Y Bit device Link relay Jn\B Link direct device Link special relay Jn\SB Link register Jn\W Word device Link special register Jn\SW Intelligent function module Word device Intelligent function module device Un\G device Index register...
  • Page 801 Generic data type ANY_SIMPLE ANY_NUM ANY_BIT ANY_INT ANY_REAL Double Array Structure Word Double Single- Double- Time String word Word (unsigned)/ word precision precision ANY16 ANY32 (unsigned)/ (signed) 16-bit string (signed) real real 32-bit string − − − − − − −...
  • Page 802 Appendix 2 Correspondence between Devices and Addresses The following table shows the correspondence between devices and addresses. Table App. 2-1 Correspondence between devices and addresses Example of correspondence between Expressing method device and address Device Device Address Device Address Input %IXn X7FF %IX2047...
  • Page 803 Table App. 2-2 Correspondence between devices and addresses Example of correspondence between Expressing method Device device and address Device Address Device Address Step relay %MX2.n S127 %MX2.127 SFC transition device %MX18.n %MX18.3 SFC block device %MX17.n %MX17.3 Link input Jx\Xn %IX16.x.n J1\X1FFF %IX16.1.8191...
  • Page 804 MEMO App-8...
  • Page 805 INDEX Index-1...
  • Page 806 ACOS(P) ............. 7-245 B-(P) ..............6-33 ACOSD(P)............7-248 B*(P)..............6-37 Address ..............3-20 B+(P) ..............6-33 ADRSET(P)............7-359 B/(P) ..............6-37 ANB................. 5-6 BACOS(P) ............7-295 AND................. 5-2 BAND(P).............. 7-304 AND$<..............6-14 BASIC INSTRUCTIONS.......... 6-1 AND$<= ..............6-14 Basic instructions tables.......... 2-8 AND$<>...
  • Page 807 DBL(P) ..............6-83 DCML(P) ............. 6-117 CALL(P) .............. 7-106 DDABCD(P) ............7-173 CHK..............7-143 DDABIN(P) ............7-166 CHKCIR .............. 7-147 DDEC(P) ............... 6-62 CHKEND ............. 7-147 Debug and error diagnostics instructions table ..2-27 CHKST ..............7-143 DEC(P) ..............6-59 CJ................
  • Page 808 DZONE(P)............7-308 GRY(P)..............6-87 E-(P)..............6-42 HABIN(P)............. 7-170 E*(P)..............6-48 HEX(P) ..............7-209 E+(P) ..............6-42 HOUR(P) ............. 7-335 E/(P) ..............6-48 How to Read Instruction Tables ......2-3 ECON(P) ............. 6-103 HOW TO READ INSTRUCTIONS......4-1 ED-(P) ..............6-45 ED*(P) ..............
  • Page 809 LDE= ............... 6-8 OR$>=..............6-14 LDE> ............... 6-8 OR(P)(F) ..............5-4 LDE>= ..............6-8 OR<................. 6-2 LDED< ..............6-11 OR<=............... 6-2 LDED<= ..............6-11 OR<>............... 6-2 LDED<> ..............6-11 OR=................. 6-2 LDED= ..............6-11 OR>................. 6-2 LDED> ..............6-11 OR>=............... 6-2 LDED>= ..............
  • Page 810 PSCAN(P) ............7-341 Specify a digit for bit data ........3-9 PSTOP(P) ............7-337 SP_FREAD ............8-20 PSWAPP............... 8-45 SP_FWRITE............8-9 PUNLOADP ............8-42 SQR(P)..............7-262 PWM ..............6-173 SQRD(P) ............. 7-264 SRND(P) ............. 7-277 STMR ..............6-160 QCDSET(P) ............7-318 STOP..............
  • Page 811 ZPUSH(P) ............7-365 ZRRDB(P) ............7-353 ZRWRB(P) ............7-356 [Signs] $+(P) ..............6-57 $MOV(P) ............. 6-114 -(P) ................ 6-22 *(P) ................ 6-27 +(P) ............... 6-22 /(P) ................ 6-27 [Numerics] 32-bit index setting ..........3-25 Index - 7...
  • Page 812 MEMO Index-8...
  • Page 813 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 814 Microsoft, Windows are registered trademarks of Microsoft Corporation in the United States and other countries. Ethernet is a registered trademark of Xerox Corporation in the United States. Ethernet is a trademark of Xerox Co., Ltd.in the United States. Other company names and product names used in this document are trademarks or registered trademarks of respective companies.
  • Page 816 QCPU Structured Programming Manual (Common Instructions) 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 is also suitable for:

Qcpu

Table of Contents