SAFETY PRECAUTIONS (Always read these cautions before using the product) Before using this product, please read this manual and the related manuals introduced in this manual, and pay full attention to safety to handle the product correctly. Please store this manual in a safe place and make it accessible when required. Always forward a copy of the manual to the end user.
PRODUCT in one or more of the Prohibited Applications, provided that the usage of the PRODUCT is limited only for the specific applications agreed to by Mitsubishi and provided further that no special quality assurance or fail-safe, redundant or other safety features which exceed the general specifications of the PRODUCTs are required.
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.
ST instructions. Before using this product, please read this manual and the relevant manuals carefully and develop familiarity with the functions and performance of the QnA series programmable controller to handle the product correctly. ■ Relevant CPU module...
CONTENTS SAFETY PRECAUTIONS ........................A - 1 CONDITIONS OF USE FOR THE PRODUCT ..................A - 2 REVISIONS ............................A - 3 INTRODUCTION ..........................A - 4 CONTENTS ............................A - 6 MANUALS............................A - 15 1. GENERAL DESCRIPTION 1 - 1 to 1 - 4 Related Programming Manuals 1 - 2 Abbreviations and Generic Terms...
Page 9
2.5.14 Switching instructions ....................2 - 44 2.5.15 Clock instructions ....................... 2 - 45 2.5.16 Peripheral device instructions..................2 - 46 2.5.17 Program control instructions..................2 - 46 2.5.18 Other instructions ....................... 2 - 47 2.5.19 Instructions for Data Link.................... 2 - 48 2.5.20 Redundant system instructions (For the Q4ARCPU) ..........
Page 10
5.3.5 Setting devices (except for annunciators) (SET) ............5 - 27 5.3.6 Resetting devices (except for annunciators) (RST)............ 5 - 29 5.3.7 Setting and resetting the annunciators (SET F,RST F) ..........5 - 32 5.3.8 Leading edge and trailing edge outputs (PLS,PLF)............ 5 - 34 5.3.9 Bit device output reverse (FF) ..................
Page 11
6.3.4 Conversion from floating decimal point data to BIN16- and 32-bit data (Single precision) (INT(P),DINT(P)) ..........6 - 62 6.3.5 Conversion from BIN 16-bit to BIN 32-bit data (DBL(P)) ..........6 - 64 6.3.6 Conversion from BIN 32-bit to BIN 16-bit data (WORD(P))........6 - 65 6.3.7 Conversion from BIN 16 and 32-bit data to Gray code (GRY(P),DGRY(P)) ....
Page 12
7.1.6 Block exclusive OR operations (BKXOR(P)) .............. 7 - 25 7.1.7 16-bit and 32-bit data exclusive NOR operations (WXNR(P),DXNR(P))....7 - 27 7.1.8 Block exclusive NOR operations (BKXNR(P))............7 - 33 Rotation instruction 7 - 35 7.2.1 Right rotation of 16-bit data (ROR(P),RCR(P)) ............7 - 35 7.2.2 Left rotation of 16-bit data (ROL(P),RCL(P)) ..............
Page 13
7.7.3 Reading newest data from data tables (FPOP(P)) ........... 7 - 140 7.7.4 Deleting and inserting data from and in data tables (FDEL(P),FINS(P))....7 - 142 Buffer memory access instruction 7 - 145 7.8.1 Reading 1-/2-word data from the intelligent function module (FROM(P),DFRO(P)) ........................
Page 14
7.12.3 TAN operation on floating-point data (Single precision) (TAN(P))......7 - 248 7.12.4 SIN operation on floating point data (Single precision) (ASIN(P)) ......7 - 250 7.12.5 COS operation on floating-point data (Single precision) (ACOS(P)) ....7 - 252 7.12.6 TAN operation on floating-point data (Single precision) (ATAN(P))......
Page 15
7.18.5 File register direct 1-byte write (ZRWRB(P)) ............7 - 334 7.18.6 Indirect address read operations (ADRSET(P)) ............7 - 336 7.18.7 Batch save or recovery of index register (ZPUSH(P),ZPOP(P)) ......7 - 337 7.18.8 Batch write operation to E PROM file register (EROMWR(P)) ........
Page 16
10.1.4 Error code list (2000 to 2999) ..................10 - 9 10.1.5 Error code list (3000 to 3999) ................... 10 - 15 10.1.6 Error code list (4000 to 4999) ................... 10 - 19 10.1.7 Error code list (5000 to 5999) ................... 10 - 28 10.1.8 Error code list (6000 to 6999) ...................
MANUALS To understand the main specifications, functions, and usage of the CPU module, refer to the basic manuals. Read other manuals as well when using a different type of CPU module and its functions. Order each manual as needed, referring to the following list. Basic manual, :Other CPU module manuals Manual name...
Related Manuals Manual name Description < Manual number (model code) > Explains the specifications for a CC-Link IE controller network for CC-Link IE Controller Network Reference Manual Controller Network. < SH-080668ENG (13JV16) > It explains the procedures and settings up to operation, setting the parameters, programming and troubleshooting.
This manual explains the common instructions required for programming of the QnACPU or Q2AS(H)CPU(S1). The common instructions refer to all instructions except those dedicated to special function modules (such as AJ71QC24 and AJ71PT32-S3) and to AD57 models, as well as PID control instructions, SFC instructions and ST instructions.
Abbreviations and Generic Terms This manual uses the generic names and abbreviations shown below to refer to QnA series CPU modules, unless otherwise specified. Table 1.1 Generic names and Abbreviations of Each Module Generic Terms/Abbreviation Description of Generic Name/Abbreviation ■ Series...
Types of Instructions The major types of CPU module instructions consist of sequence instructions, basic instructions, application instructions, data link instructions, QCPU instructions and redundant system instructions. These types of instructions are listed in Table 2.1 below. Table 2.1 Types of Instructions Reference Types of Instruction Meaning...
Page 25
Table 2.1 Types of Instructions (Continued) Reference Types of Instruction Meaning Chapter Link refresh instruction Designated network refresh Instruction dedicated to QnA Read/write of data from other stations; data transmission signals to other stations; links processing requests to other stations Instruction Instruction for A-series- Read/write for designated station word device, read/write data from remote I/O...
How to Read Instruction Tables The instruction tables found from Section 2.3 to 2.5 have been made according to the following format: Table 2.2 How to Read Instruction Tables Execution Category Symbol Processing Details ondition (D)+(S) 6-16 16-bit addition subtraction S1 S2 D operations (S1)+(S2)
Page 27
3) ..Shows symbol diagram on the ladder. S1 S2 Indicates destination. Indicates destination. Indicates source. Indicates source. Indicates instruction symbol. Indicates instruction symbol. Fig. 2.1 Symbol Diagram on the Ladder Destination.... Indicates where data will be sent after operation. Source ....Stores data prior to operation. 4) ..Indicates the type of processing that is performed by individual instructions.
2.3.2 Association instructions Table 2.4 Association Instructions Execution Category Symbol Processing Details Condition • AND between logical blocks (Series connection between logical blocks) • OR between logical blocks (Series connection between logical blocks) • Memory storage of operation results • Read of operation results stored with MPS instruction •...
2.3.5 Master control instructions Table 2.7 Master Control Instructions Execution Category Symbol Processing Details Condition • Starts master control Master 5-43 control • Resets master control 2.3.6 Termination instructions Table 2.8 Termination Instructions Execution Category Symbol Processing Details Condition 5-47 FEND •...
Page 32
Basic instructions 2.4.1 Comparison operation instructions Table 2.10 Comparison Operation Instructions Execution Category Symbol Processing Details Condition S1 S2 • Conductive status when (S1) (S2) AND= S1 S2 • Non-conductive status when (S1) (S2) S1 S2 LD<> S1 S2 • Conductive status when (S1) (S2) AND<>...
Page 33
Table 2.10 Comparison Operation Instructions (Continued) Execution Category Symbol Processing Details Condition LDD= S1 S2 • Conductive status when ANDD= (S1+1, S1) (S2+1, S2) S1 S2 • Non-Conductive status when (S1+1, S1) (S2+1, S2) ORD= S1 S2 LDD<> S1 S2 •...
Page 34
Table 2.10 Comparison Operation Instructions (Continued) Execution Category Symbol Processing Details Condition LDE= S1 S2 • Conductive status when ANDE= (S1+1, S1) (S2+1, S2) S1 S2 • Non-Conductive status when (S1+1, S1) (S2+1, S2) ORE= S1 S2 LDE<> S1 S2 •...
Page 35
Table 2.10 Comparison Operation Instructions (Continued) Execution Category Symbol Processing Details Condition • Compares character string S1 and LD$= S1 S2 character string S2 one character at a time. *2 AND$= S1 S2 • Conductive status when (character string S1) (character string S2) •...
Page 36
Table 2.10 Comparison Operation Instructions (Continued) Execution Category Symbol Processing Details Condition BKCMP= BKCMP S1 S2 D BKCMP<> BKCMP S1 S2 D BKCMP> BKCMP S1 S2 D BKCMP<= BKCMP S1 S2 D BKCMP< BKCMP S1 S2 D • Compares n points of data from S1 BIN Block BKCMP>= with n points of data from S2 in 1-word...
Page 37
2.4.2 Arithmetic operation instructions Table 2.11 Arithmetic Operation Instructions Execution Category Symbol Processing Details Condition 6-15 • (D)+(S) S1 S2 D 6-19 • (S1)+(S2) BIN 16-bit S1 S2 D addition and subtraction operations 6-15 • (D) S1 S2 D 6-21 •...
Page 38
*1: The number of steps may increase due to the conditions described in Section 3.8. *2: The number of steps may vary depending on the device and type of CPU module being used. Component Device Number of Steps • Word device: Internal device (except for file register ZR) •...
Page 39
Table 2.11 Arithmetic Operation Instructions (Continued) Execution Category Symbol Processing Details Condition 6-27 • (D)+(S) S1 S2 D BCD 4-digit 6-27 • (S1)+(S2) addition S1 S2 D subtraction 6-27 • (D) operations S1 S2 D 6-27 • (S1) (S2) S1 S2 D 6-31 •...
Page 40
Table 2.11 Arithmetic Operation Instructions (Continued) Execution Category Symbol Processing Details Condition 6-39 • (D+1, D)+(S+1, S) (D+1, D) Floating decimal S1 S2 D point data 6-39 • (S1+1, S1)+(S2+1, S2) (D+1, D) addition S1 S2 D subtraction 6-39 • (D+1, D) (S+1, S) (D+1, D) operations...
Page 41
Table 2.11 Arithmetic Operation Instructions (Continued) Execution Category Symbol Processing Details Condition 6-52 • (D)+1 INCP INCP DINC DINC 6-54 • (D+1, D)+1 (D+1, D) DINCP DINCP BIN data increment 6-52 • (D) DECP DECP DDEC DDEC 6-54 • (D+1, D) (D+1, D) DDECP DDECP...
2.4.3 Data conversion instructions Table 2.12 Data Conversion Instructions Execution Category Symbol Processing Details Condition BCD conversions BCDP BCDP BIN (0 to 9999) 6-56 conversions DBCD DBCD BCD conversions (S+1, S) (D+1, D) DBCDP BIN (0 to 99999999) DBCDP BIN conversions BINP BINP BCD (0 to 9999)
Page 43
Table 2.12 Data Conversion Instructions (Continued) Execution Category Symbol Processing Details Condition GBIN GBIN Conversion to BIN data Gray code GBINP Gray code (-32768 to 32767) GBINP 6-68 DGBIN Conversion to BIN data DGBIN (S+1, S) (D+1, D) conversions Gray code (-2147483648 to DGBINP DGBINP 2147483647)
2.4.4 Data transfer instructions Table 2.13 Data Transfer Instructions Execution Category Symbol Processing Details Condition 16-bit data ( D ) transfer MOVP MOVP 6-77 DMOV DMOV 32-bit data (D+1,D) (S+1,S) transfer DMOVP DMOVP Floating EMOV EMOV decimal point data (S+1, S) (D+1, D) 6-79 transfer...
Page 45
*1: The number of steps may increase due to the conditions described in Section 3.8. *2: The number of steps may vary depending on the device and type of CPU module being used. Number of Component Device Steps • Word device: Internal device (except for file register ZR) •...
2.4.5 Program branch instructions Table 2.14 Program Branch Instructions Execution Category Symbol Processing Details Condition • Jumps to Pn when input conditions are met. • Jumps to Pn from the scan after the 6-97 meeting of input condition. Jump • Jumps unconditionally to Pn. •...
2.5.2 Rotation instructions Table 2.19 Rotation Instructions Execution Category Symbol Processing Details Condition SM700 RORP RORP Right rotation by n bits Carry flag Right 7-35 rotation SM700 RCRP RCRP Right rotation by n bits Carry flag SM700 ROLP ROLP Carry flag Left rotation by n bits Left 7-38...
Table 2.21 Bit Processing Instrutions Execution Category Symbol Processing Details Condition (S1) TEST TEST S1 S2 D TESTP TESTP S1 S2 D Bit designated by (S2) Bit tests 7-55 DTEST (S1) DTEST S1 S2 D DTESTP DTESTP S1 S2 D Bit designated by (S2) BKRST Batch...
Page 53
Table 2.22 Data Processing Instructions (Continued) Execution Category Symbol Processing Details Condition 7-segment 7-69 decode 7SEG SEGP SEGP • Separates 16-bit data designated by (S) into 4-bit units, and stores at the lower 4 7-71 DISP bits of n points from (D). (n DISP •...
Page 54
Table 2.22 Data Processing Instructions (Continued) Execution Category Symbol Processing Details Condition S1 n SORT S2 D1 • Sorts data of n points from device · S2: Number of comparisons to be SORT made during a single run designated by (S1) in 16-bit units. ·...
2.5.6 Structure creation instructions Table 2.23 Structure Creation Instructions Execution Category Symbol Processing Details Condition • Executes n times between the 7-97 NEXT NEXT NEXT Number of repeats BREAK BREAK • Forcibly ends the execution of the 7-100 NEXT cycle and jumps pointer Pn. BREAKP BREAKP CALL...
Page 56
Table 2.23 Structure Creation Instructions (Continued) Execution Category Symbol Processing Details Condition EFCALL EFCALL • Performs non-execution processing of EFCALL Pn S1toSn subroutine program Pn if input :File name conditions have not been met. (S1 to 7-117 Sn are arguments sent to subroutine EFCALLP program.
Page 57
2.5.7 Data table operation instructions Table 2.24 Data table Operation Instructions Execution Category Symbol Processing Details Condition Pointer Pointer + 1 FIFW FIFW 7-136 FIFWP Device at FIFWP pointer + 1 (S) Pointer Pointer - 1 FIFR FIFR 7-138 FIFRP FIFRP (S) Pointer Pointer - 1...
2.5.8 Buffer memory access instructions Table 2.25 Buffer Memory Access Instructions Execution Category Symbol Processing Details Condition FROM FROM n1 n2 D • Reads data in 16-bit units from an intelligent function module. FROMP FROMP n1 n2 D Data read 7-145 DFRO DFRO...
2.5.10 Debugging and failure diagnosis instructions Table 2.27 Debugging and Failure Diagnosis Instructions Execution Category Symbol Processing Details Condition • The CHK instruction is executed when CHKST is executable. • Jumps to the step following the CHK CHKST CHKST instruction when CHKST is in a non-executable status.
2.5.11 Character string processing instructions Table 2.28 Character String Processing Instructions Execution Category Symbol Processing Details Condition • Converts 1-word BIN value designated BINDA BINDA by (S) to a 5-digit, decimal ASCII value, and stores it at the word device BINDAP BINDAP designated by (D).
Page 61
Table 2.28 Character String Processing Instructions (Continued) Execution Category Symbol Processing Details Condition • Converts a 4-digit, decimal ASCII value DABCD DABCD designated by (S) to a 1-word BCD Decimal value, and stores it at a word device DABCDP DABCDP ASCII number designated by (D).
Page 62
Table 2.28 Character String Processing Instructions (Continued) Execution Category Symbol Processing Details Condition • Converts the 1-word BIN value at the Hexadecimal device numbers designated by (S) to 7-227 hexadecimal ASCII, and stores n characters of them at the device numbers ASCP ASCP ASCII...
2.5.12 Special function instructions Table 2.29 Special Function Instructions Execution Category Symbol Processing Details Condition 7-244 Sin (S+1,S) (D+1,D) SINP SINP 7-246 (D+1,D) Cos (S+1,S) COSP COSP Trigonometric 7-248 Tan (S+1,S) (D+1,D) functions TANP TANP (Floating- ASIN point single- ASIN 7-250 (S+1,S) (D+1,D)
Page 64
Table 2.29 Special Function Instructions (Continued) Execution Category Symbol Processing Details Condition BSQR BSQR (D)+0 Integer part Decimal fraction part BSQRP BSQRP 7-269 Square root BDSQR BDSQR (S+1, S) (D)+0 Integer part Decimal fraction part BDSQRP BDSQRP S D BSIN BSIN Sin(S) (D)+0...
2.5.13 Data control instructions Table 2.30 Data Control Instructions Execution Category Symbol Processing Details Condition • When (S3) (S1) LIMIT LIMIT S1 S2 ..Stores value of (S1) at (D) • When (S1) (S3) (S2) ..Stores value of (S3) at (D) •...
2.5.15 Clock instructions Table 2.32 Clock Instructions Execution Category Symbol Processing Details Condition (Clock elements) (D) +0 Year DATERD DATERD D Month 7-300 Hour Minute DATERDP DATERDP D Sec. Read/ Day of the week write clock data (D) +0 (Clock elements) Year DATEWR DATEWR S...
2.5.16 Peripheral device instructions Table 2.33 Peripheral Device Instructions Execution Category Symbol Processing Details Condition • Stores the message designated by (S) to Input/ SD738 to SD769. This message is 7-312 output to displayed at the peripheral device. peripheral • Data input from the peripheral device is devices 7-314 PKEY...
Page 69
2.5.18 Other instructions Table 2.35 Other Instructions Execution Category Symbol Processing Details Condition • Resets watchdog timer during sequence 7-327 reset program. WDTP WDTP Timing n1 scans n2 scans 7-329 DUTY DUTY n1 n2 D clock SM420 to SM424, SM430 to SM434 •...
2.5.19 Instructions for Data Link Table 2.36 Instructions for Data Link Execution Category Symbol Processing Details Condition S.ZCOM S.ZCOM Q link SP.ZCOM SP.ZCOM Jn instruction: 8-10 Refreshes the designated network. Network S.ZCOM S.ZCOM refresh SP.ZCOM SP.ZCOM Un J.ZCOM J.ZCOM QnA link JP.ZCOM JP.ZCOM Jn instruction:...
Page 71
Table 2.36 Instructions for Data Link (Continued) Execution Category Symbol Processing Details Condition QnA link instruction: JP.ZNFR JP.ZNFR Reading data Reads data from the special function modules from special 8-92 function at remote I/O stations. modules at GP.ZNFR remote I/O GP.ZNFR station QnA link...
Page 72
2.5.20 Redundant system instructions (For the Q4ARCPU) Table 2.38 Redundant System Instructions (For the Q4ARCPU) Execution Category Symbol Processing Details Condition • Designates the operation mode at (S1) Operation mode whether to clear the Q4ARCPU devices before startup or not to clear them before setting during S.STMODE S.STMODE S1 S2...
Page 74
Configuration of Instructions Most CPU module instructions consist of an instruction part and a device part. Each part is used for the following purpose: • Instruction part ..indicates the function of the instruction. • Device part .... indicates the data that is to be used with the instruction. The device part is classified into source data, destination data, and number of devices.
Designating Data The following six types of data can be used with CPU module instructions....... Section 3.2.1 Data that can be handled by Bit data CPU module .......Section 3.2.2 Numeric data Integer data Word data ...Section 3.2.3 Double-word data Real number ..
3.2.2 Using word (16 bits) data Word data is 16-bit numeric data used by basic instructions and application instructions. The following two types of word data can be used with CPU module: • Decimal constants....K-32768 to K32767 • Hexadecimal constants ..H0000 to HFFFF Word devices and bit devices designated by digit can be used as word data.
Page 77
(c) When destination (D) data is a word device The word device for the destination becomes 0 following the bit designated by digit designation at the source. Ladder Example Processing With 16-Bit Instruction K1X0 X3 X2 X1 X0 X010 Filled with 0s MOV K1X0 0 0 0 0 0 0 0 0 0 0 X2 X1 X0...
3.2.3 Using double word data (32 bits) Double word data is 32-bit numerical data used by basic instructions and application instructions. The two types of double word data that can be dealt with by CPU module are as follows: • Decimal constants....K-2147483648 to K2147483647 •...
Page 79
(c) When destination (D) data is a word device The word device for the destination becomes 0 following the bit designated by digit designation at the source. Ladder Example Processing With 32 bit Instructions K1X0 X3 X2 X1 X0 Filled with 0s DMOV K1X0 0 0 0 0 0 0 0 0 0 0 X2 X1 X0...
(2) Using word devices A word device designates devices used by the lower 16 bits of data. A 32-bit instruction uses (designation device number) and (designation device number + 1). DMOV K100 Designation of 2 points of word devices D0 and D1 (32 bits) 32-bit data transfer instruction 3.2.4 Using real number data...
Page 81
• Variable part The 23 bits from b0 to b22, represents the XXXXXX... at binary 1.XXXXXX..1. The CPU module floating decimal point data can be monitored using the monitoring function of a peripheral device. 2. When floating-point data is used to express 0, all data in the following range are turned to 0.
3.2.5 Using character string data Character string data is character data used by basic instructions and application instructions. The target ranges from the designated character to the NULL code (00 ) that indicates the end of the character string. (1) When designated character is the NULL code One word is used to store the NULL code.
Page 83
Indexing (1) Overview of indexing Indexing is an indirect setting made by using an index register. When an Indexing is used in a sequence program, the device to be used will become the device number specified directly plus the contents of the index register. For example, if D2Z2 has been specified, the specified device is calculated as follows: D(2+3) = D5 and the content of Z2 is 3 become the specified device.
Page 84
2) Devices with limits for use with index registers Device Meaning Application Example T0Z0 K100 • Only Z0 and Z1 can be used for T1Z1 timer contacts and coils. C0Z1 K100 • Only Z0 and Z1 can be used for C1Z0 counter contacts and coils.
Page 85
[When edge relay is used] [When edge relay is not used] (M0Z1 provides normal pulse output.) (M0Z1 does not provide normal pulse output.) SM400 SM400 X0Z1 V0Z1 X0Z1 M0Z1 M0Z1 SM400 SM400 NEXT NEXT Remark The ON/OFF data of X0Z1 is stored by the edge relay V0Z1. For example, the ON/OFF data of X0 is stored by V0, and that of X1 by V1.
Indirect Specification (1) Indirect Specification (a) Indirect specification is a method that specifies address of the device to be used in a sequence program using two word devices (two points of word device). Use indirect specification as index modification when the index register is insufficient. Stores the address of ADRSET D100...
Page 87
(3) Precautions (a) The address for indirect specification uses two words.Therefore, to substitute indirect specification for index modification, the addition/subtraction of 32-bit data is required. The following is the ladder used for the address addition/subtraction of the device stored in D1 and D0 for indirect specification. [To add "1"...
Reducing Instruction Processing Time 3.5.1 Subset Processing Subset processing is used to place limits on bit devices used by basic instructions and application instructions in order to increase processing speed. However, the instruction symbol does not change. To shorten scans, run instructions under the conditions indicated below. (1) Conditions which each device must meet for subset processing (a) When using word data Device...
Page 89
(2) Instructions for which subset processing can be used Types of Instructions Instruction Symbols Contact instructions LD,LDI,AND,ANI,OR,ORI,LDP,LDF,ANDP,ANDF,ORP,ORF Output instructions OUT,SET,RST Comparison operation instruction • • +, ,*,/,INC,DEC,D+,D ,D*,D/,DINC,DDEC Arithmetic operation • B+,B ,B*,B/, E+,E ,E*,E/ Data conversion instructions • BCD, BIN, DBCD, DBIN, FLT, DFLT, INT, DINT •...
Cautions on Programming (Operation Errors) Operation errors are returned in the following cases when executing basic instructions and application instructions with CPU module: • An error listed on the explanatory page for the individual instruction occurred. • When an intelligent function module device is used, no intelligent function module is installed at the specified I/O number position.
Page 91
(b) Instructions for a block of devices, including BMOV and FMOV The device range is checked. When the device number is outside the device range, an operation error occurs. For example, when 12 k points are assigned to a data register, an error occurs if the device number of the data register exceeds D12287.
Page 92
Remark Refer to the manuals below for how to change the internal user device allocation: • QnACPU Programming Manual (Fundamentals) (d) Device range checks are conducted when indexing is performed by direct access output (DY). (2) Device data check Device data checks for the devices used by basic instructions and application instructions in CPU module are as indicated below: (a) When using BIN data No error is returned even if the operation results in overflow or underflow.
Conditions for Execution of Instructions The following four types of execution conditions exist for the execution of CPU module sequence instructions, basic instructions, and application instructions: • Non-conditional execution..Instructions executed without regard to the ON/OFF status of the device Example LD X0, OUT Y10 •...
Counting Step Number The number of steps in CPU module sequence instructions, basic instructions, and application instructions differs depending on whether indirect setting of the device used is possible or not. (1) Counting the number of basic steps The basic number of steps for basic instructions and application instructions is calculated by adding the device number and 1.
Page 95
Operation when the OUT, SET/RST, or PLS/PLF Instructions Use the Same Device The following describes the operation for executing multiple instructions of the OUT, SET/RST, or PLS/PLF that use the same device in one scan. (1) OUT instructions using the same device Do not program more than one OUT instruction using the same device in one scan.
Page 96
(2) SET/RST instructions using the same device (a) The SET instruction turns ON the specified device when the execution command is ON and performs nothing when the execution command is OFF. For this reason, when the SET instructions using the same device are executed two or more times in one scan, the specified device will be ON if any one of the execution commands is ON.
Page 97
(3) PLS instructions using the same device The PLS instruction turns ON the specified device when the execution command is turned ON from OFF. It turns OFF the device at any other time (OFF to OFF, ON to ON, or ON to OFF). If two or more PLS instructions using the same device are executed in one scan, each instruction turns ON the device when the corresponding execution command is turned ON from OFF and turns OFF the device in other cases.
Page 98
• The X0 and X1 turn ON from OFF at the same time. M0 turns ON because X1 M0 turns OFF because X1 status is other than OFF goes ON (OFF ON). (M0 remains OFF.) (M0 remains ON.) M0 turns ON because M0 turns OFF because X0 status is other X0 goes ON (OFF ON).
Page 99
[Timing Chart] • The ON/OFF timing of the X0 and X1 is different. (The specified device does not turn ON throughout the scan.) M0 turns OFF because X1 status is M0 turns OFF because X1 other than ON OFF. status is other than ON OFF.
3.10 Precautions for Use of File Registers This section explains the precautions for use of the file registers in the QnACPU. (1) Setting of file registers to be used When using the file registers, the file registers to be used must be set with the PLC parameter or QDRSET instruction.
Page 101
(4) File register specifying method There are the block switching method and serial number access method to specify the file registers. (a) Block switching method In the block switching method, specify the number of used file register points in units of 32k points (one block).
Page 102
(b) Restrictions The restrictions when specifying file registers to refresh devices are as follows. 1) Refresh cannot be performed correctly if the use of file register which has the same name as the program is specified by the PLC parameter. When the file register which has the same name as the program is used, refresh is performed to the data of the file register having the same name as the program that is set at the last number in the [Program] tab page of PLC...
Page 104
The description of instructions that are contained in the following chapters are presented in the following format. 1) Code used to write instruction (instruction symbol). 2) Section number and general category of instructions described. 3) Shows if instructions are enabled or disabled for each CPU module type. Icon Meaning QnACPU...
Page 105
4) Indicates ladder mode expressions and execution conditions for instructions. Non-conditional Executed One Time Executed One Execution Condition Executed while ON Executed while OFF Execution at ON Time at OFF Code recorded on No symbol description page recorded 5) Indicates the data set for each instruction and the data type. Data Type Meaning Bit data or head number in bit data...
Page 106
6) Devices which can be used by the instruction in question are indicated with circle. The types of devices that can be used are as indicated below: Link direct device *4 Intelligent Internal Devices File function (System, User) Index register Setting Data Register Constant *5...
LD,LDI,AND,ANI,OR,ORI Contact Instructions 5.1.1 Operation start, series connection, parallel connection (LD,LDI,AND,ANI,OR,ORI) LD,LDI,AND,ANI,OR,ORI Q4AR Bit device number / Word device bit designation ( X1/D0.1 X1/D0.1 X2/D0.2 X2/D0.2 X3/D0.3 X3/D0.3 : Devices used as contacts (bits) Internal Devices Setting Other R, ZR Constants Data DX, BL...
Page 109
LD,LDI,AND,ANI,OR,ORI AND, ANI (1) AND is the A contact series connection instruction, and ANI is the B contact series connection instruction. They read the ON/OFF data of the designated bit device* , perform an AND operation on that data and the operation result to that point, and take this value as the operation result.
LD,LDI,AND,ANI,OR,ORI Operation Error (1) There are no operation errors with LD, LDI, AND, ANI, OR, or ORI instruction. Program Example (1) A program using the LD, AND, OR, and ORI instructions. [Ladder Mode] [List Mode] Step Instruction Device Bit designated for word device (2) A program linking contacts using the ANB and ORB instructions.
LDP,LDF,ANDP,ANDF,ORP,ORF 5.1.2 Pulse operation start, pulse series connection, pulse parallel connection (LDP,LDF,ANDP,ANDF,ORP,ORF) LDP,LDF,ANDP,ANDF,ORP,ORF Q4AR Bit device number / Word device bit designation X1/D0.1 X1/D0.1 X2/D0.2 ANDP X2/D0.2 ANDF X3/D0.3 X3/D0.3 : Devices used as contacts (bits) Internal Devices Setting Other R, ZR Constants Data...
Page 112
LDP,LDF,ANDP,ANDF,ORP,ORF (2) LDF is the trailing edge pulse operation start instruction, and is ON only at the trailing edge of the designated bit device (when it goes from ON to OFF). If a word device has been designated, it is ON only when the designated bit changes from 1 to 0.
ANB,ORB Association Instructions 5.2.1 Ladder block series connection and parallel connection (ANB,ORB) ANB,ORB Q4AR Block A Block B Block A Block B For parallel connection of 1 contact, OR or ORI is used. Internal Devices Setting R, ZR Constants Other Data Word Word...
Page 114
ANB,ORB Operation Error (1) There are no operation errors associated with ANB or ORB instruction. Program Example (1) A program using the ANB and ORB instructions. [Ladder Mode] [List Mode] Step Instruction Device...
MPS,MRD,MPP 5.2.2 Operation results push,read,pop (MPS,MRD,MPP) MPS,MRD,MPP Q4AR In the ladder display, MPS, MRD and MPP are not displayed. Command Command Command Command Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Stores the memory of the operation result (ON or OFF) immediately prior to the MPS instruction.
Page 116
MPS,MRD,MPP 1. The following shows ladders both using and not using the MPS, MRD, and MPP instructions. Ladder Using the MPS, MRD and MPP Instruction Ladder not Using MPS, MRD, and MPP Instructions 2. The MPS and MPP instructions must be used the same number of times. Failure to observe this will not correctly display the ladder in the ladder mode of the peripheral device.
Page 117
MPS,MRD,MPP (2) A program using the MPS and MPP instructions successively. [Ladder Mode] [List Mode] Instruction Device Step 5-11...
5.2.3 Operation results inversion (INV) Q4AR Command Internal Devices Setting R, ZR Constants Other 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 the INV Instruction Operation Error...
Page 119
1. 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 the AND instruction. The INV instruction cannot be used at the LD and OR positions. 2.
MEP,MEF 5.2.4 Operation result conversions (MEP,MEF) MEP,MEF Q4AR Command Command Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) If operation results up to the MEP instruction are leading edge (from OFF to ON), goes ON (continuity status).
EGP,EGF 5.2.5 Pulse conversions of edge relay operation results (EGP,EGF) EGP,EGF Q4AR Command Command : Edge relay number where operation results are stored (bits) Internal Devices Setting Other R, ZR Constants Data Word Word –– Function (1) Operation results up to the EGP instruction are stored in memory by the edge relay (V). (2) Goes ON (continuity status) at the leading edge (OFF to ON) of the operation result up to the EGP instruction.
Page 122
EGP,EGF Program Example (1) A program using the EGP instruction in the subroutine program using the EGD instruction [Ladder Mode] [List Mode] Step Instruction Device [Operation] END processing Turns OFF as X0 remains ON. Turns ON at the leading Turns OFF as X1 remains ON. edge of X0.
Output Instructions 5.3.1 Out instruction (excluding timers, counters, and annunciators) (OUT) Q4AR Bit device number ( Command Word device Command bit designation ( D0.5 : Number of the device to be turned ON and OFF (bits) Internal Devices Setting Other R, ZR Constants Data...
Page 124
Program Example (1) When using bit devices [Ladder Mode] [List Mode] Instruction Device Step (2) When bit designation has been made for word device [Ladder Mode] [List Mode] Step Instruction Device Remark The number of basic steps for the OUT instructions is as follows: •...
Page 125
OUT T,OUTH T 5.3.2 Timers (OUT T,OUTH T) OUT T,OUTH T Q4AR Command Set value Setting in the range from 1 to 32767 is valid. OUT T (Low-speed timer) Command Set value Data register value in the range from 1 to 32767 is valid.
Page 126
OUT T,OUTH T (2) The contact responds as follows when the operation result up to the OUT instruction is a change from ON to OFF: Prior to Time Up After Time Up Present Value of Type of Timer Timer Coil Timer A Contact B Contact...
Page 127
OUT T,OUTH T Caution (1) When creating a program in which the operation the timer contact triggers the operation of other timer, create the program for the timer that operates later first. In the following cases, all timers go ON at the same scan if the program is created in the order the timers operate.
Page 128
OUT T,OUTH T Program Example (1) The following program turns Y10 and Y14 ON 10 seconds after X0 has gone ON. [Ladder Mode] [List Mode] Step Instruction Device *3: The setting value of the low-speed timer indicates its default time limit (100 ms). (2) The following program uses the BCD data at X10 to X1F as the timer's set value.
OUT C 5.3.3 Counter (OUT C) OUT C Q4AR Set value Command Setting in the range from 1 to 32767 is valid. OUT C Set value Command Data register value in the range from 1 to 32767 is valid. : Counter number (bits) Set value : Counter setting value (BIN 16 bits Internal Devices Setting...
Page 130
OUT C Operation Error (1) There are no operation errors associated with the OUT C instruction. Program Example (1) The following program turns Y30 ON after X0 has gone ON 10 times, and resets the counter when X1 goes ON. [Ladder Mode] [List Mode] Step...
OUT F 5.3.4 Annunciator output (OUT F) OUT F Q4AR Annunciator number Command OUT F : Number of the annunciator to be turned ON (bits) Internal Devices Setting R, ZR Constants Other Data Word Word –– (Only F) Function (1) Operation results up to the OUT instruction are output to the designated annunciator. (2) The following responses occur when an annunciator (F) is turned ON.
Page 132
OUT F Operation Error (1) There are no operation errors associated with the OUT F instruction. Remark 1. Refer to the manuals below for details of annunciators. • QnACPU Programming Manual (Fundamentals) 2. The number of basic steps for the OUT module F instruction is 2.
5.3.5 Setting devices (except for annunciators) (SET) Q4AR Command : Bit device number to be set (ON)/Word device bit designation (bits) Internal Devices Setting Other R, ZR Constants Data BL, DY Word Word –– (Other than T, C) Function (1) When the execution command is turned ON, the status of the designated devices becomes as shown below: Device Device Status...
Page 134
Operation Error (1) There are no operation errors associated with the SET instruction. Program Example (1) The following program sets Y8B (ON) when X8 goes ON, and resets Y8B (OFF) when X9 goes ON. [Ladder Mode] [List Mode] Step Instruction Device (2) The following program sets the value of D0 bit 5 (b5) to 1 when X8 goes ON, and set the bit value to 0 when X9 goes ON.
5.3.6 Resetting devices (except for annunciators) (RST) Q4AR Command : Bit device number to be reset/ Word device bit designation (bits) Word device number to be reset (BIN 16 bits) Internal Devices Setting Other R, ZR Constants Data Word Word ––...
Page 136
Operation Error (1) There are no operation errors associated with the RST instruction. Remark The basic number of steps of the RST instruction is as follows. a) For bit processing • Internal device (bit to be specified by bit device or word device) : 1 •...
Page 137
(2) The following program resets the 100 ms retentive timer and counter. [Ladder Mode] When ST225 is set as retentive timer, it is turned ON when X4 ON time reaches 30 min. Counts the number of times ST225 was turned ON. Resets the coil, contact and present value of ST225 when the contact of ST225 is turned ON.
SET F,RST F 5.3.7 Setting and resetting the annunciators (SET F,RST F) SET F,RST F Q4AR Command Command : Number of the annunciator to be set (F number) (bits) : Number of the annunciator to be reset (F number) (bits) Internal Devices Setting R, ZR...
Page 139
SET F,RST F (3) When the value of SD63 is "16", the annunciator numbers are deleted from SD64 to SD79 by the use of the RST instruction. If the annunciators whose numbers are not registered in SD64 to SD79 are ON, these numbers will be registered. If all annunciator numbers from SD64 to SD79 are turned OFF, the LED display device on the front of the CPU module, or the "USER"...
PLS,PLF 5.3.8 Leading edge and trailing edge outputs (PLS,PLF) PLS,PLF Q4AR Command Command : Pulse conversion device (bits) Internal Devices Setting Other R, ZR Constants Data Word Word –– Function (1) Turns ON the designated device when the execution command is turned OFF ON, and turns OFF the device in any other case the execution command is turned OFF ON (i.e., at ON, ON...
Page 141
PLS,PLF (3) When designating a latch relay (L) for the execution command and turning the power supply OFF to ON with the latch relay ON, the execution command turns OFF to ON at the first scan, executing the PLS instruction and turning ON the designated device. The device turned ON at the first scan after power-ON turns OFF at the next PLS instruction.
Page 142
PLS,PLF (2) The following program executes the PLF instruction when X9 goes OFF. [Ladder Mode] [List Mode] Step Instruction Device [Timing Chart] X9 OFF M9 OFF 1 scan 5-36...
5.3.9 Bit device output reverse (FF) Q4AR Command : Device number of the device to be reversed (bits) Internal Devices Setting Other R, ZR Constants Data Word Word –– Function (1) Reverses the output status of the device designated by when the execution command is turned OFF ON.
Page 144
(2) The following program reverses b10 (bit 10) of D10 when X0 goes ON. [Ladder Mode] [List Mode] Instruction Device Step [Timing Chart] D10 of b10 5-38...
DELTA(P) 5.3.10 Pulse conversions of direct outputs (DELTA(P)) DELTA(P) Q4AR Command DELTA DELTA Command DELTAP DELTAP : Bit for which pulse conversion is to be conducted (bits) Internal Devices Setting Other R, ZR Constants Data Word Word –– Function (1) Conducts pulse output of direct access output (DY) designated by If DELTA DY0 has been designated, the resulting operation will be identical to the ladder shown below, which uses the SET/RST instructions.
Page 146
DELTA(P) Program Example (1) The following program presets CH1 of the AD61 mounted at slot 0 of the main base unit, when X20 goes ON. [Ladder Mode] Stores preset value (0) at addresses 1 and 2 of the AD61 buffer memory. Outputs the preset command.
SFT(P) Shift Instructions 5.4.1 Bit device shifts (SFT(P)) SFT(P) Q4AR Command Command SFTP SFTP : Device number to shift (bits) Internal Devices Setting Other R, ZR Constants Data Word Word –– (Other than T, C) Function (1) When bit device is used (a) Shifts to a device designated by the ON/OFF status of the device immediately prior to the one designated by...
Page 148
SFT(P) (2) When word device bit designation is used (a) Shifts to a bit in the device designated by the 1/0 status of the bit immediately prior to the one designated by , and turns the prior bit to 0. For example, if D0.5 (bit 5 [b5] of D0) has been designated by the SFT instruction, when the SFT instruction is executed, it will shift the 1/0 status of b4 of D0 to b5, and turn b4 to 0.
MC,MCR Master Control Instructions 5.5.1 Setting and resetting the master control (MC,MCR) MC,MCR Q4AR Command Master control ladder : Nesting (N0 to N14) (Nesting) : Device number to be turned ON (bits) Internal Devices Other Setting R, ZR Constants Data Word Word ––...
Page 150
MC,MCR (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. If the execution command of the MC instruction is OFF, the result of the operation from the MC instruction to the MCR instruction will be as shown below: Device Device Status...
Page 151
MC,MCR Program Example The master control instruction can be used in nesting. The different master control regions are distinguished by nesting (N). Nesting can be performed from N0 to N14. The use of nesting enables the creation of ladders which successively limit the execution condition of the program.
Page 152
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 (N) 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.
FEND Termination Instructions 5.6.1 End main routine program (FEND) FEND Q4AR FEND FEND Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) The FEND instruction is used in cases where the CJ instruction or other instructions are used to cause a branch in the sequence program operations, and in cases where the main routine program is to be split from a subroutine program or an interrupt program.
Page 154
FEND Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The FEND instruction is executed after the execution of the CALL, FCALL, ECALL, or EFCALL instruction, and before the execution of the RET instruction.
5.6.2 End sequence program (END) Q4AR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Indicates termination of programs, including main routine program, subroutine program, and interrupt programs. Execution of the END instruction will cause the CPU module to terminate the program that was being executed.
Page 156
(4) The use of the END and FEND instructions is broken down as follows for main routine programs, subroutine programs, and interrupt programs: Main routine program FEND (FEND instruction is necessary.) Subroutine program Main sequence program area Interrupt program (END instruction is necessary.) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
STOP Other instructions 5.7.1 Sequence program stop (STOP) STOP Q4AR Command STOP STOP Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Resets the output (Y) and stops the CPU module operation when the execution command is turned ON.
Page 158
STOP Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The STOP instruction was executed before the execution of the RET instruction and after the execution of the CALL/FCALL/ECALL/EFCALL/XCALL instruction.
NOP,NOPLF,PAGE n 5.7.2 No operations (NOP,NOPLF,PAGE n) NOP,NOPLF,PAGE n Q4AR In the ladder display, NOP is not displayed. Command NOPLF NOPLF PAGE n PAGE n Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) This is a no operation instruction that has no impact on any operations up to that point. (2) The NOP instruction is used in the following cases: (a) To insert space for sequence program debugging.
Page 160
NOP,NOPLF,PAGE n PAGE n (1) This is a no operation instruction that has no impact on any operations up to that point. (2) No processing is performed at peripheral devices with this instruction. Operation Error (1) There are no errors associated with the NOP, NOPLF, or PAGE instruction. Program Example (1) Contact closed..
Page 161
NOP,NOPLF,PAGE n [Ladder Mode] [List Mode] Before change Instruction Device Step Changing to LD T3 Changing to NOP After change Instruction Device Step NOPLF [Ladder Mode] [List Mode] Instruction Device Step 5-55...
Page 162
NOP,NOPLF,PAGE n • Printing the ladder will result in the following: NOPLF instruction, inserted as a delimiter NOPLF of ladder blocks, causes print out page to be changed forcibly. • Printing an instruction list with the NOPLF instruction will result in the following: NOPLF Changes print output page after printing NOPLF.
BASIC INSTRUCTIONS Reference Category Processing Details Section Comparison operation Compares data to data. Section 6.1 instruction Adds, subtracts, multiplies, divides, increments, or Arithmetic operation instruction Section 6.2 decrements data with other data. Section 6.3 Data conversion instructions Converts data types. Section 6.4 Data transfer instruction Transmits designated data.
=,<>,>,<=,<,>= Comparison Operation Instructions 6.1.1 BIN 16-bit data comparisons (=,<>,>,<=,<,>=) =,<>,>,<=,<,>= Q4AR indicates an instruction symbol of Command Command Command : Data for comparison or head number of the devices where the data for comparison is stored (BIN 16 bits) Internal Devices Setting Constants...
Page 165
=,<>,>,<=,<,>= Operation Error (1) There are no operation errors associated with the , or instruction. Program Example (1) The following program compares the data at X0 to XF with the data at D3, and turns Y33 ON if the data is identical. [Ladder Mode] [List Mode] Instruction...
D=,D<>,D>,D<=,D<,D>= 6.1.2 BIN 32-bit data comparisons (D=,D<>,D>,D<=,D<,D>=) D=,D<>,D>,D<=,D<,D>= Q4AR indicates an instruction symbol of Command Command Command : Data for comparison or head number of the devices where the data for comparison is stored (BIN 32 bits) Internal Devices Setting Constants R, ZR Other...
Page 167
D=,D<>,D>,D<=,D<,D>= Operation Error (1) There are no operation errors associated with the D , D , D , D or D instruction. Program Example (1) The following program compares the data at X0 to X1F with the data at D3 and D4, and turns Y33 ON, if the data at X0 to X1F and the data at D3 and D4 match.
E=,E<>,E>,E<=,E<,E>= 6.1.3 Floating decimal point data comparisons (Single precision) (E=,E<>,E>,E<=,E<,E>=) E=,E<>,E>,E<=,E<,E>= Q4AR indicates an instruction symbol of Command Command Command : Data for comparison or head number of the devices where the data for comparison is stored (real number) Internal Devices Setting Constants R, ZR...
Page 169
E=,E<>,E>,E<=,E<,E>= Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of the specified device is (For the Q4ARCPU) (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
$=,$<>,$>,$<=,$<,$>= 6.1.4 Character string data comparisons ($=,$<>,$>,$<=,$<,$>=) $=,$<>,$>,$<=,$<,$>= Q4AR indicates an instruction symbol of Command Command Command :Data for comparison or head number of the devices where the data for comparison is stored (character string) Internal Devices Setting Constants R, ZR Other Data Word...
Page 171
$=,$<>,$>,$<=,$<,$>= (b) If the character strings are different, the character string with the larger character code will be the larger. "ABCDF" "ABCDE" Comparison Operation Comparison Operation Instruction Symbol in Instruction Symbol in Result Result Non-continuity $<= Non-continuity $<> Continuity $< Non-continuity $>...
Page 172
$=,$<>,$>,$<=,$<,$>= Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The code "00 " does not exist within the range of the relevant device, starting from the device number designated by (Error code: 4101) •...
Page 173
$=,$<>,$>,$<=,$<,$>= (3) The following program compares the character string stored following D10 with the character string stored following D100. [Ladder Mode] [List Mode] Instruction Device Step (4) The following program compares the character string stored following D200 with the character string "12345". [Ladder Mode] [List Mode] Instruction...
BKCMP ,BKCMP 6.1.5 BIN block data comparisons (BKCMP ,BKCMP BKCMP ,BKCMP Q4AR indicates an instruction symbol of Command BKCMP BKCMP Command BKCMP BKCMP : Data to be compared or head number of the devices where the data to be compared is stored (BIN 16 bits) : Head number of the devices where the comparison data is stored (BIN 16 bits) : Head number of the devices where the comparison operation result will be stored (bits) n : Number of comparison data blocks (BIN 16 bits)
Page 175
BKCMP ,BKCMP (4) The results of the comparison operations for the individual instructions are as follows: Instruction Comparison Instruction Comparison Condition Condition Symbols Operation Result Symbols Operation Result BKCMP= BKCMP= BKCMP<> BKCMP<> BKCMP> BKCMP> > ON (1) OFF (0) BKCMP<= BKCMP<= >...
Page 176
BKCMP ,BKCMP (2) The following program compares, when X1C is turned ON, the constant K1000 with the data stored at D10 to D13, and stores the operation result at b4 to b7 in D0. [Ladder Mode] [List Mode] Device Step Instruction [Operation] 2000 (BIN)
+(P),-(P) Arithmetic Operation Instructions 6.2.1 BIN 16-bit addition and subtraction operations (+(P),-(P)) +(P),-(P) Q4AR When two data are set ( indicates an instruction symbol of Command Command +P, P : Data for additing/subtracting or head number of the devices where the data for additing/subtracting is stored (BIN 16 bits) : Head number of the devices where the data to be added to/subtracted from is stored (BIN 16 bits) S1 D...
Page 178
+(P),-(P) – (1) Subtracts 16-bit BIN data designated by from 16-bit BIN data designated by stores the result of the subtraction at the device designated by 5678 (BIN) 1234 (BIN) 4444 (BIN) (2) Values for can be designated between 32768 and 32767 (BIN, 16 bits). (3) The judgment of whether data is positive or negative is made by the most significant bit (b15).
Page 179
+(P),-(P) When three data are set ( indicates an instruction symbol of Command Command +P, P : Data to be added to/subtracted from or head number of the devices where the data to be added to/subtracted from is stored (BIN 16 bits) : Data for additing/subtracting or head number of the devices where the data for additing/subtracting is stored (BIN 16 bits) : Head number of the devices where the addition/subtraction operation result will be stored (BIN 16 bits)
Page 180
+(P),-(P) – (1) Subtracts 16-bit BIN data designated by from 16-bit BIN data designated by stores the result of the subtraction at the device designated by 5678 (BIN) 1234 (BIN) 4444 (BIN) (2) Values for and can be designated between 32768 and 32767 (BIN, 16 bits).
D+(P),D-(P) 6.2.2 BIN 32-bit addition and subtraction operations (D+(P),D-(P)) D+(P),D-(P) Q4AR When two data are set (( ), ( indicates an instruction symbol of Command D+, D Command D+P, D P : Data for additing/subtracting or head number of the devices where the data for additing/subtracting is stored (BIN 32 bits) : Head number of the devices where the data to be added to/subtracted from is stored (BIN 32 bits) Internal Devices...
Page 182
D+(P),D-(P) (1) Subtracts 32-bit BIN data designated by from 32-bit BIN data designated by stores the result of the subtraction at the device designated by D +1 b16 b15 b16 b15 b16 b15 567890 (BIN) 123456 (BIN) 444434 (BIN) (2) The values for can be designated at between 2147483648 and 2147483647 (BIN 32 bits).
Page 183
D+(P),D-(P) When three data are set (( ), ( indicates an instruction symbol of D+/ D Command D+, D Command D+P, D P : Data to be added to/subtracted from or head number of the devices where the data to be added to/subtracted from is stored (BIN 32 bits) : Data for additing/subtracting or head number of the devices where the data for additing/subtracting is stored (BIN 32 bits)
Page 184
D+(P),D-(P) (1) Subtracts 32-bit BIN data designated by from 32-bit BIN data designated by stores the result of the subtraction at the device designated by b16 b15 b16 b15 b16 b15 567890 (BIN) 123456 (BIN) 444434 (BIN) (2) The values for can be designated at between 2147483648 and 2147483647 (BIN 32 bits).
*(P),/(P) 6.2.3 BIN 16-bit multiplication and division operations (*(P),/(P)) *(P),/(P) Q4AR indicates an instruction symbol of * Command *, / Command *P, / P : Data to be multiplied/divided or head number of the devices where the data to be multiplied/divided is stored (BIN 16 bits) : Data for multiplying/dividing or head number of the devices where the data for multiplying/dividing is stored (BIN 16 bits)
Page 186
*(P),/(P) (1) Divides BIN 16-bit data designated by and BIN 16-bit data designated by , and stores the result in the device designated by Quotient Remainder 5678 (BIN) 1234 (BIN) 4 (BIN) 742 (BIN) (2) If a word device has been used, the result of the division operation is stored as 32 bits, and both the quotient and remainder are stored;...
D*(P),D/(P) 6.2.4 BIN 32-bit multiplication and division operations (D*(P),D/(P)) D*(P),D/(P) Q4AR indicates an instruction symbol of Command , D/ Command P,D/P : Data to be multiplied/divided or head number of the devices where the data to be multiplied/divided is stored (BIN 32 bits) : Data for multiplying/dividing or head number of the devices where the data for multiplying/dividing is stored (BIN 32 bits)
Page 188
D*(P),D/(P) (1) Divides BIN 32-bit data designated by and BIN 32-bit data designated by , and stores the result in the device designated by b31 b16 b31 b16 b31 b16 567890 (BIN) 123456 (BIN) 4 (BIN) 74066 (BIN) (2) With a word device, the division operation result is stored in 64 bits and both the quotient and remainder are stored.
B+(P),B-(P) 6.2.5 BCD 4-digit addition and subtraction operations (B+(P),B-(P)) B+(P),B-(P) B+(P), B-(P) Q4AR When two data are set ( indicates an instruction symbol of B+/B Command B+, B Command B+P, B P : Data for adding/subtracting or head number of the devices where the data for adding/subtracting is stored (BCD 4 digits) : Head number of the devices where the data to be added to/subtracted from is stored (BCD 4 digits) Internal Devices...
Page 190
B+(P), B-(P) (3) The following will result if an underflow is generated by the subtraction operation: The carry flag in this case does not go ON. Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
Page 191
B+(P), B-(P) When three data are set ( indicates an instruction symbol of B+/B- Command B+, B- Command B+P,B-P : Data to be added to/subtracted from or head number of the devices where the data to be added to/subtracted from is stored (BCD 4 digits) : Data for adding/subtracting or head number of the devices where the data for adding/subtracting is stored (BCD 4 digits) : Head number of the devices where the addition/subtraction operation result will be stored (BCD 4 digits)
Page 192
B+(P), B-(P) (3) The following will result if an underflow is generated by the subtraction operation: The carry flag in this case does not go ON. Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
DB+(P),DB-(P) 6.2.6 BCD 8-digit addition and subtraction operations (DB+(P),DB-(P)) DB+(P),DB-(P) Q4AR When two data are set (( ), ( indicates an instruction symbol of DB+/DB- Command DB+, DB- Command DB+P. DB-P : Data for adding/subtracting or head number of the devices where the data for adding/subtracting is stored (BCD 8 digits) : Head number of the devices where the data to be added to/subtracted from is stored (BCD 8 digits) Internal Devices...
Page 194
DB+(P),DB-(P) (2) 0 to 99999999 (BCD 8 digits) can be assigned to (3) The following will result if an underflow is generated by the subtraction operation: The carry flag in this case does not go ON. 3 4 5 6 7 8 3 4 5 6 7 9 9 9 9 9 9 9 Operation Error...
Page 195
DB+(P),DB-(P) When three data are set (( ), ( indicates an instruction symbol of DB+/ DB Command DB+, DB- Command DB+P, DB-P : Data to be added to/subtracted from or head number of the devices where the data to be added to/subtracted from is stored (BCD 8 digits) : Data for adding/subtracting or head number of the devices where the data for adding/subtracting is stored (BCD 8 digits)
Page 196
DB+(P),DB-(P) (1) Subtracts the BCD 8-digit data designated by and the BCD 8-digit data designated by and stores the result of the subtraction at the device designated by (Upper 4 digits) (Lower 4 digits) (Upper 4 digits) (Lower 4 digits) (Upper 4 digits) (Lower 4 digits) 7 8 9 1 2 3 2 3 4 5 6 7...
B*(P),B/(P) 6.2.7 BCD 4-digit multiplication and division operations (B*(P),B/(P)) B*(P),B/(P) Q4AR indicates an instruction symbol of B ,B/ Command , B/ Command P, B/P : Data to be multiplied/divided or head number of the devices where the data to be multiplied/divided is stored (BCD 4 digits) : Data for multiplying/dividing or head number of the devices where the data for multiplying/dividing is stored (BCD 4 digits)
Page 198
B*(P),B/(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The BCD data is outside the 0 to 9999 range. (Error code: 4100) •...
DB*(P),DB/(P) 6.2.8 BCD 8-digit multiplication and division operations (DB*(P),DB/(P)) DB*(P),DB/(P) Q4AR indicates an instruction symbol of DB ,DB/ Command DB , DB/ Command DB P, DB/P : Data to be multiplied/divided or head number of the devices where the data to be multiplied/divided is stored (BCD 8 digits) : Data for multiplying/dividing or head number of the devices where the data for multiplying/dividing is stored (BCD 8 digits)
Page 200
DB*(P),DB/(P) (2) 64 bits are used for the result of the division operation, and stored as quotient and remainder. Quotient (BCD 8 digits) :Stored at the lower 32 bits. Remainder (BCD 8 digits) :Stored at the upper 32 bits. (3) If has been designated as a bit device, the remainder of the operation will not be stored.
E+(P),E-(P) 6.2.9 Addition and subtraction of floating decimal point data (Single precision) (E+(P),E-(P)) E+(P),E-(P) Q4AR When two data are set (( ), ( indicates an instruction symbol of E+/E- Command E+, E- Command E+P, E-P : Data for adding/subtracting or head number of the devices where the data for adding/subtracting is stored (real number) : Head number of the devices where the data to be added to/subtracted from is stored (real number) Internal Devices...
Page 202
E+(P),E-(P) (2) Values which can be designated at and which can be stored, are as follows: -126 0, 2 | Designated value (stored value) | < 2 Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
Page 203
E+(P),E-(P) When three data are set (( ), ( indicates an instruction symbol of E+/E-. Command E+, E- Command E+P, E-P : Data to be added to/subtracted from or head number of the devices where the data to be added to/subtracted from is stored (real number) : Data for adding/subtracting or head number of the devices where the data for adding/subtracting is stored (real number)
Page 204
E+(P),E-(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The contents of the designated device or the result of the addition are not "0", or not within the following range: -126 0, 2...
E*(P),E/(P) 6.2.10 Multiplication and division of floating decimal point data (Single precision) (E*(P),E/(P)) E*(P),E/(P) Q4AR indicates an instruction symbol of E* , E/ Command E* , E/ Command E* P, E/P : Data to be multiplied/divided or head number of the devices where the data to be multiplied/divided is stored (real number) : Data for multiplying/dividing or head number of the devices where the data for multiplying/dividing is stored (real number)
Page 206
E*(P),E/(P) (2) Values which can be designated at and which can be stored, are as follows: -126 0, 2 | Designated value (stored value) | < 2 Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
BK+(P),BK-(P) 6.2.11 Block addition and subtraction (BK+(P),BK-(P)) BK+(P),BK-(P) Q4AR indicates an instruction symbol of BK+, BK- . Command BK+, BK- Command BK+P, BK-P : Head number of the devices where the data to be added to/subtracted from is stored (BIN 16 bits) : Data for additing/subtracting or head number of the devices where the data for additing/subtracting is stored (BIN 16 bits) : Head number of the devices where the operation result will be stored (BIN 16 bits)
Page 208
BK+(P),BK-(P) (4) The following will happen when an underflow or overflow is generated in an operation result: The carry flag in this case does not go ON. K32767 K 32767 (7FFF (0002 (8001 K 32767 K32767 +K 2 (8001 (FFFE (7FFF (1) Subtracts n points of BIN data from the device designated by and n-points of BIN data...
Page 209
BK+(P),BK-(P) Program Example (1) The following program adds, when X20 is turned ON, the data stored at D100 to D103 to the data stored at R0 to R3 and stores the operation result into the area starting from D200. [Ladder Mode] [List Mode] Step Instruction...
$+(P) 6.2.12 Linking character strings ($+(P)) $+(P) Q4AR When two data are set ( Command Command : Data for linking or head number of the devices where the data for linking is stored (character string) : Head number of the devices where the data to be linked is stored (character string) Internal Devices Setting Constants...
Page 211
$+(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The entire character string linked from the device number designated by to the final device number of the relevant device cannot be stored.
Page 212
$+(P) When three data are set ( Command Command : Data for linking or head number of the devices where the data for linking is stored (character string) : Data to be linked or head number of the devices where the data to be linked is stored (character string) : Head number of the devices where the linking result will be stored (character string) Internal Devices Setting...
Page 213
$+(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The entire character string linked from the device number designated by to the final device number of the relevant device cannot be stored.
INC(P),DEC(P) 6.2.13 Incrementing and decrementing 16-bit BIN data (INC(P),DEC(P)) INC(P),DEC(P) Q4AR indicates an instruction symbol of INC/DEC. Command INC, DEC Command INCP, DECP : Head number of devices for INC (+1)/DEC ( 1) operation (BIN 16 bits) Internal Devices Setting R, ZR Constants Other...
Page 215
INC(P),DEC(P) Program Example (1) The following program outputs the present value at the counter C0 to C20 to the area Y30 to Y3F in BCD, every time X8 is turned ON. (When present value is less than 9999) [Ladder Mode] Outputs the present value of C (D+Z1) to Y30 to Y3F in BCD.
DINC(P),DDEC(P) 6.2.14 Incrementing and decrementing 32-bit BIN data (DINC(P),DDEC(P)) DINC(P),DDEC(P) Q4AR indicates an instruction symbol of DINC/DDEC. Command DINC, DDEC Command DINCP, DDECP : Head number of devices for DINC(+1) or DDEC(-1) operation (BIN 32 bits) Internal Devices Setting R, ZR Constants Other Data...
Page 217
DINC(P),DDEC(P) Program Example (1) The following program adds 1 to the data at D0 and D1 when X0 is ON. [Ladder Mode] [List Mode] Step Instruction Device (2) The following program adds 1 to the data set at X10 to X27 when X0 goes ON, and stores the result at D3 and D4.
BCD(P),DBCD(P) Data conversion instructions 6.3.1 Conversion from BIN data to 4-digit and 8-digit BCD (BCD(P),DBCD(P)) BCD(P),DBCD(P) BCD(P), DBCD(P) Q4AR indicates an instruction symbol of BCD/DBCD. Command BCD, DBCD Command BCDP, DBCDP : BIN data or head number of the devices where the BIN data is stored (BIN 16/32 bits) : Head number of the devices where BCD data will be stored (BCD 4/8 digits) Internal Devices Setting...
Page 219
BCD(P), DBCD(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The data of is other than 0 to 9999 at BCD instruction. (Error code: 4100) •...
BIN(P),DBIN(P) 6.3.2 Conversion from BCD 4-digit and 8-digit data to BIN data (BIN(P),DBIN(P)) BIN(P),DBIN(P) Q4AR indicates an instruction symbol of BIN/DBIN. Command BIN, DBIN Command BINP, DBINP : BCD data or head number of the devices where the BCD data is stored (BCD 4/8 digits) : Head number of the devices where BIN data will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 221
BIN(P),DBIN(P) Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When values other than 0 to 9 are designated to any digits of (Error code: 4100) Program Example (1) The following program converts the BCD data at X10 to X1B to BIN when X8 is ON, and stores it...
FLT(P),DFLT(P) 6.3.3 Conversion from BIN 16 and 32-bit data to floating decimal point (Single precision) (FLT(P),DFLT(P)) FLT(P),DFLT(P) Q4AR indicates an instruction symbol of FLT/DFLT. Command FLT, DFLT Command FLTP, DFLTP : Integer data to be converted to 32-bit floating decimal point data or head number of the devices where the integer data is stored (BIN 16/32 bits) : Head number of the devices where the converted 32-bit floating decimal point data will be stored (real number)
Page 223
FLT(P),DFLT(P) (3) Due to the fact that 32-bit floating decimal point type real numbers are processed by simple 32-bit processing, the number of significant digits is 24 bits if the display is binary and approximately 7 digits if the display is decimal. For this reason, if the integer exceeds the range of 16777216 to 16777215 (24-bit BIN value), errors can be generated in the conversion value.
INT(P),DINT(P) 6.3.4 Conversion from floating decimal point data to BIN16- and 32-bit data (Single precision) (INT(P),DINT(P)) INT(P),DINT(P) Q4AR indicates an instruction symbol of INT/DINT. Command INT, DINT Command INTP, DINTP : 32-bit floating decimal point data to be converted to BIN value or head number of the devices where the floating decimal point data is stored (real number) : Head number of the devices where the converted BIN value will be stored (BIN 16/32 bits) Internal Devices...
Page 225
INT(P),DINT(P) (3) The integer value stored at +1 and is stored as BIN 32 bits. (4) After conversion, the first digit after the decimal point of the real number is rounded off. Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
DBL(P) 6.3.5 Conversion from BIN 16-bit to BIN 32-bit data (DBL(P)) DBL(P) Q4AR Command Command DBLP DBLP : BIN 16-bit data or head number of the devices where the BIN 16-bit data is stored (BIN 16 bits) : Head number of the devices where the converted BIN 32-bit data will be stored (BIN 32 bits) Internal Devices Setting Constants...
WORD(P) 6.3.6 Conversion from BIN 32-bit to BIN 16-bit data (WORD(P)) WORD(P) Q4AR Command WORD WORD Command WORDP WORDP : BIN 32-bit data or head number of the devices where the BIN 32-bit data is stored (BIN 32 bits) : Head number of the devices where the converted BIN 16-bit data will be stored (BIN 16 bits) Internal Devices Setting Constants...
GRY(P),DGRY(P) 6.3.7 Conversion from BIN 16 and 32-bit data to Gray code (GRY(P),DGRY(P)) GRY(P),DGRY(P) Q4AR indicates an instruction symbol of GRY, DGRY. Command GRY, DGRY Command GRYP, DGRYP : BIN data or head number of the devices where the BIN data is stored (BIN 16/32 bits) : Head number of the devices where the converted Gray code will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 229
GRY(P),DGRY(P) Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The data at is a negative number. (Error code: 4100) Program Example (1) The following program converts the BIN data at D100 to Gray code when X10 is ON, and stores result at D200.
GBIN(P),DGBIN(P) 6.3.8 Conversion of Gray code to BIN 16 and 32-bit data (GBIN(P),DGBIN(P)) GBIN(P),DGBIN(P) Q4AR indicates an instruction symbol of GBIN/DGBIN. Command GBIN, DGBIN Command GBINP, DGBINP : Gray code data or head number of the devices where the Gray code data is stored (BIN 16/32 bits) : Head number of the devices where the converted BIN data will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 231
GBIN(P),DGBIN(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • Data at when the GBIN instruction was issued is outside the 0 to 32767 range. (Error code: 4100) •...
NEG(P),DNEG(P) 6.3.9 Complement of 2 of BIN 16- and 32-bit data (sign reversal) (NEG(P),DNEG(P)) NEG(P),DNEG(P) Q4AR indicates an instruction symbol of NEG/DNEG. Command NEG, DNEG Command NEGP, DNEGP : Head number of the devices where the data for which complement of 2 is performed is stored (BIN 16/32 bits) Internal Devices Setting...
Page 233
NEG(P),DNEG(P) DNEG (1) Reverses the sign of the 32-bit device designated by and stores at the device designated 32 bit Before execution -218460 Sign conversion - After 218460 execution (2) Used when reversing positive and negative signs. Operation Error (1) There are no operation errors associated with the NEG(P) or DNEG(P) instruction. Program Example (1) The following program calculates a total for the data at D10 through D20 when XA goes ON, and seeks an absolute value if the result is negative.
ENEG(P) 6.3.10 Floating-point sign invertion (Single precision) (ENEG(P)) ENEG(P) Q4AR Command ENEG ENEG Command ENEGP ENEGP : Head number of the devices where the 32-bit floating decimal point data whose sign is to be reversed is stored (real number) Internal Devices Setting R, ZR Constants...
BKBCD(P) 6.3.11 Conversion from block BIN 16-bit data to BCD 4-digit data (BKBCD(P)) BKBCD(P) Redundant Q4AR Command BKBCD BKBCD Command BKBCDP BKBCDP : Head number of the devices where BIN data is stored (BIN 16 bits) : Head number of the devices where the converted BCD data will be stored (BCD 4 digits) n : Number of variable data blocks (BIN 16 bits) Internal Devices Setting...
Page 236
BKBCD(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The range of the device n points from a device designated by or exceeds the relevant device.
BKBIN(P) 6.3.12 Conversion from block BCD 4-digit data to block BIN 16-bit data (BKBIN(P)) BKBIN(P) Q4AR Command BKBIN BKBIN Command BKBINP BKBINP : Head number of the devices where BCD data is stored (BCD 4 digits) : Head number of the devices where the converted BIN data will be stored (BIN 16 bits) n : Number of variable data blocks (BIN 16 bits) Internal Devices Setting...
Page 238
BKBIN(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The n-bit range from the , or device exceeds the range of that device. (Error code: 4101) •...
MOV(P),DMOV(P) Data Transfer Instructions 6.4.1 16-bit and 32-bit data transfers (MOV(P),DMOV(P)) MOV(P),DMOV(P) Q4AR indicates an instruction symbol of MOV/DMOV. Command MOV, DMOV Command MOVP, DMOVP : Data to be transferred or the number of the device where the data to be transferred is stored (BIN 16/32 bits) : Number of the device where the data will be transferred (BIN 16/32 bits) Internal Devices Setting...
Page 240
MOV(P),DMOV(P) Program Example (1) The following program stores input data from X0 to XB at D8. [Ladder Mode] [List Mode] Instruction Device Step (2) The following program stores the constant K155 at D8 when X8 goes ON. [Ladder Mode] [List Mode] Instruction Device Step...
EMOV(P) 6.4.2 Floating-point data transfer (Single precision) (EMOV(P)) EMOV(P) Q4AR Command EMOV EMOV Command EMOVP EMOVP : Data to be transferred or number of the device to which the data to be transferred is stored (real number) : The number of the device to which the transferred data will be stored (real number) Internal Devices Setting Constants...
Page 242
EMOV(P) Program Example (1) The following program stores the real numbers at D10 and D11 at D0 and D1. [Ladder Mode] [List Mode] Instruction Device Step [Operation] 36.475 36.475 (2) The following program stores the real number 1.23 at D10 and D11 when X8 is ON. [Ladder Mode] [List Mode] Step...
Page 243
EMOV(P) (3) If the "00 " code is being stored at lower bytes of +n, "00 " will be stored at both the higher bytes and the lower bytes of b8 b7 b8 b7 At the upper byte position, Upper byte is not transferred. "00 "...
$MOV(P) 6.4.3 Character string transfers ($MOV(P)) $MOV(P) Q4AR Command $MOV $MOV Command $MOVP $MOVP : Character string to be transferred (maximum string length: 16) or head number of the devices where the character string to be transferred is stored (character string) : Head number of the devices where the transferred character string will be stored (character string) Internal Devices Setting...
Page 245
$MOV(P) (3) If the "00 " code is being stored at lower bytes of +n, "00 " will be stored at both the higher bytes and the lower bytes of b8 b7 b8 b7 At the upper byte position, Upper byte is not transferred. "00 "...
CML(P),DCML(P) 6.4.4 16-bit and 32-bit negation transfers (CML(P),DCML(P)) CML(P),DCML(P) Q4AR indicates an instruction symbol of CML, DCML. Command CML, DCML Command CMLP, DCMLP : Data to be reversed or the number of the device where data to be reversed is stored (BIN 16/32 bits) : Number of the device where the reversing result will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 247
CML(P),DCML(P) Program Example (1) The following program inverts the data from X0 to X7, and transfers result to D0. [Ladder Mode] [List Mode] Instruction Device Step [Operation] If "Number of bits of < Number of bits of " These bits are all regarded as 0. 1 1 0 1 0 0 0 0 0 0 1 0 1 1 1 1 (2) The following program inverts the data at M16 to M23, and transfers the result to Y40 to...
Page 248
CML(P),DCML(P) (4) The following program inverts the data at X0 to X1F, and transfers results to D0 and D1. [Ladder Mode] [List Mode] Instruction Device Step [Operation] If "Number of bits of < Number of bits of " X8 X7 These bits are all regarded as 0.
BMOV(P) 6.4.5 Block 16-bit data transfers (BMOV(P)) BMOV(P) Q4AR Command BMOV BMOV Command BMOVP BMOVP : Head number of the devices where the data to be transferred is stored (BIN 16 bits) : Head number of the devices of transfer destination (BIN 16 bits) n : Number of transfers (when using an intelligent function module device (U ): 1 to 6144 (QnA only)) (BIN 16 bits)
Page 250
BMOV(P) Example Transfer ranges of ZR and R overlap when transferring 10000 blocks of data from ZR30000 (source) to R10 (block No.1 of the destination). • ZR transfer range (30000) to (30000+10000-1) (30000) to (39999) • R transfer range (10+(1 32768)) to (10+(1 32768)+10000-1) (32778) to (42777) Therefore, the range 32778 to 39999 overlaps and the data is not correctly transferred.
Page 251
BMOV(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The device range of n points from exceeds the corresponding device range. (Error code: 4101) Program Example (1) The following program outputs the lower 4 bits of data at D66 to D69 to Y30 to Y3F in 4-point...
FMOV(P) 6.4.6 Identical 16-bit data block transfers (FMOV(P)) FMOV(P) Q4AR Command FMOV FMOV Command FMOVP FMOVP : Data to be transferred or the head number of the devices where the data to be transferred is stored (BIN 16 bits) : Head number of the devices of transfer destination (BIN 16 bits) n : Number of transfers (when using an intelligent function module device (U ): 1 to 6144 ) (BIN 16 bits)
Page 253
FMOV(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The device range of n points from or exceeds the corresponding device range. (Error code: 4101) •...
XCH(P),DXCH(P) 6.4.7 16-bit and 32-bit data exchanges (XCH(P),DXCH(P)) XCH(P),DXCH(P) Q4AR indicates an instruction symbol of XCH, DXCH. Command XCH, DXCH Command XCHP, DXCHP : Head number of the devices where the data to be exchanged is stored (BIN 16/32 bits) Internal Devices Setting R, ZR...
Page 255
XCH(P),DXCH(P) Operation Error (1) There are no errors associated with the XCH (P) and DXCH (P) instruction. Program Example (1) The following program exchanges the present value of T0 with the contents of D0 when X8 goes ON. [Ladder Mode] [List Mode] Instruction Device...
BXCH(P) 6.4.8 Block 16-bit data exchanges (BXCH(P)) BXCH(P) Q4AR Command BXCH BXCH Command BXCHP BXCHP : Head number of the devices where the data to be exchanged is stored (BIN 16 bits) n : Number of exchanges (BIN 16 bits) Internal Devices Setting Constants...
Page 257
BXCH(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The range of the device of n points from a device designated by or exceeds the relevant device.
SWAP(P) 6.4.9 Upper and lower byte exchanges (SWAP(P)) SWAP(P) Q4AR Command SWAP SWAP Command SWAPP SWAPP : Head number of the devices where the data is stored (BIN 16 bits) Internal Devices Setting R, ZR Constants Other Data Word Word ––...
CJ,SCJ,JMP Program Branch Instructions 6.5.1 Pointer branch instructions (CJ,SCJ,JMP) CJ,SCJ,JMP Q4AR Command Command Label Command P** : Pointer number of jump destination (Device name) Internal Devices Setting Other R, ZR Constants Data Word Word –– Function (1) Executes the program specified by the pointer number within the same program file, when the execution command is ON.
Page 260
CJ,SCJ,JMP (1) Unconditionally executes program of designated pointer number within the same program file. Note the following points when using the jump instruction. 1. After the timer coil has gone ON, accurate measurements cannot be made if there is an attempt to jump the timer of a coil that has been turned ON using the CJ, SCJ or JMP instructions.
Page 261
CJ,SCJ,JMP Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The pointer number designated does not come prior to the END instruction. (Error code: 4210) •...
GOEND 6.5.2 Jump to END (GOEND) GOEND Q4AR Command GOEND GOEND Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Jumps to the FEND or END instruction in the same program file. Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
DI,EI,IMASK Program Execution Control Instructions 6.6.1 Interrupt disable/enable instructions, interrupt program mask (DI,EI,IMASK) DI,EI,IMASK Q4AR Sequence program IMASK IMASK : Head number of the devices where the interrupt mask data is stored (BIN 16 bits) Internal Devices Setting R, ZR Constants Other Data...
Page 264
DI,EI,IMASK IMASK (1) Enables or disables the execution of the interrupt program marked by the designated interrupt pointer by use of the bit pattern in the three points from the device designated by • 1(ON)..Interrupt program execution enabled • 0(OFF) ..Interrupt program execution disabled (2) The interrupt pointer numbers corresponding to the individual bits are as shown below: b14 b13 b12 b11 b10 b9 I15 I14...
Page 265
DI,EI,IMASK Operation Error (1) There are no operation errors associated with the DI, EI or IMASK instruction. Program Example (1) The following program creates an execution enabled state for the interrupt program marked by the interrupt pointer number when X0 is ON. [Ladder Mode] [List Mode] Device...
IRET 6.6.2 Recovery from interrupt programs (IRET) IRET Q4AR IRET IRET Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Indicates the completion of interrupt program processing. (2) Returns to sequence program processing following the execution of the IRET instruction. Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
Page 267
IRET Program Example (1) The following program adds 1 to D0 if M0 is ON when the number 3 interrupt is generated. [Ladder Mode] [List Mode] Device Step Instruction 6-105...
RFS(P) I/O Refresh Instructions 6.7.1 I/O refresh (RFS(P)) RFS(P) Q4AR Command Command RFSP RFSP : Head number of the devices to be refreshed (bits) n : Number of refreshes (BIN 16 bits) Internal Devices Setting Constants R, ZR Other Data K, H Word Word...
Page 269
RFS(P) Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The range n points from the device designated by exceeds the proximate I/O range. (Error code: 4101) Program Example (1) The following program refreshes X100 to X11F and Y200 to Y23F when M0 goes ON.
UDCNT1 Other Convenient Instructions 6.8.1 Counter 1-phase input up or down (UDCNT1) UDCNT1 Q4AR Command UDCNT1 UDCNT1 + 0: Input number for count input (bits) + 1: For setting count up/down (bits) •OFF: Count up (add numbers when counting) •ON: Count down (subtract numbers when counting) : Number of the counter to be enabled to start counting with the UDCNT1 instruction (Device name) n : Value to set (BIN 16 bits) Internal Devices...
Page 271
UDCNT1 • The counter designated at is a ring counter. If it is counting up when the present value is 32767, the present value will become 32768. Further, if it is counting down when the present value is 32768, the present value will become 32767. The count processing performed on the present value is as shown below: 32768 32767...
Page 272
UDCNT1 Program Example (1) This program uses C0 (Up/Down counter) to count the number of times X0 goes from OFF to ON after X20 has gone ON. [Ladder Mode] [List Mode] Instruction Device Step [Operation] Down C0 present 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-110...
UDCNT2 6.8.2 Counter 2-phase input up or down (UDCNT2) UDCNT2 Q4AR Command UDCNT2 UDCNT2 + 0: Input number for count input (A phase pulse) (bits) + 1: Input number for count input (B phase pulse) (bits) : Number of the counter to be enabled to start counting with the UDCNT2 instruction (Device name) n : Value to set (BIN 16 bits) Internal Devices Setting...
Page 274
UDCNT2 • The counter designated at is a ring counter. If it is counting up when the present value is 32767, the present value will become 32768. Further, if it is counting down when the present value is 32768, the present value will become 32767. The count processing performed on the present value is as shown below: 32768 32767...
Page 275
UDCNT2 Program Example (1) The following program performs a count operation as instructed by C0 (count up or down) on the status of X0 and X1 after X20 has gone ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] COM present value C0 contact 6-113...
TTMR 6.8.3 Teaching timer (TTMR) TTMR Q4AR Command TTMR TTMR + 0: The device where measurement value is stored (BIN 16 bit) + 1: For CPU module system use (BIN 16 bit) n : Measurement value multiplier (BIN 16 bits) Internal Devices Setting Constants...
Page 277
TTMR Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • There are no operation errors associated with the TTMR instruction. Program Example (1) The following program stores the amount of time that X0 is ON at D0. [Ladder Mode] [List Mode] Device...
STMR 6.8.4 Special function timer (STMR) STMR Q4AR Command STMR STMR : Timer number (word) n : Value to set (BIN 16 bits). + 0: Off delay timer output (bits) + 1: One shot timer output after OFF (bits) + 2: One shot timer output after ON (bits) + 3: ON delay and Off delay timer output (bits) Internal Devices Setting...
Page 279
STMR (3) The timer contact goes ON at the leading edge of the command for the STMR instruction, and after the trailing edge is reached, the timer coil goes OFF at the trailing edge of the STMR instruction command. The timer contact is used by the CPU module system, and cannot be used by the user. Command for STMR instruction (Coil)
Page 280
STMR Program Example (1) The following program turns Y0 and Y1 ON and OFF once each second (flicker) when X20 is ON. (Uses 100 ms timer) [Ladder Mode] [List Mode] Step Instruction Device [Timing Chart] M1, Y0 M2, Y1 1 sec 1 sec 6-118...
ROTC 6.8.5 Rotary table shortest direction control (ROTC) ROTC Q4AR Command ROTC ROTC + 0: Measures the number of table rotations (for system use) (BIN 16 bits) + 1: Call station number (BIN 16 bits) + 2: Call item number (BIN 16 bits) n1 : Number of divisions of table (2 to 32767) (BIN 16 bits) n2 : Number of low-speed sections (value from 0 to less than n1) (BIN 16 bits) + 0: A phase input signal (bits)
Page 282
ROTC +2 is the 0 point detection output signal that goes ON when item number 0 has arrived at the No. 0 station. When the device designated by +2 goes ON while the ROTC instruction is being executed, +0 is cleared. It is best to perform this clear operation first, then to begin shortest direction control with the ROTC instruction.
RAMP 6.8.6 Ramp signal (RAMP) RAMP Q4AR Command RAMP RAMP n1 : Initial value (BIN 16 bits) n2 : Final value (BIN 16 bits) + 0: Present value (BIN 16 bits) + 1: Number of executions (BIN 16 bits) n3 : Number of shifts (BIN 16 bits) + 0: Completion device (bits) + 1: Bit for selecting data retaining at completion (bit) Internal Devices...
Page 284
RAMP (2) If the scan is performed for the number of moves specified by n3, the complete device specified by +0 is turned ON. The ON/OFF status of the completion device and the contents of +0 are determined by the ON/OFF status of the device designated by •...
6.8.7 Pulse density measurement (SPD) Q4AR Command : Pulse input (bits) n : Measurement time (unit: ms) (BIN 16 bits) : Head number of the devices where the measurement result will be stored (BIN 16 bits) Internal Devices Setting Constants R, ZR Other Data...
Page 286
1. With the SPD instruction, the argument device data is 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 STOP 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.
PLSY 6.8.8 Fixed cycle pulse output (PLSY) PLSY Q4AR Command PLSY PLSY n1 : Frequency or the number of the device where frequency is stored (BIN 16 bits) n2 : Outputs count or the number of the device where the outputs count is stored (BIN 16 bits) : Number of the device to which pulses are output (bits) Internal Devices Setting...
Page 288
PLSY 1. With the PLSY instruction, the argument device data is 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 STOP RUN.) For this reason, the pulses that can be output must have longer ON and OFF times than the interrupt interval of the CPU module.
6.8.9 Pulse width modulation (PWM) Q4AR Command n1 : ON time or the number of the device where the ON time is stored (BIN 16 bits) n2 : Frequency or the number of the device where the frequency is stored (BIN 16 bits) : Number of the device to which pulses are output (bits) Internal Devices Setting...
Page 290
1. With the PWM instruction, the argument device data is 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 STOP RUN.) The interrupt interval of individual modules is shown below: CPU Module Type Name...
6.8.10 Matrix input (MTR) Q4AR Command : Head input device (bits) : Head output device (bits) : Head number of the devices where matrix input data will be stored (bits) n : Number of input rows (BIN 16 bit) Internal Devices Setting Constants R, ZR...
Page 292
Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The device other than the input (X) was specified at (Error code: 4101) •...
APPLICATION INSTRUCTIONS Reference Category Processing Details section Logical operations such as logical sum, logical product, Logical operation instructions Section 7.1 etc. Section 7.2 Rotation instruction Rotation of designated data Shift instruction Shift of designated data Section 7.3 Section 7.4 Bit processing instructions Sets and resets bit data;...
Logical operation instructions (1) The logical operation instructions perform logical sum, logical product or other logical operations in 1-bit units. Example Formula for Category Processing Details Operation Logical product Becomes 1 only when both input A and A · B (AND) input B are 1;...
Page 295
WAND(P),DAND(P) 7.1.1 Logical products with 16-bit and 32-bit data (WAND(P),DAND(P)) WAND(P),DAND(P) Q4AR When two data are set ( indicates an instruction symbol of WAND/DAND. Command WAND,DAND Command WANDP,DANDP : Data for a logical product operation or the head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the logical product operation result will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 296
WAND(P),DAND(P) DAND (1) Conducts a logical product operation on each bit of the 32-bit data for the device designated and the 32-bit data for the device designated by , and stores the results at the device designated by (2) When bit devices are designated, the bit devices below the points designated as digits are regarded as "0"...
Page 297
WAND(P),DAND(P) (2) The following program performs a logical product operation on the data at D99 and D100, and the 24-bit data between X30 and X47 when X8 is ON, and stores the results at D99 and D100. [Ladder Mode] [List Mode] Step Instruction Device...
Page 298
WAND(P),DAND(P) When three data are set ( indicates an instruction symbol of WAND/DAND. Command WAND,DAND Command WANDP,DANDP : Data for a logical product operation or the head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the logical product operation result will be stored (BIN 16/32 bits) Internal Devices Setting Constants...
Page 299
WAND(P),DAND(P) Operation Error (1) There are no operation errors associated with the WAND(P) or DAND(P) instruction. Program Example (1) The following program performs a logical product operation on the data from X10 to X1B and the data at D33 when XA is ON, and stores the results at D40. [Ladder Mode] [List Mode] Step...
Page 300
WAND(P),DAND(P) (3) The following program masks the digit in the hundred-thousands place of the 8-digit BCD value at D10 and D11 (sixth digit from the end) to 0 when XA is ON, and outputs the results to from Y10 to Y2B. [Ladder Mode] [List Mode] Step...
BKAND(P) 7.1.2 Block logical products (BKAND(P)) BKAND(P) Q4AR Command BKAND BKAND Command BKANDP BKANDP : Head number of the devices where data on which a logical operation will be conducted is stored (BIN 16 bits) : Data for a logical operation or head number of the devices where the data for the logical operation is stored (BIN 16 bits) : Head number of the devices where the operation result will be stored (BIN 16 bits) : Number of operation data blocks (BIN 16 bits)
WOR(P),DOR(P) 7.1.3 Logical sums of 16-bit and 32-bit data (WOR(P),DOR(P)) WOR(P),DOR(P) Q4AR When two data are set ( indicates an instruction symbol of WOR/DOR. Command WOR, DOR Command WORP, DORP : Data for a logical sum operation or head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the logical sum operation result will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 304
WOR(P),DOR(P) (1) Conducts a logical sum operation on each bit of the 32-bit data of the device designated by and the 32-bit data of the device designated by , and stores the results at the device designated by (2) For bit devices, the bit devices after the points designated by digit specification are regarded as "0"...
Page 305
WOR(P),DOR(P) (2) The following program performs a logical sum operation on the 32-bit data from X0 to X1F, and on the hexadecimal value FF00FF00 when XB is turned ON, and stores the results at D66 and D67. [Ladder Mode] [List Mode] Step Instruction Device...
Page 306
WOR(P),DOR(P) When three data are set ( indicates an instruction symbol of WOR/DOR. Command WOR, DOR Command WORP, DORP : Data for a logical sum operation or head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the logical sum operation result will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 307
WOR(P),DOR(P) (1) Conducts a logical sum operation on each bit of the 32-bit data of the device designated by and the 32-bit data of the device designated by , and stores the results at the device designated by (2) When bit devices are designated, the bit devices below the points designated as digits are regarded as "0"...
Page 308
WOR(P),DOR(P) (2) The following program performs a logical sum operation on the 32-bit data at D0 and D1, and the 24-bit data from X20 to X37, and stores the results at D23 and D24 when M8 is ON. [Ladder Mode] [List Mode] Step Instruction...
BKOR(P) 7.1.4 Block logical sum operations (BKOR(P)) BKOR(P) Q4AR Command BKOR BKOR Command BKORP BKORP *1 : Head number of the devices where data on which a logical operation will be conducted is stored (BIN 16 bits) *1 : Data for a logical operation or head number of the devices where the data for the logical operation is stored (BIN 16 bits) *1 : Head number of the devices where the operation result will be stored (BIN 16 bits) : Number of operation data blocks (BIN 16 bits)
Page 310
BKOR(P) (2) The constant designated by can be between 32768 and 32767 (BIN 16-bit data). 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 1 0 1...
WXOR(P),DXOR(P) 7.1.5 16-bit and 32-bit exclusive OR operations (WXOR(P),DXOR(P)) WXOR(P),DXOR(P) Q4AR When two data are set indicates an instruction symbol of WXOR/DXOR. Command WXOR, DXOR Command WXORP, DXOR : Data for an exclusive OR operation or head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the exclusive OR operation result will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 312
WXOR(P),DXOR(P) DXOR (1) Conducts an exclusive OR operation on each bit of the 32-bit data of the device designated and the 32-bit data of the device designated by , and stores the results at the device designated by D + 1 (2) For bit devices, the bit devices after the points designated by digit specification are regarded as "0"...
Page 313
WXOR(P),DXOR(P) (2) The following program compares the bit pattern of the 32-bit data from X20 to X3F with the bit pattern of the data at D9 and D10 when X6 is ON, and stores the number of differing bits at D16. [Ladder Mode] [List Mode] Step...
Page 314
WXOR(P),DXOR(P) When three data are set indicates an instruction symbol of WXOR/DXOR. Command WXOR, DXOR Command WXORP, DXORP : Data for an exclusive OR operation or head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the exclusive OR operation result will be stored (BIN 16/32 bits) Internal Devices Setting Constants...
Page 315
WXOR(P),DXOR(P) DXOR (1) Conducts an exclusive OR operation on each bit of the 32-bit data of the device designated and the 32-bit data of the device designated by , and stores the results at the device designated by (2) For bit devices, the bit devices after the points designated by digit specification are regarded as "0"...
Page 316
WXOR(P),DXOR(P) (2) The following program conducts an exclusive OR operation on the data at D20 and D21, and the data at D30 and D31 when X10 is turned ON, and stores the results at D40 and D41. [Ladder Mode] [List Mode] Step Instruction Device...
BKXOR(P) 7.1.6 Block exclusive OR operations (BKXOR(P)) BKXOR(P) Q4AR Command BKXOR BKXOR Command BKXORP BKXORP *1 : Head number of the devices where data on which a logical operation will be conducted is stored (BIN 16 bits) *1 : Data for a logical operation or head number of the devices where the data for the logical operation is stored (BIN 16 bits) *1 : Head number of the devices where the operation result will be stored (BIN 16 bits) : Number of operation data blocks (BIN 16 bits)
WXNR(P),DXNR(P) 7.1.7 16-bit and 32-bit data exclusive NOR operations (WXNR(P),DXNR(P)) WXNR(P),DXNR(P) Q4AR When two data are set ( indicates an instruction symbol of WXNR/DXNR. Command WXNR, DXNR Command WXNRP, DXNRP : Data for an exclusive NOR operation or head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the exclusive NOR operation result will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 320
WXNR(P),DXNR(P) DXNR (1) Conducts an exclusive NOR operation on the 32-bit data of the device designated by the 32-bit data of the device designated by , and stores the results at the device designated by (2) For bit devices, the bit devices after the points designated by digit specification are regarded as "0"...
Page 321
WXNR(P),DXNR(P) (2) The following program compares the bit patterns of the 32-bit data located from X20 to X3F with the bit patterns of the data at D16 and D17 when X6 is ON, and stores the number of identical bit patterns at D18. [Ladder Mode] [List Mode] Step...
Page 322
WXNR(P),DXNR(P) When three data are set ( indicates an instruction symbol of WXNR/DXNR. Command WXNR, DXNR Command WXNRP, DXNRP : Data for an exclusive NOR operation or head number of the devices where the data is stored (BIN 16/32 bits) : Head number of the devices where the exclusive NOR operation result will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 323
WXNR(P),DXNR(P) DXNR (1) Conducts an exclusive NOR operation on the 32-bit data of the device designated by the 32-bit data of the device designated by , and stores the results at the device designated by (2) For bit devices, the bit devices after the points designated by digit specification are regarded as "0"...
Page 324
WXNR(P),DXNR(P) (2) The following program performs an exclusive NOR operation on the 32-bit data at D20 and D21 and the data at D10 and D11 when X10 is turned ON, and stores the result to D40 and D41. [Ladder Mode] [List Mode] Step Instruction...
BKXNR(P) 7.1.8 Block exclusive NOR operations (BKXNR(P)) BKXNR(P) Q4AR Command BKXNR BKXNR Command BKXNRP BKXNRP *1 : Head number of the devices where data on which a logical operation will be conducted is stored (BIN 16 bits) *1 : Data for a logical operation or head number of the devices where the data for the logical operation is stored (BIN 16 bits) *1 : Head number of the devices where the operation result will be stored (BIN 16 bits) : Number of operation data blocks (BIN 16 bits) Internal Devices...
ROR(P),RCR(P) Rotation instruction 7.2.1 Right rotation of 16-bit data (ROR(P),RCR(P)) ROR(P),RCR(P) Q4AR indicates an instruction symbol of ROR/RCR. Command ROR, RCR Command RORP, RCRP : Head number of the devices to rotate (BIN 16 bits) : Number of rotations (0 to 15) (BIN 16 bits) Internal Devices Setting Constants...
Page 328
ROR(P),RCR(P) (2) When a bit device is designated for , a rotation is performed within the device range specified by digit specification. The number of bits by which a rotation is carried out is the remainder of n/(specified number of bits). For example, when n 15 and (specified number of bits) 12 bits, the remainder of 15/12...
Page 329
ROR(P),RCR(P) Operation Error (1) There are no operation errors associated with the ROR(P) or RCR(P) instructions. Program Example (1) The following program rotates the contents of D0, not including the carry flag, 3 bits to the right when XC is turned ON. [Ladder Mode] [List Mode] Step...
ROL(P),RCL(P) 7.2.2 Left rotation of 16-bit data (ROL(P),RCL(P)) ROL(P),RCL(P) Q4AR indicates an instruction symbol of ROL/RCL. Command ROL, RCL Command ROLP, RCLP : Head number of the devices to rotate (BIN 16 bits) : Number of rotations (0 to 15) (BIN 32 bits) Internal Devices Setting Constants...
Page 331
ROL(P),RCL(P) (2) When a bit device is designated for , a rotation is performed within the device range specified by digit specification. The number of bits by which a rotation is executed is the remainder of n/(specified number of bits). For example, when n 15 and (specified number of bits) 12 bits, the remainder of 15/12...
Page 332
ROL(P),RCL(P) Operation Error (1) There are no operation errors associated with the ROL(P) or RCL(P) instructions. Program Example (1) The following program rotates the contents of D0, not including the carry flag, 3 bits to the left when XC is turned ON. [Ladder Mode] [List Mode] Step...
DROR(P),DRCR(P) 7.2.3 Right rotation of 32-bit data (DROR(P),DRCR(P)) DROR(P),DRCR(P) Q4AR indicates an instruction symbol of DROR/DRCR. Command DROR, DRCR Command DRORP, DRCRP : Head number of the devices to rotate (BIN 32 bits) : Number of rotations (0 to 31) (BIN 16 bits) Internal Devices Setting Constants...
Page 334
DROR(P),DRCR(P) DRCR (1) Rotates 32-bit data, including carry flag, at device designated by n bits to the right. The carry flag goes ON or OFF depending on its status prior to the execution of the DRCR instruction. Carry flag (SM700) b30 b29 b28 b27 b15b14 b5 b4 b3...
Page 335
DROR(P),DRCR(P) (2) The following program rotates the contents of D0 and D1, including the carry flag, 4 bits to the right when XC is ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Carry flag (SM700) b28b27 b24b23 b20b19 b12b11 b8b7 b4b3 D0, D1 0...
DROL(P),DRCL(P) 7.2.4 Left rotation of 32-bit data (DROL(P),DRCL(P)) DROL(P),DRCL(P) Q4AR indicates an instruction symbol of DROL/DRCL. Command DROL, DRCL Command DROLP, DRCLP : Head number of the devices to rotate (BIN 32 bits) : Number of rotations (0 to 31) (BIN 16 bits) Internal Devices Setting Constants...
Page 337
DROL(P),DRCL(P) (2) When a bit device is designated for , a rotation is performed within the device range specified by digit specification. The number of bits by which a rotation is executed is the remainder of n /(specified number of bits). For example, when n 31 and (specified number of bits) 24 bits, the remainder of 31/24...
SFR(P),SFL(P) Shift instruction 7.3.1 n-bit shift to right or left of 16-bit data (SFR(P),SFL(P)) SFR(P),SFL(P) Q4AR indicates an instruction symbol of SFR/SFL. Command SFR, SFL Command SFRP, SFLP : Head number of the devices where shift data is stored (BIN 16 bits) : Number of shifts (0 to 15) (BIN 16 bits) Internal Devices Setting...
Page 339
SFR(P),SFL(P) The number of bits by which a shift is executed is the remainder of n/(specified number of bits). For example, when n 15 and (specified number of bits) 8 bits, the remainder of 15/8 1 is "7", and the data is shifted 7 bits. (3) Specify any of 0 to 15 as n.
Page 340
SFR(P),SFL(P) Program Example (1) The following program shifts the data of D0 to the right by the number of bits designated by D100 when X20 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] b14 b13b12 b11b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 D100 Carry flag b14 b13b12 b11b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0...
BSFR(P),BSFL(P) 7.3.2 1-bit shift to right or left of n-bit data (BSFR(P),BSFL(P)) BSFR(P),BSFL(P) Q4AR indicates an instruction symbol of BSFR/BSFL. Command BSFR, BSFL Command BSFRP, BSFLP : Head number of the devices to be shifted (bits) : Number of devices to which shift is executed (BIN 16 bits) Internal Devices Setting Constants...
Page 342
BSFR(P),BSFL(P) Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The range of the device n points from a device designated by , or exceeds the relevant device.
DSFR(P),DSFL(P) 7.3.3 1-word shift to right or left of n-word data (DSFR(P),DSFL(P)) DSFR(P),DSFL(P) Q4AR indicates an instruction symbol of DSFR/DSFL. Command DSFR, DSFL Command DSFRP, DSFLP : Head number of the devices to be shifted (BIN 16 bits) : Number of devices to which shift is executed (BIN 16 bits) Internal Devices Setting Constants...
Page 344
DSFR(P),DSFL(P) Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The range of the device n points from a device designated by , or exceeds the relevant device.
BSET(P),BRST(P) Bit processing instructions 7.4.1 Bit set and reset for word devices (BSET(P),BRST(P)) BSET(P),BRST(P) Q4AR indicates an instruction symbol of BSET/BRST. Command BSET, BRST Command BSETP, BRSTP : Number of the device whose bits are set/reset (BIN 16 bits) : Number of the bit to be set/reset (0 to 15) (BIN 16 bits) Internal Devices Setting Constants...
Page 346
BSET(P),BRST(P) Operation Error (1) There are no operation errors associated with the BSET(P) or BRST(P) instructions. Program Example (1) The following program resets the 8th bit of D8 (b8) to 0 when XB is OFF, and sets the 3rd bit of D8 (b3) to 1 when XB is ON.
TEST(P),DTEST(P) 7.4.2 Bit tests (TEST(P),DTEST(P)) Q4AR TEST(P),DTEST(P) indicates an instruction symbol of TEST/DTEST. Command TEST, DTEST Command TESTP, DTESTP : Number of the device where bit data to be extracted is stored (BIN 16/32 bits) : Location of the bit data to be extracted (0 to 15 (TEST)/0 to 31 (DTEST)) (BIN 16/32 bits) : Number of the bit device where the extracted data will be stored (bits) Internal Devices Setting...
Page 348
TEST(P),DTEST(P) (3) The position designated by indicates the position of an individual bit in a 2-word data block (0 to 31). When 32 or more is designated at , the target is the bit data at the position indicated by the remainder of n / 32. For example, when n 34, the target is the data at b2 since the remainder of 34 / 32 1 is "2".
Page 349
TEST(P),DTEST(P) (2) The following program turns Y40 ON or OFF, depending on the status of the 19th bit of the 2-word data (W0 and W1). [Ladder Mode] [List Mode] Step Instruction Device [Operation] 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 1 1 1 0 1 1 0 Turns Y40 OFF since b19 is "0."...
BKRST(P) 7.4.3 Batch reset of bit devices (BKRST(P)) BKRST(P) Q4AR Command BKRST BKRST Command BKRSTP BKRSTP : Head number of the devices to be reset (bits) : Number of the devices to be reset (BIN 16 bits) Internal Devices Setting Constants R, ZR Other...
Page 351
BKRST(P) Program Example (1) The following program turns OFF devices from M0 to M7 when X0 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 Not changed (2) The following program sets data from 2nd bit (b2) of D10 to 1st bit (b1) of D11 to 0 when X20 is turned ON.
SER(P),DSER(P) Data processing instructions 7.5.1 16-bit and 32-bit data searches (SER(P),DSER(P)) SER(P),DSER(P) Q4AR Command SER, DSER Command SERP, DSERP : Search data or head number of the devices where the search data is stored (BIN 16/32 bits) : Data to be searched or head number of the devices where the data to be searched is stored (BIN 16 bits) : Head number of the devices where the search result will be stored (BIN 16 bits) : Number of searches (BIN 16 bits) Internal Devices...
Page 353
SER(P),DSER(P) DSER (1) Searches n points from the device designated by in 32-bit units (2 n points in 16-bit units.) regarding 32-bit data of the device designated by +1 and as a keyword. Then, the number of matches with the keyword is stored at the device designated by +1, and the first matched device number (in the relative number from ) is stored at the device...
Page 354
SER(P),DSER(P) Program Example (1) The following program searches D100 to D105 for the contents of D0 when X20 is ON, and stores the search results at W0 and W1. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Search data Data to be searched D100 Search results D101...
SUM(P),DSUM(P) 7.5.2 16-bit and 32-bit data checks (SUM(P),DSUM(P)) SUM(P),DSUM(P) Q4AR indicates an instruction symbol of SUM/DSUM. Command SUM, DSUM Command SUMP, DSUMP : Head number of the devices where the total number of bits of "1" is counted (BIN 16/32 bits) : Head number of the devices where the total number of the bits will be stored (BIN 16/32 bits) Internal Devices Setting...
Page 356
SUM(P),DSUM(P) Operation Error (1) There are no operation errors associated with the SUM(P) or DSUM(P) instructions. Program Example (1) The following program stores the number of bits which are ON from X8 to X17 into D0 when X10 is turned ON. [Ladder Mode] [List Mode] Step...
DECO(P) 7.5.3 Decoding from 8 to 256 bits (DECO(P)) DECO(P) Q4AR Command DECO DECO Command DECOP DECOP : Data to be decoded or the number of the device where the data to be decoded is stored (BIN 16/32 bits) : Head number of the devices where the decoding result will be stored (Device name) : Valid bit length (1 to 8), 0: No processing (BIN 16 bits) Internal Devices Setting...
Page 358
DECO(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of n is not in the 0 to 8 range. (Error code: 4100) •...
ENCO(P) 7.5.4 Encoding from 256 to 8 bits (ENCO(P)) ENCO(P) Q4AR Command ENCO ENCO Command ENCOP ENCOP : Head number of the device where the data to be encoded is stored (Device name) : Number of the device where the encoding result will be stored (BIN 16 bits) : Valid bit length (1 to 8), 0: No processing (BIN 16 bits) Internal Devices Setting...
Page 360
ENCO(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of n is not in the 0 to 8 range. (Error code: 4100) •...
SEG(P) 7.5.5 7-segment decode (SEG(P)) SEG(P) Q4AR Command Command SEGP SEGP : Data to be decoded or head number of the devices where the data to be decoded is stored (BIN 16 bits) : Head number of the devices where the decoding result will be stored (BIN 16 bits) Internal Devices Setting Constants...
Page 362
SEG(P) 7-segment decode display Configuration of 7 Display Data Hexa- Segments Bit Pattern decimal 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Head number of bit device Lowest bit of word device Program Example (1) The following program converts the data from XC to XF to 7-segment display data and outputs it to Y38 to Y3F when X0 is turned ON.
DIS(P) 7.5.6 4-bit dissociation of 16-bit data (DIS(P)) DIS(P) Q4AR Command Command DISP DISP : Head number of the devices where data to be dissociated is stored (BIN 16 bits) : Head number of the devices where the dissociated data will be stored (BIN 16 bits) : Number of dissociations (1 to 4), 0: No processing (BIN 16 bits) Internal Devices Setting...
Page 364
DIS(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The range n-points from exceeds the relevant device. (Error code: 4101) •...
UNI(P) 7.5.7 4-bit linking of 16-bit data (UNI(P)) UNI(P) Q4AR Command Command UNIP UNIP : Head number of the devices where data to be linked is stored (BIN 16 bits) : Head number of the devices where the linked data will be stored (BIN 16 bits) : Number of links (1 to 4), 0: No processing (BIN 16 bits) Internal Devices Setting...
Page 366
UNI(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The range n-points from exceeds the relevant device. (Error code: 4101) •...
NDIS(P),NUNI(P) 7.5.8 Dissociation or linking of random data (NDIS(P),NUNI(P)) NDIS(P),NUNI(P) Q4AR indicates an instruction symbol of NDIS/NUNI. Command NDIS, NUNI Command NDISP, NUNIP : Head number of the devices where data to be dissociated/linked is stored (BIN 16 bits) : Head number of the devices where the dissociated/linked data will be stored (BIN 16 bits) : Head number of the devices where the units of dissociation/linking will be stored (BIN 16 bits) Internal Devices Setting...
Page 368
NDIS(P),NUNI(P) (2) The number of dissociated bits designated at can be designated within a range of 1 to 16 bits. (3) Bits from the device number designated at to the device number where "0" is stored are processed as dissociated bits. (4) Do not overlap the device range for data to be dissociated( to end range of ) with the...
Page 369
NDIS(P),NUNI(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The number of bits to be dissociated or linked as specified by , or the device use range specified by exceeds the final device number of their respective devices.
Page 370
NDIS(P),NUNI(P) (2) The following program links the lower 4 bits of data from D10, the lower 3 bits of data from D11, and the lower 6 bits of data from D12, and stores at D0. [Ladder Mode] [List Mode] Device Step Instruction [Operation]...
WTOB(P),BTOW(P) 7.5.9 Data dissociation and linking in byte units (WTOB(P),BTOW(P)) WTOB(P),BTOW(P) Q4AR indicates an instruction symbol of WTOB/BTOW. Command WTOB, BTOW Command WTOBP, BTOWP : Head number of the devices where data to be dissociated/linked in byte units is stored (BIN 16 bits) : Head number of the devices where the result of dissociated/linking in byte units will be stored (BIN 16 bits) : Number of byte data to be dissociated/linked (BIN 16 bits) Internal Devices...
Page 372
WTOB(P),BTOW(P) (2) Setting the number of bytes with n automatically determines the range of the 16-bit data designated by and the range of the devices to store the byte data designated by (3) No processing will be conducted when the number of bytes designated by n is "0". (4) The "00 "...
Page 373
WTOB(P),BTOW(P) (4) The upper 8 bits of the byte storage device designated by are ignored, and the lower 8 bits are used. (5) Linking is correctly processed even when the device range ( +(n-1)) where the data to be linked is stored overlaps with the device range ( -1)) where the linked data will be stored.
Page 374
WTOB(P),BTOW(P) (2) The following program links the lower 8 bits of data from D20 through D25 and stores the result at D10 to D12 when X0 is turned ON. [Ladder Mode] [List Mode] Instruction Device Step [Operation] 6 bytes Upper byte is ignored. 7-82...
MAX(P),DMAX(P) 7.5.10 Maximum value search for 16- and 32-bit data (MAX(P),DMAX(P)) MAX(P),DMAX(P) Q4AR indicates an instruction symbol of MAX/DMAX. Command MAX, DMAX Command MAXP ,DMAXP : Head number of the devices where a maximum value is searched (BIN 16/32 bits) : Head number of the devices where the maximum value search result will be stored (BIN 16/32 bits) : Number of data blocks to be searched (BIN 16 bits) Internal Devices...
Page 376
MAX(P),DMAX(P) DMAX (1) Searches in the n points of 32-bit BIN data, from the device designated by , for the maximum value and stores the searched maximum value at the device designated by Starts the search from the device designated by and stores the location, specified in the number of points counted from , of the device where the maximum value is found first at...
Page 377
MAX(P),DMAX(P) (2) The following program searches for the maximum value from the32-bit data at D0 to D7, and stores it at D100 to D103 when X20 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] D1, D0 3786213 (BIN) D101, D100 8744740 D3, D2...
MIN(P),DMIN(P) 7.5.11 Minimum value search for 16- and 32-bit data (MIN(P),DMIN(P)) MIN(P),DMIN(P) Q4AR indicates an instruction symbol of MIN/DMIN. Command MIN, DMIN Command MINP, DMINP : Head number of the devices where a minimum value is searched (BIN 16/32 bits) : Head number of the devices where the minimum value search result will be stored (BIN 16/32 bits) : Number of data blocks to be searched (BIN 16 bits) Internal Devices...
Page 379
MIN(P),DMIN(P) DMIN (1) Searches in the n points of 32-bit BIN data, from the device designated by , for the minimum value and stores searched minimum value at the devices designated by Starts the search from the device designated by and stores the location, specified in the number of points counted from , of the device where the minimum value is found first at...
Page 380
MIN(P),DMIN(P) (2) The following program, when X20 is turned ON, searches for the minimum value from the 32-bit data contained from D0 to D7, and stores it from D100 to D103. [Ladder Mode] [List Mode] Step Instruction Device [Operation] D1,D0 57020175 (BIN) D101,D100 69386...
SORT,DSORT 7.5.12 BIN 16 and 32 bits data sort operations (SORT,DSORT) SORT,DSORT Q4AR indicates an instruction symbol of SORT/DSORT. Command SORT, DSORT : Head device number in the table to be sorted (BIN 16/32 bits) : Number of data blocks to be sorted (BIN 16 bits) : Number of data blocks to be compared in one sort operation (BIN 16 bits) : Number of the bit device to be turned ON at the completion of the sort operation (bits) : Device reserved for the system (BIN 16 bits)
Page 382
SORT,DSORT (2) Several scans are required for sorts performed by the SORT instruction. The number of scans executed until completion is the value obtained by dividing the maximum number of times executed until the completion of the sort by the number of data blocks compared at one execution designated by .
Page 383
SORT,DSORT (2) Several scans are required for sorts performed by the DSORT instruction. The number of scans executed until completion is the value obtained by dividing the maximum number of times executed until the completion of the sort by the number of data blocks compared at one execution designated by .
Page 384
SORT,DSORT Program Example (1) The following program sorts the BIN 16-bit data in 10 points from D0 in the ascending/ descending order when X10 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Data after sort -999 Data before sort 12345 12345 -999...
WSUM(P) 7.5.13 Calculation of totals for 16-bit data (WSUM(P)) WSUM(P) Q4AR Command WSUM WSUM Command WSUMP WSUMP : Head number of the devices where data to be summed are stored (BIN 16 bits) : Head number of the devices where the sum will be stored (BIN 32 bits) : Number of data blocks (BIN 16 bits) Internal Devices Setting...
Page 386
WSUM(P) Program Example (1) The following program adds the 16-bit BIN data from D10 to D14, and stores it in D100 and D101 when X1C is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] 4500 (BIN) 2500 (BIN) 3276 (BIN) 14948 (BIN) D101,D100...
DWSUM(P) 7.5.14 Calculation of totals for 32-bit data (DWSUM(P)) DWSUM(P) Q4AR Command DWSUM DWSUM Command DWSUMP DWSUMP : Head number of the devices where data to be summed are stored (BIN 32 bits) : Head number of the devices where the sum will be stored (BIN 64 bits) : Number of data blocks (BIN 16 bits) Internal Devices Setting...
Page 388
DWSUM(P) Program Example (1) The following program adds the 32-bit BIN data at D100 to D107, and stores the result at D10 and D13 when X20 is turned ON. [Ladder Mode] [List Mode] Device Step Instruction [Operation] D101,D100 11245600 (BIN) D103,D102 27543200 (BIN) D13 to...
FOR,NEXT Structure creation instructions 7.6.1 FOR to NEXT instruction loop (FOR,NEXT) FOR,NEXT Q4AR Repeat program NEXT NEXT n : Number of repetitions of FOR to NEXT loop (1 to 32767) (BIN 16 bits) Internal Devices Setting Constants R, ZR Other Data K, H Word...
Page 390
FOR,NEXT Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • An END, FEND or GOEND instruction was executed before the execution of a NEXT instruction and after the execution of a FOR instruction.
Page 391
FOR,NEXT Remark 1. To force an end to the repetitious execution of the FOR to NEXT loop during the execution of the loop, insert a BREAK instruction. See 7.6.2 for details concerning the use of the BREAK instruction. 2. Use the EGP/EGF instruction to perform the pulse operation of an index-modified program between the FOR and NEXT instructions.
BREAK(P) 7.6.2 Forced end of FOR to NEXT instruction loop (BREAK(P)) BREAK(P) Q4AR Command BREAK BREAK Command BREAKP BREAKP : Number of the device where the remaining number of loops will be stored (BIN 16 bits) Pn : Number of the pointer (device name (pointer)) where the program is branched at the forced end of a loop. Internal Devices Setting Other...
Page 393
BREAK(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The BREAK instruction is used in a case other than with the FOR to NEXT instruction loop.
CALL(P) 7.6.3 Subroutine program calls (CALL(P)) CALL(P) Q4AR Command CALL CALL Command CALLP CALLP Command CALL CALL Command CALLP CALLP : Head pointer number of a subroutine program (Device name) : Number of the device to be passed as an argument to a subroutine program (bits, BIN 16 bits, BIN 32 bits) Internal Devices Setting Constants...
Page 395
CALL(P) (2) When function devices (FX, FY, FD) are used by a subroutine program, specify a device with corresponding to the function device. The contents to the devices specified by are as indicated below. (a) Prior to execution of the subroutine program, bit data is transmitted to FX, and word data is transmitted to FD.
Page 396
CALL(P) (6) The device used in the argument of the CALL (P) instruction should not be used in a subrou- tine program. If used, it will not be possible to obtain accurate calculations. (Refer to the following program example.) (7) When the device, either timer or counter, is used in the argument of the CALL(P) instruction, only the current value is transmitted/received.
Page 397
CALL(P) Correct operation example The following example shows the operation performed when D0 is specified for FD0 in the subroutine program and D4 is used in the subroutine program. [Program example] [Operation performed after subroutine program execution] Immediately after the At the time of Before the execution execution of CALL...
Page 398
CALL(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The device specified for the argument cannot be secured for the data size. (Error code: 4101) •...
7.6.4 Return from subroutine programs (RET) Q4AR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Indicates end of subroutine program (2) When the RET instruction is executed, returns to the step following the CALL (P), FCALL (P), ECALL (P), EFCALL (P) or XCALL instruction which called the subroutine program.
FCALL(P) 7.6.5 Subroutine program output OFF calls (FCALL(P)) FCALL(P) Q4AR Command FCALL FCALL Command FCALLP FCALLP Command FCALL FCALL Command FCALLP FCALLP : Head pointer number of a subroutine program (Device name) : Number of the device to be passed as an argument to a subroutine program (bits, BIN 16 bits, BIN 32 bits) Internal Devices Setting Other...
Page 401
FCALL(P) (b) The operation results for the individual coil instructions following non-execution processing will be as follows, regardless of the ON/OFF status of the individual contacts: OUT instruction ..Forced OFF SET instruction RST instruction SFT instruction ..Maintains status Basic instructions Application instructions PLS instruction...
Page 402
FCALL(P) (4) When function devices (FX, FY, FD) are used by a subroutine program, specify a device with corresponding to the function device. The contents to the devices specified by are as indicated below. (a) Prior to execution of the subroutine program, bit data is transmitted to FX, and word data is transmitted to FD.
Page 403
FCALL(P) (6) Up to 16 nesting levels are possible with the FCALL(P) instruction. However, this 16 levels is the total number of levels in the CALL(P), FCALL(P), ECALL(P), EFCALL(P), and XCALL instructions. CALL FCALL CALL CALL FCALL P10 FCALL P20 FEND Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and...
ECALL(P) 7.6.6 Subroutine calls between program files (ECALL(P)) ECALL(P) Q4AR Command ECALL ECALL File name Command ECALLP ECALLP File name Command ECALL ECALL File name Command ECALLP File name ECALLP File name : Name of the program file to be called (character string) : Head pointer number of a subroutine program (Device name) : Number of the device to be passed as an argument to a subroutine program (bits, BIN 16 bits, BIN 32 bits) Internal Devices...
Page 405
ECALL(P) (2) Only the file name of a program file stored in the drive 0 (program memory/internal RAM) can be designated for a file name. (3) It is not necessary to designate the extension (.QPG) with the file name. (Only .QPG files will be acted on.) (4) When function devices (FX, FY, FD) are used by a subroutine program, specify a device corresponding to the function device with .
Page 406
ECALL(P) (5) From can be used by the ECALL instruction. (6) The device used in the argument of the ECALL instruction should not be used in a subroutine program. If used, it will not be possible to obtain accurate calculations. (Refer to the following program example.) Incorrect operation example The following example shows the operation performed when D0 is specified for FD0 in the...
Page 407
ECALL(P) Correct operation example The following example shows the operation performed when D0 is specified for FD0 in the subroutine program and D4 is used in the subroutine program. [Program example] [MAIN] [ABC] [Operation performed after subroutine program execution] Immediately after the At the time of Before the execution execution of ECALL...
Page 408
ECALL(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The device specified for the argument cannot be secured for the data size. (Error code: 4101) •...
Page 409
EFCALL(P) 7.6.7 Subroutine output OFF calls between program files (EFCALL(P)) EFCALL(P) Q4AR Command EFCALL EFCALL File name Command EFCALLP EFCALLP File name Command EFCALL EFCALL File name Command EFCALLP File name EFCALLP File name : Name of the program file to be called (character string) : Head pointer number of a subroutine program (Device name) : Number of the device to be passed as an argument to a subroutine program (bits, BIN 16 bits, BIN 32 bits)
Page 410
EFCALL(P) (b) The operation results for the individual coil instructions following non-execution processing will be as follows, regardless of the ON/OFF status of the individual contacts: OUT instruction ..Forced OFF SET instruction RST instruction SFT instruction ..Maintains status Basic instructions Application instructions PLS instruction...
Page 411
EFCALL(P) (4) Only the file name of a program file stored in the drive 0 (program memory/internal RAM) can be designated for a file name. (5) It is not necessary to designate the extension (.QPG) with the file name. (Only .QPG files will be acted on.) (6) When function devices (FX, FY, FD) are used by a subroutine program, specify a device corresponding to the function device with [MAIN]...
Page 412
EFCALL(P) can be used with the EFCALL (P) instruction. (8) The number of function devices used by subroutine programs must be identical to the number of arguments used by the EFCALL (P) instruction. Further, the function devices should be identical to the types of arguments used by the EFCALL (P) instruction. (9) Up to 16 levels of nesting can be used with the EFCALL (P) instruction.
XCALL 7.6.8 Subroutine program call (XCALL) XCALL Q4AR Command XCALL XCALL : Head pointer number of a subroutine program (Device name) : Number of the device to be passed as an argument to a subroutine program (bits, BIN 16 bits, BIN 32 bits) Internal Devices Setting Constants...
Page 414
XCALL (2) Operation of XCALL instruction varies according to the CPU module type. The following program example shows the operation of XCALL instruction for each CPU module. [Program example] Subroutine program (P1) call by XCALL instruction P1 subroutine program [ON/OFF timing of X0] (1) Turning X0 ON (3) Turning X0 OFF (OFF...
Page 415
XCALL (3) When function devices (FX, FY, FD) are used by a subroutine program, specify a device with corresponding to the function device. The contents to the devices specified by are as indicated below. (a) Prior to execution of the subroutine program, bit data is transmitted to FX, and word data is transmitted to FD.
Page 416
XCALL (7) Up to 16 nesting levels can be used with the XCALL instruction. However, this 16 levels is the total number of levels in the CALL(P), FCALL(P), ECALL(P), EFCALL(P), and XCALL instructions. XCALL P0 X0 XCALL P10 X10 XCALL P20 X20 FEND (8) The device used for the argument of the XCALL instruction must not be used in a subroutine...
Page 417
XCALL Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The device specified for the argument cannot be secured for the data size. (Error code: 4101) •...
7.6.9 Refresh instruction (COM) Q4AR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Use the COM instruction when: (a) It is desired to increase the speed of transmission/reception processing to/from the remote I/O stations. (b) It is desired to ensure reliable data transmission/reception with other stations that use different scan times during the execution of the data link.
Page 419
(3) At the point of the execution of the COM instruction, the CPU module temporarily stops the processing of the sequence program, and performs the same operation as ordinary data processing as well as auto refresh of intelligent function modules (including link refreshes) at the END processing.
Page 420
(6) If the scan time from the linked station is longer than the sequence program scan time at the host station, designating the COM instruction at the host station will not increase the speed of data communications. Sequence program 0 COM END 0 COM Link scan The programs in which the COM instruction cannot be used are shown below:...
IX,IXEND 7.6.10 Index modification of entire ladder (IX,IXEND) IX,IXEND Q4AR Ladder where index modification is performed IXEND I X END : Head number of the devices where index modification data is stored (BIN 16 bits) Internal Devices Setting R, ZR Constants Other Data...
Page 422
IX,IXEND (2) Index modification for device numbers is accomplished in the manner as below: By setting a modification value to each of the devices, the set modification values are added to the all device numbers of the devices used in the ladder between the IX and IXEND instructions. The program is executed using the index modified device numbers.
Page 423
IX,IXEND (8) Whether the program will be expanded or a user needs to create the program is depending on your GPP function software package. (a) When a user needs to create the program (When GX Developer is used) The index register should be added to the index modification ladder established with the IX and IXEND instructions.
Page 424
IX,IXEND Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The IX and IXEND instructions are not used together. (Error code: 4231) •...
IXDEV,IXSET 7.6.11 Designation of modification values in index modification of entire ladders (IXDEV,IXSET) IXDEV,IXSET Q4AR IXDEV IXDEV IXSET IXSET Dummy contact Offset designation sections : Head number of the devices where index modification data is stored (pointer only) P (Pointer) : Head number of the devices where index modification data will be stored (except a pointer) (BIN 16 bits) Internal Devices Setting...
Page 426
IXDEV,IXSET (6) If two offsets for two identical types of device have been set in the offset designation area, the last value set will be valid. (7) The IXDEV and IXSET instructions should be treated as a pair. (8) Any value from 0 to 32767 is valid for ZR. (The offset value will be the remainder of the quotient of the designated device number divided by 32768.) (9) The dummy contacts in the offset specifying part are valid for only LD and AND located within the range of the IXDEV-IXSET instructions.
Page 427
IXDEV,IXSET Program Example (1) The following program changes the modification values for input (X), output (Y), data register (D) and pointer (P). [Ladder Mode] [List Mode] Step Instruction Device Index modification ladder Index modification table *4: Refer to 7.6.10 for index modification using the IX to IXEND instructions. 7-135...
FIFW(P) Data Table Operation Instructions 7.7.1 Writing data to the data table (FIFW(P)) FIFW(P) Q4AR Command FIFW FIFW Command FIFWP FIFWP : Data to be written into the table or the number of the device where the data is stored (BIN 16 bits) : Head number of the table (BIN 16 bits) Internal Devices Setting...
Page 429
FIFW(P) Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The data table range exceeds the relevant device range when the FIFW instruction is executed.
FIFR(P) 7.7.2 Reading oldest data from tables (FIFR(P)) FIFR(P) Q4AR Command FIFR FIFR Command FIFRP FIFRP : Head number of the devices where the data read from the table will be stored (BIN 16 bits) : Head number of the table (BIN 16 bits) Internal Devices Setting R, ZR...
Page 431
FIFR(P) Program Example (1) The following program stores the R1 data from the table R0 to R7 at D0 when X10 is turned [Ladder Mode] [List Mode] Step Instruction Device [Operation] Data table Data table Number of stored data blocks Number of stored data blocks 4321 4321...
FPOP(P) 7.7.3 Reading newest data from data tables (FPOP(P)) FPOP(P) Q4AR Command FPOP FPOP Command FPOPP FPOPP : Head number of the devices where the data read from the table will be stored (BIN 16 bits) : Head number of the table (BIN 16 bits) Internal Devices Setting R, ZR...
Page 433
FPOP(P) Program Example (1) The following program stores the data stored last in the data table R0 to R7 at D0 when X10 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Data table Data table -123 -123 1400 1400 1234...
FDEL(P),FINS(P) 7.7.4 Deleting and inserting data from and in data tables (FDEL(P),FINS(P)) FDEL(P),FINS(P) Q4AR indicates an instruction symbol of FDEL/FINS. Command FDEL, FINS Command FDELP, FINSP : Head number of the devices where data to be inserted is stored (BIN 16 bits) Head number of the devices where the data to be deleted will be stored (BIN 16 bits) : Head number of the table (BIN 16 bits) : Location on the table where data is inserted/deleted (BIN 16 bits)
Page 435
FDEL(P),FINS(P) FINS (1) Inserts the 16-bit data designated by at the nth block of the data table designated by After the execution of the FINS instruction, the data in the table following the inserted block is all dropped one position. Data table Data table Number of stored...
Page 436
FDEL(P),FINS(P) Program Example (1) The following program deletes the second data from the table R0 to R7 and stores the deleted data at D0 when X10 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Data table Data table X10:ON -123 -123...
FROM(P),DFRO(P) Buffer memory access instruction 7.8.1 Reading 1-/2-word data from the intelligent function module (FROM(P),DFRO(P)) FROM(P),DFRO(P) Q4AR indicates an instruction symbol of FROM/DFRO. Command FROM, DFRO Command FROMP, DFROP n1 : Head I/O number of an intelligent function module (BIN 16 bits) n2 : Head address of data to be read (BIN 16 bits) : Head number of the devices where the read data will be stored (BIN 16/32 bits) n3 : Number of data blocks to be read (BIN 16 bits)
Page 438
FROM(P),DFRO(P) DFRO (1) Reads the data in (n3 2) words from the buffer memory address designated by n2 of the the intelligent function module designated by n1, and stores the data into the area starting from the device designated by Intelligent function module buffer memory CPU module...
Page 439
FROM(P),DFRO(P) Program Example (1) The following program reads the digital value of CH1 of the A68AD mounted at I/O numbers 040 to 05F into D0 when X0 is turned ON. (Reads 1 word of data from address 10 of the buffer memory.) [Ladder Mode] [List Mode]...
TO(P),DTO(P) 7.8.2 Writing 1-/2-word data to intelligent function module (TO(P),DTO(P)) TO(P),DTO(P) Q4AR indicates an instruction symbol of TO/DTO. Command TO, DTO Command TOP, DTOP n1 : Head I/O number of an intelligent function module (BIN 16 bits) n2 : Head address of the area where data is written (BIN 16 bits) : Data to be written or head number of the devices where the data to be written is stored (BIN 16/32 bits) n3 : Number of data blocks to be written (BIN 16 bits) •...
Page 441
TO(P),DTO(P) Writes the data stored in n3 2 points starting from the device designated by into the area starting from buffer memory address designated by n2 of the intelligent function module designated by n1. Intelligent function module buffer memory CPU module Device designated by S n2+1...
Page 442
TO(P),DTO(P) Program Example (1) The following program sets the CH1 and CH2 of the Q68ADV mounted at the I/O numbers 040 to 04F to the "A/D conversion" mode, when X0 is turned ON. (Writes 3 into the buffer memory address 0.) [Ladder Mode] [List Mode] Device...
Display instructions 7.9.1 Print ASCII code instruction (PR) Q4AR Command : ASCII code or head number of the devices where the ASCII code is stored (character string) : Head number of the output module to which the ASCII code will be output (bits) Internal Devices Setting Constants...
Page 444
(b) If SM701 is OFF, everything from the device designated by to the 00 code will be the target of the operation. Device where ASCII code is stored Upper 8 bits Lower 8 bits Output Y b8 b7 Head of output ASCII code output Scheduled Printer or...
Page 445
Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • There is no 00 code within the range of the device specified by when SM701 is OFF. (Error code: 4101) Program Example (1) The following program converts the string "ABCDEFGHIJKLMNOP"...
7.9.2 Print comment instruction (PRC) Q4AR Command : Head number of the devices where the comment to be printed is stored (Device name) : Head number of the output module to which the comment will be output (bits) Internal Devices Setting Other R, ZR...
Page 447
[Timing Chart] Y30 to Y37 30 ms (Strobe signal) (PRC instruction in execution flag) (2) Output signals from the output module are transmitted at the rate of 30 ms per character. For this reason, the time required to the completion of the transmission of the designated number of characters will be 30 ms n (ms).
7.9.3 ASCII code LED display instruction (LED) Q4AR Command : Display data or head number of the devices where the data to be displayed is stored (character string) Internal Devices Setting Constants R, ZR Other Data Word Word –– –– ––...
Page 449
Operation Error (1) There are no operation errors associated with the LED instruction. This instruction can be used only on Q3ACPU, Q4ACPU, and Q4ARCPU. If it is executed on a CPU module without LED display on its front surface (Q2ACPU, Q2AS(H)CPU), no processing will be performed. Program Example (1) The following program converts the string "ABCDEFGHIJKLMNOP"...
LEDC 7.9.4 LED display instruction for comments (LEDC) LEDC Q4AR Command LEDC LEDC : Head number of the device which displays a comment (Device name) Other Internal Devices Setting R, ZR Constants BL, BL\S, Data Word Word BL\TR –– Function (1) Displays the comment (16 characters) being stored at device designated by at the LED display at the front of the CPU module.
Page 451
LEDC Program Example (1) The following program displays comments from D0 to D15 in 30-second intervals. [Ladder Mode] Counts 30 seconds. Displays the comment of D(0+Z0) at the LED display unit of the CPU module. Executes Z0+1 when T5 turns from OFF to ON. Resets Z0 to 0 when Z0 reaches 16.
LEDR 7.9.5 Error display and annunciator reset instruction (LEDR) LEDR Q4AR Command LEDR LEDR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function Resets the self-diagnosis error display so that annunciator display or operation can be continued. With one execution of this instruction, either error display or annunciator is reset.
Page 453
LEDR (2) Operations when an annunciator (F) is ON. (a) When the CPU module has no LED display The following operations will be conducted 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 for SD65 to SD79 are moved up.
Page 454
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 supply cut AC DOWN Redundant base unit power supply voltage SINGLE PS.DOWN drop SINGLE PS.ERROR...
CHKST,CHK 7.10 Debugging and failure diagnosis instructions 7.10.1 Special format failure checks (CHKST,CHK) CHKST,CHK Q4AR Command CHKST CHKST Check condition (Only a contact is valid; b contact is ignored) Only input (X) can be used Up to 150 contacts can be connected Internal Devices Setting R, ZR...
CHKST,CHK (b) The contact instruction prior to the CHK instruction does not control the execution of the CHK instruction, but rather sets the check conditions. Advance command (X4) Advance operation (Y50) Advance Retract operation (Y51) Retract Advance end sensor (X0) Retract end sensor (X1) turns ON at the detection turns ON at the detection...
Page 457
CHKST,CHK (2) Depending on the designated contact, the CHK instruction undergoes processing identical to that shown for the ladder below: CHKST (Detection by both advance and retraction end sensors during advance operation of the conveyor) Max. 150 contacts X +1 Y SM80 Coil No.
Page 458
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 LDI or ANI, the processing for the check condition they specify will not be conducted.
CHKCIR,CHKEND 7.10.2 Changing check format of CHK instruction (CHKCIR,CHKEND) CHKCIR,CHKEND Q4AR When the GX Developer is used (QnACPU/Q4ARCPU) Command CHKST Refer to CHKST Section 7.10.1. SM400 CHKCIR CHKCIR Ladder pattern to be checked Max. 9 coils SM400 CHKEND CHKEND Internal Devices Setting R, ZR Constants...
Page 460
CHKCIR,CHKEND (a) The device numbers indicated at check conditions (X2 and X8 in the figure below) will assume index modification values for the individual device numbers (with the exception of annunciators (F)) described in the ladder patterns. Example X10 in the in the figure below would be as follows: When corresponding to check condition X2 Processing performed by...X12 When corresponding to check condition X8 Processing performed by...X18...
Page 461
CHKCIR,CHKEND (b) Failure checks check the ON/OFF status of OUT F by using the ladder pattern in the various check conditions. In all check conditions, SM80 will be turned ON if even one of the OUT F is ON in a ladder pattern.
Page 462
CHKCIR,CHKEND (4) The CHKCIR and CHKEND instructions can be written at any step in the program desired. It can be used in up to two locations in all program files being executed. However, the CHKCIR and CHKEND instructions cannot be used in more than 1 location in a single program file.
Page 463
CHKCIR,CHKEND When SW -GPPQ is used Command CHKST CHKST Refer to Section 7.10.1. SM400 CHKCIR CHKCIR Ladder pattern to be checked Max. 9 coils SM400 CHKEND CHKEND Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function CHKCIR, CHKEND (1) The check ladder pattern that will be used in the CHK instruction can be updated to any format desired.
Page 464
CHKCIR,CHKEND (a) The device numbers indicated at check conditions (X2 and X8 in the figure below) is the index modification values for the individual device numbers (except annunciators (F)) described in the ladder patterns. Example X10 in the in the figure below would be as follows: When corresponding to check condition X2 Processing performed by...X12 When corresponding to check condition X8 Processing performed by...X18 However, the order in which failure detection is executed differs depending on whether...
Page 465
CHKCIR,CHKEND (b) Failure checks check the ON/OFF status of OUT F by using the ladder pattern in the various check conditions. In all check conditions, SM80 will be turned ON if even one of the OUT F is ON in a ladder pattern.
Page 466
CHKCIR,CHKEND (4) The CHKCIR and CHKEND instructions can be written at any step in the program desired. It can be used in up to two locations in all program files being executed. However, the CHKCIR and CHKEND instructions cannot be used in more than 1 location in a single program file.
SLT,SLTR 7.10.3 Setting and resetting status latch (SLT,SLTR) SLT,SLTR Q4AR Command Command SLTR SLTR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) When the SLT instruction is executed, the data set at set devices of the programming tool at the time the SLT instruction is executed is stored in a file for status latch use in the memory card.
Page 468
SLT,SLTR Operation Error (1) There are no operation errors associated with the SLT or SLTR instructions. Program Example (1) The following program executes the SLT instruction when X0 is turned ON, and resets it with the SLTR instruction when X1 goes ON. [Ladder Mode] [List Mode] Step...
STRA,STRAR 7.10.4 Setting and resetting sampling trace (STRA,STRAR) STRA,STRAR Q4AR Command STRA STRA Command STRAR STRAR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function The sampling trace function collects the data in the specified device of a CPU module consecutively at the specified timing.
Page 470
STRA,STRAR STRA (1) The STRA 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) After the completion of the STRA instruction, sampling trace is finished and SM805 is turned (3) Once the STRA instruction has been executed, the next or later STRA instruction will be ignored.
PTRAEXE(P),PTRA,PTRAR 7.10.5 Execution, setting, and resetting of program trace (PTRAEXE(P),PTRA,PTRAR) PTRAEXE(P),PTRA,PTRAR Q4AR Command PTRAEXE PTRAEXE Command PTRAEXEP PTRAEXEP Command PTRA PTRA Command PTRAR PTRAR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function The program trace function collects the execution status at the specified step of the specified program and stores the results in the program trace file of the memory card.
Page 472
PTRAEXE(P),PTRA,PTRAR PTRA (1) The PTRA instruction turns ON SM813, executes sampling by the number of times set for "sampling after trigger" in the trace condition settings, latches the data and stops program trace. (2) After the execution of the PTRA instruction, and at the completion of the program trace, SM815 will go ON.
BINDA(P),DBINDA(P) 7.11 Character string processing instructions 7.11.1 Conversion from BIN 16-bit or 32-bit to decimal ASCII (BINDA(P),DBINDA(P)) BINDA(P),DBINDA(P) Q4AR indicates an instruction symbol of BINDA/DBINDA. Command BINDA, DBINDA Command BINDAP, DBINDAP : BIN data to be converted to ASCII (BIN 16/32 bits) : Head number of the devices where the conversion result will be stored (character string) Internal Devices Setting...
Page 474
BINDA(P),DBINDA(P) (3) The operation results stored at are as follows: (a) The sign "20 " will be stored if the BIN data is positive, and the sign "2D " will be stored if it is negative. (b) The sign "20 "...
Page 475
BINDA(P),DBINDA(P) Operation Error (1) There are no operation errors associated with the BINDA(P),DBINDA(P) instruction. Program Example (1) The following example program uses the PR instruction to output the 16-bit BIN data W0 value by decimal to Y40 to Y48 as ASCII. [Ladder Mode] [List Mode] Step...
BINHA(P),DBINHA(P) 7.11.2 Conversion from BIN 16-bit or 32-bit data to hexadecimal ASCII (BINHA(P),DBINHA(P)) BINHA(P),DBINHA(P) Q4AR indicates an instruction symbol of BINHA/DBINHA. Command BINHA, DBINHA Command BINHAP, DBINHAP : BIN data to be converted to ASCII (BIN 16/32 bits) : Head number of the devices where the conversion result will be stored (character string) Internal Devices Setting Constants...
Page 477
BINHA(P),DBINHA(P) DBINHA (1) Converts the individual digit numbers of hexadecimal notation of the BIN 32-bit data designated by into ASCII codes, and stores the results into the area starting from the device designated by 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 478
BINHA(P),DBINHA(P) Program Example (1) The following program uses the PR instruction to output the hexadecimal value of the 16-bit BIN data at W0 in ASCII code to Y40 to Y48. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Conducts ASCII output of Y40 to Y48 by using the PR instruction when X0 goes ON. Because SM701 is OFF, The PR instruction will output ASCII code until 00 is encountered.
BCDDA(P),DBCDDA(P) 7.11.3 Conversion from BCD 4-digit and 8-digit to decimal ASCII data (BCDDA(P),DBCDDA(P)) BCDDA(P),DBCDDA(P) Q4AR indicates an instruction symbol of BCDDA/DBCDDA. Command BCDDA,DBCDDA Command BCDDAP,DBCDDAP : BCD data to be converted to ASCII (BCD 4 digits/8 digits) : Head number of the devices where the conversion result will be stored (character string) Internal Devices Setting Constants...
Page 480
BCDDA(P),DBCDDA(P) (4) The data to be stored at the device designated by +2 differs depending on the ON/OFF status of SM701 (number of characters to output select signal). When SM701 is OFF..Stores "0" When SM701 is ON ..Does not change DBCDDA (1) Converts the individual digit numbers of hexadecimal notation of the BCD 8-digit data designated by...
Page 481
BCDDA(P),DBCDDA(P) Program Example (1) The following program uses the PR instruction to convert BCD 4-digit data (the value at W0) to decimal, and outputs it in ASCII format to Y40 to Y48. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Conducts ASCII output of Y40 to Y48 by using the PR instruction when X0 goes ON.
DABIN(P),DDABIN(P) 7.11.4 Conversion from decimal ASCII to BIN 16-bit and 32-bit data (DABIN(P),DDABIN(P)) DABIN(P),DDABIN(P) Q4AR indicates an instruction symbol of DABIN/DDABIN. Command DABIN,DDABIN Command DABINP,DDABINP : ASCII data to be converted to BIN value or head number of the devices where the ASCII data is stored (character string) : Head number of the devices where the conversion result will be stored (BIN 16/32 bits) Internal Devices...
Page 483
DABIN(P),DDABIN(P) DDABIN (1) Converts decimal ASCII data stored into the area starting from the device number designated by into BIN 32-bit data, and stores it in the device number designated by b8b7 Sign data ASCII code for billions place ASCII code for ten-millions place ASCII code for hundred-millions place b16b15 ASCII code for hundred-thousands place...
Page 484
DABIN(P),DDABIN(P) Program Example (1) The following program converts the decimal, 5-digit ASCII data and sign set at D20 through D22 to BIN values, and stores the result at D0. [Ladder Mode] [List Mode] Step Instruction Device [Operation] b8b7 (space) (space) (Regarded as -00276) BIN value (2) The following program converts the decimal, 10-digit ASCII data and sign set at D20 through...
HABIN(P),DHABIN(P) 7.11.5 Conversion from hexadecimal ASCII to BIN 16-bit and 32-bit data (HABIN(P),DHABIN(P)) HABIN(P),DHABIN(P) Q4AR indicates an instruction symbol of HABIN/DHABIN. Command HABIN,DHABIN Command HABINP,DHABINP : ASCII data to be converted to BIN value or head number of the devices where the ASCII data is stored (character string) : Head number of the devices where the conversion result will be stored (BIN 16/32 bits) Internal Devices...
Page 486
HABIN(P),DHABIN(P) DHABIN (1) Converts hexadecimal ASCII data stored in the area starting from the device number designated by into BIN 32-bit data, and stores it in the device number designated by b8b7 ASCII code for the 7th digit ASCII code for the 8th digit b16 b15 ASCII code for the 5th digit ASCII code for the 6th digit...
Page 487
HABIN(P),DHABIN(P) Program Example (1) The following program converts the hexadecimal, 4-digit ASCII data set at D20 and D21 to BIN data, and stores the result at D0. [Ladder Mode] [List Mode] Step Instruction Device [Operation] b8b7 22977 Regarded as A63F BIN value A63F (-22977 in decimal...
DABCD(P),DDABCD(P) 7.11.6 Conversion from decimal ASCII to BCD 4-digit or 8-digit data (DABCD(P),DDABCD(P)) DABCD(P),DDABCD(P) Q4AR indicates an instruction symbol of DABCD/DDABCD. Command DABCD,DDABCD Command DABCDP,DDABCDP : ASCII data to be converted to BCD value or head number of the devices where the ASCII data is stored (character string) : Head number of the devices where the conversion result will be stored (BCD 4 digits/8 digits) Internal Devices...
Page 489
DABCD(P),DDABCD(P) DDABCD (1) Converts decimal ASCII data stored in the area starting from the device designated by 8-digit BCD data, and stores it into the area starting from the device designated by ASCII code for millions place ASCII code for ten-millions place ASCII code for ten-thousands place ASCII code for hundred-thousands place b31 b28...
Page 490
DABCD(P),DDABCD(P) Program Example (1) The following program converts the decimal ASCII data set from D20 to D22 to BCD 4-digit data, and outputs the results to Y40 to Y4F. [Ladder Mode] Outputs the converted BCD value to a display device. [List Mode] Step Instruction...
COMRD(P) 7.11.7 Reading device comment data (COMRD(P)) COMRD(P) Q4AR Command COMRD COMRD Command COMRDP COMRDP : Head number of the devices where a comment to be read is stored (Device name) : Head number of the devices where the read comment will be stored (character string) Other Internal Devices Setting...
Page 492
COMRD(P) (2) If no comment has been registered for the device specified by despite the fact that the comment range setting is made, all of the characters for the comment are processed as "20 " (space). (3) The device number plus 1 where the final character of is stored differs depending on the ON/OFF status of SM701 (number of characters to output select signal).
Page 493
COMRD(P) Program Example (1) The following program stores the comments set at D100 into the area starting from W0 as ASCII when X1C is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] b8 b7 (space) Comment at D100 (space) LINE A TARGET...
Page 494
COMRD(P) Command COMRD COMRD Command COMRDP COMRDP : Head number of the devices where a comment to be read is stored (Device name) : Head number of the devices where the read comment will be stored (character string) Other Internal Devices Setting BL\S,BL R, ZR...
Page 495
COMRD(P) 1. For device comments used with the COMRD instruction, use comment files stored in the memory card. Comment files stored in the internal memory cannot be used. 2. Use "PLC file setting" in the PLC parameter dialog box to set the comment file to be used with the COMRD instruction.
LEN(P) 7.11.8 Character string length detection (LEN(P)) LEN(P) Q4AR Command Command LENP LENP : Character string or head number of the devices where the character string is stored (character string) : Number of the device where the length of detected character string will be stored (BIN 16 bits) Internal Devices Setting Constants...
Page 497
(1) The following program outputs the length of the character string from D0 to Y40 to Y4F as BCD 4-digit values. [Ladder Mode] Outputs the length of character string to a display device. [List Mode] Step Instruction Device [Operation] b8b7 BCD conversion 0 0 1 0 BCD value "MITSUBISHI" (Characters "ABC" that follow 00 are ignored) 7-205...
STR(P),DSTR(P) 7.11.9 Conversion from BIN 16-bit or 32-bit to character string (STR(P),DSTR(P)) STR(P),DSTR(P) Q4AR indicates an instruction symbol of STR/DSTR. Command STR,DSTR Command STRP,DSTRP : Head number of the devices where the digits numbers for the numerical value to be converted are stored (BIN 16 bits) : BIN data to be converted (BIN 16/32 bits) : Head number of the devices where the converted character string will be stored (character string)
Page 499
STR(P),DSTR(P) (2) The total number of digits that can be designated by is from 2 to 8. (3) The number of digits that can be designated by +1 as a part of the decimal fraction is from 0 to 5. However, the number of digits following the decimal point must be smaller than or equal to the total number of digits minus 3.
Page 500
STR(P),DSTR(P) DSTR (1) Adds a decimal point to the BIN 32-bit data designated by at the location designated by , converts the data to character string data, and stores it following the device number designated by Total number of digits b8 b7 Number of digits in decimal fraction ASCII code for the...
Page 501
STR(P),DSTR(P) (c) If the total number of digits following the 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. ".
Page 502
STR(P),DSTR(P) Program Example (1) The following program converts the BIN 16-bit data stored at D10 when X0 is turned ON in accordance with the digit designation of D0 and D1, and stores the result from D20 to D23. [Ladder Mode] Sets the data.
Page 503
STR(P),DSTR(P) (2) The following program converts the BIN 32-bit data stored at D10 and D11 when X0 is turned ON in accordance with the digit designation of D0 and D1, and stores the result at from D20 to D26. [Ladder Mode] Sets the data.
VAL(P),DVAL(P) 7.11.10 Conversion from character string to BIN 16-bit or 32-bit data (VAL(P),DVAL(P)) VAL(P),DVAL(P) Q4AR indicates an instruction symbol of VAL/DVAL. Command VAL,DVAL Command VALP,DVALP : Character string to be converted to BIN data or head number of the devices where the character string is stored (character string) : Head number of the devices where the number of digits of the converted BIN data will be stored (BIN 16 bits) : Head number of the devices where the converted BIN data will be stored (BIN 16/32 bits)
Page 505
VAL(P),DVAL(P) For example, if the character string " 123.45" is designated for the area starting from the operation result would be stored at in the following manner: b8 b7 1 2 3 4 5 1 2 3 (2) The total number of characters that can be designated as a character string at is from 2 to 8.
Page 506
VAL(P),DVAL(P) DVAL (1) Converts the character string stored in the area starting from the device designated by BIN 32-bit data, and stores the digits numbers and BIN data in For conversions from character strings to BIN, all data from the device number designated to the device number where "00 "...
Page 507
VAL(P),DVAL(P) (8) In cases where the character string designated by contains "20 " (space) or "30 " (0) between the sign and the first numerical value other than "0", these "20 " and "30 " are ignored in the conversion into a BIN value. Total number of digits Number of digits 6 5 4 3 .
Page 508
VAL(P),DVAL(P) Program Example (1) The following program reads the character string data stored from D20 to D22 as an integer, converts it to a BIN value, and stores it at D0 when X0 is ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation]...
ESTR(P) 7.11.11 Conversion from floating decimal point to character string data (ESTR(P)) ESTR(P) Q4AR Command ESTR ESTR Command ESTRP ESTRP : 32-bit floating decimal point data to be converted or head number of the devices where the data is stored (real number) : Head number of the devices where display designation for the numerical value to be converted is stored (BIN 16 bits) : Head number of the devices where the converted character string will be stored (character string)
Page 510
ESTR(P) For example, in a case where there are 8 digits in total, with 3 digits in the decimal fraction part, and the value designated is 1.23456, the operation result would be stored in the area starting from in the following manner: b8 b7 (space) (space)
Page 511
ESTR(P) 4) If the total number of digits, excluding the sign, the decimal point and the decimal fraction part, is greater than the integer part of the 32-bit floating point type real num- ber data, "20 (space)" will be stored between the sign and the integer part. Total number of digits .
Page 512
ESTR(P) (a) The total number of digits that can be designated by +1 is as shown below: When the number of decimal fraction digits is "0" ....Number of digits (max.: 24) When the number of decimal fraction digits is other than "0" ....
Page 513
ESTR(P) 5) The ASCII code "2C " (+) will be stored as the sign for the exponent portion of the value if the exponent is positive in value, and the code "2D " ( ) will be stored if the exponent is a negative value.
Page 514
ESTR(P) Program Example (1) The following program converts the 32-bit floating point type real number data which had been stored at R0 and R1 in accordance with the conversion designation that is being stored at R10 to R12, and stores the result following D0 when X0 goes ON. [Ladder Mode] [List Mode] Step...
EVAL(P) 7.11.12 Conversion from character string to floating decimal point data (EVAL(P)) EVAL(P) Q4AR Command EVAL EVAL Command EVALP EVALP : Character string data to be converted to 32-bit floating decimal point real number data or head number of the devices where the character string data is stored (character string) : Head number of the devices where the converted 32-bit floating decimal point real number data will be stored (real number)
Page 516
EVAL(P) (b) When using exponent format (space) -1. 320 1E + 10 32-bit floating-point real number . 3 2 0 1 E + 1 0 (3) Excluding the sign, decimal point, and exponent portion of the result, 6 digits of the character string designated by to be converted to a 32-bit floating decimal point type real number will be effective;...
Page 517
EVAL(P) (6) In a case where the ASCII code "20 (space)" or "30 " (0) exists between numbers not including the initial zero in a character string specified by , it will be ignored when the conversion is done. b8b7 (space) -1 .
Page 518
EVAL(P) Program Example (1) The following program converts the character string stored in the area starting from R0 to a 32-bit floating decimal point type real number, and stores the result at D0 and D1 when X20 is turned ON. [Ladder Mode] [List Mode] Step...
ASC(P) 7.11.13 Conversion from hexadecimal BIN to ASCII (ASC(P)) ASC(P) Q4AR Command Command ASCP ASCP : Head number of the devices where BIN data to be converted to a character string is stored (BIN 16 bits) : Head number of the devices where the converted character string will be stored (character string) : Number of characters to be stored (BIN 16 bits) Internal Devices Setting...
Page 520
ASC(P) (2) The use of n to set the number of characters causes the BIN data range designated by and the character string storage device range designated by to be set automatically. (3) Processing will be performed accurately even if the device range where BIN data to be converted is being stored overlaps with the device range where the converted ASCII data will be stored.
HEX(P) 7.11.14 Conversion from ASCII to hexadecimal BIN (HEX(P)) HEX(P) Q4AR Command Command HEXP HEXP : Head number of the devices where a character string to be converted to BIN data is stored (character string) : Head number of the devices where the converted BIN data will be stored (BIN 16 bits) : Number of characters to be stored (BIN 16 bits) Internal Devices Setting...
Page 522
HEX(P) (3) Accurate processing will be conducted even in cases where the range of devices where the ASCII code to be converted is being stored overlaps with the range of devices that will store the converted BIN data. b8b7 (4) If the number of characters designated by n is not divisible by 4, "0" will be automatically stored after the designated number of characters in the final device number of the devices which are storing the converted BIN values.
RIGHT(P),LEFT(P) 7.11.15 Extracting character string data from the right or left (RIGHT(P),LEFT(P)) RIGHT(P),LEFT(P) Q4AR indicates an instruction symbol of RIGHT/LEFT. Command RIGHT,LEFT Command RIGHTP,LEFTP : Character string or head number of the devices where the character string is stored (character string) : Head number of the devices where the character string consisting of n characters starting from the right or left of will be stored (character string)
Page 524
RIGHT(P),LEFT(P) (2) The NULL code (00 ) indicating the end of the character string is automatically appended at the end of the character string. Refer to 5.2.5 for the format of the character string data. (3) If the number of characters designated by n is "0", the NULL code (00 ) will be stored at LEFT (1) Stores n number of characters from the left side of the character string (the beginning of the...
Page 525
RIGHT(P),LEFT(P) Program Example (1) The following program stores 4 characters of data from the rightmost of the character string stored in the area starting from R0, and stores it into the area starting from D0 when X0 is turned ON. [Ladder Mode] [List Mode] Step...
MIDR(P),MIDW(P) 7.11.16 Random selection from and replacement in character strings (MIDR(P),MIDW(P)) MIDR(P),MIDW(P) Q4AR indicates an instruction symbol MIDR/MIDW. Command MIDR,MIDW Command MIDRP,MIDWP : Character string or head number of the devices where the character string is stored (character string) : Head number of the devices where a character string data obtained as the result of operation will be stored (character string) : Head number of the devices where the location of the first character and the number of characters will be stored (BIN 16 bits)
Page 527
MIDR(P),MIDW(P) (2) The NULL code (00 ) indicating the end of the character string is automatically added to the end of the character string. Refer to 3.2.5 for the format of the character string data. (3) No processing will be conducted if the number of characters designated by +1 is "0".
Page 528
MIDR(P),MIDW(P) (4) If the number of characters designated by +1 exceeds the final character from the character string data designated by , data will be stored up to the final character. Before execution b8b7 b8b7 "ABCDEFGHI" After execution "012345678" b8b7 Position counted from the left end of character string data designated by...
Page 529
MIDR(P),MIDW(P) • The +1 value exceeds the number of characters for (Error code: 4101) • The + 0 value is 0. (Error code: 4101) • "00 " does not exist in the specified devices that follow the device specified for (Error code: 4101) Program Example (1) The following program stores the 3rd character through the 6th character from the left of the...
INSTR(P) 7.11.17 Character string search (INSTR(P)) INSTR(P) Q4AR Command INSTR INSTR Command INSTRP INSTRP : Character string to be searched or head number of the devices where the character string to be searched is stored (character string) : Character string in which a search is performed or head number of the devices where the character string is stored (character string) : Head number of the devices where the result of search will be stored (BIN 16 bits) : Location to start the search (BIN 16 bits)
Page 531
INSTR(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of n exceeds the number of characters for (Error code: 4100) •...
EMOD(P) 7.11.18 Floating decimal point to BCD (EMOD(P)) EMOD(P) Q4AR Command EMOD EMOD Command EMODP EMODP : 32-bit floating decimal point real number data or head number of the devices where the floating decimal point real number data is stored (real number) : Decimal fraction digits data (BIN 16 bits) : Head number of the devices where the data after break down into BCD will be stored (BIN 16 bits) Internal Devices...
Page 533
EMOD(P) 0 . 03542768 3542770 1 . 5 4 3 2 1E + 2 1543210 (2) The 7th digit of the significant digits being stored at +1 and +2 is rounded off to make a 6-digit number. . 2 3456789 1234570 123456789 Rounded off...
EREXP(P) 7.11.19 From BCD format data to floating decimal point (EREXP(P)) EREXP(P) Q4AR Command EREXP EREXP Command EREXPP EREXPP : Head number of the devices where BCD type floating point format data is stored (BIN 16 bits) : Decimal fraction digits data (BIN 16 bits) : The device where the converted 32-bit floating point real number data will be stored (real number) Internal Devices Setting...
Page 535
EREXP(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The format designated by was neither 0 nor 1. (Error code: 4100) •...
SIN(P) 7.12 Special function instructions 7.12.1 SIN operation on floating-point data (Single precision) (SIN(P)) SIN(P) Q4AR Command Command SINP SINP : Angle data of which the SIN (sine) value is obtained or head number of the devices where the angle data is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices...
Page 537
SIN(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of the specified device is (For the Q4ARCPU) (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
COS(P) 7.12.2 COS operation on floating-point data (Single precision) (COS(P)) COS(P) Q4AR Command Command COS P COSP : Angle data of which the COS (cosine) value is obtained or head number of the devices where the angle data is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Setting...
Page 539
COS(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of the specified device is (For the Q4ARCPU) (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
TAN(P) 7.12.3 TAN operation on floating-point data (Single precision) (TAN(P)) TAN(P) Q4AR Command Command TANP TANP : Angle data of which the TAN (tangent) value is obtained or head number of the devices where the angle data is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Setting...
Page 541
TAN(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • Operation results are outside the range shown below: -126 0, 2 |operation result| (For the Q4ARCPU) (Error code: 4100)
ASIN(P) 7.12.4 operation on floating point data (Single precision) (ASIN(P)) ASIN(P) Q4AR Command ASIN ASIN Command ASINP ASINP : SIN value of which the SIN (inverse sine) value is obtained or head number of the devices where the SIN value is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Setting...
Page 543
ASIN(P) Program Example (1) The following program seeks the inverse sine of the 32-bit floating decimal point real number at D0 and D1, and outputs the angle to the 4 BCD digits at Y40 to Y4F. [Ladder Mode] Calculates an angle (radian value) by SIN operation ( Converts the radian value...
ACOS(P) 7.12.5 operation on floating-point data (Single precision) (ACOS(P)) ACOS(P) Q4AR Command ACOS ACOS Command ACOSP ACOSP : COS value of which the COS (inverse cosine) value is obtained or head number of the devices where the COS value is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Setting...
Page 545
ACOS(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value designated by is outside the range of from 1.0 to 1.0. (Error code: 4100) •...
ATAN(P) 7.12.6 operation on floating-point data (Single precision) (ATAN(P)) ATAN(P) Q4AR Command ATAN ATAN Command ATANP ATANP : TAN value of which the TAN (inverse tangent) value is obtained or head number of the devices where the TAN value is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Setting...
Page 547
ATAN(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of the specified device is (For the Q4ARCPU) (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
RAD(P) 7.12.7 Conversion from floating-point angle to radian (Single precision) (RAD(P)) RAD(P) Q4AR Command Command RADP RADP : Angle to be converted to radian units or head number of the devices where the angle is stored (real number) : Head number of the devices where the value converted in radian units will be stored (real number) Internal Devices Setting Constants...
Page 549
RAD(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. -126 0, 2 | Contents of designated device | < 2 • The value of the specified device is (For the Q4ARCPU) (Error code: 4100) *1: There are CPU modules that will not result in an operation error if...
DEG(P) 7.12.8 Conversion from floating-point radian to angle (Single precision) (DEG(P)) DEG(P) Q4AR Command Command DEGP DEGP : Radian angle to be converted to degrees or head number of the devices where the radian angle is stored (real number) : Head number of the devices where the value converted in degrees will be stored (real number) Internal Devices Setting Constants...
Page 551
DEG(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value of the specified device is (For the Q4ARCPU) (Error code: 4100) *1: There are CPU modules that will not result in an operation error if 0 is specified.
SQR(P) 7.12.9 Square root operation for floating-point data (Single precision) (SQR(P)) SQR(P) Q4AR Command Command SQRP SQRP : Data of which the square root is obtained or head number of the devices where the data is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Setting Constants...
Page 553
SQR(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value designated by is a negative number. (Error code: 4100) •...
Page 554
SQR(P) Program Example (1) The following program seeks the square root of the value set by the 4 BCD digits from X20 to X2F, and stores the result as a 64-bit floating decimal point type real number at D0 to D3. [Ladder Mode] Inputs data used for square root operation (...
EXP(P) 7.12.10 Exponent operation on floating-point data (Single precision) (EXP(P)) EXP(P) Q4AR Command Command EXPP EXPP : Data of which the exponential value is obtained or head number of the devices where the data is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Setting Constants...
Page 556
EXP(P) Program Example (1) The following program performs an exponent operation on the value set by the 2 BCD digits at X20 to X27, and stores the results as a 32-bit floating decimal point real number at D0 and [Ladder Mode] Inputs the data used for exponent operation ( Checks the range of the...
LOG(P) 7.12.11 Natural logarithm operation on floating-point data (Single precision) (LOG(P)) LOG(P) Q4AR Command Command LOGP LOGP : Data of which the natural logarithm is obtained or head number of the devices where the data is stored (real number) : Head number of the devices where the operation result will be stored (real number) Internal Devices Settiing Constants...
Page 558
LOG(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The value designated by is negative. (Error code: 4100) • The value designated by is 0.
RND(P),SRND(P) 7.12.12 Random number generation and series updates (RND(P),SRND(P)) RND(P),SRND(P) Q4AR Command Command RNDP RNDP Command SRND SRND Command SRNDP SRNDP : Head number of the devices where random numbers will be stored (BIN 16 bits) : Random number serial data or the first number of the devices where the random number serial data is stored (BIN 16 bits) Internal Devices Setting...
Page 560
RND(P),SRND(P) Operation Error (1) There are no operation errors associated with the RND(P) or SRND(P) instructions. Program Example (1) The following program stores random number at D100 when X10 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device (2) The following program updates a random number series according to the contents of D0 when X10 is turned ON.
BSQR(P),BDSQR(P) 7.12.13 BCD 4-digit and 8-digit square roots (BSQR(P),BDSQR(P)) BSQR(P),BDSQR(P) Q4AR BSQR/BDSQR Command BSQR,BDSQR Command BSQRP,BDSQRP : Data of which the square root is obtained or the number of the device where the data is stored (BSQR(P): BCD 4 digits, BDSQR(P): BCD 8 digits) : Head number of the devices where the square root calculation result will be stored (BCD 4 digits) Internal Devices Setting...
Page 562
BSQR(P),BDSQR(P) BDSQR (1) Calculates the square root of the values designated by +1 and stores the results at the device designated by Integer part Decimal fraction part 2-word data (2) BCD value of a maximum of 8 digits (0 to 99999999) can be designated by (3) The operation results of +1 are stored as their respective BCD values of between 0 and 9999.
Page 563
BSQR(P),BDSQR(P) (2) The following program calculates the square root of BCD value 74625813 and outputs the integer part of the result to the 4 BCD digits at Y50 to Y5F, and the decimal fraction part to the 4 BCD digits from Y40 to Y4F. [Ladder Mode] Sets the data (BCD value) used for square root operation (...
BSIN(P) 7.12.14 BCD type SIN operation (BSIN(P)) BSIN(P) Q4AR Command BSIN BSIN Command BSINP BSINP : Data of which the SIN (sine) value is obtained or the number of the device where the data is stored (BCD 4 digits) : Head number of the devices where the operation result will be stored (BCD 4 digits) Internal Devices Setting Constants...
Page 565
BSIN(P) Program Example (1) The program example below calculates the SIN of 3-digit BCD data designated by X20 to X2B, and outputs a 1-digit BCD part to the integer part from Y50 to Y53, and a 4-digit BCD fraction part from Y40 to Y4F. Y60 is turned ON if the results of the operation are negative.
BCOS(P) 7.12.15 BCD type COS operations (BCOS(P)) BCOS(P) Q4AR Command BCOS BCOS Command BCOSP BCOSP : Data of which the COS (cosine) value is obtained or head number of the devices where the data is stored (BCD 4 digits) : Head number of the devices where the operation result will be stored (BCD 4 digits) Internal Devices Setting Constants...
Page 567
BCOS(P) Program Example (1) The following program calculates the cosine of the data designated by the 3 BCD digits from X20 to X2B and outputs the integer part of the result to 1 BCD digit from Y50 to Y53, and the decimal fraction part of the result to the 4 BCD digits from Y40 to Y4F.
BTAN(P) 7.12.16 BCD type TAN operation (BTAN(P)) BTAN(P) Q4AR Command BTAN BTAN Command BTANP BTANP : Data of which the TAN (tangent) value is obtained or head number of the devices where the data is stored (BCD 4 digits) : Head number of the devices where the operation result will be stored (BCD 4 digits) Internal Devices Setting Constants...
Page 569
BTAN(P) Program Example (1) The following program calculates the tangent of the data stored in the 3 BCD digits from X20 to X2B, and stores the integer part of the results in the 4 BCD digits from Y50 to Y53, and the decimal fraction part in the 4 BCD digits from Y40 to Y4F.
BASIN(P) 7.12.17 BCD type SIN operations (BASIN(P)) BASIN(P) Q4AR Command BASIN BASIN Command BASINP BASINP : Number of the device where data of which the SIN (inverse sine) value is obtained is stored (BCD 4 digits) : Head number of the devices where the operation result will be stored (BCD 4 digits) Internal Devices Setting Constants...
Page 571
BASIN(P) Program Example (1) The following program performs a SIN operation on the sign (positive when X0 is OFF, and negative when X0 is ON), the BCD 1-digit integer part from X30 to X33 and the BCD 4-digit decimal fraction part from X20 to X2F, and outputs the calculated angle in 4 BCD digits from Y40 to Y4F.
BACOS(P) 7.12.18 BCD type COS operation (BACOS(P)) BACOS(P) Q4AR Command BACOS BACOS Command BACOSP BACOSP : Number of the device where data of which the COS-1 (inverse cosine) value is obtained is stored (BCD 4 digits) : Head number of the devices where the operation result will be stored (BCD 4 digits) Internal Devices Setting R, ZR...
Page 573
BACOS(P) Program Example (1) The following program performs a COS operation on the sign (positive when X0 is OFF, and negative when X0 is ON), the BCD 1-digit integer part from X30 to X33 and the BCD 4-digit decimal fraction part from X20 to X2F, and outputs the calculated angle in 4 BCD digits from Y40 to Y4F.
BATAN(P) 7.12.19 BCD type TAN operations (BATAN(P)) BATAN(P) Q4AR Command BATAN BATAN Command BATANP BATANP : Number of the device where data of which the TAN-1 (inverse tangent) value is obtained is stored (BCD 4 digits) : Head number of the devices where the operation result will be stored (BCD 4 digits) Internal Devices Setting R, ZR...
Page 575
BATAN(P) Program Example (1) The following program performs a TAN-1 operation on the sign (positive when X0 is OFF, and negative when X0 is ON), the BCD 4-digit integer part from X20 to X2F and the BCD 4-digit decimal fraction part from X30 to X3F, and outputs the calculated angle in 4 BCD digits from Y40 to Y4F.
LIMIT(P),DLIMIT(P) 7.13 Data Control Instructions 7.13.1 Upper and lower limit controls for BIN 16-bit and BIN 32-bit data (LIMIT(P),DLIMIT(P)) LIMIT(P),DLIMIT(P) Q4AR indicates an instruction symbol of LIMIT/DLIMIT. Command LIMIT, DLIMIT Command LIMITP, DLIMITP : Lower limit value (minimum output threshold value) (BIN 16/32 bits) : Upper limit value (maximum output threshold value) (BIN 16/32 bits) : Input value to be controlled by the upper and lower limit control (BIN 16/32 bits) : Head number of the devices where the output value controlled by the upper and lower limit control will be...
Page 577
LIMIT(P),DLIMIT(P) (3) When control based only on upper limit values is performed, the lower limit value designated is set at " 32678". (4) When control based only on lower limit values is performed, the upper limit value designated is set at "32767". DLIMIT (1) The function controls the output value to be stored at the device designated by ( +1) by...
Page 578
LIMIT(P),DLIMIT(P) Program Example (1) The following program conducts limit controls from 500 to 5000 on the data set as BCD values from X20 to X2F, and stores the result at D1 when X0 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device...
BAND(P),DBAND(P) 7.13.2 BIN 16-bit and 32-bit dead band controls (BAND(P),DBAND(P)) BAND(P),DBAND(P) Q4AR indicates an instruction symbol of BAND/DBAND. Command BAND,DBAND Command BANDP,DBANDP : Lower limit value of dead band (no output band) (BIN 16/32 bits) : Upper limit value of dead band (no output band) (BIN 16/32 bits) : Input value to be controlled by a dead band control (BIN 16/32 bits) : Head number of the devices where the output value controlled by the dead band control will be stored (BIN 16/32 bits)
Page 580
BAND(P),DBAND(P) (3) The output value stored at is a signed 16-bit BIN value. Therefore, if the operation results exceed the range of from 32768 to 32767, the following will take place: Dead band lower limit value ....10 When : Input value ..........
Page 581
BAND(P),DBAND(P) Program Example (1) The following program performs the dead band control by applying the lower and upper limits of 0 and 1000 for the data set in BCD at X20 to X2F and stores the result of control at D1 when X0 is turned ON.
ZONE(P),DZONE(P) 7.13.3 Zone control for BIN 16-bit and BIN 32-bit data (ZONE(P),DZONE(P)) ZONE(P),DZONE(P) Q4AR indicates an instruction symbol of ZONE/DZONE. Command ZONE,DZONE Command ZONEP,DZONEP : Negative bias value to be added to an input value (BIN 16/32 bits) : Positive bias value to be added to an input value (BIN 16/32 bits) : Input value used for a zone control (BIN 16/32 bits) : Head number of the devices where the output value controlled by the zone control will be stored (BIN 16/32 bits).
Page 583
ZONE(P),DZONE(P) (2) The values that can be designated by , and are in the range of from 32768 to 32767. (3) The output value stored at is a signed 16-bit BIN value. Therefore, if the operation results exceed the range of 32768 to 32767, the following will take place: Negative bias value ......
Page 584
ZONE(P),DZONE(P) Program Example (1) The following program performs zone control by applying negative and positive bias values 100 to 100 for the data set at D0 and stores the result of control at D1 when X0 is turned [Ladder Mode] [List Mode] Step Instruction...
RSET(P) 7.14 File register switching instructions 7.14.1 Switching file register numbers (RSET(P)) RSET(P) Q4AR Command RSET RSET Command RSETP RSETP : Block number data used to change the block number or the number of the device where the block number data is stored (BIN 16 bits) Internal Devices Setting...
Page 586
RSET(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The block number designated by does not exist. (Error code: 4100) •...
QDRSET(P) 7.14.2 Setting files for file register use (QDRSET(P)) QDRSET(P) Q4AR Command QDRSET QDRSET Command QDRSETP QDRSETP : Character string data of the drive No./file name in which the file register is set, or head number of the devices where the character string data is stored (character string) Internal Devices Setting Constants...
Page 588
QDRSET(P) (2) Drive number can be designated from 1 to 4. (The drive number cannot be designated as drive 0 (program memory/internal memory).) Note that available drives vary depending on the CPU module used. Refer to the manual of the CPU module and check the drives that can be specified. (3) It is not necessary to designate the extension (.QDR) with the file name.
Page 589
QDRSET(P) Program Example (1) The following program compares R0 of ABC in block No. 1 and R0 of DEF in block No. 1. [Ladder Mode] [List Mode] Step Instruction Device [Operation] Block No. 0 Block No. 1 -3216 5001 9330 -1762 -7981 -3216...
QCDSET(P) 7.14.3 File setting for comments (QCDSET(P)) QCDSET(P) Q4AR Command QCDSET QCDSET Command QCDSETP QCDSETP : Character string data of the drive No./file name in which the comment file is set, or head number of the devices where the character string data is stored (character string) Internal Devices Setting Constants...
Page 591
QCDSET(P) (4) A file name setting can be deleted by designating the NULL character (00 ) for the file name. (5) File names designated with this instruction will be given priority even if a drive number and file name have been designated in the parameters. If the file name is changed with the QCDSET instruction, the file name returns to the name specified by the parameter when the CPU module is switched from STOP to RUN.
DATERD(P) 7.15 Clock instructions 7.15.1 Reading clock data (DATERD(P)) DATERD(P) Q4AR Command DATERD DATERD Command DATERDP DATERDP : Head number of the devices where the read clock data will be stored (BIN 16 bits) Internal Devices Setting R, ZR Constants Other Data Word...
Page 593
DATERD(P) Operation Error (1) There are no operation errors associated with the DATERD(P) instruction. Program Example (1) The following program outputs the following clock data as BCD values: Year ..Y70 to Y7F Month ..Y68 to Y6F Day ... Y60 to Y67 Hour..
DATEWR(P) 7.15.2 Writing clock data (DATEWR(P)) DATEWR(P) Q4AR Command DATEWR DATEWR Command DATEWRP DATEWRP : Head number of the devices where clock data to be written into the clock device is stored (BIN 16 bits) Internal Devices Setting R, ZR Constants Other Data...
Page 595
DATEWR(P) Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • Individual items of data have been set outside the setting range. (Error code: 4100) Program Example (1) The following program writes the following clock data to the clock element as BCD values when X40 is turned ON.
DATE+(P) 7.15.3 Clock data addition operation (DATE+(P)) DATE+(P) Q4AR Command DATE+ DATE+ Command DATE+P DATE+P : Head number of the devices where the clock data to be adjusted by addition is stored (BIN 16 bits) : Head number of the devices where the time data to be added for adjustment is stored (BIN 16 bits) : Head number of the devices where the result of addition of clock (time) data will be stored (BIN 16 bits) Internal Devices Setting...
Page 597
DATE+(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The data set by is outside the setting range. (Error code: 4100) Program Example (1) The following program adds 1 hour to the clock data read from the clock element, and stores the results in the area starting from D100 when X20 is ON.
DATE-(P) 7.15.4 Clock data subtraction operation (DATE-(P)) DATE-(P) Q4AR Command DATE- DATE- Command DATE-P DATE-P : Head number of the devices where the clock time data to be adjusted by substraction is stored (BIN 16 bits) : Head number of the devices where time data to be subtracted for adjustment is stored (BIN 16 bits) : Head number of the devices where the result of subtraction of clock (time) data will be stored (BIN 16 bits) Internal Devices Setting...
Page 599
DATE-(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The data set by is outside the setting range. (Error code: 4100) Program Example (1) The following program subtracts the time data stored in devices starting from D10 from the clock data read from the clock element when X1C is turned ON, and stores the result at...
SECOND(P) 7.15.5 Time data conversion (from Hour/Minute/Second to Second) (SECOND(P)) SECOND(P) Q4AR Command SECOND SECOND Command SECONDP SECONDP : Head number of the devices where the clock data before conversion is stored (BIN 16 bits) : Head number of the devices where the clock data after conversion will be stored (BIN 32 bits) Internal Devices Setting R, ZR...
Page 601
SECOND(P) Program Example (1) The following program converts the clock time data read from the clock element into second when X20 is turned ON, and stores the result at D100 and D101. [Ladder Mode] [List Mode] Step Instruction Device [Operation] •...
HOUR(P) 7.15.6 Time data conversion (from Second to Hour/Minute/Second ) (HOUR(P)) HOUR(P) Q4AR Command HOUR HOUR Command HOURP HOURP : Head number of the devices where clock data before conversion is stored (BIN 32 bits) : Head number of the devices where the clock data after conversion will be stored (BIN 16 bits) Internal Devices Setting Constants...
Page 603
HOUR(P) Program Example (1) The following program converts the seconds stored at D0 and D1 into an hour, minute, second format, and stores the result at devices starting from D100 when X20 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation]...
7.16 Peripheral device instructions 7.16.1 Message displays to peripheral devices (MSG) Q4AR Command : Character string data to be displayed, or head number of the devices where the character string data is stored (character string) Internal Devices Setting Constants R, ZR Other Data Word...
Page 605
Program Example (1) The following program sends the message "TOSOU LINE READY" for display at a peripheral device when X0 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] b8b7 SD738 SD739 TOSOU LINE READY SD740 (space) Display SD741 SD742 SD743...
PKEY 7.16.2 Keyboard input from peripheral devices (PKEY) PKEY Q4AR Command PKEY PKEY : Head number of the devices where a keyboard input will be stored (BIN 16 bits) Internal Devices Setting Constants R, ZR Other Data Word Word –– ––...
Page 607
PKEY Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • An attempt was made to store keyboard input data that exceeded the device range designated by (Error code: 4101) Program Example...
PKEY 7.17 Program control instructions (1) Processing when the execution type is converted with the program control instruction is as follows. Executed Instruction Execution type before change PSCAN PSTOP POFF PLOW No change-remains Output turned OFF in Scan execution type scan type execution.
Page 609
PKEY (2) As program execution type conversions by PSCAN and PSTOP instructions occur at the END processing, such conversions are impossible during program execution. When different execution types have been set for the same program in the same scan, the execution type will be that specified by the execution switching command that was executed last.
PSTOP(P) 7.17.1 Program standby instruction (PSTOP(P)) PSTOP(P) Q4AR Command PSTOP PSTOP Command PSTOPP PSTOPP : Character string for the name of the program file to be set in the stand-by status or head number of the devices where the character string data is stored (character string) Internal Devices Setting Constants...
POFF(P) 7.17.2 Program output OFF standby instruction (POFF(P)) POFF(P) Q4AR Command POFF POFF Command POFFP POFFP : File name of the program to be set in the standby status by turning OFF the output, or the device where the file name is stored (character string) Internal Devices Setting Constants...
Page 612
POFF(P) Remark 1. Non-execution processing is identical to the processing that is conducted when the condition contacts for the individual coil instructions are in the OFF state. The operation results for the individual coil instructions following non-execution processing will be as follows, regardless of the ON/OFF status of the individual contacts: OUT instruction ..
PSCAN(P) 7.17.3 Program scan execution registration instruction (PSCAN(P)) PSCAN(P) Q4AR Command PSCAN PSCAN Command PSCANP PSCANP : File name of the program to be set as a scan execution type, or head number of the devices where the file name is stored (character string) Internal Devices Setting Constants...
Page 614
PSCAN(P) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • The program with the file name specified by does not exist. (Error code: 2410) •...
Page 615
PLOW(P) 7.17.4 Program low speed execution registration instruction (PLOW(P)) PLOW(P) Q4AR Command PLOW PLOW Command PLOWP PLOWP : File name of the program to be set as a low speed execution type, or head number of the devices where the file name is stored (character string) Internal Devices Setting...
Page 616
PLOW(P) Program Example (1) The following program sets the program with file name ABC as low-speed execution type when X0 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device 7-324...
PCHK 7.17.5 Program execution status check instruction (PCHK) PCHK Q4AR LDPCHK File name PCHK Command ANDPCHK PCHK File name Command ORPCHK File name PCHK : File name of the program whose execution status will be checked (character string) Internal Devices Setting Constants R, ZR...
Page 618
PCHK Remark Non-execution indicates that the program execution type is a stand-by 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. The PCHK instruction is in conduction when the program of the specified file name (target program) is in execution, and the instruction is in non-conduction when the program is in non-execution.
WDT(P) 7.18 Other instructions 7.18.1 Resetting watchdog timer (WDT(P)) WDT(P) Q4AR Command Command WDTP WDTP Internal Devices Setting R, ZR Constants Other Data Word Word –– –– Function (1) Resets watchdog timer during the execution of a sequence program. (2) Used in cases where the scan time exceeds the value set for the watchdog timer due to prevailing conditions.
Page 620
WDT(P) Operation Error (1) There are no operation errors associated with the WDT(P) instruction. Program Example (1) The following program has a watchdog timer setting of 200 ms, when due to the execution conditions program execution requires 300 ms from step 0 to the END (FEND) instruction. [When WDT instruction is used] Program where Program where...
DUTY 7.18.2 Timing pulse generation (DUTY) DUTY Q4AR Command DUTY DUTY n1 : Number of scans for ON (BIN 16 bits) n2 : Number of scans for OFF (BIN 16 bits) : User timing clock (SM420 to SM424, SM430 to M434) (bits) Internal Devices Setting Constants...
Page 622
DUTY Program Example (1) The following program turns SM420 ON for 1 scan, and OFF for 3 scans if X0 is ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] SM420 1 scan 3 scans 7-330...
TIMCHK 7.18.3 Time check instruction (TIMCHK) TIMCHK Q4AR command TIMCHK TIMCHK : Device where the measured current value will be stored (BIN 16 bits) : Device where the set value of measurement is stored (BIN 16 bits) : Device to be turned ON at time-out (bits) Internal Devices Setting Constants...
ZRRDB(P) 7.18.4 Direct 1-byte read from file register (ZRRDB(P)) ZRRDB(P) Q4AR Command ZRRDB ZRRDB Command ZRRDBP ZRRDBP n : Serial byte number for the file register to be read (BIN 32 bits) : Number of the device where the read data will be stored (BIN 16 bits) Internal Devices Setting Constants...
Page 625
ZRRDB(P) (a) If the value of n has been designated as 23560, the data at the lower 8 bits of ZR11780 will be read. Read destination b8 b7 b8 b7 designation ZR11780 23560 Data is stored (b) If the value of n has been designated as 43257, the data at the upper 8 bits of ZR21628 will be read.
ZRWRB(P) 7.18.5 File register direct 1-byte write (ZRWRB(P)) ZRWRB(P) Q4AR Command ZRWRB ZRWRB Command ZRWRBP ZRWRBP n : Serial byte number for the file register to be written (BIN 32 bits) : Number of the device where the data to be written is stored (BIN 16 bits) Internal Devices Setting Constants...
Page 627
ZRWRB(P) If n 12340 is specified, the data will be written to the lower 8 bits of ZR11170. Write destination b8 b7 b8 b7 designation 12340 Ignored ZR11170 b8 b7 If n 43257 is specified, the data will be written to the upper 8 bits of ZR21628. Write destination designation b8 b7...
ADRSET(P) 7.18.6 Indirect address read operations (ADRSET(P)) ADRSET(P) Q4AR Command ADRSET ADRSET Command ADRSETP ADRSETP : Number of the device whose indirect address is read out (Device name) : Number of the device where the indirect address of the device designated by will be stored (BIN 32 bits) Internal Devices Setting...
ZPUSH(P),ZPOP(P) 7.18.7 Batch save or recovery of index register (ZPUSH(P),ZPOP(P)) ZPUSH(P),ZPOP(P) Q4AR indicates an instruction symbol of ZPUSH/ZPOP. Command ZPUSH, ZPOP Command ZPUSHP, ZPOPP : Head number of the devices to/from which contents of an index register are saved/recovered (BIN 16 bits) Internal Devices Setting R, ZR...
Page 630
ZPUSH(P),ZPOP(P) ZPOP (1) Recovers the contents saved in the area starting from the device designated by to the index register. (When the saved content is read out to the index register, + 0 (the number of saves made) is decreased by 1.) Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0.
EROMWR(P) 7.18.8 Batch write operation to E PROM file register (EROMWR(P)) EROMWR(P) Q4AR Command EROMWR EROMWR Command EROMWRP EROMWRP : Head number of the devices where data to be written is stored (BIN 16 bits) : Head number of the devices of the file register to which data is written (BIN 16 bits) n : Number of words to be written (BIN 16 bits) : Completion bit device (bits) Internal Devices...
INSTRUCTIONS FOR DATA LINK Reference Category Processing Details section Network refresh instructions Section 8.2 Refreshes the specified network module. Section 8.3.1 Reading the QnACPU device data from target station of target network number. Section 8.3.2 Section 8.3.3 Writing data to the QnACPU device of target station of target network number.
Overview QnACPU allows the data link using MELSECNET/10, Ethernet, MELSECNET (II,/B), CC-Link, and serial communication. The instructions for data link are instructions that allow the CPU to read data to the host station from other stations connected to the CC-Link IE controller network, MELSECNET/H, MELSEC- NET/10 or MELSECNET (II,/B).
Page 635
(2) Reading/wring range of data (a) With CC-Link IE controller network, MELSECNET/H and MELSECNET/10, the host station can read/write data not only from/to connected stations in the same network, but also from/to connected stations in the other networks. (1) Reading/writing data from/to connected stations in the same network The network number set to the target station must be the same network number set to the host station.
Page 636
The device of the other station CPU module that reads/writes according to instructions for data link must be specified within the device range applicable to the host station CPU module. Care must be taken when the applicable device range differs between the other station CPU module and the host station CPU module.
Page 637
(b) Arrival confirmation When sending by the QnA link dedicated instructions, 'With/Without arrival confirmation' can be set. (When reading by QnA link dedicated instructions, only 'With arrival confirmation' can be set.) • With arrival confirmation : Instruction is completed when data is written to a specified channel of a specified target station.
Page 638
(4) Network module channels (a) For SEND, RECV, READ, WRITE, REQ, ZNRD, ZNWR, SREAD or SWRITE instruction The network module has eight channels to execute instructions. Eight channels can be used at once, but the same channel cannot be used by multiple instructions.
Page 639
(5) Overview of each instructions The following explains the instructions that can be used for the QnACPU. Channels 1 to 8 are common areas for SEND / RECV / READ / WRITE / REQ / SREAD / SWRITE instructions. Instruction Execution Station Target Station (Host Station) Meaning...
Page 640
Instruction Execution Target Station Station (Host Station) Meaning QCPU Station Type Station Type ACPU QnA(R)CPU Performs "remote RUN/STOP" and "clock data read/write" to other Control station Control station stations. Normal station Normal station Network Network Remote master station Remote master station QnA(R)CPU module module...
Page 641
Instruction Execution Target Station Station (Host Station) Meaning QCPU Station Type Station Type ACPU QnA(R)CPU Reads the buffer memory data of special function module mounted at the remote I/O station. Remote master station Remote I/O station Remote I/O Multiplexed remote master Special function station network Network...
ZCOM Network refresh instructions 8.2.1 Refresh instruction for the designated module (S(P)/J(P)/G(P).ZCOM) ZCOM Q4AR Command J.ZCOM J.ZCOM Command JP.ZCOM JP.ZCOM Command G.ZCOM G.ZCOM Command GP.ZCOM GP.ZCOM Jn : Network No. of host station (BIN 16 bits) Un : Head I/O number of host station network module (BIN 16 bits) Internal Devices Setting R, ZR...
Page 643
ZCOM (3) PLC to PLC network (a) When the scan time for the sequence program of host station is longer than the scan time for the other station, the ZCOM instruction is used to ensure the data reception from the other station. (1) Example of data communications when the ZCOM instruction is not used Control station program...
Page 644
ZCOM (4) Remote I/O network The link refresh of the remote master station is performed by the "END processing" of the CPU module. Since link scan is performed at completion of link refresh, link scan 'synchronizes' with the program of the CPU module. When the ZCOM instruction is used at the remote master station, link refresh is performed at the point of ZCOM instruction execution, and link scan is performed at completion of link refresh.
ZCOM Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the specified network number is not connected to the host station (Error code: 4102) •...
READ QnA Link Dedicated Instruction 8.3.1 Reading word device data from another station (JP/GP.READ) READ Q4AR For MELSECNET/10 or Ethernet Command JP.READ JP.READ Command GP.READ GP.READ Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– ––...
Page 647
READ 1. The READ instruction can be executed only when the target station is a QCPU/ QnACPU. (The READ instruction cannot be executed to the ACPU connected to MELSECNET/10 or Ethernet.) 2. Specify the device of target station CPU module to be read by the READ instruction within the range applicable to the host station CPU module.
Page 648
READ Device Item Setting Data Setting Range Set by With arrival confirmation: Set 1 to bit 0 (b0) (Fixed). Execution type Sets clock data setting status at error completion. 0001 Do not set clock data : Set 0 to bit 7 (b7). User 0081 Error completion type...
Page 649
READ Function (1) The data of the word device that is specified by or later word device of the station connected to MELSECNET/10 or Ethernet specified by the target station network No. ( + 4) and target station number( + 5) of the control data is stored to the device specified by of host station or later device.
Page 650
READ [Operation of host station when READ instruction is executed] END processing END processing END processing END processing Host station program Completion of reading of the Execution of READ instruction device data designated by READ instruction READ instruction Communications directive flag Host station completion device ON at error completion...
Page 651
READ Program Example (1) The following program reads the data D10 to D14 of station No.2 connected to MELSECNET/10 to D200 to D204 of the host station when X0 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number Number of retransmissions...
Page 652
READ For CC-Link or serial communication CC-Link can be used with the master module (A(1S)J61QBT11) of software version J or later. Command GP.READ GP.READ Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– ––...
Page 653
READ Device Item Setting Data Setting Range Set by 0001 User Execution type 0001 : Fixed (With arrival confirmation) Status at completion of instruction is stored. : No errors (normal completion) Completion status System –– Other than 0 : Error code Designates channel used by host station Channel used by host 1 : Use the CH1 side...
Page 654
READ Function (1) The data of the word device that is specified by or later word device of the station specified by master/local station number or special function module station number ( + 6) of the control data is stored to the device specified by of host station or later device.
Page 655
READ [Operation of host station when READ instruction is executed] END processing END processing END processing END processing Host station program Completion of reading of the Execution of READ instruction device data designated by READ instruction READ instruction Communications directive flag Host station completion device ON at error completion...
Page 656
READ Program Example (1) The following program reads the data D10 to D14 of the local station (station No.1) connected to CC-Link to D200 to D204 of the master station when X20 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number...
SREAD 8.3.2 Reading word device data from other station (JP/GP.SREAD) SREAD Q4AR For MELSECNET/10 or Ethernet Command JP.SREAD JP.SREAD Command GP.SREAD GP.SREAD Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used.
Page 658
SREAD 1. The SREAD instruction can be executed only when the target station is the QCPU/QnACPU. (The SREAD instruction cannot be executed at the ACPU connected to MELSECNET/10 or Ethernet.) 2. Specify the device of the target station CPU module to be read by the SREAD instruction within the range applicable to the host station CPU module (Head device number of the target for the reading of the target station CPU...
Page 659
SREAD Device Item Setting Data Setting Range Set by Execution type With arrival confirmation: Set 1 to bit 0 (b0) (Fixed). Sets clock data setting status at error completion. 0001 Do not set clock data: Set 0 to bit 7 (b7). User 0081 Error completion type...
Page 660
SREAD Function (1) The data of the word device that is specified by or later word device of the station connected to MELSECNET/10 or Ethernet specified by the target station network No. ( 4) and target station number ( + 5) of the control data is stored to the device specified by of host station or later device.
Page 661
SREAD (d) Completion device for target station ( ) : Turns ON at END processing of the scan where the transmission of the device data specified by the SREAD instruction is completed, and turns OFF at the next END processing. *11: The communications directive flags for the channels used are as indicated below: Channel No.
Page 662
SREAD Program Example (1) The following program reads the data D10 to D14 of station No.2 connected to MELSECNET/10 to D200 to D204 of the host station when X0 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number Number of retransmissions...
Page 663
SREAD For CC-Link or serial communication CC-Link can be used with the master module (A(1S)J61QBT11) of software version J or later. Command GP.SREAD GP.SREAD Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– ––...
Page 664
SREAD Device Item Setting Data Setting Range Set by 0001 User Execution type 0001 : Fixed (With Arrival confirmation) Status at completion of instruction is stored. : No errors (normal completion) Completion status System –– Other than 0 : Error code Designates channel used by host station Channel used by host 1 : Use the CH1 side...
Page 665
SREAD Function (1) The data of the word device that is specified by or later word device of the station specified by master/local station number or special function module station number ( of the control data is stored to the device specified by of host station or later device.
Page 666
SREAD (d) Completion device for target station ( ): Turns ON at END processing of the scan where the transmission of the device data specified by the SREAD instruction is completed, and turns OFF at the next END processing. *7: The communications directive flags for the channels used are as indicated below: Channel No.
Page 667
SREAD Program Example (1) The following program reads the data D10 to D14 of the local station (station No.1) connected to CC-Link to D200 to D204 of the master station when X20 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number...
WRITE 8.3.3 Writing word device data to other station (JP/GP.WRITE) WRITE Q4AR For MELSECNET/10 or Ethernet Command JP.WRITE JP.WRITE Command GP.WRITE GP.WRITE Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used. *2: T, ST, C, D and W can be used.
Page 669
WRITE 1. The WRITE instruction can be executed only when the target station is a QCPU/QnACPU (The WRITE instruction cannot be executed to the ACPU connected to MELSECNET/10 or Ethernet.) 2. The WRITE instruction can specify 'FF (all stations in target network)' to target station number for the network that consists of QnACPU only.
Page 670
WRITE Device Item Setting Data Setting Range Set by Without arrival confirmation: Set 0 to bit 0 (b0). Execution type With arrival confirmation: Set 1 to bit 0 (b0). 0000 Sets clock data setting status at error completion. 0001 User Do not set clock data: Set 0 to bit 7 (b7).
Page 671
WRITE Function (1) The data of the device specified by or later device of the host station is stored to the word device specified by or later word device of a station connected to MELSECNET/10 or Ethernet specified by the target station network number ( +4) and target station number +5) of the control data.
Page 672
WRITE [Operation of host station when WRITE instruction is executed] END processing END processing END processing END processing Host station program Execution of WRITE instruction Completion of sending of the device data designated by WRITE instruction to the object station WRITE instruction Communications directive flag...
Page 673
WRITE Program Example (1) The following program writes the data D200 to D204 of the host station to D10 to D14 of station No.2 connected to MELSECNET/10 when X0 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number Number of retransmissions...
Page 674
WRITE For CC-Link or serial communication CC-Link can be used with the master module (A(1S)J61QBT11) of software version J or later. Command GP.WRITE GP.WRITE Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– ––...
Page 675
WRITE Device Item Setting Data Setting Range Set by 0000 : Without arrival confirmation 0000 Execution type User 0001 0001 : With arrival confirmation Status at completion of instruction is stored. : No errors (normal completion) System Completion status –– Other than 0 : Error code Designates channel used by host station Channel used by host...
Page 676
WRITE Function (1) The data of the device specified by or later device of the host station is stored to the word device specified by or later word device of a station specified by the master/local station number or the special function module station number ( +6) of the control data.
Page 677
WRITE [Operation of host station when WRITE instruction is executed] END processing END processing END processing END processing Host station program Execution of WRITE instruction Completion of sending of the device data designated by WRITE instruction to the object station WRITE instruction Communications directive flag...
Page 678
WRITE Program Example (1) The following program writes the data D200 to D204 of the master station to D10 to D14 of the local station (station No.1) connected to CC-Link when X20 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number...
SWRITE 8.3.4 Writing word device data to other station (JP/GP.SWRITE) SWRITE Q4AR For MELSECNET/10 or Ethernet Command JP.SWRITE JP.SWRITE Command GP.SWRITE GP.SWRITE Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used.
Page 680
SWRITE 1. The SWRITE instruction can be executed only when the target station is a QCPU/QnACPU. (The SWRITE instruction cannot be executed to the ACPU connected to MELSECNET/10 or Ethernet.) 2. The SWRITE instruction can specify 'FF (all stations in target network)' to target station number for the network that consists of QCPU/QnACPU only.
Page 681
SWRITE Device Item Setting Data Setting Range Set by Without Arrival confirmation : Set 0 to bit 0 (b0). Execution type With Arrival confirmation : Set 1 to bit 0 (b0). 0000 Sets clock data setting status at error completion. 0001 User 0080...
Page 682
SWRITE Function (1) The data of the device specified by or later device of the host station is stored to the word device specified by or later word device of a station connected to MELSECNET/10 or Ethernet specified by the target station network number ( +4) and target station number +5) of the control data.
Page 683
SWRITE (d) Completion device for target station ( ): Turns ON at END processing of the scan where the transmission of the device data specified by the SWRITE instruction is completed, and turns OFF at the next END processing. *10: The communications directive flags for the channels used are as indicated below: Channel No.
Page 684
SWRITE Program Example (1) The following program writes the data D200 to D204 of the host station to D10 to D14 of station No.2 connected to MELSECNET/10 when X0 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number Number of retransmissions...
Page 685
SWRITE For CC-Link or serial communication CC-Link can be used with the master module (A(1S)J61QBT11) of software version J or later. SWRITE Command GP.SWRITE GP.SWRITE Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– ––...
Page 686
SWRITE Device Item Setting Data Setting Range Set by 0000 : Without arrival confirmation 0000 Execution type User 0001 0001 : With arrival confirmation Status at completion of instruction is stored. : No errors (normal completion) System Completion status –– Other than 0 : Error code Designates channel used by host station Channel used by host...
Page 687
SWRITE Function (1) The data of the device specified by or later device of the host station is stored to the word device specified by or later word device of a station specified by the master/local station number or the special function module station number ( +6) of the control data.
Page 688
SWRITE (d) Completion device for target station ( ) : Turns ON at END processing of the scan where the transmission of the device data specified by the SWRITE instruction is completed, and turns OFF at the next END processing. *7: The communications directive flags for the channels used are as indicated below: Channel No.
Page 689
SWRITE Program Example (1) The following program writes the data D200 to D204 of the master station to D10 to D14 of the local station (station No.1) connected to CC-Link when X20 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Target station network number Target station number...
SEND 8.3.5 Sending data to other stations (JP/GP.SEND) SEND Q4AR For MELSECNET/10 or Ethernet Command JP.SEND JP.SEND Command GP.SEND GP.SEND Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used. *2: T, ST, C, D and W can be used.
Page 691
SEND Device Item Setting Data Setting Range Set by Without arrival confirmation : Set 0 to bit 0 (b0). Execution type With arrival confirmation : Set 1 to bit 0 (b0). 0000 Sets clock data setting status at error completion. 0001 User Do not set clock data : Set 0 to bit 7 (b7).
Page 692
SEND Function (1) The data of the device specified by of the host station or later device is stored to the specified channel of the MELSECNET/10 or Ethernet network module that is specified by the target station network number ( +4) and target station number ( +5) of the control data.
Page 693
SEND [Operation of host station when SEND instruction is executed] END processing END processing END processing END processing Host station program Execution of SEND instruction Completion of sending of the device data designated by SEND instruction to the object station SEND instruction Communications directive flag...
Page 694
SEND Program Example (1) The following program sends the data D100 to D103 of the host station connected to MELSECNET/10 to channel 5 of station No. 2 when X100 is turned ON. [Ladder Mode] Sets "With arrival confirmation"/clock data. Channel used by the host station Channel used by the target station Target station network number Target station number...
Page 695
SEND For CC-Link or serial communication CC-Link can be used with the master module (A(1S)J61QBT11) of software version J or later. Command GP.SEND GP.SEND Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used. *2: T, ST, C, D and W can be used.
Page 696
SEND Device Item Setting Data Setting Range Set by 0000 : Without arrival confirmation 0000 Execution type User 0001 0001 : With arrival confirmation Status at completion of instruction is stored. : No errors (normal completion) Completion status System –– Other than 0 : Error code Designates channel used by host station Channel used by host...
Page 697
SEND Function (1) The data of the device specified by of the host station is stored to the specified channel of the module specified by the master/local station number or special function module station number ( +6) of the control data. The completion device specified by turns ON when writing the device data to the target station is completed.
Page 698
SEND [Operation of host station when SEND instruction is executed] END processing END processing END processing END processing Host station program Execution of SEND instruction Completion of sending of the device data designated by SEND instruction to the object station SEND instruction Communications directive flag...
Page 699
SEND Program Example (1) The following program sends the data D100 to D103 of the master station connected to CC-Link to channel 2 of the local station (station No. 1) when X100 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Channel used by the target station Master/local station number...
RECV 8.3.6 Receiving data from other station (JP/GP.RECV) RECV Q4AR For MELSECNET/10 or Ethernet Command JP.RECV JP.RECV Command GP.RECV GP.RECV Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used. *2: T, ST, C, D and W can be used.
Page 701
RECV Device Item Setting Data Setting Range Set by Waits without data (waits for a given time until data is received) Execution type : Set 0 to bit 0 (b0) (fixed) Provides presence/absence of clock data setting at error completion. 0000 User Not to set clock data : Set 0 to bit 7 (b7).
Page 702
RECV Function (1) The data sent by the SEND instruction from a station connected to MELSECNET/10 or Ethernet is stored to the device specified by or later device from the network module of the host station. The completion device specified by turns ON when the read of the device data from the network module is completed.
Page 703
RECV [Operation of host station when RECV instruction is executed] END processing END processing END processing END processing Host station program Execution of RECV instruction Completion of reading of the device data designated by RECV instruction RECV instruction Communications directive flag Host station completion device ON at error completion...
Page 704
RECV Program Example (1) The following program reads the data sent from other station connected to MELSECNET/10 to channel 5 of the host station to D100 or later when X100 is turned ON. [Ladder Mode] Sets clock data. Channel used by the host station Arrival monitoring time (20 sec) Turns M1 ON when X100 turns from OFF to ON.
Page 705
RECV For CC-Link or serial communication CC-Link can be used with the master module (A(1S)J61QBT11) software version J or later. Command GP.RECV GP.RECV Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used. *2: T, ST, C, D and W can be used.
Page 706
RECV Device Item Setting Data Setting Range Set by 0000 User Execution type 0000 : Fixed (Without arrival confirmation) Status at completion of instruction is stored. : No errors (normal completion) Completion status System –– Other than 0 : Error code Specifies channel where data to be read is stored.
Page 707
RECV Function (1) The data sent by the SEND instruction from a station connected to CC-Link or serial communication module is stored into the area starting from the device designated by from the network module of the host station. The completion device specified by turns ON when reading the device data from the network module is completed.
Page 708
RECV [Operation of host station when RECV instruction is executed] END processing END processing END processing END processing Host station program Execution of RECV instruction Completion of reading of the device data designated by RECV instruction RECV instruction Communications directive flag Host station completion device ON at error completion...
Page 709
8.3.7 Transient requests from other stations (reading/writing clock data, remote RUN/STOP) (JP/GP.REQ) Q4AR For MELSECNET/10 or Ethernet Command JP.REQ JP.REQ Command GP.REQ GP.REQ Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used.
Page 710
Device Item Setting Data Setting Range Set by Execution type With arrival confirmation: Set 1 to bit 0 (b0) and bit 4 (b4) (fixed). Sets clock data setting status at error completion. 0011 Do not set clock data : Set 0 to bit 7 (b7). User 0091 Error completion type...
Page 711
[Request data/Response data] (1)During reading/writing clock data 1) Request data Reading Writing Device Item Meaning Clock Data Clock Data 0001 : Reading clock data Request type 0011 : Writing clock data (When station number is specified by 0031 : Writing clock data (When all stations or group is specified by 0002 : Reading clock data Sub-request type...
Page 712
2) Response data If "When all stations or group is specified (81 to 89 , FFH )" is set at the target station number + 5), the response data are not stored. Reading Writing Device Item Meaning Clock Data Clock Data 0081 : Reading clock data Request type...
(2) During remote RUN/STOP 1) Request data Remote Remote Device Item Meaning STOP 0010 : (When station number is specified by Request type 0030 : (When all stations or group is specified by 0001 : Remote RUN Sub-request type 0002 : Remote STOP Specifies whether or not to execute a remote RUN forcibly.
Page 714
Function (1) The request data stored in the device specified by or later of the station connected to MELSECNET/10 or Ethernet specified by the target station network number ( + 4) and target station number ( + 5) of the control data is sent to execute a service request. The completion device specified by turns ON when the device data request from the target station is completed.
Page 715
(c) Completion status display device ( +1) : Turns ON/OFF depending on the completion status of the REQ instruction. •Normal completion : Stays OFF, with no changes. •Error completion : Turns ON at the END processing for the scan where the REQ instruction is completed, and turns OFF at the next END...
Page 716
Program Example (1) The following program sets the QnACPU of station No.2 in the network No. 1 connected to the MELSECNET/10 to "STOP" when X100 is turned ON. [Ladder Mode] Sets "With arrival confirmation"/clock data. Channel used by the host station Target station network number Target station number Number of retransmissions...
Page 717
For CC-Link or serial communication CC-Link can be used with the master module (A(1S)J61QBT11) of software version J or later. Command GP.REQ GP.REQ Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used.
Page 718
Device Item Setting Data Setting Range Set by Execution type 0011 : Fixed (With arrival confirmation) 0011 User Status at completion of instruction is stored. : No errors (normal completion) System Completion status –– Other than 0 : Error code Designates channel used by host station Channel used by host 1 : Use the CH1 side...
Page 719
[Request data/Response data] (1) During reading/writing clock data 1) Request data Reading Writing Device Item Meaning Clock Data Clock Data 0001 : Reading clock data Request type 0011 : Writing clock data 0002 : Reading clock data Sub-request type 0001 : Writing clock data (1) Change pattern (bits 0 to 7) Specifies which item to be written from the high-order byte bit of...
Page 720
(2) During remote RUN/STOP 1) Request data Remote Remote Device Item Meaning STOP Request type 0010 0001 : Remote RUN Sub-request type 0002 : Remote STOP Specifies whether or not to execute a remote RUN forcibly. 0001 : Do not force run Mode 0003 : Force run (setting during remote STOP)
Page 721
Function (1) The request data stored in the device specified by or later device of the station specified by the master/local station number or the special function module station number ( +6) of the control data is sent for a service request. The completion device specified by turns ON when the device data request from the target station is completed.
Page 722
[Operation of host station when REQ instruction is executed] END processing END processing END processing END processing Host station program Execution of REQ instruction Completion of sending of the request data designated by REQ instruction REQ instruction Communications directive flag Host station completion device ON at error completion...
Page 723
Program Example (1) The following program reads the clock data of the QnACPU of the local station (station No. 1) connected to CC-Link when X100 is turned ON. [Ladder Mode] Sets "With arrival confirmation." Channel used by the host station Master/local station number Number of retransmissions Arrival monitoring time (20 sec)
Page 724
ZNFR 8.3.8 Reading data from special function module of remote I/O station (JP/GP.ZNFR) ZNFR Q4AR Command JP.ZNFR JP.ZNFR Command GP.ZNFR GP.ZNFR Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used. *2: T, ST, C, D and W can be used.
Page 725
ZNFR Device Item Setting Data Setting Range Set by Execution type With Arrival confirmation: Set 1 to bit 0 (b0) (Fixed). Sets clock data setting status at error completion. 0001 Do not set clock data : Set 0 to bit 7 (b7). User 0081 Error completion type...
Page 726
ZNFR Function (1) The buffer memory data of the special function module at the MELSECNET/10 remote I/O station specified by the target station number ( +5) and the sequence number in the station +6) of the control data is stored to the device specified by or later device.
Page 727
ZNFR (c) Cyclic transmission status at each station (SW74 to 77) : The cyclic transmission status of all stations in the network is stored in the form of bit information, and when the station has cyclic transmission error, the corresponding bit is turned ON.
Page 728
ZNFR Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the control data contents are not within the setting range (Error code: 4100) •...
ZNTO 8.3.9 Writing data to special function module of remote I/O station (JP/GP.ZNTO) ZNTO Q4AR Command JP.ZNTO JP.ZNTO Command GP.ZNTO GP.ZNTO Internal Devices Setting R, ZR Constants Other Data Word Word –– –– –– –– –– –– –– –– *1: X, Y, M, L, F, V and B can be used. *2: T, ST, C, D and W can be used.
Page 730
ZNTO Device Item Setting Data Setting Range Set by Execution type With arrival confirmation: Set 1 to bit 0 (b0) (Fixed). Sets clock data setting status at error completion. 0001 User Do not set clock data : Set 0 to bit 7 (b7). 0081 Error completion type Set clock data...
Page 731
ZNTO Function (1) The data stored in the area starting from the device designated by is written to the buffer memory of the special function module at the MELSECNET/10 remote I/O station designated by the target station number ( + 5) and the sequence number n in the station + 6) of the control data.
Page 732
ZNTO [Operation of host station when ZNTO instruction is executed] END processing END processing END processing END processing Host station program Completion of sending of the Execution of ZNTO instruction device data designated by ZNTO instruction to the object station ZNTO instruction Read/write request signal...
Page 733
ZNTO Program Example (1) The following program writes the data W108 to W10A of the master station to the buffer memory addresses 10 to 12 of the first special function module of remote I/O station No.1 of network No.1. When using the programs below in actual applications, create the interlock circuit referring to the description in Section 8.1.
ZNRD A-series compatible link instructions 8.4.1 Reading device data from other stations (MELSECNET/10, Ethernet) (J(P).ZNRD) ZNRD Q4AR Command J.ZNRD J.ZNRD Command JP.ZNRD JP.ZNRD Jn : Target network number (BIN 16 bits) n1 : Target station number (BIN 16 bits) : Head device of target station where data to be read is stored (Device name) : Head device of host station where the read data is stored (Device name) n2 : Receive data length (Device name) : Device that turns ON for 1 scan by the instruction completion (bits)
Page 735
ZNRD Function (1) The data of the device specified by or later device of the station connected to the network number specified by Jn and n1 is read into the device specified by or later device in MELSECNET/10 or Ethernet data link system. The completion device specified by turns ON for 1 scan when reading the device data from the target station is completed.
Page 736
ZNRD (9) The execution status of the ZNRD instruction and its normal/error completion can be checked by the following: (a) ZNRD directive flag (SB30) : Turns ON at execution of the ZNRD instruction, and turns OFF at the END processing of the scan where reading is completed.
Page 737
ZNRD Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the n2 points from the device specified by exceeds the final device number of the relevant device range.
Page 738
ZNRD 8.4.2 Reading device data from local stations (MELSECNET) (J(P).ZNRD) ZNRD Q4AR Command J.ZNRD J.ZNRD Command JP.ZNRD JP.ZNRD Jn : Target network number [Fixed to 0 (J0)] (BIN 16 bits) n1 : Target local station number(BIN 16 bits) : Head device of local station where the data to be read is stored (Device name) : Head device of host station where the read data is stored (Device name) n2 : Receive data length (Device name) : Device that turns ON for 1 scan by the instruction completion (bits)
Page 739
ZNRD Function (1) Reads the data two points from the word device designated by of the local station designated by n1 in the MELSECNET (II,/B) and stores it into the area starting from the device designated by at the host station. The completion device designated by turns ON for one scan when reading the device data from the local station is completed.
Page 740
ZNRD (8) The normal/error completion of the ZNRD instruction can be checked by the following: (a) Host station completion device ( : Turns ON at the END processing of scan where transmission by the ZNRD instruction is completed, and turns OFF at the next END processing.
Page 741
ZNRD Program Example (1) The following program reads the data D10 to D14 of the local station No.1 to D200 to D204 of the master station when X20 of the master station is turned ON. [Ladder Mode] Turns M1 ON when X20 turns from OFF to ON. Reads out the present value at D10 to D14 of the local station No.1 to D200 to D204 of the master station.
ZNWR 8.4.3 Writing device data to other stations (MELSECNET/10 and Ethernet) (J(P).ZNWR) ZNWR Q4AR Command J.ZNWR J.Z NWR Command JP.ZNWR JP.ZNWR Jn : Target network number (BIN 16 bits) n1 : Target station number (BIN 16 bits) : Head device of target station where the data is written (Device name) : Head device of host station where the data to be written is stored (Device name) n2 : Number of write points (Device name) : Device that turns ON for 1 scan by the instruction completion (bits)
Page 743
ZNWR Function (1) The data of n2 points from the word device specified by of the host station is stored into the area starting from the device specified by of the station connected to the network number specified by Jn and n1 in the MELSECNET/10 or Ethernet data link system. The completion device specified by turns ON when writing the device data from the target station is completed.
Page 744
ZNWR (8) The execution status of the ZNWR instruction and its normal/error completion can be checked by the following: (a) ZNWR directive flag (SB32) : Turns ON at the execution of the ZNWR instruction and turns OFF at END processing of the scan where writing is completed.
Page 745
ZNWR Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the n2 points from the device specified by exceeds the final device number of the relevant device range.
Page 746
ZNWR 8.4.4 Writing device data to local stations (MELSECNET) (J(P).ZNWR) ZNWR Q4AR Command J.ZNWR J.Z NWR Command JP.ZNWR JP.ZNWR Jn : Target network number [Fixed to 0 (J0)] (BIN 16 bits) n1 : Target local station number(BIN 16 bits) : Head device of the local station where the data is written (Device name) : Head device of host station where the data to be written is stored (Device name) n2 : Send data length (Device name) : Device that turns ON for 1 scan by the instruction completion (bits)
Page 747
ZNWR Function (1) The data n2 points from the word device of host station designated by is stored to the device designated by or later device of the local station designated by n1 in the MELSECNET (II,/B). The completion device specified by turns ON for one scan when writing the device data to the local station is completed.
Page 748
ZNWR (8) The normal/error completion of the ZNWR instruction can be checked by the following: (a) Host station completion device ( : Turns ON at the END processing of the scan where transmission by the ZNWR instruction is completed, and turns OFF at the next END processing.
Page 749
ZNWR Program Example (1) The following program writes the data D300 to D303 of the master station to D50 to D53 of the local station No.1 when X20 of the master station is turned ON. [Ladder Mode] Turns M1 ON when X20 turns from OFF to ON. Writes the present value at D300 to D303 of the master station to D50 to D53 of the local station No.1.
RFRP 8.4.5 Reading data from special function module of remote I/O station (MELSECNET) (G(P).RFRP) RFRP Q4AR Command G.RFRP G.RFRP Command GP.RFRP GP.RFRP Un : Head I/O number of the master station allocated to the special function module that reads the data (BIN 16 bits) n1 : Head number of the buffer memory of the special function module where the data to be read is stored (BIN 16 bits) : Head number of host station link register that stores the read data (Device name) n2 : Receive data length (BIN 16 bits)
Page 751
RFRP Function (1) Stores the data n2 points from the buffer memory designated by n1 of the remote I/O station special function module allocated to the I/O number designated by Un into the area starting from the link device designated by of the host station (master station) in the MELSECNET (II,/B).
Page 752
RFRP (7) Even when conducting only reading from the special function module using the RFRP instruction, it is necessary to set the "master station remote I/O station" link register that the system uses at the network parameters. An area starting from the first link register set by the parameter "master station remote I/O station"...
Page 753
RFRP Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the I/O number specified by Un is not that of a remote I/O station. (Error code: 4102) •...
RTOP 8.4.6 Writing data to special function module of remote I/O station (MELSECNET) (G(P).RTOP) RTOP Q4AR Command G.RTOP G.RTOP Command GP.RTOP GP.RTOP Un : Head I/O number of master station allocated to special function module that writes the data (BIN 16 bits) n1 : Head number of the buffer memory of special function module where the data to be written is stored (BIN 16 bits) : Head number of host station link registers where data to be written is stored (Device name) n2 : Send data length (BIN 16 bits)
Page 755
RTOP Function (1) The data n2 points from the host station (master station) specified by is stored into the area starting from the buffer memory specified by n1 of the special function module of the remote I/O station allocated to the I/O number specified by Un in the MELSECNET (II,/B). When writing device data to the remote I/O station is completed, the completion device specified by turns ON for one scan.
Page 756
RTOP (6) The link register that can be specified by is in the range set for the network parameter "master station remote I/O station" . The area starting from the first link register set by the parameter "master station remote I/O station" to the number of special function modules mounted to the corresponding remote I/O station is used by the system.
Page 757
RTOP Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the I/O number specified by Un is not that of a remote I/O station. (Error code: 4102) •...
RTREAD Reading/Writing Routing Information 8.5.1 Reading routing information (S(P)/Z(P).RTREAD) RTREAD Q4AR Command Z.RTREAD Z.RTREAD Command ZP.RTREAD ZP.RTREAD : Transfer destination network No. (1 to 239) (BIN 16 bits) : Head number of the devices that stores the read data (Device name) Internal Devices Setting Constants...
Page 759
RTREAD Program Example (1) The following program reads the routing information for the network number specified by D0 when X0 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] [Content of routing parameter setting] Transfer Relay network Relay station Routing station destination number...
RTWRITE 8.5.2 Registering routing information (S(P)/Z(P).RTWRITE) RTWRITE Q4AR Command Z.RTWRITE Z.RTWRITE Command ZP.RTWRITE ZP.RTWRITE : Transfer destination network No. (1 to 239) (BIN 16 bits) : Head number of the devices where the data to be written is stored (Device name) Internal Devices Setting Constants...
Page 761
RTWRITE Program Example (1) The following program writes the routing information specified by D1 to D3 to the network module of the network number specified by D0 when X0 is turned ON. [Ladder Mode] [List Mode] Step Instruction Device [Operation] [Content of routing parameter setting] Transfer Relay station...
REDUNDANT SYSTEM INSTRUCTIONS (FOR Q4ARCPU) Reference Category Processing Details section Designates the operation mode at (S1) whether to clear the Operation mode setting Section 9.1 Q4ARCPU devices before start-up or not to clear them before instruction during CPU start-up start-up when the power supply is turned ON for CPU startup. Designates the operation mode at (S1) whether to clear the Operation mode setting Q4ARCPU devices before start-up or not to clear them before...
S.STMODE Operation Mode Setting Instruction during CPU Start up (S.STMODE) S.STMODE Q4AR Command S.STMODE S.STMODE : Operation mode setting (BIN 16 bits) : Initial start switch power failure time (BIN 16 bits) Internal Devices Setting Constants R, ZR Other Data K, H Word Word...
Page 765
S.STMODE Operation Error (1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the value that exceeds the specification allowable range is specified (Error code: 4104) Program Example (1) This program starts up the CPU module in the hot start mode and sets the switching power failure time to 10s.
S.CGMODE Operation Mode Setting Instruction at CPU Switching (S.CGMODE) S.CGMODE Q4AR Command S.CGMODE S.CGMODE : Operation mode setting (BIN 16 bits) Internal Devices Setting Constants R, ZR Other Data K, H Word Word –– –– Function (1) When control is switched from the control system to the standby system, this instruction specifies whether the Q4ARCPU devices will be cleared at switching or not cleared at switching.
Page 767
S.CGMODE Program Example (1) This program places a CPU module in hot start mode when the CPU module is switched from the control system to the standby system. [Ladder Mode] [List Mode] Step Instruction Device...
S.TRUCK Data Tracking Instruction (S.TRUCK) S.TRUCK Q4AR Command S.TRUCK S.TRUCK : Head device of parameter block (BIN 16 bits) Internal Devices Setting R, ZR Constants Other Data Word Word –– –– *1: Latched devices only Function (1) The Q4ARCPU performs device memory tracking following the parameter block data stored in the devices from that designated in during the END processing of every scan...
Page 769
S.TRUCK (4) The parameter block has the following configuration. Head device number designated Total number of parameter by the data tracking instruction blocks (n) Number of settings in block 1 (m1) Number of settings in block 2 (m2) Details of block 1 device setting area +(n-1) Number of settings in block n (mn)
Page 770
S.TRUCK 2) The number of device points sets the number of devices to be tracked. The setting is done in decimal or hexadecimal. The bit devices are set in multiples of 3) Head device number sets the device memory head number. The setting is done in decimal or hexadecimal.
Page 771
S.TRUCK Operation Error (1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into SD0. • When the file for the file register does not exist even when file register R is designated in the parameter block.
S.SPREF Buffer Memory Batch Refresh Instruction (S.SPREF) S.SPREF Q4AR Command S.SPREF S.SPREF : Head device of parameter block (BIN 16 bits) Internal Devices Setting R, ZR Constants Other Data Word Word –– –– *1: Latched devices only Function (1) The special function module buffer memory contents are batch read/written in accordance with the contents of the parameter block data stored in the area starting from the device designated by Power supply...
Page 773
S.SPREF (2) Set the parameter block before this instruction is executed. The parameter block is composed of multiple blocks. This instruction is executed after the special relay SM1520 to SM1583 is set for the block to be executed (special relay is turned ON).
Page 774
S.SPREF (c) Block n device setting area This is used to set the type, number of points, and head device number for the device memory and buffer memory of the special function module to be batch refreshed. (1) The module head I/O number sets the head I/O number for the target special function module.
Page 775
S.SPREF Program Example (1) This program refreshes the buffer memory following the Block 1 and Block 2 of the parameter block stored in the area starting from R100. [Ladder Mode] [List Mode] Step Instruction Device (2) This is an example of parameter blocks for when the X/Y20 special function module buffer memory 0 to 3, 10 to 11 contents and the X/Y100 special function module buffer memory 110 to 119 contents are refreshed.
Alphanumeric characters in the parentheses of the titles indicate the special register numbers where each information is stored. (b) Compatible CPU : Indicates the QnA series and Q2ASCPU series. Each CPU module : Indicates the relevant specific CPU module. model name...
• Q series: QCPU User’s Manual (Hardware design, CPU module 4000 to 4FFF Maintenance and Inspection) • QnA series: User’s manual of the used CPU module Serial communication 7000 to 7FFF Serial Communication User’s Manual, etc. module, etc. CC-Link System Master/Local Module User’s...
• Hardware fault 1000 same error is displayed again, this suggests a ■Collateral informationmmon CPU module hardware fault.(Contact your local • Common Information:– Mitsubishi representative.) • Individual Information:– ■Diagnostic Timing • Always [END NOT EXECUTE] Entire program was executed without the execution of an END instruction.
Page 781
CPU Status: • At power ON/At reset This suggests a CPU module hardware fault. (Con- Stop tact your local Mitsubishi representative.) [OPE. CIRCUIT ERR.] The operation circuit for index modification in the CPU module does not operate normally. ■Collateral informationmmon 1203 •...
Page 782
ERR.: function module that was accessed is experiencing ber of the special function module that corresponds Flicker 1401 a hardware fault. (Contact your local Mitsubishi rep- to the common information is stored.) resentative.) ■Collateral informationmmon CPU Status: • Common Information:Module No.(Slot No.) Stop •...
Page 783
The CPU module, base unit and/or the special (When an error is generated, the program error function module that was accessed is experiencing location corresponding to the individual information 1402 a hardware fault.(Contact your local Mitsubishi rep- is stored.) ■Collateral informationmmon resentative.) • Common Information:Module No.(Slot No.) •...
Page 784
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [DUAL DC DOWN 5V] The power supply voltage (100 to 240VAC) of either of the two power supply modules on the RUN: power supply duplexing extension base unit dropped to or below 85% of the rated voltage.
10.1.4 Error code list (2000 to 2999) The following shows the error messages from the error code 2000 to 2999, the contents and causes of the errors, and the corrective actions for the errors. Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status...
Page 786
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [SP. UNIT LAY ERR.] At the MELSECNET/MINI auto refresh network parameter settings, the module allocation that was Reset the network parameter MELSECNET/MINI set is different from the actual module models at auto refresh unit module allocation setting so that it the station numbers in the link system.
Page 787
Therefore, [SP. UNIT ERROR] change the faulty module. Alternatively, contact • The location designated by a link direct device RUN: your local Mitsubishi representative. Off/On ) is not a network module. ERR.: • The I/O module (special function module) was...
Page 788
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status RUN: [SP. UNIT ERROR] Data of special function module to be simulated is Off/On Read the individual information of the error using a not set in the simulation date. ERR.: peripheral device, and check the special function ■Collateral informationmmon...
Page 789
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [FILE SET ERROR] • Read the individual information of the error using The file specified by parameters cannot be made. ■Collateral informationmmon the peripheral device, check to be sure that the •...
Page 790
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [CAN'T EXE. PRG.] • Read the common information of the error using • There is a program file that uses a device that is out of the range set in the PLC parameter device the peripheral device, check to be sure that the parameter device allocation setting and the pro- setting.
• Common Information:File name/Drive name • If the same error occurs, it is thought to be a RUN: • Individual Information:Parameter number hardware error. (Contact your local Mitsubishi ■Diagnostic Timing representative.) ERR.: • At power ON/At reset/STOP RUN/...
Page 792
• Correct and write the network parameters. ERR.: ten. Flicker • If the error occurs after correction, it suggests a ■Collateral informationmmon 3100 hardware fault. (Contact your local Mitsubishi • Common Information:File name/Drive name CPU Status: representative.) • Individual Information:Parameter number Stop ■Diagnostic Timing •...
Page 793
• Correct and write the network parameters. • Ethernet (parameter + dedicated instruction) is • If the error occurs after correction, it suggests a set to more than five. hardware fault. (Contact your local Mitsubishi ■Collateral informationmmon representative.) • Common Information:File name/Drive name •...
Page 794
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [SFC PARA. ERROR] The parameter setting is illegal. • Though Block 0 was set to "Automatic start" in the SFC setting of the PLC parameter dialog box, Block 0 does not exist.
10.1.6 Error code list (4000 to 4999) The following shows the error messages from the error code 4000 to 4999, the contents and causes of the errors, and the corrective actions for the errors. Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status...
Page 796
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [MISSING END INS.] There is no END (FEND) instruction in the pro- gram. ■Collateral informationmmon 4010 • Common Information:Program error location • Individual Information:– ■Diagnostic Timing • At power ON/At reset/STOP [CAN'T SET(P)] The total number of internal file pointers used by the program exceeds the number of internal file...
Page 797
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [OPERATION ERROR] • The network No. or station No. specified for the dedicated instruction is wrong. • The link direct device (J \ ) setting is incorrect. •...
Page 798
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [FOR NEXT ERROR] A NEXT instruction was executed although no FOR instruction has been executed. Read the common information of the error using Alternatively, there are more NEXT instructions the peripheral device, check error step correspond- than FOR instructions.
Page 799
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [CAN'T EXECUTE(I)] Though an interrupt input occurred, the corre- sponding interrupt pointer does not exist. ■Collateral informationmmon 4220 • Common Information:Program error location • Individual Information:– ■Diagnostic Timing •...
Page 800
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [EXTEND INST. ERR.] The designation of an AD57/AD58 control instruc- tion was wrong. Read the common information of the error using the peripheral device, check error step correspond- ■Collateral informationmmon 4301 •...
Page 801
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [SFCP. FORMAT ERR.] The numbers of BLOCK and BEND instructions in an SFC program are not equal. ■Collateral informationmmon 4500 • Common Information:Program error location • Individual Information:– ■Diagnostic Timing •...
Page 802
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [SFCP. OPE. ERROR] Exceeds device range that can be designated by the SFC program. ■Collateral informationmmon 4601 RUN: • Common Information:Program error location Off/On • Individual Information:– ERR.: ■Diagnostic Timing Read common information of the error using the...
Page 803
Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status [STEP EXE. ERROR] Startup was executed at a block in the SFC pro- Read common information of the error using the gram that was already started up. ■Collateral informationmmon peripheral device, check error step corresponding 4630...
10.1.7 Error code list (5000 to 5999) The following shows the error messages from the error code 5000 to 5999, the contents and causes of the errors, and the corrective actions for the errors. Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status...
Hardware fault of the CPU module. (Please contact (This can be detected from the control system or your local nearest Mitsubishi or sales representa- ERR.: standby system of the redundant system.) tive, explaining a detailed description of the prob-...
Page 806
(This can be detected from the control system of the redundant system.) Continue This is a bus switching module hardware fault. 6221 ■Collateral informationmmon (Contact your local Mitsubishi representative.) • Common Information:Reason(s) for system switching • Individual Information:– ■Diagnostic Timing • At switching request [DUAL SYS.
10.1.9 Error code list (7000 to 10000) The following shows the error messages from the error code 7000 to 10000, the contents and causes of the errors, and the corrective actions for the errors. Error LED Status Corresponding Error Contents and Cause Corrective Action Code CPU Status...
10.2 Canceling of Errors Q series CPU module can perform the cancel operation for errors only when the errors allow the CPU module to continue its operation. To cancel the errors, follow the steps shown below. 1) Eliminate the cause of the error. 2) Store the error code to be canceled in the special register SD50.
Appendix 1 OPERATION PROCESSING TIME Appendix 1.1 Definition (1) Processing time taken by the QCPU/QnA(R)CPU is the total of the following processing times. • Total of each instruction processing time • END processing time (including I/O refresh time) • Processing time for the function that increases the scan time (2) Instruction processing time This is the total of processing time of each instruction shown in Appendix 1.1.
Appendix 1.2 Operation Processing Time of QnACPU The processing time for the individual instructions are shown in the table on the following pages. Operation processing time can vary substantially depending on the nature of the sources and destinations of the instructions, and the values contained in the following tables should therefore be taken as a set of general guidelines to processing times rather than as being strictly accurate.
Page 812
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR (OFF OFF) When not 0.40 0.30 0.15 changed (OFF When changed 0.40 0.30 0.15 OFF) When OFF When displayed When Display completed When not executed After time up When executed When added When not executed...
Page 813
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR When not executed 0.90 0.45 SFTP When executed 0.60 0.45 0.23 –– 0.20 0.15 0.075 –– Error check performed 1643 1236 No error check performed FEND (• Battery check) 1106 (•...
Page 814
(2) Basic instructions The processing time when the instruction is not executed is calculated as follows: Q2ACPU (S1), Q2ASCPU (S1) ···················0.20 (No. of steps for each instruction + 1) µs Q3ACPU ·····················································0.15 (No. of steps for each instruction + 1) µs Q2ASHCPU (S1), Q4ACPU, Q4ARCPU ····0.075 (No.
Page 815
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR When not executed 0.55 OR < = In conductive status When executed In non-conductive status In conductive status LD < In non-conductive status When not executed 0.55 In conductive status AND <...
Page 816
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR In conductive status LDD < In non-conductive status When not executed 0.55 In conductive status ANDD < When executed In non-conductive status When not executed 0.55 In conductive status ORD <...
Page 817
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR Single In conductive status –– –– –– precision In non-conductive status –– –– –– LDE<> Double In conductive status precision In non-conductive status When not executed 0.55 –– –– ––...
Page 818
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR When not executed 0.55 –– –– –– Single When In conductive status –– –– –– precision executed In non-conductive status –– –– –– ORE> When not executed 0.55 0.55 Double When In conductive status...
Page 819
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR When not executed 0.55 –– –– –– Single In conductive status –– –– –– When precision executed In non-conductive status –– –– –– ANDE< When not executed 0.55 0.55 Double In conductive status When...
Page 820
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR When not executed 0.55 –– –– –– Single In conductive status When –– –– –– precision executed In non-conductive status –– –– –– ORE>= When not executed 0.55 0.55 Double In conductive status When...
Page 821
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q3A Q4A, Q2ASH Q4AR When not executed 0.55 AND$ > In conductive status When executed In non-conductive status When not executed 0.55 In conductive status OR$ > When executed In non-conductive status In conductive status LD$ <...
Page 822
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR When executed S1 S2 When executed S1 S2 When executed S1 S2 When executed S1 S2 When executed S1 S2 When executed S1 S2 When executed D - P S1 S2 When executed D - P...
Page 823
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR S1 S2 –– S1 S2 DB * S1 S2 –– DB * P S1 S2 S1 S2 –– DB/P S1 S2 –– –– –– = 0, Single precision –– ––...
Page 825
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR –– DBLP WORD –– WORDP –– GRYP DGRY –– DGRYP GBIN –– GBINP DGBIN –– DGBINP –– NEGP DNEG –– DNEGP ENEG –– ENEGP n = 1 BKBCD n = 96 BKBCDP n = 1 BKBIN...
Page 826
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR n = 1 BMOV n = 96 BMOVP n = 1 FMOV n = 96 FMOVP XCHP –– DXCH DXCHP n = 1 BXCH D1 D2 n = 96 BXCHP D1 D2 SWAP...
Page 827
(3) Application instructions The processing time when the instruction is not executed is calculated as follows: Q2ACPU (S1), Q2ASCPU (S1) ·················· 0.20 (No. of steps for each instruction + 1) µs Q3ACPU ····················································· 0.15 (No. of steps for each instruction + 1) µs Q2ASHCPU (S1), Q4ACPU, Q4ARCPU ····0.075 (No.
Page 828
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR WXNR When executed WXNRP WXNR S1 S2 When executed WXNRP S1 S2 DNXR When executed DNXRP DNXR S1 S2 When executed DNXRP S1 S2 n = 1 BKNXOR S1 S2 n = 96 BKNXORP S1 S2...
Page 829
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR n = 1 BSET n = 15 BSETP n = 1 BRST n = 15 BRSTP TEST S1 S2 –– TESTP S1 S2 DTEST S1 S2 –– DTESTP S1 S2 n = 1 BKRST n = 96...
Page 830
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR n = 1 n = 96 MAXP n = 1 n = 96 MINP n = 1 DMAX n = 96 DMAXP n = 1 DMIN n = 96 DMINP n = 1 SORT...
Page 831
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR –– –– IXEND –– Number of contacts 1 IXDEV + IXSET Number of contacts 14 Number of data points 0 FIFW FIFWP Number of data points 96 Number of data points 1 FIFR FIFRP Number of data points 96...
Page 832
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR When displayed LEDC Display completed No display no display LEDR LED instruction execution no display CHKST –– 1 contact no error 150 contact no error 4232 3182 1591 1 contact error CHKCIR 10 steps All internal devices...
Page 836
Processing Time (µs) Instruction Condition (Device) Q2A, Q2AS Q4A, Q2ASH Q4AR No digit increase DATE+ DATE+P Digit increase No digit increase DATE - DATE - P Digit increase SECOND –– SECONDP HOUR –– HOURP 1 character 32 characters Initial time PKEY No reception PSTOP...
Appendix 2.1.4 Timer comparison TableApp.2.4 Timer Comparison Function QCPU/QnACPU AnUCPU AnACPU AnNCPU 100ms (default value) Change of measurement unit at the parameter is enabled. Measurement Fixed at 100ms QCPU : 1 to 1000ms (1ms unit) unit Low speed timer QnACPU : 10 to 1000ms (10ms unit) Designation K100 K100...
Example • For timers T0 to T2, the program is created in the order the timer operates later. T2 timer starts measurement from the next scan after turning the contact of T1 ON. T1 timer starts measurement from the next scan after turning the contact of T0 ON. T0 timer starts measurement when X0 is turned ON.
Appendix 2.1.7 Instructions whose designation format has been changed (Except dedicated instructions for AnACPU and AnUCPU) Because the QnACPU does not have accumulators (A0, A1), the format of AnUCPU, AnACPU and AnNCPU instructions that used accumulators has been changed. TableApp.2.7 Instructions Whose Expression Has Changed QnACPU AnUCPU/AnACPU/AnNCPU Function...
Appendix 2.1.8 AnACPU and AnUCPU dedicated instructions (1) Method of expression of dedicated instructions Dedicated instructions based on the LEDA, LEDB, LEDC, SUB, and LEDR instructions, that are used with the AnACPU or AnUCPU have been changed for the same format as the basic instructions and the application instructions for the QnACPU.
Indicates the corresponding CPU module type name. Corresponding : Indicates the QnA series and Q2ASCPU series. Each CPU module model name: Indicates the relevant specific CPU module. (Example: Q4AR, Q3A) For details on the following items, refer to the following manuals: •...
(1) Diagnostic Information TableApp.3.2 Special relay Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) • Turns ON if an error occurs as a result of diagnosis. (Includes when an annunciator is ON, and when an OFF : No error Diagnostic errors error is detected with CHK instruction) S (Error)
(2) System information TableApp.3.3 Special relay Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) • When this relay goes from OFF to ON, the LEDs SM202 LED OFF command ON : LED OFF corresponding to the individual bits at SD202 go off SM203 STOP contact STOP status...
Page 847
TableApp.3.3 Special relay Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) • Initial value is set at the same value as SM320. OFF : SFC program not (Goes ON automatically if SFC program is present.) Start/stop SFC executed (stop) •...
Page 848
(3) System clocks/counters TableApp.3.4 Special relay Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) S (Every END SM400 Always ON • Normally is ON M9036 processing) S (Every END SM401 Always OFF • Normally is OFF M9037 processing) •...
(4) Scan information TableApp.3.5 Special relay Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU OFF : Completed or not Low speed program • Goes ON when low speed execution type program is S (Every END SM510 executed execution flag executed.
Page 850
(6) Instruction-Related Special Relays TableApp.3.7 Special relay Corres- Set by ponding Corresponding Number Name Meaning Explanation ACPU (When Set) OFF : Carry OFF S (Instruction SM700 Carry flag • Carry flag used in application instruction M9012 ON : Carry ON execution) Switching the number of Number of output...
Page 851
(7) Debug TableApp.3.8 Special relay Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) OFF : Not ready Sampling trace SM800 • Goes ON when sampling trace is ready S (Status change) preparation ON : Ready OFF : Suspend •...
Page 852
(9) A to Q/QnA conversion correspondences Special relays SM1000 to SM1255 are the relays which correspond to ACPU special relays M9000 to M9255 after A to QnA conversion. These special relays are all set by the system, and cannot be set by the user program. To turn them ON/OFF by the user program, change the special relays in the program into those of QnACPU.
Page 853
TableApp.3.11 Special relay ACPU Special Special Corresponding Special Relay after Relay for Name Meaning Details Relay Conversion Modification • Turns ON if an instantaneous power failure of within 20ms occurs during use of the AC power supply module. OFF : AC DOWN not •...
Page 854
TableApp.3.11 Special relay ACPU Special Special Corresponding Special Relay after Relay for Name Meaning Details Relay Conversion Modification • Alternates between ON and OFF according to the seconds specified at SD414. (Default: n = 30) 2n minute clock(1 • Not turned on or off per scan but turned on and off even –...
Page 855
TableApp.3.11 Special relay ACPU Special Special Corresponding Special Relay after Relay for Name Meaning Details Relay Conversion Modification OFF : Other than when P, I Main side P, I set set being requested M9056 SM1056 request ON : P, I set being •...
Page 856
TableApp.3.11 Special relay ACPU Special Special Corresponding Special Relay after Relay for Name Meaning Details Relay Conversion Modification OFF : Continuous transition Presence/absence • Set whether continuous transition will be performed for the not effective M9103 SM1103 SM323 of continuous block where the "continuous transition bit"...
Page 857
TableApp.3.11 Special relay ACPU Special Special Corresponding Special Relay after Relay for Name Meaning Details Relay Conversion Modification ZNRD instruction • Depends on whether or not the ZNRD (word device read) (LRDP instruction instruction has been received. OFF : Not accepted –...
Page 858
TableApp.3.11 Special relay ACPU Special Special Corresponding Special Relay after Relay for Name Meaning Details Relay Conversion Modification Local station, remote I/O station OFF : No errors Depends on whether or not a local or a remote I/O station – M9235 SM1235 parameter error...
(10) Process control instructions TableApp.3.12 Special relay Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU • Specifies whether or not to hold the output value OFF : No-hold SM1500 Hold mode when a range over occurs for the S.IN instruction ON : Hold range check.
Page 860
TableApp.3.13 Special relay Corres- ponding Set by Corresponding Number Name Explanation ACPU (When Set) SM1520 SM1520 Block 1 SM1521 SM1521 Block 2 SM1522 SM1522 Block 3 SM1523 SM1523 Block 4 SM1524 SM1524 Block 5 SM1525 SM1525 Block 6 SM1526 SM1526 Block 7 SM1527 SM1527...
Page 861
TableApp.3.13 Special relay Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) SM1575 SM1575 Block 56 SM1576 SM1576 Block 57 SM1577 SM1577 Block 58 • When data is transferred SM1578 SM1578 Block 59 by the data tracking Data tracking transfer OFF : No trigger SM1579...
Page 862
TableApp.3.15 Special relay Corres- ponding Set by Corresponding Number Name Meaning Explanation (When Set) ACPU SM1712 SM1712 Block 1 SM1713 SM1713 Block 2 SM1714 SM1714 Block 3 SM1715 SM1715 Block 4 SM1716 SM1716 Block 5 SM1717 SM1717 Block 6 SM1718 SM1718 Block 7 SM1719...
Page 863
TableApp.3.15 Special relay Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU SM1760 SM1760 Block 49 SM1761 SM1761 Block 50 SM1762 SM1762 Block 51 SM1763 SM1763 Block 52 SM1764 SM1764 Block 53 SM1765 SM1765 Block 54 SM1766 SM1766 Block 55 Turns ON only during one...
• New indicates the special register newly added to the QnACPU. Indicates the relevant CPU module. Corresponding CPU : Can be applied to QnA series and Q2ASCPU series Each CPU type name : Can be applied only to the specific CPU. (e.g. Q4AR, Q3A) For details on the following items, refer to the following manuals: •...
Page 865
(1) Diagnostic Information TableApp.4.2 Special register Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU D9008 Diagnostic Diagnosis error • Error codes for errors found by diagnosis are stored as BIN data. S (Error) format errors code •...
Page 866
TableApp.4.2 Special register Corres- Set by ponding Corresponding Number Name Meaning Explanation ACPU (When Set) • Common information corresponding to the error codes (SD0) is stored here. • The following five types of information are stored here: • The error common information type can be judged by the "common infor- mation category code"...
Page 867
TableApp.4.2 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) Time (value set) Number Meaning Time : 1 s units (0 to 999 s) Time : 1ms units (0 to 65535ms) SD10 (Vacancy) SD11 SD12 SD13 SD14 SD15...
Page 868
TableApp.4.2 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation (When Set) ACPU • Individual information corresponding to error codes (SD0) is stored here. • There are the following seven different types of information are stored. • The error individual information type can be judged by the "individual SD16 information category code"...
Page 869
Remark *6 : Extensions are shown below. TableApp.4.3 Extension name SDn+1 Extension File Type Higher 8 bits Lower 8 bits Higher 8 bits Name Parameters • Sequence program • SFC program Device comment Initial device value File register Simulation data Local device Sampling trace data Status latch data...
Page 870
TableApp.4.2 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation (When Set) ACPU Annunciator Annunciator S (Instruction SD62 • The first annunciator number (F number) to be detected is stored here. D9009 number number execution) Number of Number of S (Instruction SD63 •...
Page 871
(2) System information TableApp.4.4 Special register Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU • The CPU switch status is stored in the following format: b12 b11 b8 b7 b4 b3 Vacancy 0: RUN 1): CPU switch status 1: STOP 2: L.CLR Status of CPU...
Page 872
TableApp.4.4 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation (When Set) ACPU • When error is generated, the LED display (flicker) is made according to the error number setting priorities. (The Basic model QCPU supports only the annunciator (error item No. SD207 Priorities 1 to 4 D9038...
Page 873
TableApp.4.4 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) Loaded Loaded maximum • When SM250 goes from OFF to ON, the upper 2 digits of the final I/O S (Request SD250 maximum I/O I/O No. number plus 1 of the modules loaded are stored as BIN values.
Page 874
TableApp.4.4 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation (When Set) ACPU No. of modules SD340 • Indicates the number of mounted Ethernet module. installed SD341 I/O No. • Indicates I/O No. of mounted Ethernet module Network SD342 •...
Page 875
(4) Scan information TableApp.4.6 Special register Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU Execution Program No. in • Program number of program currently being executed is stored as BIN S (Status SD500 program No. execution value.
TableApp.4.6 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation (When Set) ACPU Execution time for low speed SD546 execution type • Stores the execution time of a low speed execution type program during programs Execution time one scan into SD546 and SD547. (in 1 ms units) for low speed (Measurement is made in 100 s units.)
Page 877
TableApp.4.7 Special register Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU • Indicates memory card B type installed b8 b7 b4 b3 S (Initial/Card Memory card B Memory card B SD620 0: Does not exist installation and Drive 3 (RAM) typs typs...
Page 878
(6) Instruction-Related Registers TableApp.4.8 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) • During block operations, turning SM705 ON makes it possible to use the SD705 mask pattern being stored at SD705 (or at SD705 and SD706 if double Mask pattern Mask pattern words are being used) to operate on all data in the block with the...
Page 879
TableApp.4.8 Special register Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU Remaining No. of simultaneous execution of • Stores the remaining number of simultaneous execution of the CC-Link SD780 0 to 32 CC-Link dedicated instructions. dedicated instruction (7) Debug TableApp.4.9 Special register...
(8) Latch area TableApp.4.10 Special register Corres- ponding Set by Corresponding Number Name Meaning Explanation ACPU (When Set) Drive where Access file drive S (Status SD900 power was number during • Stores drive number if file was being accessed during power loss. change) interrupted power loss...
Page 881
TableApp.4.13 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion • When fuse blown modules are detected, the first I/O number of the lowest number of the detected modules is stored in hexadecimal. (Example: When fuses of Y50 to 6F output modules have blown, "50"...
Page 882
TableApp.4.13 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion • The operation status of CPU as shown below are stored in SD203. Remote RUN/STOP CPU key switch by computer STOP STOP PAUSE Operating Operating status of...
Page 883
TableApp.4.13 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion • The day and hour are stored as BCD code as shown below. Example: Clock data 31st, 10 a.m. – D9026 SD1026 Clock data (day, hour) H3110...
Page 884
TableApp.4.13 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion • Stores the step number, where error code 84 occurred in an SFC Step number where program, in BIN value. – D9052 SD1052 Error step error occurred...
Page 885
TableApp.4.13 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion D9108 SD1108 • Set the value of the step transition monitoring timer and the annunciator number (F number) that will be turned ON when the D9109 SD1109 monitoring timer times out.
Page 886
(9) Special register list dedicated for QnA TableApp.4.14 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion Stores the execution result of the ZNRD (word device read) 0 : Normal end instruction ZNRD 2 : ZNRD instruction •...
Page 887
TableApp.4.14 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion • Loopback in forward loop only 0 : Forward loop, during data link Master 1 : Reverse loop, Station Station Station station Station n No.1 No.2...
Page 888
TableApp.4.14 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion Local station parameters non-conforming; Stores conditions for – D9220 SD1220 remote I/O up to numbers 1 to 16 station I/O assignment Stores the local station numbers which contain mismatched error parameters or of remote station numbers for which incorrect I/O Local station...
Page 889
TableApp.4.14 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion Local station and remote I/O Stores conditions for – D9232 SD1232 station loop up to numbers 1 to 8 error Stores the local or remote station number at which a forward or reverse loop error has occurred Local station and remote I/O...
Page 890
TableApp.4.14 Special register Special ACPU Special Register Corresponding Special Register for Name Meaning Details after Register Modification Conversion Local station Stores conditions for – D9248 SD1248 up to numbers 1 to 16 Stores the local station number which is in STOP or PAUSE mode. operation status Device number...
Page 891
(11) I/O module verification TableApp.4.16 Special register Corres- Set by ponding Corresponding Number Name Meaning Explanation (When Set) ACPU SD1400 • When the I/O modules whose I/O module information differs from that D9116 registered at power-ON are detected, the numbers of those I/O modules SD1401 D9117 are entered in bit pattern.
Page 892
(14) For redundant systems (Other system CPU information SD1600 to SD1659 is only valid during the back up mode for redundant systems, and refresh cannot be done when in the separate mode. SD1651 to SD1699 are valid in either the backup mode or separate mode. When a stand-alone system SD1600 to SD1699 are all 0.
Appendix 5 APPLICATION PROGRAM EXAMPLES Appendix 5.1 Concept of Programs which Perform Operations of X Though the QnACPU do not have instructions which perform the operations of X , the LOG and EXP instructions can be used together to perform the operations of X (1) Concept of programs which perform operations of X (nlogeX) can be operated using e...
INDEX . . . 6-19 0 to 9 BIN 32-bit addition and subtraction operations ....6-4 BIN 32-bit data comparisons ....7-63 16-bit and 32-bit data checks BIN 32-bit multiplication and division operations .
Page 897
....7-65 Conversion from BIN data to 4-digit and 8-digit Decoding from 8 to 256 bits ....... . 6-56 Deleting and inserting data from and in data tables .
Page 899
Reading device data from other stations ....8-102 (MELSECNET/10, Ethernet) ..7-140 TAN operation on floating-point data Reading newest data from data tables .
6. Failure caused by reasons unpredictable by scientific technology standards at time of shipment from Mitsubishi. 7. Any other failure found not to be the responsibility of Mitsubishi or that admitted not to be so by the user. 2. Onerous repair term after discontinuation of production (1) Mitsubishi shall accept onerous product repairs for seven (7) years after production of the product is discontinued.
Page 906
Microsoft, Windows, Windows NT are registered trademarks of Microsoft Corporation in the United States and other countries. Pentium and Celeron are trademarks of Intel Corporation in the United States and other countries. Ethernet is a trademark of Xerox Co., Ltd. in the United States. CompactFlash is a trademark of SanDisk Corporation.
Need help?
Do you have a question about the QnA Series and is the answer not in the manual?
Questions and answers