Home

QCPU(Q Mode)/QnACPU Programming Manual(Common

image

Contents

1. Processing Details Converts 1 word BIN values of the device number and later designated by S to ASCII and stores only n characters of them at the device number designated by D Converts only n ASCII characters of the device number and later designated by S to BIN values and stores them at the device number designated by D Stores n characters from the end of a character string designated by S at the device designated by D Stores n characters from the beginning of a character string designated by S at the device designated by D Stores the designated number of characters in the character string designated by S1 from the position designated by S2 at the device designated by D Stores the designated number of characters in the character string designated by S1 from the position designated by S2 at the device designated by D Searches character string 51 from the nth character of character string S2 and stores matched positions at D Converts floating decimal point data S1 to BCD data with number of decimal fraction digits designated by S2 and stores at device designated by D Converts BCD data S1 to floating decimal point data with the number of decimal fraction digits designated by S2 and stores at device designated by D
2. When source S data is a word device X10 1 _ pov DO camp Destination D Do not change Fig 3 6 Ladder Example and Processing Conducted POINTS 1 When digit designation processing is conducted a random value can be used for the bit device initial device number 2 Digit designation cannot be made for the direct device designation DX and DY 2 When 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 MO I pwov kioo The 2 points DO and D1 are used 32 bit data transfer instruction 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 2 4 Using real number data Real number data is 32 bit floating decimal point data used with basic instructions and application instructions Only word devices are capable of storing real number data Instructions which deal with real numbers designate devices which are used for the lower 16 bits of data Real numbers are stored in the 32 bits which make up designated device number and designated device number 1 MO Bd EMOY Rioo The 2 points DO and D1 32 bits are used The 2 points R100 and R101 32 bits are used Real number data transfer p 4 rape d Floati
3. b15 to b8b7 to bO S 8 bits 8 bits Po b15 to b8 b7 to bO 8 bits 8 bits 2 INSTRUCTION TABLES MELSEC Q QnA 1 1 The number of steps may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit High Performance model QCPU Process CPU designation is K8 and which use no index modification Constant No limitations 2 When using devices other than 1 Note 2 The number of steps may increase due to the conditions described in Section 3 8 2 2 The number of steps may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification Constant No limitations High Performance model QCPU Process CPU 2 When using devices other than 1 Basic model QCPU QnCPU Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 3 3 The subset
4. n D ZRRDBP n D ZRWRB n S ZRWRBP n S ADRSET S D S D D D D D ADRSETP KEY S n D1 D2 D ZPUSH ZPUSHP D ZPOP ZPOPP EROMWR 5 01 1 Other Instructions Processing Details Resets watchdog timer during sequence program Dl E q L n1 scan 2 5 420 to SM424 SM430 to SM434 Lower 8 bits Upper 8 bits Lower 8 bits Upper 8 bits 8 bits Lower 8 bits Upper 8 bits Execution Condition Lower 8 bits Upper 8 bits C 8bits Indirect address of designated device Device name Takes in ASCII data for 8 points of input unit designated by S converts to hexadecimal value following device number designated by D1 and stores Saves the contents of index registers ZO to Z15 to a location starting from the device designated by D Reads the data stored in the location starting from the device designated by D to index registers ZO toZ15 Writes a batch of data to EPROM file register Number of Basic Steps MELSEC Q QnA Description 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 19 Instructions for data link Table 2 36 Instructions for
5. Conductive status when S141 S1 gt S241 S2 Non Conductive status when S141 S1 lt S241 S2 number data com Conductive status when parisons S141 S1 S241 S2 Non Conductive status when S141 S1 gt S21 S2 Conductive status when S141 S1 lt S21 S2 Non Conductive status when S141 S1 gt S21 S2 Conductive status when 814 1 81 8241 S2 Non Conductive status when S1 1 S1 lt S241 S2 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 10 Comparison Operation Instructions Continued 0 S2 Sg else a Execution amp Category 5 Symbol Processing Details Condition t 2 83 o 54 010 8 o Compares character string S1 and character string S2 one character at a time Conductive status when character string S1 character string S2 Non Conductive status when character string S1 character string S2 Compares character string 51 and character string S2 one character at a time Conductive status when character string S1 character string S2 Non Conductive status when character string S1 character string S2 Compares character string S1 and character string S2 one character
6. 6 40 6 2 10 Multiplication and division of floating decimal point data EP E E P 6 44 6 2 11 Block addition and subtraction BK BK P BK BK P 6 46 6 2 12 Linking character strings P sse 6 49 6 2 13 Incrementing and decrementing 16 bit BIN data INC INCP DEC DECP 6 53 6 2 14 Incrementing and decrementing 32 bit BIN data DINC DINCP DDEC DDECP 6 55 6 3 Data Conversion Instructions essssssssssssssssssssee enne 6 57 6 3 1 Conversion from BIN data to 4 digit and 8 digit BCD BCD BCDP DBCD DBCDP 6 57 6 3 2 Conversion from BCD 4 digit and 8 digit data to BIN data BIN BINP DBIN DBINP 6 59 6 3 3 Conversion from BIN 16 and 32 bit data to floating decimal point FLT FLTP DFLT DFLTP 6 61 6 3 4 Conversion from floating decimal point data to BIN 16 and 32 bit data UNT INTP DINT S ua tert eret eret eret 6 63 6 3 5 Conversion from BIN 16 bit to BIN 32 bit data DBL DBLP 6 65 6 3 6 Conversion from BIN 32 bit to BIN 16 bit data WORD 6 66 5 5 6 3 7 Conversion from BIN 16 and 32 bit data to Gray code GRY GRYP DGRY
7. Trace set TRACE TRACE 4 SP FREAD Reads data from the designated file designated file Transfers the program stored in a memory card or standard memory other than drive 0 to drive 0 and places the program in standby status PLOADP PLOADP Deletes the standby program stored in standard memory drive 0 Deletes standby program stored in standard memory drive 0 designated by S1 Then transfers the program PSWAPP stored in a memory card or standard memory other than drive 0 designated by S2 to drive 0 and places it in standby status 51 82 DH RBMOV S D n Transfers n points of 16 bit data from the device designated by S to the SID n n3 n4 D PUNLOADP UNIRDP SP FWRITE PUNLOADP RBMOVP location starting from the device RBMOVP designated by D 4S TO n2 Writes the device data of the host station to the shared memory area of the host station CPU module Reads device data from the CPU shared memory area of another station CPU module to the host station Performs the automatic refresh of the intelligent function module general data processing and the automatic refresh of the CPU shared memory
8. 7 54 7 5 3 Decoding from 8 to 256 bits DECO DECOP L 7 56 7 5 4 Encoding from 256 to 8 bits ENCO ENCOP L 7 58 7 5 5 7 segment decode SEG SEGP sse nennt nennen inen 7 60 7 5 6 4 bit groupings of 16 bit data DIS DISP nennen tnnt 7 62 7 5 7 4 bit linking of 16 bit data UNI UNIP 7 64 7 5 8 Dissociation or linking of random data NDIS NDISP NUNI 7 66 7 5 9 Data dissociation and linking in byte units WTOB WTOBP BTOW BTOWP 7 71 7 5 10 Maximum value search for 16 and 32 bit data DMAX DMAXP 7 75 7 5 11 Minimum value search for 16 and 32 bits data MIN MINP DMIN DMINP 7 77 7 5 12 BIN 16 and 32 bits data sort operations SORT SORTP DSORT DSORTP 7 80 7 5 13 Calculation of totals for 16 bit data WSUM WSUMP a 7 83 7 5 14 Calculation of totals for 32 bit data DWSUM 0 7 85 7 6 Structured Program Instructions U 7 87 7 6 1 FOR to NEXT instruction loop FOR NEXT L a 7 87 7 6 2 Forced end of FOR to NEXT instructio
9. ORB BlckB 1 contact parallel connections 1 Functions ANB 1 Performs an AND operation on block A and block B and takes the resulting value as the operation result 2 The symbol for ANB is not the contact symbol but rather is the connection symbol 3 When programming in the list mode up to 15 ANB instructions 16 blocks can be written consecutively ORB 1 Conducts an OR operation on Block A and Block B and takes the resulting value as the operation result 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 2 ORB is used to perform parallel connections for ladder blocks with two or more contacts For ladder blocks with only one contact use OR or ORI there is no need for ORB in such cases Ladder Mode List Mode pu Y10 0 LD XO or lt gt 1 AND X 2 2 LD X2 3 AND X3 LE 4 ORB Fl 4 5 OR X4 m m Eu 6 OUT X10 8 The ORB symbol is not the contact symbol but rather is the connection symbol 4 When programming in the list mode it is possible to use up to 15 ORB instructions successively 16 blocks Operation Errors 1 There are no operation errors associated with ANB or ORB instructions Program Example 1 A program using ANB and ORB instructions Ladder Mode List Mode Steps Instruction Device 0 LD X0 1 OR X2 2 LD Xl 3 OR x3 4 A
10. L L 6 93 6 4 9 Upper and lower byte exchanges SWAP SWAPP a 6 95 6 5 Program Branch Instr ction cit Lee re Le ie ee ani ini a ee 6 96 6 5 1 Pointer branch instructions CJ SCJ JMP eene ennt 6 96 6 5 2 Jump to END GOENDJ state tp RI su Rs 6 99 6 6 Program Execution Control Instructions esses nnne ennt 6 100 6 6 1 Interrupt disable enable instructions interrupt program mask DI El IMASK 6 100 6 6 2 Recovery from interrupt programs IRET 1 nennen 6 109 6 7 VO Refresh InStr ctionis us coire rd PP e ete e e El n ee d 6 111 6 7 1 VO Refresh RFS RESP esee nier eiae Peg Suspe ege 6 111 6 8 Other Convenient Instructions L L 6 113 6 8 1 Count 1 phase input up or down UDCNT1 6 113 6 8 2 Counter 2 phase input up or down UDCNT 2 sse nne nnns 6 115 6 8 3 Teaching timer TEMP k k toan trorum gt ee iro nutre ROO Uere ened 6 117 6 8 4 Special function timer STMR sss 6 119 6 8 5 Rotary table near path rotation control ROTO sss enne nennen 6 122 6 8 6 Ramp signal RAMP u uy k e
11. 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 21 Redundant system instructions For Q4ARCPU Table 2 38 Redundant system instructions For Q4ARCPU Execution Processing Details Condition Category Instruction Number of Basic Steps Description Designates the operation mode at S1 whether to clear the Q4ARCPU devices S STMODE H before startup or not to clear them before startup when the power supply is turned on for CPU startup Designates the operation mode at S1 whether to clear the Q4ARCPU devices before startup or not to clear them before startup when control is switched from the control system to the standby System S CGMODE s H Conducts device memory tracking in accordance with the parameter block S TRUCK E data contents stored in the area starting from the device designated by S during END processing Batch reads writes the contents of special function module buffer memory in accordance with the contents of SSPREF 5 parameter block data stored in the area starting from the device designated by S 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 3 CONFIGURATION OF INSTRUCTIONS 3 1 Configuration of Instructions Most CPU module instructions consist of an instruction part and a device part Instruction part Indicates the function of the instruction e Device part Indicates the data that is to be used
12. Stores message designated by S at QnACPU 2 This message is displayed at the peripheral device Data input from the peripheral device is x stored at device designated by D EE 2 7 305 2 5 17 Program instructions Table 2 34 Program Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description PSTOP PSTOP Program Name Places designated program in standby status PSTOPP PSTOPP Program Name POFF POFF Program Name POFFP Program Name Turns OUT instruction coil of designated program OFF and places program in standby status program execution PSCAN Program Name Registers designated program as scan statuses execution program PSCANP Program Name Registers designated program as low speed execution program PLOW Program Name PLOWP PLOWP Program Name number of program name characters 2 indicates a step Decimal fractions are rounded up 2 INSTRUCTION TABLES 2 5 18 Other instructions Category WDT reset Numerical Instruction WDTP WDTP ZRRDB ZRRDB ZRRDBP ZRWRB ADRSET ZPUSH P EROMWR RBP RSETP PP MWRP n D2 EROMWRP S D1 n D2 Table 2 35
13. x x x x x x x x COS CN 00 CN CN 00 lt f QE 00 OTN cN OTA BCD 99999999 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 Ten Millions Hundred Ten Thousands Hundreds Tens Ones millions digits thousands thousands digits digits digits digits digits digits digits D 1 Upper 4 digits D Lower 4 digits 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The data at S was not in the 0 to 9999 range when the BCD instruction was issued Error code 4100 The data at 1 and was not in the 0 to 99999999 range when the DBCD instruction was issued Error code 4100 Program Example 1 The following program outputs the present value of C4 from Y20 to Y2F to the BCD display device PLC Output Module Suuqo m lt o oo t NANA CN CN N CV CN N N CN NANA O gt gt gt gt gt gt gt gt gt gt gt gt gt 8888 8888 v7 e Sao OO QN Output power supply 0111011 01111 0111111 1 0 0 0 7 element display unit Ladder Mode List Mode 0 nd LET i C4 K4120 Steps Instruction Device 0 LD SM400 1 BCDP C4 K4Y20 4 END 2 The following program outputs 32 bit data from DO to D1 to Y40 to Y67
14. BIN 305419896 00 01100 10001101000101011001111000 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO Data at when GBIN instruction was issued is outside the 0 to 32767 range Data at when DGBIN instruction was issued is outside the 0 to 2147483647 range Program Example 1 The following program converts the Gray code data at D100 when X10 is ON to BIN data and stores the result at D200 Ladder Mode List Mode 0 GBIN 0100 0200 Steps Instruction Device 0 LD X10 1 GBINP D100 0200 4 END 2 The following program converts the Gray code data at D10 and D11 to BIN data when X1C is ON and stores the result at DO and D1 Ladder Mode List Mode 0 o yr DIO DO Steps Instruction Device 0 LD 1 DGBINP D10 DO 4 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Lee 20202027 Process CPU 6 3 9 Complement of 2 of BIN 16 and 32 bit data data UT NEG NEGP DNEG DNEGP Usable Devices Internal Devices MELSECNET 10 H Special Index E BF User File EH B i Function Constant Dus Register Other Register Module K H Word UM Zn Instruction Symbol Execution Condition Ll indicates NEG or DNEG Command NEG DNEG Command NEGP DNEGP
15. Digits upper than those which were designated will be read as 0 2 The values for and can be between 0 to 99999999 BCD 8 digits 3 If the result of the addition operation exceeds 99999999 the upper bits will be ignored The carry flag in this case does not go ON 9 90 0 00000 0 0 1 6 54 3 2 1 gt 0 0 6 5 4 3 2 1 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Subtracts the BCD 8 digit data designated by and the BCD 8 digit data designated by 69 and stores the result of the subtraction at the device designated by 1 62 1 G3 1 m Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits 567 89123 0 1 2 34 5 6 7 gt 5 5 5 5 4 5 5 6 L Digits higher than those which were designated will be read as 0 2 The values for 6 63 and can be between 0 to 99999999 BCD 8 digits 3 The following will result if an underflow is generated by the subtraction operation The carry flag in this case does not go ON 112 3 4 5 6 7 8 1 a s a s e o r gt 9 9 9 9 9 9 9 9 Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The amp 3 or D BCD data is outside the 0 to 99999999 range Error code 4100 Program Example
16. Set Data Set Data I Transfer data or number of device storing transfer data BIN 16 32 bits XB Number of device to store transferred data Functions MOV 1 Transfers the 16 bit data from the device designated by to the device designated by Prior to transfer 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 After transfer 1 0 1 1 0 1 0 1 1 1 0 0 1 0 2 Transfers 32 bit data at the device designated by to the device designated by 1 DIDS SSS ese SSS 60 615 gt eee b0 Prior to transfer S 110111 0 1 0 0 01111 110 01 1 O Qu Transmission Dd De ee tiak s b0 b15 o ce b0 After transfer 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the MOV P or DMOV P instructions Program Example 1 The following program stores input data from XO to XB at D8 Ladder Mode List Mode 0 K3X0 08 Steps Instruction Device 1 W rc 4 T END 08 2 The following program stores the constant 155 at 08 when X8 goes Ladder Mode List Mode 0 Es qd K155 08 Steps Instruction Device 0 LD X8 1 MOV K1
17. Set Data p m or subtraction data or head number of device storing addition or subtraction data BCD 4 digit Data to be added to or subtracted from or head number of device storing such data Functions 1 Adds the BCD 4 digit data designated by and the BCD 4 digit data designated by and stores the result of the addition at the device designated by ES r N d 5 6 7 8 1 2 3 4 D gt 6 9 1 2 2 The values for and be between 0 to 9999 BCD 4 digit 3 If the result of the addition operation exceeds 9999 the higher bits are ignored The carry flag in this case does not go ON 6 4 3 2 3 5 8 3 C55 0 0 1 5 1 Subtracts the BCD 4 digit data designated by D and the BCD 4 digit data designated by S and stores the result of the subtraction at the device designated by t C A o 6 7 8 o 2 a 4 c 5 o 4 4 4 gt Digits higher than those which were designated will be read as 0 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 The values for S and can be between 0 to 9999 BCD 4 digit 3 The following will result if an underflow is generated by the subtraction operation The carry flag in this case does not go ON e o o 1 o o gt 9 9 8 Operation Errors 1 In the following cases an operation e
18. 7 30 7 2 2 Left rotation of 16 bit data ROL ROLP RCL 7 32 7 2 3 Right rotation of 32 bit data DROR DRORP 7 34 7 2 4 Left rotation of 32 bit data DROL DROLP DRCL DRCLP 7 36 7 9 Shift Instr ction ti ote te ea 7 38 7 3 1 n bit shift to right or left of 16 bit data SFR SFRP SFL SFLP 7 38 7 3 2 1 bit shift to right or left of n bit data BSFR BSFRP BSFL BSFLP 7 40 7 3 3 1 word shift to right or left of n word data DSFR DSFRP DSFL DSFLP 7 42 7 4 Bit Processing Instructions iade hee fide tee i Pe ee e Lin ee o HE Pe eR dd 7 44 7 4 1 Bit set and reset for word devices BSET BSETP BRST 7 44 7 4 2 Bit tests TEST TESTP DTEST DTESTP um a 7 46 7 4 3 Batch reset of bit devices BKRST BKRSTP sss nennen 7 48 7 5 Data Processirig Instr ctloris 1 eel Le cene Lem ec ee hee e e e eene 7 50 7 5 1 16 bit and 32 bit data searches SER SERP DSER 7 50 7 5 2 16 bit and 32 bit data checks SUM SUMP DSUM 0
19. Ladder Mode List Mode 0 9 PLF M9 Steps Instruction Device 0 LD x9 1 PLF M9 3 END 3 END ON X9 OFF ON M9 OFF MM 1 scan 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin or p ee p e 16x 5 3 9 Bit device output reverse FF Usable Devices Internal Devices MELSECNET 10 H Special index Other ea Br s User File 3 Function Constant Daa Register Module Register K H U AGO Zn Instruction Symbol Execution Condition reverse command f L Set Data Set Data Meaning Device number to reverse L Bit Functions 1 The status of the device designated by D is reversed when the inversion command goes from OFF to ON Device Device Status Prior to FF execution After FF execution Bit device Designation of word device Operation Errors 1 There are no operation errors associated with the FF instruction Program Example 1 The following program reverses the output of Y10 when X9 goes ON Ladder Mode List Mode 0 DE FF Y10 Steps Instruction Device Dog fh 3 END 3 END Timing Chart ON X9 1 Y10 OFF 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 2 The following program reverses b10 bit 10 of D10 when goes ON Ladder Mode List Mode 0 M FF 10 0A Steps Instruction Device 0 LD X0 1 FF 10 0 3 END 3 END T
20. 6 2 4 BIN 32 bit multiplication and division operate operations ms Dx DEP 5 1 D DIP Usable Devices Internal Devices MELSECNET 10 H Special Index eo User File EN pen E Function Constant Dara Register Other Register Module K H Word Word UA Zn 2 E Instruction Symbol Execution Condition Ll indicates the signs D or D Command Ds D IAT Command DxP DP 7 Set Data Meaning Data Type Data that will be multiplied or divided or the head number of the device storing data that will be multiplied or divided BIN 32 bi Data to multiply or divide by or the head number of device storing such Sees data Head number of the device storing the operation results of multiplication BIN 64 bits or division operation Functions 1 Multiplies BIN 32 bit data designated by 6 and BIN 32 bit data designated by 62 and stores the result in the device designated by 6241 G2 1 62 3 2 Q1 A A A b31 b16 b15 bO b31 b16 b15 b0 b63 b48 b47 b32b31 b16 b15 b0 567890 BIN x 123456 BIN gt 70109427840 BIN 2 If is a bit device only the lower 32 bits of the multiplication result will be considered and the upper 32 bits cannot be designated Example K1 Lower 4 bits bO to 3 KA Lower 16 bits bO to 15 K8 Lower
21. 6 67 6 3 8 Conversion of Gray code to BIN 16 and 32 bit data GBIN GBINP DGBIN DGBINP 6 69 6 3 9 Complement of 2 of BIN 16 and 32 bit data sign reversal NEG NEGP DNEG 6 71 6 3 10 Sign reversal for floating decimal point data ENEG ENEGP 6 73 6 3 11 Conversion from block BIN 16 bit data to BCD 4 digit data BKBCD BKBCDP 6 74 6 3 12 Conversion from block BCD 4 digit data to block BIN 16 bit data BKBIN BKBINP 6 76 6 4 Data Transfer InstruCtions sca rrt ete teg entr e RO UR EE RO OEN Y E EHE MO Tee Lx 6 78 6 4 1 16 bit and 32 bit data transfers MOV MOVP DMOV 6 78 6 4 2 Floating decimal point data transfers EMOV EMOVP 6 80 6 4 3 Character string transfers 8MOV MOVP ennt 6 82 6 4 4 16 bit and 32 bit negation transfers CML CMLP DCML DCMLP 6 84 6 4 5 Block 16 bit data transfers BMOV BMOVP L 6 87 6 4 6 Identical 16 bit data block transfers FMOV FMOVP 6 89 6 4 7 16 bit and 32 bit data exchanges XCHP DXCH 6 91 6 4 8 Block 16 bit data exchanges BXCH BXCHP
22. BINHA BINHAP DBINHA DBINHAP BCDDA BCDDAP DBCDDA DBCDDAP DABIN DABINP DDABIN DDABINP HABIN HABINP DHABIN DHABINP Processing Details Converts 1 word BIN value designated by S to a 5 digit decimal ASCII value and stores it at the word device designated by D Converts 2 word BIN value designated by S to a 10 digit decimal ASCII value and stores it at word devices following the word device number designated by D Converts 1 word BIN value designated by S to a 4 digit hexadecimal ASCII value and stores it at a word device following the word device number designated by D Converts 2 word BIN value designated by S to an 8 digit hexadecimal ASCII value and stores it at word devices following the word device number designated by D Converts 1 word BCD value designated by S to a 4 digit decimal ASCII value and stores it at a word device following the word device number designated by D Converts 2 word BCD value designated by S to an 8 digit decimal ASCII value and stores it at word devices following the word device number designated by D Converts a 5 digit decimal ASCII value designated by S to a 1 word BIN value and stores it at a word device number designated by D Converts a 10 digi
23. Set Data Set Data Meaning Head number of device storing data for the complement of 2 operation BIN 16 32 bits Functions NEG 1 Reverses the sign of the 16 bit device designated by D and stores at the device designated by Before execution D Sign conversion After execution D ol1 o 1 o 1 o 1 o 1 0 Je 21846 2 Used when reversing positive and negative signs 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Reverses the sign of the 32 bit device designated by D and stores at the device designated by 32 Bit lt Pp D35252 ssameqa sya Teresi op Deut apita aise b0 Before execution 11 111 11111 011100110 0 Jerre 218460 1 0 oo 0 0 00 Sign conversion 111111 1 113 0 1 0 0 After execution D 1101 1 11 1 0 0 218460 2 Used when reversing positive and negative signs Operation Errors 1 There are no operation errors associated with the NEG P or DNEG P instructions 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 Ladder Mode M3 goes ON if D10 is smaller than D20 Subtracts D20 from D10 Seeks an absolute value complement of 2 when M3 is ON
24. Ladder Mode List Mode DEL O4 Steps Instruction Device Bon io 4 END o 07 4 The following program stores the data from to X1F at DO D1 Ladder Mode List Mode o on 00 Steps Instruction Device 0 LD SM400 1 igno END 4 6 79 6 79 4 Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU or QnA Programming Manual for details of each device 3 5 When T ST and C are used for other than the instructions below only word data can be used Bit data cannot be used Instructions that can be used with bit data LD LDI AND ANI OR ORI LDP LDF ANDP ANDF ORP ORF OUT RST Indicates ladder mode expressions and execution conditions for instructions Execution Non conditional Executed while ON Executed One Executed while Executed One Condition Execution Time at ON OFF Time at OFF Code recorded on No symbol 4 HOW TO READ INSTRUCTIONS MELSEC Q QnA amp Discusses the data set for each instruction and the data type Bit Bit data or first number in bit data BIN 16 bits BIN 16 bit data or first number in word device BIN 32 bits BIN 32 bit data or first number in double word device 1 BCD4digts 4 digit BCD data Device name Device name data amp Indicates the function of the instruction Indicates conditions under which error is returned and error number S
25. List Steps Instruction Device 0 LD 1 AND D10 D20 4 OUT M3 5 LD 6 020 010 8 M3 9 NEGP D10 12 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Lem pen Process CPU Cin 6 3 10 Sign reversal for floating decimal point On dea TENEG ENEGP Usable Devices Internal Devices MELSECNET 10 H Special Index F User File E S pisi E Function Constant Other Register Module 9 K H Instruction Symbol Execution Condition Command ENEG Tl P Command ENEGP AU E M M 4 Set Data Meaning Data Type Head number of device storing floating decimal point data for which sign B al number will be inverted Functions 1 Reverses the sign of the floating decimal point type real number data designated by D and stores at the device designated by 2 Used when reversing positive and negative signs Operation Errors 1 There are no errors associated with the ENEG P instruction Program Example 1 The following program inverts the sign of the floating decimal point type real number data at D100 and D101 when X20 goes ON and stores result at D100 and D101 Ladder Mode List Mode 0 Bho t ENES D100 Steps Instruction Device 0 LD X20 1 ENEGP D100 3 END 3 END D101 D100 D101 D100 1 2345 1 2345 6 BASIC INSTRUCTIONS MELSEC Q
26. ceccecceseecceeeeseeaeceeeeeeeaeeaecaeeeeesaecaeceeseaesaecaesaeseaesaesaeseseaesaesaeseeseseeseaeeateas 9 31 9 8 High speed Block Transfer of File Register RBMOV P sees 9 33 9 9 Write to Host Station CPU Shared Memory S TO P a 9 36 9 10 Read from Shared Memory of Another Station FROM P sees 9 38 9 11 Refresh Instruction COM eere Sa ae Adina aed ede eletti ens 9 40 10 REDUNDANT SYSTEM INSTRUCTION FOR Q4ARCPU 10 1to10 14 10 1 Operation Mode Setting Instructions During CPU Start Up S STMODE 10 2 10 2 CPU Switch Time Operation Mode Setting Instructions S CGMODEB 10 4 10 3 Data tracking instruction S TRUCK nnns 10 6 10 4 Buffer memory batch refresh instruction S SPREF sse 10 10 11 ERROR CODES 11 1to11 46 11 1 How to Read Error Codes nennen nnne nnn nnne nnne nennen nnns nnns nnns 11 1 TEZ Gode EE M M 11 2 11 2 1 Error Code List of Basic model 11 2 11 2 2 Error Code List of High Performance model 11 10 11 2 3 Error Code Eistof Process CPU t os eco t dione reda repa te e eres 11 28 11 3 Fiesettirig anerTOr our dran
27. 3276632767 When counting down 4 Count processing based on the UDCNT1 instruction starts the count when the count command goes from OFF to ON and suspends the count when it goes from ON to OFF When the count command goes from OFF to ON once again the count is restarted from the value in effect when it was suspended When counting up 5 The RST instruction clears the present value of the counter designated at and turns the contact OFF POINTS 1 The UDCNT1 instruction registers the argument device data to the work area of the CPU module and the actual counting operation is processed as a system interrupt The device data registered to the work area of the CPU module are cleared when the command input is turned OFF or when the CPU module is STOPped and then RUN Therefore to count pulses it is necessary to provide their ON and OFF time as long as the interrupt time of the CPU module or longer The interrupt time of individual CPU module is shown below CPU module Type Name Interrupt Time High Performance model QCPU Process CPU QnACPU 5ms 2 The setting values cannot be changed during a count based on the UDCNT1 instruction while the command input is ON To change the setting values first turn the command input off 3 Counters which have been designated by the UDCNT1 instruction cannot be used by other instructions If they are used by other instructions they will not be capable of returning
28. DO 4 END KO 6 118 6 118 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA perge pO 6 8 4 Special function timer STMR Usable Devices Internal Devices MELSECNET 10 H Special Index ea ace User File Ka pen 3 Function Constant Dara Register Other Register Module K H Word UA Zn rale n I ecu te de m Can be used only by timer T data Instruction Symbol Execution Condition Command STMR JTL Set Data D 0 Off delay timer output D 1 One shot timer output after OFF D 2 One shot timer output after ON D 3 ON delay timer output Functions 1 The STMR instruction uses the 4 points from the device designated by D to perform four types of timer output OFF delay timer output 0 Goes ON at the leading edge of the command for the STMR instruction and after the trailing edge of the command goes OFF when the amount of time designated by n has passed One shot timer output after OFF 1 Goes ON at the trailing edge of the command for the STMR instruction and goes OFF when the amount of time designated by n has passed One shot timer output after ON 2 Goes ON at the leading edge of the command for the STMR instruction and goes OFF either when the amount of time designated by n has passed or when the command for the STMR instruction goes OFF ON delay timer output 3 G
29. List Mode Steps Instruction Device 0 LD X0 1 BINP K4X10 D10 4 LD X2 5 OUT T2 D10 9 LD T2 10 OUT Y15 11 END Converts BCD data at X10 to 1F to BIN and stores at D10 When X2 goes ON the data stored at D10 is calculated as the set value Y15 goes ON when T2 counts out 3 The following program turns Y10 ON 250 m after goes ON Ladder Mode 2 X 25 0 H K 0 h ox o ss TO 5 O 110 7 END List Mode Steps Instruction Device 0 LD X0 1 OUTH TO X25 5 LD TO 6 OUT Y10 7 END 1 1 The set value of the low speed timer indicates its default time limit 100 ms 2 2 The set value of the high speed timer indicates its default time limit 10 ms 3 The number of basic steps of the OUT T c instruction is 4 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin or p ee p e 16x 5 3 3 Counters OUT C Usable EET Internal Devices MELSECNET 10 H Special Inda Other rg BE User File RS pon Function Constant bas Register K Register Module ux Set Other Instruction Symbol Execution Condition K50 Set value c co gt Settings from 1 to are valid D10 Set value C1 Contents of data register settings from 1 to 32767 are valid Set Data Set Data Q Jjoonternmbr Counter set value BIN 16 bit
30. following D10 Ladder Mode List Mode oH po no f y33 Steps Instruction Device 0 LD DO 4 END o 133 2 The following program compares the character string ABCDEF with the character string stored following D10 Ladder Mode List Mode 0 o ABODEF 010 C133 Steps Instruction Device 0 LD M3 1 AND lt gt ABCDEF D10 T OUT Y33 8 END 6 BASIC INSTRUCTIONS MELSEC Q QnA 3 The following program compares the character string stored following D10 with the character string stored following D100 Ladder Mode List Mode 0 id gt DLO 0100 Y33 Steps Instruction Device DOR gt M8 D100 4 OR M8 5 ANB 6 OUT Y33 7 END 4 The following program compares the character string stored following D10 with the character string 12345 Ladder Mode List Mode 0 pot Y33 Steps Instruction Device 0 LD M3 i m lt DO 12345 719345 8 OUT Y33 9 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA K COS eel 6 1 5 BIN block data comparisons BKCMP Usable Devices Internal Devices MELSECNET 10 H Special inda ea User File Ka pen 1 Function Register Register Instruction Symbol Execution Condition L indicates the signs lt gt gt lt lt or gt Command BKCMPO sxc 62 n Command oP f
31. Searches the data of 2 n points from the device designated by S in 32 bit units and stores the minimum value at the device designated by D s g g g 2 2 s 2 lt 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 22 Data Processing Instructions Continued Execution Processing Details Condition Instruction Number of Basic Steps Description Sorts data of n points from device SORT S1 n S2 D1D2 designated by S1 in 16 bit units n x n 1 2 scans required S2 Number of comparisons made during one run D1 Device to turn ON when sort is completed D2 For system use DSORT 81 n S2 D1D2 Sorts data of 2 n points from device designated by S1 in 32 bit units n x n 1 2 scans required S2 Number of comparisons made during one run D1 Device to turn ON when sort is completed D2 For system use Adds 16 bit BIN data of n points from the device specified by S and stores it in the device specified by D Adds 32 bit BIN data of n points from the m SD n device specified by S and stores it in D n the device specified by D DWSUMP S 2 31 2 31 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 6 Structure creation instructions Table 2 23 Stru
32. Ladder Mode X7 P 0 H 0 100 D8 Transfers the value 100 to D8 when X7 is ON X8 M38 4 He 18 When M38 is OFF X8 goes from OFF to ON and 1 is decremented from D8 8H K0 08 l VMV M Mw38 At D8 0 M38 goes ON List Mode Steps Instruction Device 0 LD X7 1 MOVP K100 D8 4 LD X8 5 ANI M38 6 DECP D8 8 LD KO D8 11 QUT M38 12 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin E a S C e ee as 6 2 14 Incrementing and decrementing 32 bit BIN data DINC DINCP DDEC DDECP Usable Devices Internal Devices MELSECNET 10 H Special Set Index E NF User File EH B P Function Constant Data Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition indicates DINC DDEC DINC DDEC See Command DINCP DDECP Set Data Meaning Data Type BIN 32 bits Head number of device what will execute the DINC 1 or DDEC 1 operation Functions 1 Adds 1 to the device designated by 32 bit data O4 O4 b31 b16 b15 b31 b16 b15 bO 73500 BIN 1 gt 73501 BIN 2 If the contents of the device designated by D are 2147483647 and the DINC or DINCP instruction is executed the value 2147483648 will be stored at the device designated by 1 Subtracts 1 from the device designated by D 32 bit data
33. Zn 2 ca cum Local devices and the file registers set for individual programs cannot be used Instruction Symbol Execution Condition Command SPD Set Data Meaning Pulse input oe Measurement time unit ms BIN 16 bits Head number of device which stores measurement results Functions 1 Input from the device designated by is counted for just the amount of time designated by n1 and results of the count are stored in the device designated by Measurement begins n ms T n ms i Command OFF ON se Measurement results Measurement results stored at D stored at D 2 When measurement directed by the SPD instruction has been completed measurement is done again from 0 To suspend measurement directed by the SPD instruction turn the command OFF 6 126 6 126 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 The SPD instruction registers the data from the argument device in the CPU module work area and the actual count operation is conducted during a system interrupt The device data registered to the work area of the CPU module are cleared when the command input is turned OFF or when the CPU module is STOPped and then RUN Therefore to count the pulses it is necessary to provide their ON and OFF time as long as the interrupt time of the CPU module or longer The int
34. Circuit PLS mo H X1 rh Ps Mmo H Timing Chart The ON OFF timing of the and X1 is different The specified device does not turn ON throughout the scan 0 ris MoH ris mo 1 xo ore x Xt OFF f ON ON OFF turns OFF because MO turns ON because X1 X1 is not turning ON from OFF turns ON from OFF turns OFF because is not turning MO turns ON because turns ON from OFF ON from OFF MO stays OFF The X0 and X1 turn ON from OFF at the same time Hss ris vH x1 1 PLs PLS MO END END Pd ES H m turns ON because X1 turns turns OFF because X1 is ON from OFF stays not turning ON from OFF turns ON because MO stays OFF turns ON from OFF turns OFF because is not turning ON from OFF 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 4 PLF instructions using the same device The PLF instruction turns ON the specified device when the PLF command turns ON from OFF It turns OFF the specified device at any other time OFF OFF OFF gt ON and ON gt ON When two or more PLF instructions using the same device are programmed in one scan each PLF instruction turns OFF the specified device when the corresponding PLF command turns OFF from ON and it turns OFF the specified device at any other time For this reason when two or more PLF ins
35. Execution Condition Number of Basic Steps MELSEC Q QnA Description 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 12 Special function instructions Table 2 29 Special Function Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps See for Description Sin S41 S 0 1 D Cos S41 S D41 D Tan 841 S D 1 D Sin 9 1 S D 1 D Cos S 1 S gt 0 1 D 841 S gt 0 1 D 5 1 S 0 1 D Conversion from angles to radians e S 1 S 0 1 D Conversion from radians to angles Log e 41 S 0 1 D Generates a random number from 0 to less than 32767 and stores it at the device designated by D Updates random number series according to the 16 bit BIN data stored in the device designated by S 2 INSTRUCTION TABLES 7 Execution Category Symbol Processing Details Condition BSOR BSOR 00 Integer part Square root MELSEC Q QnA Table 2 29
36. QCPU PLG Process CPU Cin e P o 6 6 2 Recovery from interrupt programs IRET Usable Devices Internal Devices MELSECNET 10 H Special Index eo Br s User File zs pon E Function Constant Dara Register Other Register Module K H UA Zn Instruction Symbol Execution Condition Lxx IRET 1 Indicates the completion of interrupt program processing Functions 2 Returns to sequence program processing following the execution of the IRET instruction Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO There is no pointer corresponding to the interrupt number Error code 4220 The IRET instruction has been issued prior to the execution of the interrupt program Error code 4223 An END FEND GOEND or STOP instruction as been executed after the generation of an interrupt and prior to the execution of the IRET instruction Error code 4221 6 109 6 109 6 BASIC INSTRUCTIONS MELSEC Q QnA Program Example 1 The following program adds 1 to DO if MO is ON when the number 3 interrupt is generated Ladder Mode List Mode 0 Steps Instruction Device 0 LD SM400 1 MOVP H5 D11 D10 4 MOVP HO B 7 MOVP D12 s 10 IMASK D10 12 EI D10 13 LD x0 14 OUT YO 15 FEND 16 13 BE 17 LD M0 18 INC DO 20 IRET 0 21 END FEND IRET 6 1
37. Reads data in 32 bit units from special function module Writes data in 16 bit units to special function module Data wri I TER SIMA Writes data in 32 bit units to special function module 2 5 9 Display instructions Table 2 26 Display Instructions Execution Symbol Processing Details Condition SM701 When OFF Outputs ASCII code of 8 points 16 PR S D characters from device designated by S to output module Outputs ASCII code from device ON designated by S to 00x to output module Category Instruction Number of Basic Steps Description ASCII print PR SD Converts comments from device PRC PRC s Ip designated by S to ASCII code and outputs to output module Displays ASCII code of 8 points 16 ej characters from the device designated by 3 e 5 S at the LED display device on the front TISS Display of the CPU f 2 S e Displays the comments from the device LEDC LEDC designated by S at the LED display 7 150 device on the front of the CPU module Resets annunciator and display unit Y 2 34 2 34 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 10 Debugging and failure diagnosis instructions Table 2 27 Debugging and Failure Diagnosis Instructions Category Instruction I E m Check C
38. gt 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 D102 gt 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 D103 Becomes 0 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Le pen Process CPU CIR 6 4 7 16 bit and 32 bit data exchanges XCH XCF XCHP DXCE DXCH DXCHF DXCHP Usable Devices Internal Devices MELSECNET 10 H Special Index x Br User File Eu 3 Function Constant Das Register Other Register Module K H Word 2 Instruction Symbol Execution Condition indicates XCH DXCH Command XCH DXCH Command XCHP DXCHP Set Data Head number of device storing data to be exchanged BIN 16 32 bits Functions XCH 1 Conducts 16 bit data exchange between 6 and 62 b15 b8b7 bO b15 b8b7 bO Before execution b15 After execution lilo s 0 111 1 0 0 0 0 0 0 0 00 1 111 DXCH 1 Conducts 32 bit data exchange between 1 6 and 6 1 1 63 1 b16b15 b Before execution 11111 E E 111 1111 b31 b16b15 bO b31 bl6b15 b0 After execution o oro ri mmm pn 11170070 0 0 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no errors ass
39. or P instructions Program Example 1 The following program adds 28 bit data from X10 to X2B to the data at D9 and D10 when XO goes ON and outputs the result of the operation to Y30 to Y4B Ladder Mode List Mode 0 m i K7X10 09 K7Y30 Steps Instruction Device 0 LD X0 1 D P K7X10 D9 K7Y30 5 END 2 The following program subtracts the data from MO to M23 from the data at DO and D1 when XB goes ON and stores the result at D10 and D11 Ladder Mode List Mode 0 js K6M0 210 Steps Instruction Device 0 LD X0B 1 D P 00 K6M0 D10 5 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Le 20202027 Process CPU Cn 6 2 3 BIN 16 bit multiplication and operations TI PIA P Usable Devices Internal Devices MELSECNET 10 H Special Index es A User File eo EU Function Constant bus Register Other Register Module K H Word U Ae Zn So Instruction Symbol Execution Condition L J indicates the signs or Command amp F Command Set Data Meaning Data that will be multiplied or divided or the first number of the device storing data that will be multiplied or divided BIN 16 bit Data to multiply or divide by or the first number of device storing such s First number of the device storing the operation results of multiplication or BIN 32
40. 43 C 1 44 D 434 C 2 45 00H D 2 00H 00H Upper byte is not The 00H code is automatically transferred stored at the Upper byte Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO There is no 00H code stored between the device number designated by and the relevant device Error code 4101 e It is not possible to store the entire designated character string in the number of points from the device designated by D to the final device number cited Error code 4101 Program Example 1 The character string data stored in D10 to D12 is transfered to D20 to D22 when X0 goes ON Ladder Mode List Mode 0 M 00 2020 Steps Instruction Device 0 LD X0 1 MOVP 010 4 4 END b15 b8b7 b0 b15 b8b7 bO D10 4D M 2A D20 4D M 2A D11 D12 45 E 45 E 00 gt D21 45 E 45 E D22 004 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Ie 20002027 Process CPU ONA 6 4 4 16 bit and 32 bit negation transfers MLP DOMI DCMLP Usable Devices Internal Devices MELSECNET 10 H Special Index x Br User File Eu 3 Function Constant Das Register Other Register Module K H Word UA Zn Instruction Symbol Execution Cond
41. Instruction Device 0 LD SM400 1 DFLTP 020 DO 4 END D21 D20 integer D1 DO EXT LK conversion 16543521 pe 16543521 BIN value Floating decimal point type real number Integer Bob D20 conversion 173963112 An error is generated in the operation results BIN value because there are 7 significant digits D1 DO 173963120 Floating decimal point type real number 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU j 6 3 4 Conversion from floating decimal point data to BIN 16 and 32 bit data INT INTP DINT DINTP Usable Devices Internal Devices MELSECNET 10 H Special Index E zu BE User File ER P Function Reaister Register MU Ier 9 Instruction Symbol Execution Condition indicates INT or DINT Command INT DINT INTP DINTP f Command Set Data Meaning Head device number storing floating decimal point data that will be Real number converted to BIN value Head device number to store BIN value after conversion BIN 16 32 bits Functions 1 Converts the floating decimal point real number designated at into BIN 16 bit data and stores it at the device number designated at 1 gt um N A Floating decimal point type real number 2 The range of floating decimal point type real numbers that be designated at 1 or is from 32768 to 32767 3 Stores integer
42. OFF Count up add numbers when counting ON Count down subtract numbers when counting Number of counter that will perform count on UDCNT1 instruction BIN16 Functions 1 When the input designated at goes from OFF to ON the present value of the counter designated at will be updated 2 The direction of the count is determined by the ON OFF status of the input designated by S 1 OFF Count up counts by adding to the present value ON Count down counts by subtracting from the present value 8 Count processing is conducted as described below When the count is going up the counter contact designated at D goes ON when the present value becomes identical with the setting value designated by n However the present value count will continue even when the contact of the counter designated at goes ON See Program Example 1 When the count is going down the counter for the contact designated at D goes OFF when the present value reaches the set value minus 1 See Program Example 1 The counter designated at is a ring counter If itis 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 6 113 6 113 6 BASIC INSTRUCTIONS MELSEC Q QnA The count processing performed on the present value is as shown below 32768 32767 1 01o2
43. PLC Output Module Y67to 4 Y63to Y60 Y5Fto Y5C 58 Y57toY54 Y53toY50 Y4Fto Y4C Y4Bto YA8 Y47to 44 Y43 to Y40 Output power supply 7 element display unit Ladder Mode List Mode 0 see DO K10000 D2 Steps Instruction Device 0 LD SM400 K10000 K6Y50 6 DBCDP D2 9 BCD PUN K4Y40 12 END END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin es I C O ie os 6 3 2 Conversion from BCD 4 digit and 8 digit data to BIN data BIN BINP DBIN DBINP Usable Devices Internal Devices MELSECNET 10 H Special inda Other zu BE User File Direct Ji N 4 Function Constant Dai Register Module Register K H Instruction Symbol Execution Condition indicates BIN or DBIN Command BIN DBIN Command BINP DBINP Set Data SetData Data Meaning DataType Type BCD data or head number of device storing BCD data BCD 4 8 digits Head number of device that will store BIN data BIN 16 32 bits Functions Converts BCD data 0 to 9999 at device designated by S to BIN data and stores at the device designated by 8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1 Bcb9999 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 t Thousands digits Hundreds digits Tens digits Ones digits BIN conversio
44. System User File Direct ENI Function Constant Register Register Module Zn UL Command MOV DMOV Command lt MOVP DMOVP Set Data Set Data Transfer data or number of device storing transfer data BIN 16 32 bits Number of device to store transferred data P Functions MOV 1 Transfers the 16 bit data from the device designated by to the device designated by 15 bO Prior totranster 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 g Transmission bi5 LEA AA ee Ser e Id Ii 2 22 60 After transfer 1 0 11101 1 111 1 1 DMOV 2 Transfers 32 bit data at the device designated by to the device designated by Qa bIbrie Fes SHS b1b 6 bO Prior to transfer 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 1 U Transmission 15 bO0bi5 bO Aftertranster 1 0 1 1 0 1 0 0 1 1 1 0 1 0 6 78 6 78 Code used to write instruction instruction symbol 2 Section number and general category of instructions being discussed Devices which can be used by the instruction in question are
45. K32766 H8000 HFFFE H7FFE BK 1 Subtracts n points of BIN data from the device designated by and n points of BIN data from the device designated by 62 and stores the result from the device designated by onward 8765 BIN 62 1234 BIN 7531 BIN 6 1 8888 BIN 62 1 5678 BIN 1 3210 BIN 6 2 9325 BIN 2 2 551 BIN SS SSS C SS 2 5000 BIN G3 n 2 4321 BIN n 2 679 BIN 1 4352 BIN G2 4 n 1 4000 BIN B n 1 352 BIN 2 Block subtraction is performed in 16 bit units 3 The constant designated by 63 can be between 32768 to 32767 BIN 16 bits b15 b0 b15 6 8765 BIN D 115 BIN 6 1 8888 BIN Dis eee b0 Ou 8 BIN 6 2 9325 BIN 8880 BIN 2 445 BIN SS SS 6 2 5000 BIN n 2 3880 BIN 6 1 4352 BIN n 1 4528 BIN 4 The following happens if an underflow or overflow is generated in the operation results The carry flag in this case does not go ON e 32768 K2 gt K32766 H8000 H0002 H7FFF e K32767 K 2 32766 H8000 H0002 H8001 Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The n bit range from the 6 or D device exce
46. Usable Devices Internal Devices MELSECNET 10 H Special 1 rara System User File Direct JL A 4 Function Register Constant Other Register 2 Module Bit Bit Word UA Zn Instruction Symbol Execution Condition Command ROTC H Rorc n1 n2 H Set Data Meaning S 0 Measures table rpm for system use S 1 Call station number S 2 Call item number BIN 16 bits 0 A phase input signal e 1 B phase input signal D 2 0 point detection input signal D 3 High speed forward rotation output signal for system use e 4 Low speed forward rotation output signal for system use D 5 Stop output signal for system use 6 High speed reverse rotation output signal for system use D 7 Low speed reverse rotation output signal for system use Functions 1 This control functions to enable near path rotation of the rotary table to the position of the station number designated by S 1 in order to remove or deposit an item whose number has been designated by 2 on a rotary table with equal divisions of the value designated by n1 2 The item number and station number are controlled as items allocated by counterclockwise rotation 3 The system uses 0 as a counter to instruct it as to what item is at which number counting from station number 0 Do not rewrite the sequence program data Accurate controls will not be possible in cases where users hav
47. k1234 QD100 oes The value 1234 is written to the designation address by D101 and D100 Reads the contents of D100 Device area DO D1 i 1 0100 100 D101 address W100 1234 1 1 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 2 Devices Capable of Indirect Designation The CPU module devices that can be designated indirectly is shown in Table 3 3 Table 3 3 List of Devices Capable of Indirect Designation Indirect Designation Designation Bitdevices 1 Incapable D100 e D100Z2 2 Internal user devices Word devices 1 Capable Bit devices 1 Incapable MEME Link direct devices 5 J1 W10 Mibi s apes J1Z1 W10Z2_ 2 T U10 G0 Special direct devices Capable 3 U10Z1 G0Z2 2 index register Incapable eee n GRO ZR20000 File register Capable ROZ1 ZR20000Z1 2 prose ese one petu oe SFC block devices Incapable 1 1 Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU module or QnACPU Programming Manual Fundamentals for device names 2 2 Indicates index modification by index register 3 3 The device can be designated indirectly however the address cannot be written in the ADRSET instruction 8 Cautions The address for indirect designation is designated using two words Therefore to substitute indirect designation for index modification the additio
48. oO 0 1 1 1 1 HE ON D jd OFF OFF i 8 EN X1 OFF if ON i Turns OFF as X0 remains ON ON 1 V0 OFF Ke 2 Tume ON nen 29 ON T OFF X1 urns a V1 OFF turns from OFF to ON ik avc ue i Turns ON when X1 turns from OFF to ON DO EN on TEF 1 1 l l l 1 l l 1 I I D1 I 1 I POINTS 1 Since EGP and EGF instructions are executed according to the results of operation performed immediately before the EGP EGF instruction these instructions must be used in the same position as the AND instruction refer to 5 1 1 An EGP and EGF instruction cannot be used at the position of an LD or OR instruction 2 EGP and EGF instructions cannot be used at the circuit block positions shown below Xi SET Mo I 1 SET 2 2 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU ONA ope epo pes o L e 5 3 Out Instructions 5 3 1 Out instructions excluding timers counters and annunciators OUT Usable Devices Internal Devices MELSECNET 10 H Special index Other a NU User File EX EUE Function Constant Data Register Module Register K H Word Zn EA than T C or F Instruction Symbol Execution Condition Si Bit device number D Bit designation of word device D weh Set Data Data Type Number device
49. Designated value stored value 2 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Subtracts the floating decimal point type real number designated by from the floating decimal point type real number designated by 63 and stores the result at the device designated by 641 621 62 1 E ir oR J N v E SE v 2 Re ot Floating decimal point Floating decimal point Floating decimal point type real number type real number type real number 2 Values that can be designated by 6 6 or and values that can be stored are as follows 0 2126 lt Designated value stored value lt 2128 Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The contents of the designated device or the result of the addition or subtraction operation are not 0 or not within the following range Error code 4100 0 127126 lt Contents of designated device result of operation lt 2128 When the specified device contains 0 Q4ARCPU Operation error does not occur even if 0 is stored if SM707 is turned on Error code 4100 Program Example 1 The following program adds the floating decimal point type real numbers at D3 and D4 and the floating decimal point type real numbers at D10 and D11 when X20 goes ON and outputs the result to RO and R1 Ladder Mode List Mode X20 P Steps Instruction Dev
50. Instruction Symbol Comparison Operation in Result Continuity Comparison Operation Result 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The code OOH or non matching does not exist within the relevant device range following the device number designated by or 6 Error code 4101 At the same time that it is conducting a character string comparison character string data comparison instruction also checks the device range For this reason even in cases where the character string exceeds the device range the character string data is compared If character non matching is detected within the device range at this time the comparison operation results are output without returning an operation error IMs 012287 J gt data 62 data D12287 In the example shown above the 6 character string exceeds the device range but because its second character is different from that of 62 the comparison result is does not equal 62 and the operation result is non continuity In this case because the non continuity detection is for D12287 inside the device range there will be no operation error returned Program Example 1 The following program compares character strings stored following DO and characters
51. RST input HE eere gt Pi cere ray Rene No To No Operation Errors 1 There are no operation errors associated with the RST instruction 1 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 Direct output Timer counter Other than above N 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA b For word processing Internal device word to be specified by bit device 2 Index resister 2 Other than above e Program Example 1 The following program sets the value of the data register to 0 Ladder Mode X0 0 H Mov 4 0 18 When goes ON the contents of X10 to 1F are stored at D8 X5 3 RST 18 When 5 goes ON the value of D8 is set to 0 6 END List Mode Steps Instruction Device 0 LD X0 1 MOV K4X10 08 3 LD X5 4 RST D8 6 END 2 The following program resets the 100 ms retentive timer and counter Ladder Mode 18000 When T225 is set at the retentive timer 01 CT225 the ON time for X4 is 30 minutes then T225 goes ON T225 K16 5 C23 Counts the number of times T225 goes ON RST 1225 When the T225 contact goes ON the T225 coil contact and present value are reset When C23 reaches the count out state Y55 goes ON Resets C23 when X5 goes ON List Mode Steps Instruction Device 0 LD X4 1 OUT 7225 K18000 5 LD T225 6 OU
52. Stored at the upper 32 bits 3 If has been designated as a bit device the remainder of the operation will not be stored Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The or 62 data is outside the 0 to 99999999 range Error code 4100 Attempt to divide 62 by 0 Error code 4100 Program Example 1 The following program multiplies the BCD data 67347125 and 573682 stores the result from D502 to D505 and at the same time outputs the upper 8 digits to Y30 to Y4F Ladder Mode List Mode SM400 P 0 DBs H68347125 H573682 0502 Steps Instruction Device 0 SM400 me DMOV D504 K8Y30 H573 7 MN D504 10 END D505 D504 D503 D502 A A A AN i6 8 3 4 7 1 2 5 00 5 7 3 6 8 2 gt 0 0 39 2 0 9 5 1 5 3 6 4 2 5 0 Multiplicand Multiplier 2 The following program divides the BCD data from X20 to 3F by the BCD data at D8 and D9 when goes ON and stores the result from D765 to D768 Ladder Mode List Mode 0 uu DRE m K8X20 08 D765 Steps Instruction Device 0 LD 1 DB P K8x20 165 5 END D9 Upper 4 digits D8 Lower 4 digits 3 X20 9 8 6 4 3 2 1 1 5 2 6 3 7 4 8 Multiplicand Divider D766 D765 D768 D767 Upper 4 digits Low
53. When XB is ON jumps to label P23 from P23 executes the next step Executed when XB is OFF Indicates the termination of the sequence program when XB is OFF List Mode Steps Instruction Device 0 LD X0 1 QUT Y20 2 LD 3 CJ P23 5 LD X13 6 OUT Y30 7 LD X14 8 UT Y31 9 FEND 10 P23 11 LD Xi 12 OUT Y22 13 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin or p ee p e 16x 5 6 2 End sequence program END Usable Devices Internal Devices MELSECNET 10 H Special index Other eo Br s User File zs pon E Function Constant baia Register Register K H Module UA Zn Instruction Symbol Execution Condition Functions 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 Sequence program END Y 2 An END instruction cannot be used during the execution of the main sequence program If itis necessary to perform END processing during the execution of a program use the FEND instruction 3 When programming in the ladder mode of a peripheral device it is not necessary to input an END instruction 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 4 The use of the END and FEND instructions is broken down as follows for main r
54. d Register Word Module Zn K UL AG a DE PEE Other goe e Jos Instruction Symbol Execution Condition K50 4 Set value Settings from 1 to 32767 are valid OUT Low speed timer Set value Contents of data register settings from 1 to 32767 are valid Set value Settings from 1 to 32767 OUTH T are valid High speed timer H D10 Set value TO gt Contents of data Se settings from 1 to 32767 are valid K50 Set value X STO gt Settings from 1 to 32767 OUT ST are valid Low speed retentive timer D10 Set value STO gt Contents of data register settings from 1 to 32767 are valid K50 lt Set value sto gt Settings from 1 to 32767 OUTHST are valid High speed retentive timer H D10 Set value STO gt Contents of data register settings from 1 to 32767 are valid 1 values can be set only as a decimal constant Hexadecimal constants H and real numbers cannot be used for timer settings 2 The file register cannot be used in the Q00JCPU 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Set Data Set Data Timer number Setvdue Value set for timer BIN 16 bits 3 x3 The value setting for the timer cannot be designated indirectly Indirect designation not possible HELM See Section 3 4 for further information on indirect designa
55. 1 Stores 62 1 the value which varies the value specified in n1 to the value specified in n2 linearly by the number of shifts specified in n3 The value to be stored in 1 is calculated every scan with the following expression Value specified in n2 Value specified in n1 Number of shifts X Number of executions L One variation 0 is varied to 350 in six scans as shown below 350 Value stored in 0 ate Value 350 specified in n2 Value 0 specified in n1 L Number of shifts 7 When the calculated one variation is indivisible compensation is made to achieve the value specified in n2 by the number of shifts specified in n3 Hence a linear ramp may not be made 6 124 6 124 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 For n3 designate the number of scans required to move data from n1 to n2 No processing is performed when n3 0 3 The system uses 6 1 to store the number of times the instruction has been executed 4 When the move is completed to the final value the completion device designated by 62 0 will go ON The ON OFF status of the completion device and the contents of 6 0 are determined by the ON OFF status of the device designated by 2 1 When 2 1 is OFF 63 0 will go OFF at the next scan and the RAMP instruction will begin a new move operation from the value currently at 6 0 e When 1 is ON 2 0 will remain ON and the contents of 6 0 will no
56. 1 The following program adds the BCD data at D3 and D4 to the BCD data at Z1 and Z2 when X20 goes ON and stores the result at R10 and R11 Ladder Mode List Mode 0 03 71 R10 Steps Instruction Device 0 LD X20 1 B P 03 5 END P 5 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU 1 1 11 QCPU PLG Process CPU Cn idem ccu 6 2 7 BCD 4 digit multiplication and division operations B B P Usable Devices Internal Devices MELSECNET 10 H Special Set ese Index System User File Direct JL N 4 Function Constant Data Module Register KH Other DEC ERES E Instruction Symbol Execution Condition J indicates the signs or B Command B BxP B P f Command Set Data Data that will be multiplied or divided or the head number of the device data that will be multiplied or divided BCD 4 digit Head number of the device storing the operation results of multiplication BCD 8 digit or division operation Functions 1 Multiplies BCD data designated by 6 and BCD data designated by 63 and stores the result in the device designated by Q 1 6 Upper 4 digits Lower 4 digits 5 67 8 7 6 2 16 4 9 7J 3 9 28 2 Values for and 6 can be set from 0 to 9999 BCD 4 digits 1 Divides BCD data designated by 6
57. 3 RST D0 5 b5 of DO at 0 S CREE 4 END b5 b0 Doj r1 REMARK The basic SET instructions are as follows When internal device or file register RO to R32767 are in use Step 1 e When direct access output DY or SFC program device BL use Step 2 When timer T or counter C are in use Step 4 When some other device is in use Step 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin pog S p e 5 3 6 Resetting devices except for annunciators RST Usable Devices Internal Devices MELSECNET 10 H Special Index n BE s User File EX EH 3 Function baia Register Register Instruction Symbol Execution Condition RST input RT 7 Set Data Meaning Data Type Bit device number to be reset Word device bit designation Word device number to be reset BIN 16 bits Functions 1 Designated devices respond as follows when RST input is turned ON Device Device Status Bitdevice Tums oils and contacts OFF Sets the present value to 0 and turns coils and contacts OFF Set Data Timers and counters babe designation has been made for word Sets value of designated bit to 0 Word devices other than timers and counters Sets contact to 0 2 Device status does not change when RST input goes OFF 8 The functions of the word devices designated by the RST instruction are identical to the following ladder 4
58. Basic Steps Description BIN 16 bit addition and subtraction operations 0 1 D S 1 S 0 1 D e S11 S1 S241 S2 2 0 1 D BIN 32 bit addition and subtraction operations D 1 D S 1 S D 1 D e 51 1 51 52 1 S2 0 1 D 81 52 0 1 D BIN 16 bit e 8141 S1 S241 S2 gt 0 3 D 2 D 1 D e S141 S1 S21 S2 Quotient 0 1 D Remainder D 3 D 2 2 INSTRUCTION TABLES MELSEC Q QnA 1 1 The number of steps may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification High Performance model QCPU Process CPU Constant No limitations 2 When using devices other than 1 Basic model QCPU QnCPU Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 3 2 2 The number of step
59. Constant Data Register Other r o o el j o J Instruction Symbol Execution Condition Cl indicates the signs lt gt gt lt lt or gt LD Set Data 6 First number of comparison data or of the device where comparison data is being stored Character string Functions 1 Treats character string data stored following the device designated by and character string data stored following the device designated by 62 as A contact and performs comparison operation 2 A comparison operation involves the character by character comparison of the ASCII code of the first character in the character string 3 The and 6 character strings encompass all characters from the designated device number to the next device number storing the code 00u a If all character strings match the comparison result will be matched b15 b8 b7 bO b15 b8 b7 bO 42H B 41H A B 41H A G2 1 44H D 43H C 1 44H D 43H C 6242 45H E 2 00H 45H E ABCDE ABCDE Instruction Symbol Comparison Operation Instruction Symbol Comparison Operation inc Result Result Non continuity Non continuity Non continuity Continuity 6 BASIC INSTRUCTIONS MELSEC Q QnA b If the charact
60. Functions Explanation device names of High Programming Performance model QCPU fundamentals This manual Y QCPU mode QCPU Q mode QnACPU QnACPU QCPU Q mode QCPU Q mode Programming Programming QnACPU Programming Manual Manual Programming Manual Common PID Manual SFC MELSAP L Instructions Control Instructions Describes the instructions Describes the instructions Describes SFC Describes MELSAP L other than described in the to perform PID control manuals on the right 1 GENERAL DESCRIPTION MELSEC Q QnA 2 QOOJCPU Q00CPU Q01CPU Basic model QCPU Q mode Describes the functions User s Manual executable programs Functions l O processing and Explanation device names of Programming Basic model QCPU fundamentals This manual QCPU Q mode QnACPU Programming Manual Common Instructions 3 Q12PHCPU Q25PHCPU Process CPU yid x Describes the functions Function executable programs Explanation I O processing and Programming Fund tal device name of Process CPU This manual QCPU Q mode QnACPU Programming Manual Common Instructions Describes the instructions other than described in the manuals on the right Describes the instructions to perform process control QnPHCPU Programming Manual Process Control Instructions QCPU Q mode QnACPU Programming Manual SFC Describes
61. LD LDI AND ANI OR ORI 5 2 5 1 2 Pulse operation start pulse series connection pulse parallel connection EDP EDR ANDP ANDA ORP tet oit eden e ee eec n 5 5 5 2 Connection Instructions nas 5 7 5 2 1 Ladder block series connections and parallel connections ANB ORB 5 7 5 2 2 Operation results push read MPS MRD MPP a 5 9 5 2 3 Operation results inversion INV c cccsccceceeeseeeeceeeeeeeeeeaeceeseeeeaesaeceeseaesaesaeseeeaesaesaeseaeeaseeseaseateas 5 13 5 2 4 Operation result pulse conversion MEP 5 14 5 2 5 Pulse conversion of edge relay operation results EGP EGF 5 16 QUE IFISITUGHOFIS A E E E 5 18 5 3 1 Out instructions excluding timers counters and annunciators OUT 5 18 5 3 2 Timers OUT T OUT EL T itcr aah casts oui peret coca eec ri ce ip t 5 20 5 9 9 Gounters tee eL Rd EU i P b e LEE b ta THERE 5 24 5 9 4 Annunciator output OU T EJ et rim er tee D Era ed de err ab e re LR ae eret 5 26 5 3 5 Setting devices except for annunciators SET sse 5 28 5 3 6 Resetting devices
62. One shot after on timer output D 3 On delay timer output Rotates a rotary table with n1 divisions from the stop position to the position designated by S 1 by the nearest path from n1 to n2 in n3 scans Counts the pulse input from the device designated by S for the duration of time designated by n and stores the count in the device designated by D n1 Hz D Output n2 times 1 D Store 16 times of n lows in the device specified by S to the device specified by D2 in sequence 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 Application Instructions 2 5 1 Logical operation instructions Table 2 18 Logical Operation Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description Logical 0 1 0 A S 1 S D 1 D product e S1 1 51 A S2 1 52 gt D 1 D 0 1 D N S 1 S gt D 1 D Logical sum e S1 1 51 52 1 52 gt D 1 D
63. Program Example 1 The following program compares floating decimal point real number data at DO and D1 to floating decimal point real number data at D3 and D4 Ladder Mode List Mode OE DO 03 f G33 Steps Instruction Device 0 LDE Do 4 END Ton 2 The following program compares the floating decimal point real number 1 23 to the floating decimal point real number data at D3 and D4 Ladder Mode List Mode 0 id HH Eo 8 23 03 33 Steps Instruction Device 0 LD M3 1 ANDE lt gt 1 23 6 ED 5 Y33 6 END 3 The following program compares floating decimal point real number data at DO and D1 to floating decimal point real number data at D3 and D4 Ladder Mode List Mode jE BS pu Steps Instruction Device 0 LD M3 ui 1 LDE gt D 4 OR M8 5 ANB 6 OUT Y3 7 END 4 The following program compares the floating decimal point data at DO and 01 to the floating decimal point real number 1 23 Ladder Mode List Mode 133 Steps Instruction Device 0 LD M3 1 AND M8 2 ORE lt DO E1 23 6 OUT Y33 7 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU 1 1 CPU Process CPU I QLAR pe Nee Se S L 6 1 4 Character string data comparisons lt gt gt lt lt gt Usable Devices Internal Devices MELSECNET 10 H Special Set i rara Index System User File Direct JL N 4 Function
64. QnACPU Functions 1 Transfers in batch 16 bit data n points from the device designated by to location n points from the device designated by S 15 b0 1234 1 5678 D 5678H transmission 2 7FFOH D 2 7FFOH M n 2 6FFFH B n 2 6FFFH n 1 553FH n 1 553FH 2 Transfers can be accomplished even in cases where there is an overlap between the source and destination device In the case of transmission to the smaller device number transmission is from S for transmission to the larger device number transmission is from S n 1 3 When 9 is a word device and D is a bit device the object for the word device will be the number of bits designated by the bit device digit designation If K1Y30 has been designated by D the lower four bits of the word device designated by will become the object bibo b4b3b2b1b0 n 2 1 D100 1101111 Y8B Y38Y37 Y34Y33 Y30 1 0101 oot gt 0111001141011 n gt 2 D102 6 BASIC INSTRUCTIONS MELSEC Q QnA 4 If bit device has been designated for S and D then S and D should always have the same number of digits 5b Only either of S or D can be designated for the MELSECNET 10 H direct device and intelligent function module special function module device Operation Errors 1 In the following
65. Shows symbol diagram on the ladder ls DH 521014 destination Indicates destination Indicates source Indicates source Indicates instruction symbol Indicates instruction symbol Fig 2 1 Shows Symbol Diagram on the Ladder Destination Indicates where data will be sent after operation SOUICG ce o erre Stores data prior to operation Indicates the type of processing that is performed by individual instructions D S D D 1 D S 1 S D 1 D p 16 bits 16 bits Indicates 16 bits Indicates 32 bits D 1 D The upper 16 bits The lower 16 bits Fig 2 2 Type of Processing Performed by Individual Instructions The details of conditions for the execution of individual instructions are as follows Execution Condition Instruction executed under normal circumstances with no regard to the ON OFF No symbol recorded status of conditions prior to the instruction If the preconditions is OFF the instruction will conduct OFF processing Executed during ON instruction is executed only while the precondition is ON If the preconditions is OFF the instruction is not executed and no processing is conducted Executed once at ON instruction executed only at leading edge when precondition goes from OFF to ON Following execution instruction will not be executed and no processing conducted even if condition rema
66. Word Device Bit No Designation of bit numbers is done in hexadecimal For example bit 5 65 of DO is designated as 00 5 and bit 10 b10 of DO is designated as DO A However there can be no bit designation for timers T retentive timers ST counters C or index register Z Example 20 0 is not available Word device bit designation x Bit 5 b5 of DO designated as X0 m sr pos ON 1 Word device bit designation di Turned ON or OFF according SET Y10 to the 1 O status of bit 5 b5 of DO 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 e Decimal constants K 32768 to K32767 e Hexadecimal constants H0000 to HFFFF Word devices and bit devices designated by digit can be used as word data For direct access input DX and direct access output DY word data cannot be designated by digit output DY For details of direct access input and direct access output refer to the User s Manual Function Explanation Program Fundamentals of the CPU module in use or the QnACPU Programming Manual Fundamentals 1 When using bit devices a Bit devices can deal with word data when digits are designated Digit designation of bit devices is done by designating Number of digits Initial number of bit device P Digit d
67. a When printing ladders A page break will be inserted between ladder blocks with the presence of the NOPLF instruction The ladder cannot be displayed correctly if an NOPLF instruction is inserted in the midst of a ladder block Do not insert an NOPLF instruction in the midst of a ladder block b When printing instruction lists The page will be changed after the printing of the NOPLF instruction 8 Refer to the Operating Manual for the peripheral device in use for details of printouts from peripheral devices 5 52 5 52 PAGEn 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 1 This is a no operation instruction that has no impact on any operations up to that point 2 Causes processing from step 0 of the designated nth page of the program following the PAGE n instruction Peripheral device display printers etc 3 If there is no PAGE n instruction processing begins from page O Operation Errors 1 There are no errors associated with the NOP NOPLF or PAGE instructions Program Example NOP 1 Contact closed Before change Ladder Mode X8 om Y96 it 12 Changed to END After change Ladder Mode X8 Y96 0 91 T 2 Contact closed CY12 gt END Deletes AND or ANI instruction List Mode Steps Instruction Device 0 LD X8 px AND Y97 2 ANI Y96 3 OUT Y12 4 END List Mode
68. b8b7 bO 42 41H A 32 2 1 424 41 A 1 44 D 4384 Qu 344 4 331 gt O 1 44u D 43 2 O04 45 E 2 36 6 35 5 2 31 1 45 E ka CER 3 004 2 2 123456 4 5 3 4 5 00H 364 6 ABCDE123456 2 When character strings are linked the 00H which indicates the end of character string data designated at D is ignored and the character string designated at S is appended to the last character of the D string 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SD The entire character string linked from the device number designated by D to the final device number of the relevant device cannot be stored Error code 4100 The storage device numbers for the character strings designated by S and D overlap Error code 4101 2 See Section 3 6 for information regarding errors during index modification Program Example 1 The following program links the character string stored from D10 to D12 to the character string ABCD when is ON Ladder Mode List Mode 0 iu LL 3 d gt ABCD D10 Steps Instruction Device 0 LD X0 1 ABCD 6 END 010 b15 08
69. fixed T contact and coil ST contact and coil C contact and coil Present value of T Present value of ST Present value of C D w SW Empty area File register 32 k points Empty area created when device used is less than 28 75 k words 1 Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU module or the QnACPU Programming Manual Fundamentals for how to change the internal user device allocation 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 7 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 e Non conditional Instructions executed without regard to the ON OFF status of the device Example LD X0 OUT Y10 e Executed at Instructions executed while input condition is ON Example MOV instruction FROM instruction e Executed at leading edge Instructions executed only at the leading edge of the input condition when it goes from OFF to ON Example PLS instruction MOVP instruction e Executed at trailing edge Instructions executed only at the trailing edge of the input condition when it goes from ON to OFF Example PLF instruction For coil or equiv
70. o gt M36 M45 X010 X011 X012 X013 X014 X015 X016 X017 X018 X019 1 X01B X01C X01D XO1E xotF Caution 1 Note that the MTR instruction directly operates on actual input and cutput The output 6 that had been turned ON by the MTR instruction does not turn OFF when the MTR command turns OFF Turn OFF the specified output in the sequence program 2 An MTR instruction execution interval must be longer than the total of response time of input and output modules If the set interval is shorter than the value indicated above an input cannot be read correctly If the scan time in a sequence program is short select the constant scan and set the scan time longer than the total of response time 6 133 6 133
71. 0 0 L PMM 100 KI 20 Steps Instruction Device 0 LD X0 1 PWM K100 K1000 Y20 5 END 6 131 6 181 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA pepe EO 6 8 10 Matrix input MTR Usable Devices Internal Devices MELSECNET 10 H Special Index ea Br s User File EN Eu 1 Function baia Register Constant Other Register Module Word UA Zn re Instruction Symbol Execution Condition Command MTR c MR n H Set Data Set Data Meaning Data Type Head input device Head output device L9 Head number of device that will store matrix input data Number of input rows BIN 16 bits Functions 1 Successively reads the input from 16 points starting from the input number designated by multiplied by n rows then stores the data fetched in this operation from the device designated by 62 onward 2 One row 16 points can be fetched in 1 scan 8 Fetching from the first to the nth row is progressively repeated 4 The first through the 16th points store the first row of data and the next 16 points store the second row of data at the devices following the device designated by 63 For this reason the space of 16xn points from the device designated by 63 are occupied by the MTR instruction 5 69 is the output needed to select the row which will be fetched and the system automatically turns it ON and OFF It uses the n points f
72. 1 RD 4 END When the number of bits at is less than the number of bits at D M35 24 23 M16 E pp a These bits are all read as 0 0100 01110010 1100 Y6391 Y56 Y48Y47 Y40 1 y 1000 t 0 100 11 6 Inverts the data at DO and D1 when X3 is ON and stores the result at D16 and D17 Ladder Mode List Mode 0 B DO D16 Steps Instruction Device 0 LD x3 T 1 DCMLP n 4 END b31 b24 b8b7 bO DO D1 0 1 11 0 0 10 1 100 b31 b24 b8b7 bO D16 D17 1111101111 1 0 0 0 1 1 0 1 0 0 1 1 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA gp OS C S OS L CO 6 4 5 Block 16 bit data transfers BMOV BMOVP Usable Devices Internal Devices MELSECNET 10 H Special Index eo Br s User File a pen E Function Constant Dara Register Other Register Module K H Word Word 2 px es Instruction Symbol Execution Condition Command BMOV Y BMOV n BMOVP f a Set Data Set Data Meaning Head number of device storing data to be transferred Head number of destination device BIN 16 bits Number of transfers If special direct device UL AG 2 is used 1 to 6144
73. 2 Instructions for which subset processing can be used Types of Instructions Instruction Symbols Comparison instructions lt gt lt lt gt gt D D lt gt D lt D lt D gt D gt pacc al melo INC DEC D D D DINC DDEC addition subtraction STU eus B B B multiplication and division Data conversion instructions BCD BIN DBCD DBIN MOV DMOV CML DCML XCH DXCH FMOV BMOV EMOV with QCPU only Program branch instruction CJ SCJ JMP 1 Itis only QCPU that can use three devices to conduct subset processing of the logic operation instructions WAND DAND WOR DOR WXOR DXOR WXNR or DXNR WAND H wanD H Subset processing possible Subset processing possible only with Q QnACPU with QCPU Data transfer instruction 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 6 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 No intelligent function module or special function module is installed at the designated I O No position when using the buffer register The relevant network does not exist when using a link device No network module is installed at the desig
74. 3 Floating decimal point data comparisons E E lt gt E E lt E lt 6 6 6 1 4 Character string data comparisons lt gt gt lt lt gt 6 8 6 1 5 BIN block data comparisons BKCMP BKCMPP a 6 12 6 2 Arithmetic Operation Instructions 6 16 6 2 1 BIN 16 bit addition and subtraction operations P P 6 16 6 2 2 BIN 32 bit addition and subtraction operations D D P D D P 6 20 6 2 3 BIN 16 bit multiplication and division operations x P P 6 24 6 2 4 BIN 32 bit multiplication and division operations DP D D P 6 26 6 2 5 BCD 4 digit addition and subtraction operations B B P B 6 28 6 2 6 BCD 8 digit addition and subtraction operations DB DB P DB DB P 6 32 6 2 7 BCD 4 digit multiplication and division operations B B 6 36 6 2 8 BCD 8 digit multiplication and division operations DB kP DB DB P 6 38 6 2 9 Addition and subtraction of floating decimal point data E E P E E P
75. 32 bits bO to 31 If the upper 32 bits of the bit device are required for the result of the multiplication operation first temporarily store the data in a word device then transfer the word device data to the bit device by designating 2 and 3 data 3 The values for 6 62 and D can be designated at between 2147483648 to 2147483647 BIN 32 bits 6 BASIC INSTRUCTIONS MELSEC Q QnA 4 Judgment whether values for 6 63 and D are positive or negative are made on the basis of the most significant bit 631 for 6 and 62 and b63 for 0 Positive x pe Negative 1 Divides BIN 32 bit data designated by 63 and BIN 32 bit data designated by 62 and stores the result in the device designated by 6 1 6 634 1 62 1 3 2 b31 b16b15 bO 631 b16 b15 bO b1 b15 b0 K b16 b15 b0 567890 BIN 123456 BIN c J usni 74066 BIN 2 If a word device has been used the result of the division operation is stored as 64 bits and both the quotient and remainder are stored if a bit device has been used 32 bits are used and only the quotient is stored Quotient Stored at the lower 32 bits Remainder Stored at the higher 32 bits Can be stored only when a word device has been used 3 The values for and 63 can be designated at between 2147483648 to 2147483647 BIN 32 bits 4 Judgment whether values for 6 63 D and 2 are positive or negative is m
76. 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the lt gt gt lt lt or gt instructions Program Example 1 The following program compares the data at to with the data at and turns Y33 ON if the data is identical Ladder Mode List Mode 0H 03 133 Steps Instruction Device 0 LD K4X0 4 END 3 QUT Y33 4 END 2 The following program compares BIN value K100 to the data at D3 and establishes continuity if the data in D3 is something other than 100 Ladder Mode List Mode 0 s RK lt gt KO J C n 33 Steps Instruction Device 0 LD M3 1 AND lt gt K100 5 END 4 OUT Y33 5 END 3 The following program compares the BIN value 100 with the data in XO to XF and establishes continuity if the D3 data is less than 100 Ladder Mode List Mode 0 gt KI D3 y33 Steps Instruction Device 0 LD M3 M8 1 LD gt K100 D3 4 OR M8 5 ANB 6 OUT Y33 T END 4 The following program compares the data in DO and D3 and if the data in DO is equal to or less than the data in D3 establishes continuity Ladder Mode List Mode 0 M e Y33 Steps Instruction Device 0 LD M3 1 AND M8 lt 20 D3 2 OR lt D3 5 OUT Y33 6 END 6 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA C COS o a 6 1 2
77. BCD 4 digit data to block BIN 16 bit data BKBIN BKBINP Usable Devices Internal Devices MELSECNET 10 H Special Index x BE User File ui Bo P Function Constant Dus Register Other Register Module Zn K H UL AG i ep o rt Instruction Symbol Execution Condition Command BKBIN BKBIN n E Command BKBINP f E BKBINP Set Data Meaning BIN 16 bits Functions 1 Converts BCD data 0 to 9999 n points from device designated by to BIN and stores result following the device designated by OO f N 00 SF OFNT OTN BCD 1234 0101011 00 1 0 01011 1 011 00 O 1 BCD 5678 011101170111110101111 1111010 0 n 2 BCD 4321 o 110 0 070 1 1 070 17007001 n 1 BCD 5555 0 40 10 10110 1010101 ll BIN conversions CN COOO st O O st CNCN COCO OO SF LO N CO CO OO f N BIN 1234 0 00 0 0 1 0 0 1 1 0 1 0010 1 BIN 5678 0 0 0 1 0 1 1 0 0 0 1 0 1111 1 0 2 BIN 1545 0 0 0 0 0 1 110 0 0 0 0 110 0 1 2 BIN 4321 01010 110101010 11111 0 01010 1 n 1 BIN 5555 0 001011 0 1 11011107011 k 6 BASIC INSTRUCTIONS Operation Errors MELSEC Q QnA 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored
78. BIN 32 bit data comparisons D D lt gt D gt D lt D lt D gt Usable Devices Internal Devices MELSECNET 10 H Special Index xx MI User File E no 1 Function Constant bu Register Other Register Module K H Word UA Zn Ee Instruction Symbol Execution Condition L indicates the signs D D lt gt D D lt D lt or D gt LoL FOC erp H i D Set Data Set Data Meaning Comparative data or device number where comparative data is stored BIN 32 bits Functions 1 Treats BIN 32 bit data from device designated by and BIN 32 bit data from device designated by 63 as an A contact and performs comparison operation 2 The results of the comparison operations for the individual instructions are as follows Instruction Comparison Instruction Comparison Symbol Condition Operation piss Condition Operation kemi Result Result Continuity Non continuity 3 In cases where hexadecimal constants have been designated by and 62 or when a numerical value 8 to F where the highest bit 631 will be 1 has been designated the value will be read as a negative BIN value number for the purposes of the comparison 4 Data used for comparison should be designated by a 32 bit instruction DMOV instruction etc If designation is made with a 16 bit instruction MOV instruction etc comparisons of large an
79. D 1 1 b31 b16 b15 b0 b16 b15 b0 73500 BIN 1 E E BIN 2 If the contents of the device designated by are 0 and the DINC or DINCP instruction is executed the value 1 will be stored at the device designated by D Operation Errors 1 There are no operation errors associated with DINC P or DDEC P 6 BASIC INSTRUCTIONS MELSEC Q QnA Program Example 1 The following program adds 1 to the data at DO and D1 when is ON Ladder Mode List Mode 0 2 m im D0 Steps Instruction Ai Device 0 LD Xo 1 DINCP D0 3 END 3 END 2 The following program adds 1 to the data set at X10 to X27 when goes ON and stores the result at D3 and D4 Ladder Mode List Mode 0 K6X10 03 Steps Instruction Device 0 LD X0 P 1 DMOVP K6X10 DING D3 4 D3 6 END 3 The following program subtracts 1 from the data at DO and D1 when goes ON Ladder Mode List Mode 0 TES DO Steps Instruction Device 0 LD X0 1 DDECP 00 3 END 3 END 4 The following program subtracts 1 from the data set at X10 to X27 when goes ON and stores the result at and D4 Ladder Mode List Mode 0 Doy 6 10 03 Steps Instruction Device LD X0 P DMOVP K6X10 DDEC DDECP D3 END on o 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin ope epo pee copie qo 6 3 Data Conversion Instruc
80. EGP instruction is used for sub routine programs and for conducting pulse operations for programs designated by index modification between FOR and NEXT instructions 4 The EGP instruction can be used like an AND instruction EGF 1 Operation results up to the EGF instruction are stored in memory by the edge relay V 2 Goes ON at the trailing edge from ON to OFF of the operation result up to the EGF instruction If the operation result up to the EGF instruction is other than a trailing edge i e from OFF to ON ON to ON or OFF to OFF it goes OFF non continuity status 8 The EGF instruction is used for sub routine programs and for conducting pulse operations for programs designated by index modification between FOR and NEXT instructions 4 The EGF instruction can be used like an AND instruction 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the EGP or EGF instructions Program Example 1 A program containing a subroutine program using an EGP instruction Ladder Mode List Mode 0 ES MN KO 70 H Steps Instruction Device 0 LD SM400 1 MOV m Lamm H 4 CALL PO 6 MOV 70 MOV Kl 70 H 9 CALL PO 11 FEND 12 13 LD 070 CALL PO H 14 EGP VOZO 15 INC 10720 FEND H P0 020 020 F r I IN 000 H RT H END H Operation END processing D
81. Exclusive OR 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 18 Logical Operation Instructions Continued Execution Processing Details Condition Category Instruction Number of Basic Steps Description S 1S2D n 1S2D n ww ww SID s D S1S2 D S1S2 D 11521 dew BKXNR S REMARK 1 1 The number of steps may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification Constant No limitations High Performance model QCPU Process CPU 2 When using devices other than 1 Basic model QCPU 3 QnCPU Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 2 INSTRUCTION TABLES MELSEC
82. K4 designation range 16 points K5 designation range 20 points K6 designation range 24 points K7 designation range 28 points K8 designation range 32 points Fig 3 4 Digit Designation Setting Range for 32 Bit Instructions b In cases where digit designation has been made at the source S the numeric values shown in Table 3 2 are those which can be dealt with as source data Table 3 2 List of Numeric Values that Can Be Dealt with as Digit Designation Designated Instructions Designated K8 32 points In cases where the source is a bit device designated by digit designation and the destination is a word device the word device for the destination becomes 0 following the bit designated by digit designation at the source Ladder Example With 32 bit instruction K1X0 UA Vv X10 HE es KiX0 H Souce data s Become 0 Fig 3 5 Ladder Example and Processing Conducted 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA c In cases where digit designation is made at the destination D the number of points designated are used as the destination Bit devices after the number of points designated as digits do not change Ladder Example Processing When source S data is a numerical value sh 01 X10 vov H78123456 K5M0 Destination D
83. L JHk ew P amp D n H Set Data Meaning Data Type Data being compared or first number of the device where the data being BIN 16 bits compared is being stored First number of the device where the comparison data is being stored BIN 16 bits First number of the device where the results of the comparison operation are being stored Number of data blocks compared BIN 16 bits Functions 1 Compares BIN 16 bit data the nth point from the device number designated by with BIN 16 bit data the nth point from the device number designated by 63 and stores the result from the device designated by D onward a If the comparison condition has been met the device designated by will be turned ON b If the comparison condition has not been met the device designated by D will be turned OFF Operation Results 6 1234 BIN 69 5321 BIN 6241 5678 BIN 341 3399 BIN 2 5000 BIN ips 9 5678 BIN n 2 7777 BIN n 2 6543 BIN n 1 4321 BIN n 1 1200 BIN 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 The comparison operation is conducted in 16 bit units 3 The constant designated by can be between 32768 and 32767 BIN 16 bit data Operation Results 32000 BIN ON 0 Gu 4321 BIN D OFF 0 32000 BIN 2 ee gt O 2 ON 1 n 2 12
84. MPS 16 AND X8 17 MPS 18 AND x9 19 MPS 20 AND X0A 21 OUT Y40 22 MPP 23 OUT Y41 24 MPP 25 OUT Y42 26 MPP 21 OUT Y43 28 MPP 29 OUT 44 30 31 OUT Y45 32 MPP 33 QUT Y46 34 MPP 35 OUT Y47 36 MPP 37 OUT Y48 38 MPP 39 OUT Y49 40 MPP 41 QUT 42 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin K COS S L e pvp 5 2 3 Operation results inversion INV Usable Devices Internal Devices MELSECNET 10 H Special File E pen 1 Function Constant per baia Register K H Register Module Word UA Zn Instruction Symbol Execution Condition INV Functions Inverts the operation result immediately prior to the INV instruction OFF Operation Errors 1 There are no operation errors associated with the INV instruction Program Example 1 A program which inverts the X0 ON OFF data and outputs from Y10 Ladder Mode List Mode i E 2 CY10 Steps Instruction Device 0 ID x0 1 INV mH iW m Timing Chart POINTS 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 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin o COS cp e sP o 5 2 4 Operation result pulse
85. NOPLF H O gt gt Page change forced when NOPLF is inserted between two ladder blocks a mi RFID TREE DUE O X001 o I 1 H 8 MN CMM a Printing an instruction list with the NOPLF instruction will result in the following o 0 LD X000 1 MOV K1 Changes pages after printing NOPLF PAGEn Ladder Mode List Mode o PAGE KS Steps Instruction Device T T 0 PAGE K5 2 LD 2 YO 3 AND xi 4 OUT YO 2 P 5 LD 2 S F NOP _ Y1 gt 6 NOP 7 OUT Y1 8 NOPLF 8 NOPLF 9 PAGE K6 11 LD x3 12 OUT Y2 9 _ _ PAGE K6 13 END _ y 13 END 6 BASIC INSTRUCTIONS MELSEC Q QnA 6 BASIC INSTRUCTIONS The following types of basic instructions are available Instruction Reference Section Comparison operation i p Compare data to data Chapter 6 1 instruction Arithmetic operation Adds subtracts multiplies divides increments or Chapter 6 2 instructions Core g ss data with other data Data conversion instruction Converts data Converts data types Chapter63 6 3 Data transfer instruction Transmits data Chapter 6 4 Program branch instruction PPogamjums jumps Chapter 6 5 Program execution control Enables and disables program interrupts Chapter 6 6 instructions Refresh instruction Refreshes bit devices C
86. PLF 1 When turned from ON to OFF the PLF command turns ON the specified device and other than when turned from ON to OFF i e from OFF to OFF from OFF to ON or from ON to ON it turns OFF the specified device When there is one PLF instruction for the device designated by D during one scan the specified device turns ON one scan See Section 3 9 for the operation to be performed when the PLF instruction for the same device is executed more than once during one scan ON oe X5 OFF REF MO ON MO OFF 1scan 1 scan 2 If the RUN STOP key switch is changed from RUN to STOP after the execution of the PLF instruction the PLF instruction will not be executed again even if the switch is set back to RUN Note that the device designated by D may be ON more than one scan if the PLS or PLF instruction is jumped by the CJ instruction or if the subroutine program where the PLS PLF instructon was executed was not called by the CALL instruction Operation Errors 1 There are no operation errors associated with the PLS or PLF instructions Program Example 1 The following program executes the PLS instruction when X9 goes ON Ladder Mode List Mode 0 PS M Steps Instruction Device 0 LD X9 1 PLS M9 3 END 3 END ON 5 X9 OFF ON M9 OFF 1 scan 2 The following program executes the PLF instruction when X9 goes OFF
87. QnA QCPU PLG Process CPU Cin E e up C o sro G OS L O 6 3 11 Conversion from block BIN 16 bit data to BCD 4 digit data BKBCD BKBCDP Usable Devices Internal Devices MELSECNET 10 H Special Index zu WEE User File ui Bo P Function Constant Dus Register Other Register Module Zn K H UL AG i ep wa Lore o EW ESE Instruction Symbol Execution Condition Command BKBCD BKBCD BKBCDP BKBCDP n Set Data BIN 16 bits Number of data blocks converted Functions 1 Converts BIN data 0 to 9999 n points from device designated by S to BCD and stores result following the device designated by These should be set to 9 SES2eem O OO LOCGQN rf OO SF N LO N O CO OO f N BIN 1234 0 0 070 0 1 0 0 1 10 101010 4 Q1 BIN 5678 0 0 01 0 111 0 070 1 0 1 11110 2 BIN 1545 0 0 01010 1 110 010 0 0 1101011 n 2 BIN 4321 00010000111100001 1 BIN 5555 0001010110110011 BCD conversions ceooco SOO00000 SOOOOO OO xt N 00 f N OO f N OSA BCD 1234 0001 001000110100 1 BCD 5678 0 10100 110 01111000 2 BCD 1545 00 0 10110101000101 n n 2 BCD 4321 0 1 0 0 0 0 11 010 1 0 0001 1 BCD 5555 0111011 0111011 01110 1 0111
88. Steps Instruction Device 0 LD X8 1 NOP 2 ANI Y96 3 OUT Y12 4 END LD LDI changed to NOP Note carefully that changing the LD and LDI instructions to NOP completely changes the nature of the ladder Before change Ladder Mode List Mode 0 LD XO E 1 OUT Y16 ED I YG 525 X56 Changed to NOP 3 AND B 5 END 5 END After change Ladder Mode List Mode 0 CY16 gt Steps Instruction Device 0 LD n cY66 1 OUT Y16 2 3 AND T3 _ yr 4 UT Y66 5 END 5 SEQUENCE INSTRUCTIONS Before change Ladder Mode CY16 gt CY66 gt Changed to NOP to LD T3 After change Ladder Mode X0 0 F YYYai END H 3 gt s NOPLF Ladder Mode oe MOV D30 H MOV K2 H 5 NOPLF xi aaa Y gt END H MELSEC Q QnA List Mode Instruction Device 0 LD 1 OUT Y16 F 2 LD X56 mm AND T3 4 OUT Y66 5 END List Mode Steps Instruction Device 0 LD X0 1 OUT Y16 2 NOP 3 LD T3 4 OUT Y66 5 END List Mode Steps Instruction Device 0 LD X0 1 MOV K1 D30 3 MOV K2 D40 5 NOPLF 6 LD x1 7 OUT Y40 8 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Printing the ladder will result in the following X000 K MOV 1 D30 O t MOV 2 D40 O 5c
89. X3 1 OR 0 5 Word 2 OR 3 QUT y33 device bit 4 LD X5 i z 5 AND designa 6 ORI X6 tion 7 OUT Y34 8 END 2 A program linking contact points established through the use of ANB and ORB instructions Ladder Mode i om A bbc ss 536 8355 b4 b1b0 x3 06 1 9 vel W LX 91 as gt 1 gt 4 END H 3 parallel program with OUT instruction Ladder Mode List Mode Steps Instruction Device 1 AD 8 1 2 6 4 Word 3 ANI XT device bit 4 ORB 5 ANI 9 designa 6 OUT y33 i D y ton 8 LD M8 9 OR M9 10 ANB 11 ANI M11 12 OUT Y34 13 END List Mode Steps Instruction Device 0 LD X5 1 OUT X35 2 AND X8 3 OUT Y36 4 ANI 9 5 OUT Y37 6 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Gn I QLAR r CO a ae o pu 5 1 2 Pulse operation start pulse series connection pulse parallel connection LDP LDF ANDP ANDF ORP ORF Usable Devices Set Internal Devices MELSECNET 10 H Special meee Other E Br User File EX E P Function Constant pale Register Module Register K H UA Zn I structio Sy nbol Executio Co ditio Bit device ber Bit desi atio of word device X1 D0 1 X1 D0 1 SJ X2 D0 2 X2 D0 2 lt oe ato Set Data Set Data Devices used as contacts Bit Functions LDP LDF 1 LDP is the leading edge pulse operat
90. at a time Conductive status when character string S1 character string S2 Character Non Conductive status when character string data string S1 character string S2 compari Compares character string S1 and character string S2 one character at a time Conductive status when character string 51 lt character string S2 e Non Conductive status when character string S1 character string S2 Compares character string S1 and character string S2 one character at a time Conductive status when character string S1 character string S2 Non Conductive status when character string S1 gt character string S2 Compares character string S1 and character string S2 one character at a time Conductive status when character string S1 2 character string S2 Non Conductive status when character string S1 character string S2 1 The conditions under which character string comparisons can be made are as shown below Match All characters in the strings must match e Larger string If character strings are different determines the string with the largest number of character codes If the lengths of the character strings are different de
91. bits division operation Functions 1 Multiplies BIN 16 bit data designated by 6 and BIN 16 bit data designated by and stores the result in the device designated by D TE b 15 bO 631 616615 b0 5678 BIN 1234 BIN gt 7006652 BIN 2 If D is a bit device designation is made from the lower bits Example K1 Lower 4 bits bO to 3 KA Lower 16 bits bO to 15 K8 Lower 32 bits bO to 31 3 The values for and can be designated at between 32768 and 32767 BIN 16 bits 4 Judgments whether 6 62 and D are positive or negative are made on the basis of the most significant bit b15 for and amp 3 for D and 631 sO 7 ta Positive e usd Negative 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Divides BIN 16 bit data designated by and BIN 16 bit data designated by 6 and stores the result in the device designated by Quotient Remainder 69 Q1 A b15 bO S NET bO b15 b0 b15 0 5678 BIN 1234 BIN gt 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 if a bit device has been used 16 bits are used and only the quotient is stored Quotient Stored at the lower 16 bits Remainder Stored at the higher 16 bits Can be stored only whe
92. cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The device range n points from or exceeds the relevant device Error code 4101 The number of transfers exceeds 6144 when a special direct device is used QnACPU Error code 4101 Program Example 1 The following program outputs the lower 4 bits of data at D66 to D69 to Y30 to in 4 point units Ladder Mode List Mode 0 9402 T 066 K1Y30 K4 Steps Instruction Device 0 LD SM402 1 BMOVP 66 K1Y30 K4 5 END indi After execution transfer destination transfer destination b15 b4b3 b0 D66 1110 Y33 to Y30 D67 0 00 0 Y37 to Y34 D68 110 0 1 1 Y3B to Y38 D69 0111101 Y3F to Y3C lt S Ignored 2 The following program outputs the data at X20 to X2F to D100 to D103 in 4 point units Ladder Mode List Mode 02 P Y 0 BMOV K1X20 D100 K4 Steps Instruction Device 0 LD SM402 1 BMOVP K1X20 D100 K4 5 END X2F X2C X2B X28 X27 X24 X23 X20 Before execution 1 000 O 1 1 1 0 1 110 0 100 big e See Se b4b3 b0 gt 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 D100 L execution transfer destination 2 0 0 0 0 0 0 0 0 0 0 00 0 1 1 0 D101 4 points gt 0 0 0 0 0 0 0 0 0 0 00 0 1 0 0 D102 2 0 0 0 00 0 0
93. contents of the values stored in SD63 to SD79 Use the RST iinstruction to turn OFF the USER ERR LED and to delete the annunciator which was turned OFF by the OUT F gt instruction from SD63 to SD79 Operation Errors 1 There are no operation errors associated with the OUT F 2 instruction 1 Refer to User s Manual Functions Explanation Programming Fundamentals of the used CPU module or QnACPU Programming Manual Fundamentals for details of annunciators 2 The number of basic steps for the OUT module F t iinstruction is 4 3 The table below shows which CPU module features either the LED display device on front of the CPU module or USER LED Type of LED CPU module Type Name LED display device Q3A Q4A Q4AR 3 Q2A S1 Q2AS S1 Q2ASH S1 USE LED High Performance model QCPU ERR LED Basic model QCPU Program Example 1 The following program turns F7 ON when goes ON and stores the value 7 from SD64 to SD79 Ladder Mode List Mode 0 m Steps Instruction Device 0 LD X0 1 OUT FT 3 END 3 END X0 ON SD63 0 Adds o Spes 1 SD64 0 SDe4 7 SD65 0 SD65 0 SD66 0 SD66 0 SD67 0 SD67 O SD79 0 SD79 0 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin p D gc p xe Po L O 5 3 5 Setting devices except for annunciators SET Usable Devices Internal Devices MELSECNET 10
94. d N1 M16 M16 Executed O when A and C B are ON C ivc v2 Mt7H N2 b Executed 1 when A B and C are ON MORI N2 T Executed 11 gt when A and B are ON Executed when A is ON MORI NO T O l No relation H gt to status of A or G 5 44 5 44 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Cautions when Using Nesting Architecture 1 Nesting can be used up to 15 times NO 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 QnACPU will not be capable of performing correct operations For example if nesting is designated in the order N1 to NO by the MC instruction and also designated in the N1 to NO order by the MCR instruction the vertical bus will intersect and a correct master control ladder will not be produced Ladder as displayed in the GPP ladder mode N1 M15 N1 M15 gt B MC No M16 MC No Mte Ht NO M16 NO M16 gt gt gt gt McR No 1 tat gt P Ladder as it actually operates 2 If the nesting architecture results in MCR instructions concentrated in one location all master controls can be t
95. et itd e i iens APP 46 3 1 Special Relay List of Basic model QCPU L nnns APP 46 3 2 Special Relay List of High Performance model APP 50 3 3 Special Relay List of Process CPU L ethernet trennt enne APP 71 APPENDIX 4 SPECIAL REGISTER LIST sss nre APP 87 4 1 Special Register List of Basic Model QCPU sss APP 87 4 2 Special Register List of High Performance model QCPU QnACPU APP 98 4 3 Special Register List of Process CPU sse nennen nnne APP 134 APPENDIX 5 APPLICATION PROGRAM EXAMPLES sess APP 162 5 1 Concepts of Programs Which Perform Operations of x NK as ect te reacted e Se vire APP 162 Manuals The following table lists the manuals related to the Q QnACPU Please order the one you need Related Manuals Manual Number uns Basic model QCPU Q mode User s Manual Hardware design Maintenance and Inspection SH 080187 Describes the specifications of the CPU module power supply module base unit and extension cables Sold separately pra Basic model QCPU Q mode User s Manual Functions Explanation Programming Fundamentals SH 080188 Describes the functions programming method and devices to create programs with Basic model QCPU 13JR44 Q mode Sold separately High Perfor
96. hour minute second and seconds Other convenient instructions Character string processing instructions Special function instructions Clock instructions Peripheral device instructions V O to peripheral devices Program instructions Instructions to switch program execution conditions Instructions that do not fit in the above categories such as watchdog timer reset instructions and timing clock instructions ink refresh instructions Designated network refresh d R rite of from other ion ransmission signals to other Instructions dedicated to QnA links ead w ite o data om other stations data transmission signals stations processing requests to other stations Instructions for A series compatible Read write for designated station word device read write data from remote I O link station special function module n outing Reads writes and registers routing information instructions Reading module information trace set reset reading writing binary data Instruction for QCPU load unload load unload program from memory card high speed block transfer of file register Operation mode setting during CPU startup operation mode setting instructions during CPU switch data tracking buffer memory batch refresh 2 INSTRUCTION TABLES MELSEC Q QnA 2 2 How to Read Instruction Tables Category BIN 16 bit addition and subtraction operations The instruction tables found from Section 2 3 to 2 6 have
97. indicated with circle The types of devices that can be used are as indicated below Internal Devices MELSECNET 10 H 3 Special Index Device Type System User File Register Direct Jt 2A 3 cton Register onstant Other 1 1 Bit Bt UAG Zn Decimal constants Hexadecimal Usable 4 constants een Real number devices constant Character string constant 1 Devices which can be set are recorded in the Constant and the Other columns 2 FX and FY can be used only for bit data and FD only for word data x3 Usable with the MELSECNET H MELSECNET 10 4 HOW TO READ INSTRUCTIONS MELSEC Q QnA 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors lt 1 There no operation errors associated with the MOV P or DMOV P instructions Program Example 1 The following program stores input data from X0 to XB at D8 Ladder Mode List Mode o opa m H Steps Instruction Device 0 wb S400 1 MOVP K3X0 0B 4 END H 4 END 2 The following program stores the constant K155 at D8 when X8 goes ON Ladder Mode List Mode or K155 08 H Steps Instruction Device I x8 1 MVP Kiss 4 END i t Hoa w 009BH L bi5 b8b7 b0 D8 00000 0001001 10 1 1 3 The following program stores the data from DO and D1 at D7 and D8
98. input STOP Functions 1 When stop input is turned ON output Y is reset and the CPU module operations are terminated The same result will take place if the RUN STOP key switch is turned to the STOP setting 2 Execution of the STOP instruction will cause the value of b4 to b7 of the special register 50203 to become 3 b15 to bi2 011 to b8b7 to b4b3 to b0 SD203 i 00rfid or becomes 3 3 In order to restart CPU module operations after the execution of the STOP instruction return the RUN STOP key switch which has been changed from RUN to STOP back to the RUN position Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO A STOP instruction was executed before the execution of the RET instruction and after the execution of the CALL ECALL instruction Error code 4211 A STOP instruction was executed before the execution of a NEXT instruction and after the execution of the FOR instruction Error code 4200 ASTOP instruction was executed during an interrupt program prior to the execution of the IRET instruction Error code 4221 ASTOP instruction was executed within the CHKCIR to CHKEND instruction loop Error code 4230 A STOP instruction was executed within the IX to IXEND instruction loop Error code 4231 5 SEQUENCE INSTRUCTIONS Program Example 1 The following program stops the CPU module when X8 g
99. is effective only with QCPU 4 4 The number of steps may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification Constant No limitations High Performance model QCPU Process CPU 2 When using devices other than 1 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit Basic model QCPU designation is K8 and which use no index modification Constant No limitations 2 When using devices other than 1 Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 2 INSTRUCTION TABLES MELSEC Q QnA 2 4 5 Program branch instruction Table 2 14 Program Branch Instruction Execution Processing Details Condition Category 2 5 2 22 3 Zn Instruction Description Jumps to Pn when input conditions are met Jumps to Pn from the scan after the meeting of input condition Jump e Jumps unconditionally to Pn Jumps to END instruction when input condition is
100. 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 If the set value is smaller than a scan time e If 1 is set Example For timers TO to T2 the program is created in the order the timer operates later 1 K1 lt T2 T2 timer starts counting from the next scan after the timer T1 contact is turned ON TO K1 t lt 1 T1 timer starts counting from the next scan after the timer TO contact is turned ON K1 t TO TO timer starts counting if XO is turned ON For timers TO to T2 the program is created in the order of timer operation X0 K1 lt TO TO timer starts counting if XO is turned ON TO K1 t lt Ti B T1 and T2 timer contacts are turned ON if the Z K1 contact of T0 is turned ON T2 Operation Errors 1 There are no operation errors associated with the OUT instruction 5 SEQUENCE INSTRUCTIONS Program Example 1 The following program turns Y10 and Y14 ON 10 seconds after X0 has gone ON Ladder Mode X0 K100 0 a S Tl 5 14 MELSEC Q QnA List Mode Steps Instruction Device 0 LD X0 1 OUT Ti K100 5 LD 1 6 OUT Y10 T QUT Y14 8 END 2 The following program uses the BCD data at X10 to 1F as the timer s set value Ladder Mode X0 P 0 F BIN K4XI0 010 X2 D10 4 a 12 T2 9 Y15 11 END
101. leading edge pulse parallel connection instruction and ORF is a trailing edge pulse parallel connection instruction They perform an OR operation with the operation result to that point and take the resulting value as the operation result Devices Designated by Devices Designated by ORF Word Device Bit ORP State BitDevice Device Bit ORF State OFF ON ee OFF ON E or o OFF o 3 or o ON gt OFF on gt orr imo o Operation Errors 1 There are no operation errors with LDP LDF ANDP ANDF ORP or ORF instructions Program Example 1 The following program executes the MOV instruction at input or at the leading edge of b10 bit 10 of data register DO Ladder Mode List Mode Steps Instruction Device 0 LDP 0 2 ORP D0 0A 4 KO DO 6 END Word device bit designations are performed in hexadecimal Bit b10 of DO would be DO 0A 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU ope epo pes P S L CO 5 2 Connection Instructions 5 2 1 Ladder block series connections and parallel connections ANB ORB Usable Devices Internal Devices MELSECNET 10 H Special Set i Index Fu Br User File EX EE Function Constant Data Register Other Register Module K H Word Zn Instruction Symbol Execution Condition BlockA Block B Block A
102. met 2 4 6 Program execution control instructions Table 2 15 Program Execution Control Instructions Execution Condition Instruction Number of Basic Steps Description 6 10 Prohibits or permits interrupts for each interrupt program Reum IRET 2 4 7 VO refresh instructions Table 2 16 I O Refresh Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description Refreshes the relevant I O area during scan 2 INSTRUCTION TABLES MELSEC Q QnA 2 4 8 Other convenient instructions Table 2 17 Other Convenient Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description so nnnnnnnnnnnmnnnnnnmnnnm S1 Up Down Up Current Cn value 0 1234567651432 10 1 2 3 240 Cn contact point 2 l UDCNT1 S 0 Jil 5 1 ALA Current Cn value 0 1 Cn contact point UDCNT2 The 4 points from the bit device designated by D operate as shown below depending on the ON OFF status of the input conditions for the STMR instruction 0 Off delay timer output D 1 One shot after off timer output D 2
103. nd ON delay timer ty E MN Set value Set value Set value Set value designated designated designated designated by n1 by n1 by n1 by n1 4 Measurement of the present value of the timer designated by the STMR instruction is conducted during the execution of the STMR instruction If the STMR instruction is jumped with the JMP or similar instruction it will not be possible to get accurate measurement 5 Measurement unit for the timer designated by D is identical to the low speed timer 6 A value between 1 to 32767 can be set for n 7 The timer designated by S cannot be used by the OUT instruction If the STMR instruction and the OUT instruction use the same timer number accurate operation will not be conducted Operation Errors 1 There are no errors associated with the STMR instruction 6 120 6 120 6 BASIC INSTRUCTIONS Program Example MELSEC Q QnA 1 The following program turns YO and Y1 ON and OFF once each second flicker when X20 is ON Uses the 100ms timer Ladder Mode X 20 M3 0 L T ASTMR T0 K10 10 6 121 List Mode Steps Instruction Device 0 LD X20 1 ANI M3 2 STMR TO K10 MO 6 LD MI 7 OUT YO 8 LD M2 9 OUT 1 10 END 6 121 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU 1 1 PLG SEM Process CPU Cn tA X C C O C S o 6 8 5 Rotary table near path rotation control ROTC
104. other stations MELSECNET 10 ZNRD 8 74 8 3 2 Reading device data from local stations MELSECNET ZNRD 8 78 8 3 3 Writing device data to other stations MELSECNET 10 ZNWR 8 81 8 3 4 Writing data to devices at local stations MELSECNET ZNWR 8 85 8 3 5 Reading data from a remote I O station special function module MELSECNET RFRP 8 88 8 3 6 Writing data to special function modules of remote I O stations MELSECNET RTOP 8 92 8 4 Routing Information Read Write sse 8 96 8 4 1 Reading routing information RTREAD L 8 96 8 4 2 Registering routing information RTWRITE essen 8 100 9 QCPU INSTRUCTIONS 9 1109 42 9 1 Reading Module Information UNIRD P u 9 2 9 2 Trace Set reset TRACE 9 6 9 3 Writing Data to Designated File FWRITE uuu u 9 8 9 4 Reading Data from Designated File FREAD essent 9 16 9 5 Loading Program from Memory Card PLOADP L 9 27 9 6 Unloading program from program memory PUNLOADP U 9 29 9 7 Load Unload PSWAPP
105. present value is as shown below 32768 5 32707 2 1 gt 0 gt 1 gt 2 gt 3276632767 When counting down 4 Count processing conducted according to the UDCNT2 instruction begins when the count command goes from OFF to ON and is suspended when it goes from ON to OFF When the count command goes from OFF to ON once again the count is restarted from the value in effect when it was suspended When counting up b The RST instruction clears the present value of the counter designated at D and turns the contact OFF POINTS 1 The UDCNT2 instruction registers the argument device data to the work area of the CPU module and the actual counting operation is processed as a system interrupt The device data registered to the work area of the CPU module are cleared when the command input is turned OFF or when the CPU module is STOPped and then RUN Therefore to count pulses it is necessary to provide their ON and OFF time as long as the interrupt time of the CPU module or longer The interrupt time of individual CPU module is shown below CPU module Type Name Interrupt Time High Performance model QCPU Process CPU 2 The set value cannot be changed while a count operation performed according to the UDCNT2 instruction is being executed while the command input is ON To change the set value first turn the command input off 8 Counters designated by the UDCNT2 instruction cannot b
106. real number at D10 and D1 1 from the floating decimal point type real numbers at D20 and D21 and stores the result of the subtraction at D20 and D21 Ladder Mode List Mode 0 DIO D20 Steps Instruction Device E TE 4 END 010 4 END 021 D20 D11 D10 D21 D20 97365 2 76059 8 gt 2130541 6 BASIC INSTRUCTIONS MELSEC Q QnA Usable Devices Internal Devices MELSECNET 10 H Special E SIX User File E ry E Function Register Register Module UL AG i Instruction Symbol Execution Condition Cl indicates the signs E or E Command E 6 Command A o gt Set Data Meaning Data Type Data to be added to or subtracted from or the head number of the device storing such data Addition or subtraction data or head number of device storing addition Real number subtraction data Head number of device storing addition or subtraction data Functions 1 Adds the floating decimal point type real number designated by and the floating decimal point type real a designated by 62 p stores the result at Hs device designated by D 2 1 62 1 1 decimal ue Floating decimal point ETN decimal s type real number type real number type real number 2 Values that can be designated by 6 63 or and values that can be stored are as follows 0 2 126 lt
107. result at D502 and D503 and at the same time outputs the quotient to Y30 to Ladder Mode List Mode oL B O H1234 0502 Steps Instruction Device 0 LD SM400 T Bow us MOV D502 K4Y30 Dus 5 MOVP D502 K4Y30 8 END D502 D503 1070 08 a LT E412 Quotient Remainder Y30 gt 0 0 0 4 Quotient 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA LK CS CoO C ep 6 2 8 BCD 8 digit multiplication and division operations DB DB DB P Usable Devices Internal Devices MELSECNET 10 H Special Set Index xu BE User File ES Em P Function Constant Data Register Other Register Module K H Word UA Zn Pa oo Instruction Symbol Execution Condition L indicates the signs DB or DB Command DB amp DB DB P DB P c Set Data Meaning Data that will be multiplied or divided or the head number of the device storing data that will be multiplied or divided BCD 8 digit Data to multiply or divide by or the head number of device storing such cp s aigis data Head number of the device storing the operation results of multiplication BCD 16 digits or division operation Functions DBx 1 Multiplies the BCD 8 digit data designated by 6 and the B
108. results at the number of the three devices starting from RO Ladder Mode List Mode 0 Pic D100 8765 RO K3 Steps Instruction Device 0 LD XiC 1 D100 K8765 RO K3 5 END b15 b0 b15 b0 D100 12345 BIN b15 255 bO RO 3580 BIN 0101 8701 BIN 8765 BIN E R1 64 BIN D102 3502 BIN R2 5263 BIN 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA pepe EO 6 2 12 Linking character strings P Usable Devices Internal Devices MELSECNET 10 H Special Index n x User File ECN Eu E Function Berister Constant Other Register Module 9 Instruction Symbol Execution Condition Command LL Fr Command Set Data Meaning Data Type Head number of device holding linked data or data Character string Head number of device holding data which has been linked Functions 1 Character string data stored in device numbers starting with that designated at S will be appended after character string data stored in device numbers starting with that designated at and will be stored in device numbers starting with that designated at The object of character string data is that character string data stored from device numbers designated at D and to that stored at OOH b15 b8b7 b0 b15 b8b7 bO b15
109. software package OPERATING MANUAL Offline 18 66774 Describes how to create programs and print out data when using SW2IVD GPPQ and the offline functions of SW2IVD GPPQ such as file maintenance Included with product Type SW2IVD GPPQ software package OPERATING MNUAL Online IB 66775 Describes the online functions of SW21VD GPPQ including the methods for monitoring and debugging Included with product 19922 13J921 Type SW2IVD GPPQ software package OPERATING MANUAL SFC IB 66776 Describes SFC functions such as SFC program editing and monitoring Included with product 13923 1 GENERAL DESCRIPTION MELSEC Q QnA 1 GENERAL DESCRIPTION This manual describes the common instructions for QCPU QnACPU and Q2AS H CPU S1 that are required when programming with a QCPU QnACPU and Q2AS H CPU S1 Common instructions are all instructions except those used for special function modules such as AJ71QC24 AJ71PT32 S3 etc the instructions for AD57 the instructions for PID control and those for MELSAP3 1 1 Related Programming Manuals Before reading this manual check the programs I O processes and devices that can be used with your CPU module in the CPU Module User s Manual or in the QnACPU Programming Manual 1 QO2 H CPU QO6HCPU Q12HCPU Q25HCPU High Performance model Describes the functions QCPU Q mode executable programs User s Manual I O processing and
110. string to floating decimal point data EVAL EVALP 7 214 7 11 13 Conversion from hexadecimal BIN to ASCII ASC 7 218 7 11 14 Conversion from ASCII to hexadecimal BIN HEX HEXP 7 220 7 11 15 Extracting character string data from the right or left RIGHT RIGHTP LEFT LEFTP 7 222 7 11 16 Random selection from and replacement in character strings MIDR MIDRP MIDW MIDWP n u 7 225 7 11 17 Character string search INSTR INSTRP a 7 229 7 11 18 Floating decimal point to BCD EMOD EMODP 7 231 7 11 19 From BCD format data to floating decimal point EREXP 7 233 7 12 Speci l Function Instr ctioris a 2e iret petente eb ek de E be ies 7 235 7 12 1 SIN operation on floating decimal point data SIN SINP 7 235 7 12 2 COS operation on floating decimal point data COS COSP 7 237 7 12 3 TAN operation on floating decimal point data TAN 7 239 7 12 4 SIN operation on floating decimal point data ASIN 7 241 A 8 A 8 7 12
111. the fact that 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 The conversion results round off at the 25th bit from the highest bit of the integer value and eliminate everything from the 26th bit and beyond Integer value After conversion 222030030 10 0 0 0 1 1 0 1 0 0 11 1 0 1 1 1111100011001110 gt Becomes 222030032 lt Eliminated Rounded off Becomes 372588912 lt I _ Eliminated Rounded off Operation Errors 1 There are no errors associated with the FLT P or DFLT P instructions Program Example 1 The following program converts the BIN 16 bit data at D20 to a floating decimal point type real number and stores the result at DO and D1 Ladder Mode List Mode Steps Instruction Device 0 LD SM400 1 FLTP D20 00 4 END Integer D20 conversion D1 DO 15923 15923 BIN value Floating decimal point type real number 2 The following program converts the BIN 32 bit data at D20 and D21 to a floating decimal point type real number and stores the result at DO and D1 Ladder Mode List Mode 0 D20 DO Steps
112. the lower 4 bits of n points from D n 4 Links the lower 4 bits of n points from the device designated by S and stores at the device designated by D n 4 Separates the data at the devices below that designated by S1 into bits designated below S2 and stores in sequence from the device designated by D Links the data at the devices below that designated by S1 in the bits designated below S2 and stores in sequence from the device designated by D Breaks n points of 16 bit data from the device designated by S into 8 bit units and stores in sequence at the device designated by D Links the lower 8 bits of 16 bit data of n points from the device designated by S into 16 bit units and stores in sequence at the device designated by D Searches the data of n points from the device designated by S in 16 bit units and stores the maximum value at the device designated by D Searches the data of n points from the device designated by S in 16 bit units and stores the minimum value at the device designated by D Searches the data of 2 n points from the device designated by S in 32 bit units and stores the maximum value at the device designated by D
113. to ON from ON to OFF or from OFF to OFF it turns OFF the specified device When there is one PLS instruction for the device designated by during one scan the specified device turns ON one scan See Section 3 9 for the operation to be performed when the PLS instruction for the same device is executed more than once during one scan ON LI X5 PLS Mo Py 1 rod 1 scan 1 scan 2 If the RUN STOP key switch is changed from RUN to STOP after the execution of the PLS i d the PLS instruction will not be executed again even if the switch is set back to RUN PLS MO Set CPU module RUN STOP key Set CPU module switch from STOP to RUN RUN STOP key switch Set the CPU module RUN STOP from STOP to RUN key switch from RUN to STOP Set CPU module RUN STOP key switch LD X0 LD X0 from RUN to STOP LD X0 ps Mo ET MO 7 NC MO ENDO END END 0 ON X0 OFF ON MO OFF s 1 scan of PLS Amount of time QnACPU gt operation has been stopped 3 When a latch relay L is specified for the PLS command switching power OFF with the latch relay L ON and then switching it ON again executes the PLS instruction to turn ON the specified device since the PLS command turns from OFF to ON at the first scan The device turned ON at the first scan after power ON turns OFF at the next PLS instruction 5 34 5 34 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA
114. to be turned ON and OFF Bit Functions 1 Operation results up to the OUT instruction are output to the designated device When Bit Designation has When Using Bit Devices Operation E Made for Word Device Results Contact Coil Bit Designated A Contact B Contact OFF OFF Nonconiuty Continuity o ON ON Continuity Noncotiuty 1 Operation Errors 1 See Section 3 6 for information regarding errors during index modification 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Program Example 1 When bit device is in use Ladder Mode List Mode 0 p 1733 Steps Instruction Device 0 LD X5 3 i 3 QUT Y34 4 OUT Y35 5 END Y35 5 END 2 When bit designation has been made for word device Ladder Mode List Mode I n y sees X6 2 c Ss 5 moor 345 cU coo ET REMARK The number of basic steps for OUT instructions is as follows When using internal device or file register R 1 When using direct access output DY 2 When using any other device 13 Including serial number access file register 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU Process CPU Cin 5 3 2 Timers OUT T OUTH T Usable Devices Internal Devices MELSECNET 10 H Special gt RES Index User File Direct J 4 Function Constant bun Register Other
115. values stored at D as BIN 16 bit values 4 After conversion the first digit after the decimal point of the real number is rounded off 1 Converts floating decimal point type real number designated by S to BIN 32 bit data and stores the result at the device number designated by D OG Ou gt The upper 16 bits The lower 16 bits N v Floating decimal point BIN 32 bits type real number 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 The range of floating decimal point type real numbers that can be designated at 1 or is from 2147483648 to 2147483647 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 Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The floating decimal point type data designated by S when the INT instruction was used was outside the 31768 to 32767 range The floating decimal point type data designated by S when the DINT instruction was used was outside the 2147483648 to 2147483647 range Program Example 1 The following program converts the floating decimal point type real number at D20 and D21 to BIN 16 bit data and stores the result at DO Ladder Mode List Mode 0 ___ im 020 DO Steps Instruction Device 0 LD SM400 1 INTP 020 D0 4
116. with the instruction The device part is classified into source data destination data and number of devices 1 Source S Source is the data used for operations b The following source types are available depending on the designated device Designates the numeric value to be used in the operation This is set when the program is written and cannot be changed during the execution of the program Constants should be indexed when using them as variable data Bit devices and Word devices Designates the device that stores the data to be used for the operation Data must be stored in the designated device until when the operation is executed By changing the data stored in a designated device during program execution the data to be used in the instruction can be changed 2 Destination D a The destination stores the data after the operation has been conducted However some instructions require storing the data to be used in an operation at the destination prior to the operation execution Example An addition instruction involving BIN 16 bit data Stores the data needed for operation Stores only the operation results prior to the actual operation b A device for the data storage must always be set to the destination 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 Number of devices and number of transfers n a The number of devices and numbe
117. 00000 1000 D103 Becomes 0 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA K CS cute p eie p 6 4 6 Identical 16 bit data block transfers FMOV FMOVP Usable Devices Internal Devices MELSECNET 10 H Special Index x Br User File IN pen E Function Constant Das Register Other Register Module K H Wow Word UA Zn Instruction Symbol Execution Condition Command FMOV Command FHovP Set Data Meaning Data to transfer or head number of device storing data to transfer s E Head number of destination device BIN 16 bits n Number of transfers If special direct device UL AG 2 is used 1 to 6144 QnACPU Functions 1 Transfers 16 bit data from device designated by S to location n points from device designated by b15 bO Transmission gt On Q2 i F O Ooo Q 2 n 1 2 In cases where designates a word device and a bit device the number of bits designated by digit designation for the bit device will be the object bits for the word device If K1Y30 has been designated by D the object bits for the word device designated by will be the lower 4 bits sz 3 2 D 1 bi5 55 7 b4b3b2bibo Transmission Y3B Y39 Y38 Y38Y37 Y34Y33 Y30 S D100 1100111 gt 11 1 011 1 011 n gt 3 If bit device has been d
118. 011 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The range n points from the device at or exceeds the relevant device Error code 4101 The data n points from the device designated by S is outside the 0 to 9999 range Error code 4100 The and devices overlap Error code 4101 2 See Section 3 6 for information regarding errors during index modification Program Example 1 The following program converts BIN 16 bit data the number of points from D100 corresponding to the value stored at DO to BCD when X20 goes ON and stores the result following D200 Ladder Mode List Mode BKBCD MOO 0200 DO Steps Instruction Device 0 LD X20 1 BKBCDP D100 D200 5 END CN cO OO lt l CN CN CO CO T OOO t D100 BIN 5432 0 0 0 1 011 0 1 0 0 1 1 1 0070 D101 BIN 4444 0 0 0 1 0 0 0 1 011 0 1 1 100 D102 BIN 3210 0 0 0 0 1 1 0 0 1 07 00 110 10 BCD po 3 conversions Qu OTA D200 BCD 5432 01 011 0 1 0 0 0 0 11 070 110 D201 BCD 4444 011 0 0 0 1 0 0 01 00 0 11070 D202 BCD 3210 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 800 400 200 00 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Hop CS Re cep 6 3 12 Conversion from block
119. 07 bO b15 b8b7 bO D10 624 b a D10 624 b 61H a 011 66 d 63H ABCD gt 011 644 d 634 D12 65x e 012 41H A 65H D13 43H C 42 B D14 OOH 44 D Automatically stores 00x 6 BASIC INSTRUCTIONS MELSEC Q QnA Usable Devices Internal Devices MELSECNET 10 H Special pu EIE User File EX rx E Function i Register Instruction Symbol Execution Condition Command 5 M i 8 Command ap Set Data Meaning Character string Functions 1 Appends character string data stored from the device number designated by 6 to the character string data stored from the device number designated by 6 and stores it from the device number designated by 67 b15 b8b7 bO b15 b8b7 bO b15 b8b7 bO 6 46 48 H 35 1 1 6 1 209 41 SEXES C gt 1 2D 41 A 2 00H 2 41 2 354 5 1 1 3 394 9 33H 3 4 O00 4t 2 When character strings are linked the 00H which indicates the end of character string data indicated by is ignored and the character string indicated by 6 is appended to the last character of the string 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation err
120. 1 67 and 62 devices are overlapping Error code 4101 Program Example 1 The following program exchanges 16 bit data for 3 points from D200 for 16 bit data for 3 points from RO when X1C goes ON Ladder Mode List Mode 295 BXCH D200 m x Steps Instruction Device 0 1 D200 RO K3 5 END D200 0 111011101110111 Ro oot 1 1 00 13 nnn D201 010111 0101111010111 0101111 R1 1 11111 0701070 010101 D202 111 0 0 0 0 010 11110 0 0 0 070 R2 11 0 1 0 1 0 1 0 1 011 0 1107170 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SE Process CPU Cin p OS cup op 6 4 9 Upper and lower byte exchanges SWAP SWAPP Usable Devices Internal Devices MELSECNET 10 H Special Index ea Br s User File iE pen E Function Constant Dara Register Other Register Module K H UA Zn Instruction Symbol Execution Condition Command SWAP SWAPP E Command Set Data Set Data Meaning Head number of device where data is stored BIN 16 bits Functions 1 Exchanges the higher and lower 8 bits of the device designated by b15 b12b11 b8b7 b4b3 b 01010 10111101101010 i a b15 b12b11 b8b7 b4b3 b0 Moroo torto 101 Operation Errors 1 There are no opera
121. 10 6 110 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU QnA Q4AR ope epo pee o L O 6 7 I O Refresh Instructions 6 7 1 I O Refresh RFS RFSP Usable Devices Internal Devices MELSECNET 10 H Special Index S ud User File EX EUE Function Constant ind Register Other Register Module K H Word Word UA Zn Instruction Symbol Execution Condition Command Command Set Data Meaning Head device number of the device that will conduct refresh operation Bit n Number of points to be refreshed BIN 16 bits Functions 1 Refreshes only the device being scanned during a scan and functions to fetch input from external sources or to output data to an output module 2 Fetching of input from or sending output to an external source is conducted in batch only after the execution of an END instruction so it is not possible to output a pulse signal to an outside source during the execution of a scan When a refresh operation is conducted inputs X or outputs Y of the device numbers relevant to the program being executed are forcibly refreshed so it is possible to output a pulse signal to an external source during a scan 6 111 6 111 6 BASIC INSTRUCTIONS MELSEC Q QnA 3 Use direct access inputs DX or direct access outputs DY to refresh inputs X or outputs Y in 1 point units Program based on the RFS instruction Comma
122. 112111120111191111811117111161111511114 111311112 3 When the power is turned ON or when the CPU module has been reset with the execution of interrupt programs 10 to 131 is enabled 4 The statuses of devices 1 S 2 and S 3 to 7 are stored in SD715 to SD717 and SD781 to SD785 storage area for IMASK instruction mask pattern 5 Although the special registers are separated as SD715 to SD717 and SD781 to SD785 device numbers should be designated as 9 to S 7 successively POINTS 1 An interrupt pointer occupies 1 step 110 Stored at step 50 al 50 53 55 2 Refer to the Basic model QCPU Q mode User s Manual Function Explanation Program Fundamentals for information on interrupt conditions 3 The DI state interrupt disabled is active during the execution of an interrupt program Do not insert El instructions in interrupt programs to attempt the execution of multiple interrupts with interrupt programs running inside interrupt programs 4 If there are El and DI instructions within a master control these instructions will be executed regardless of the execution non execution status of the MC instruction 6 101 6 101 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the DI and EI instructions 2 There are no operation errors associated with the IMASK instruction Program Example 1 The following program is designed
123. 1234 BIN gt 6912 BIN 2 Values for S and D 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 O Positive ssi tis Negative 6 BASIC INSTRUCTIONS MELSEC Q QnA 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 e K32767 K2 K 32767 A negative value is generated if b15 is 1 H7FFF H0002 H8001 e K 32768 K 2 K32766 A positive value is generated if b15 is 0 H8000 HFFFE H7FFE 1 Subtracts 16 bit BIN data designated by from 16 bit BIN data designated by and stores the result of the subtraction at the device designated by Y b15 bO b15 bO b15 5678 BIN 1234 BIN gt 4444 BIN 2 Values for S and D 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 0 Positive 1 2s Negative 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 e K 32768 K2 K32766 A positive value is generated if b15 is 0 H8000 H0002 H7FFE e K32767 2 K 32767
124. 12345678 D100 Subtracts 12345678 from data in D100 D101 and stores result as BCD data at D100 D101 DMOV D100 Outputs data at D100 D101 to Y30 to Y4F 12 I END Ladder Mode Steps Instruction Device 0 LD SM400 1 DMOVP E EE 5 DB P H12345678 D100 9 DMOVP D100 K8Y30 12 END 6 BASIC INSTRUCTIONS MELSEC Q QnA Usable Devices Internal Devices MELSECNET 10 H Special Index E EE User File EX rs i Function Constant ban Register Other Register Module K H Word UA Instruction Symbol Execution Condition L indicates the signs DB or DB Command e DB P Command pap t rrr oreo H SetData Data Meaning DataType Type Data to be added to or subtracted from or the head number of the device storing such data Addition or subtraction data or head number of device storing addition or BCD 8 digit subtraction data Head number of device storing addition or subtraction data Functions 1 Adds the BCD 8 digit data designated by and the BCD 8 digit data designated by 62 and stores the result of the addition at the device designated by 6241 63 1 62 41 A A Set Data Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits sle s e 1 2 3 0 1 2 3 4 5 6 7 gt 5 8 0 2 3 6 9 0
125. 154 1 153 1152 1 1511 150 149 1 148 4 79 1178 1 177 1176 1175 1174 1 173 1172 1 171 1 170 1169 1168 167 1661 1651 164 19511941193 1192 1191 90 189 1 188 1 187 186 185 184 1831 1821 1811 180 6 11111111011109111081110711106 1105 110 031110210111100 1991 1981 1971 196 7 112711126111251112411123111221112111120 1911118 111171111611115111141111311112 8 431114211141 111401113911138 113711136111351113411133111321 113111130 112911128 9 15911158111571115611155111541 11531115211151 1115011149111481 1147111461 11451 1144 S 10 11751117411173111721117111170 116911168 6711166 111651116411163 1162111611160 11 119111190111891118811187111861118511184 831118211181 111801 1179111781 117711176 12 20711206 11205 1120411203 112021 1201 11200 1119911198 1119711196 1195 119411193 1192 13 2231122211221 11220112191121811217112161121511214112131121211211112101120911208 14 2391123811237 1123611235 11234 1123311232 11231 1123011229 1122811227 12261 12251 1224 15 2551125411253 1125211251 11250 1124911248 11247 11246 11245112441 1243 12421 124111240 3 When the power is turned ON or when the CPU module has been reset the execution of interrupt programs 10 to 131 148 to 1255 is enabled and the execution of interrupt
126. 2 Conductive status when S1 S2 Non conductive status when S1 S2 16 bit data compari Conductive status when S1 S2 Non conductive status when S1 S2 Conductive status when S1 S2 Non conductive status when S1 gt S2 Conductive status when S1 gt S2 Non conductive status when S1 S2 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 10 Comparison Operation Instructions Continued Execution Processing Details Condition Category Instruction Number of Basic Steps See for Description Conductive status when S141 S1 S21 S2 Non Conductive status when S141 S1 8241 S2 Conductive status when S141 51 8241 S2 Non Conductive status when S141 S1 S2 1 S2 Conductive status when S141 S1 gt S21 S2 Non Conductive status when S141 S1 lt S21 S2 32 bit data compari sons Conductive status when S141 S1 lt S241 S2 Non Conductive status when S141 S1 gt S21 S2 Conductive status when S11 51 lt S2 1
127. 34 BIN n 2 OFF 0 n 1 5678 BIN n 1 OFF 0 4 The results of the comparison operations for the individual instructions are as follows Instruction Comi arison Instruction Comi arison as 5 If all comparison results stored n points from D are ON 1 SM704 block comparison signal goes ON Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The range of the device n points from a device designated by 62 or D exceeds the relevant device Error code 4101 The device range for n points starting from the device designated by overlaps with the device range for n points starting from the device designated by Error code 4101 The device range for n points starting from the device designated by overlaps with the device range for n points starting from the device designated by Error code 4101 The device range for n points starting from the device designated by overlaps with the device range for n points starting from the device designated by 6 Error code 4101 2 See Section 3 6 for information regarding errors during index modification 6 BASIC INSTRUCTIONS MELSEC Q QnA Program Example 1 The following program performs a comparison operation when X20 goes ON comparing the data for the number of points from D100 equivalent to the value stored in DO with the data the n
128. 39 31 o o o s gt 9 9 9 8 Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The amp 3 or D BCD data is outside the 0 to 9999 range Error code 4100 Program Example 1 The following program adds the D3 BCD data and the Z1 BCD data when X20 goes ON and outputs the result to Y8 to Y17 Ladder Mode List Mode 0 ist D3 71 K4Y8 Steps Instruction Device 0 LD X20 1 B P 03 5 END ir 5 END 2 The following program subtracts the BCD data at D20 from the BCD data at D10 when X20 goes ON and stores the result at R10 Ladder Mode List Mode Steps Instruction Device 0 LD X20 1 B P D10 020 R10 5 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Le pen Process CPU Cn AR 6 2 6 BCD 8 digit addition and M operations ins DBs DEP D DB D DBP P Usable Devices Internal Devices MELSECNET 10 H Special Index x Br User File Eu 3 Function Constant Das Register Other Register Module K H Word 2 Instruction Symbol Execution Condition L J indicates the signs DB or DB Command B ad I 9 Command Set Data SetData Data Meaning DataType Type EE or subtraction data or head number of device
129. 49 gt execution of CJ instruction 9 K v4c gt 6 The label occupies step 1 pa Escape from loop when X7 is ON CJ P9 E Occupies step 1 16 6 gt 5 YB 5 7 Jump instructions can be used only for pointer numbers within the same program file 8 If a jump is made to a pointer number inside the skip range during a skip operation program execution will be taken up following the pointer number of the jump destination 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation is returned the error flag SMO goes ON and the error code is stored at SDO The pointer number designated does not come prior to the END instruction Error code 4210 A pointer number which is not in use as a label in the same program has been designated Error code 4210 A common pointer has been designated Error code 4210 Program Example 1 The following program jumps to P3 when X9 goes ON Ladder Mode List Mode Steps Instruction Device 0 LD x9 1 CJ P3 3 LD X30 4 OUT Y6F 5 P3 6 LD X41 7 OUT 8 END 2 The following program jumps to P3 from the next scan after XC goes ON Ladder Mode List Mode Steps Instruction Device 0 LD 1 SCJ P3 3 LD X30 1 QUT tor E3 6 ID 41 7 QU
130. 5 COS operation on floating decimal point data ACOS 7 243 7 12 6 TAN operation on floating decimal point data ATAN 7 245 7 12 7 Conversion from floating decimal point angle to radian RAD RADP 7 247 7 12 8 Conversion from floating decimal point radian to angle DEG DEGP 7 249 7 12 9 Square root operations for floating decimal point data SQR SQRP 7 251 7 12 10 Exponent operations on floating decimal point data EXP 7 253 7 12 11 Natural logarithm operations on floating decimal point data LOG LOGP 7 255 7 12 12 Random number generation and series updates RND RNDP SRND SRNDP 7 257 7 12 13 BCD 4 digit and 8 digit square roots BSQR BSQRP BDSQR BDSQRP 7 259 7 12 14 BCD type SIN operation BSIN BSINP sesenta 7 262 7 12 15 BCD type COS operations BCOS 5 7 264 7 12 16 BCD type TAN operation BTAN BTANP u 7 266 7 12 17 BCD type SIN operations BASIN BASINP U 7 268 7 12 18 BCD type COS operation BACOS BACOSP nennen 7 270 7 12 19 BCD ty
131. 55 4 END 08 4 END 009 bi5 b8b7 bO L D8 0 0 0 0 0 0 0 0 10011 1011 3 The following program stores the data from DO and D1 at D7 D8 Ladder Mode List Mode a D D Steps Instruction Device 0 LD SM400 1 DMOVP DO ERD 4 END 4 The following program stores the data from to X1F at DO and D1 Ladder Mode List Mode 0 DMOV K8X0 200 Steps Instruction Device 0 LD SM400 1 DMOVP raxo 4 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin Se Oa j 6 4 2 Floating decimal point data transfers EMOV EMOVP Usable Devices Internal Devices MELSECNET 10 H Special Inda ea User File EX pi 1 Function Register Register Instruction Symbol Execution Condition Command Command sow f Set Data Set Data data or number of device storing transfer data Real number Number of device to store transferred data Functions 1 Transfers floating decimal point type real number data being stored at the device designated by to a device designated by Di 28 oe 4 23542 4 23542 n n k 5 Floating decimal point type real number Floating decimal point type real number Operation Errors 1 There are no operation errors associated with the EMOV P instruct
132. 6 Functions 1 The present value of the counter designated by D is updated depending on the status of the input designated by A phase pulse and the status of the input designated by 1 B phase pulse 2 Direction of the count is determined in the following manner When is ON if 1 goes from OFF to ON count up operation is performed values are added to the present value of the counter When 9 is ON if S 1 goes from ON to OFF count down operation is performed values are subtracted from the present value of the counter e No count operation is performed if S is OFF 8 Count processing is conducted as described below When the count is going up the counter contact designated at D goes ON when the present value becomes identical with the setting value designated by n However the present value count will continue even when the contact of the counter designated at D goes ON See Program Example 1 When the count is going down the counter for the contact designated at D goes OFF when the present value reaches the setting value minus 1 See Program Example 1 The counter designated at D is a ring counter If itis 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 6 115 6 115 6 BASIC INSTRUCTIONS MELSEC Q QnA The count processing performed on the
133. 6 2 59 20 OGPU iDStC CHOTFIS dn eee en nad 2 48 2 5 21 Redundant system instructions For QAARCPU ssessssssssssssseeee nennen 2 49 3 1 Configuration of IBSWueti ii uu u ul l nnne nnne nennen nnns nnns 3 1 a2 Designating Data o m aeo en etsi istis 3 2 SiS UsingiDit data o teer rmt eer i c ere OE ca A SEED TER UR eed Me Tes ve cio leant eres 3 2 3 2 2 Using word 16 bits data n na 3 3 3 2 3 Using double word data 32 bits L n 3 5 3 2 4 Using real n mber data oie err n eene e EE He eoe Et erdt edere 3 8 3 2 5 Using character string data n 3 9 3 3 Index Modification u u 3 10 3 4 Indirect Designation Ei Ea ae c am an k es TRA RRF AR AKASA 3 13 3 5 Subset PrOCESSING oet eet pb uiid ue buds rl le eir ique 3 15 3 6 Cautions on Programming Operation Errors L n 3 16 3 7 Conditions for Execution of Instructions sse ener 3 19 3 8 Counting Step oa dl wine alien ven el ave aa aed eee 3 20 3 9 Operation when OUT SET RST or PLS PLF Instructions Use the Same Device 3 21 5 SEQUENCE INSTRUCTIONS 5 1105 55 5 TGontactInstructioris e nd A een pee dy 5 2 5 1 1 Operation start series connection parallel connection
134. 6 2 9 4 Shift in Str Ctlofs 2 e Ferte ilr D a ee Oe gh eec eere ieget La 2 6 2 3 5 Master control instructions nennen nnne nnne nnne enne nnne 2 7 2 3 6 Termination Instr ction ice ce tat steve neste ee at eee e e hn ea a aea e LER ex a cueva 2 7 2 3 7 Other IDs tructioris i Eee Ellen en t Ra rne a e a een eet ots 2 7 S Bas aa Suka 2 8 2 4 1 Comparison operation instruction I L 2 8 2 4 2 Arithmetic operation instructions I uu 2 14 2 4 3 Data conversion instructions A L u nennen nennen 2 19 2 4 4 Data transrer instructions ivr a rn roter ro tne Ot e eid ae e ah e ger 2 21 2 4 5 Program branch instruction rtra AeA nne ERE nne 2 23 2 4 6 Program execution control instructions 2 23 2 47 VO refresh instructions ie ee ee eee 2 23 2 4 8 Other convenient instructions L L L n 2 24 2 5 Application Instr ctloris tec ed Dee c ded eec e e ede e De scite 2 25 2 5 1 Logical operation instructions uu 2 25 2 5 2 Rotation instr ctlons a i a a p RR RR SERERE 2 27 2 5 3 Shift INSTUCTIONS o e ten n enitn Pe ip
135. 7 16 Peripheral Device Instructions k l a pasapun aku aaa qa nennen trennen nnns 7 303 7 16 1 Message displays to peripheral devices MSG senes 7 303 7 16 2 Keyboard input from peripheral devices PKEY 7 305 7 17 Program Control Instructions essent nnne trente nnne nnns nnns 7 307 7 17 1 Program standby instruction PSTOP PSTOPP a 7 308 7 17 2 Program output OFF standby instruction POFF POFFP a 7 309 7 17 3 Program scan execution registration instruction PSCAN PSCANP 7 314 7 17 4 Program low speed execution registration instruction PLOW PLOWP 7 313 718 Other Instructions er oin one ena e net ven E Eu evene iets 7 315 7 18 1 Resetting watchdog timer WDT WDTP uuu u 7 315 7 18 2 Timing pulse generation DUTY sse nnne nnne nennen nnne nns 7 317 7 18 3 Direct 1 byte read from file register ZRRDB ZRRDBP eee 7 319 7 18 4 File register direct 1 byte write ZRWRB ZRWRBP sese 7 321 7 18 5 Indirect address read operations ADRSET 7 323 7 18 6 Numerical key input from keyboard nennen 7 324 7 18 7 B
136. A negative value is generated if b15 is 1 H7FFF H0002 H8001 Operation Errors 1 There are no operation errors associated with the P or P instructions 6 BASIC INSTRUCTIONS MELSEC Q QnA Usable Devices Internal Devices MELSECNET 10 H Special Index E EE User File EX rs E Function Constant ban Register Other d Register Word d Module K H UL AGL i Instruction Symbol Execution Condition L indicates the signs Command sel Command Set Data SetData Data Meaning DataType Type Data to be added to or subtracted from or the first number of the device storing such data Addition or subtraction data or first number of device storing addition or BIN 16 bits subtraction data First number of device storing addition or subtraction data Functions 1 Adds 16 bit BIN data designated by to 16 bit BIN data designated by 6 and stores at the device designated by 6 ma AS b15 bo bi5 b bi5 b0 b15 5678 BIN 1234 BIN r 6912 BIN 2 Values for 6 and can be designated from 32768 to 32767 BIN 16 bits 3 The judgment of whether data is positive or negative is made by the most significant bit b15 ey Lus Positive 8d udis Negative 4 The following will happen when an underflow or overflow is generated in an operation result Th
137. CD 8 digit data designated by 69 and stores the product at the device designated by 1 9 919 1 9 9 9 9 9 9 9 9 9 9 98 0 3 2 1 A A N E gt 9 o 9 9 s8a o o o oJjJ o o o 1 2 If has designated a bit device the lower 8 digits lower 32 bits will be used for the product and the higher 8 digits upper 32 bits cannot be designated K1 Lower 1 digit bO to 3 K4 Lower 4 digits bO to 15 K8 Lower 8 digits bO to 31 3 The values for 6 and 62 can be designated from 0 to 99999999 8 digit BCD 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Divides 8 digit BCD data designated by and 8 digit BCD data designated by 62 and stores the result in the device designated by G 1 1 A 4 516178 91112131 10111213 114151617 Digits higher than those which were designated will be read as 0 O 3 2 Quotient Upper 4 digits Lower 4 digits Remain Upper 4 digits Lower 4 digits f Am der 25 gt 0 0 4 5 111213 3 6 8 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
138. Data Link Execution Category Condition Processing Details Instruction Number of Basic Steps Description J ZCOM JP ZCOM Refreshes the designated network JP READ GP READ Reads the word device data of another J SREAD station to host station G SREAD JP SREAD GP SREAD J WRITE G WRITE JP WRITE GP WRITE Writes the data of host station to the word device of other stations J SWRITE G SWRITE JP SWRITE GP SWRITE Sends data message to other stations JP SEND GP SEND Receives data message sent to the host JERECV station GP RECV Sends a transient request to other stations and executes it 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 36 Instructions for Data Link Continued Execution Category Condition Instruction Number of Basic Steps Description JP ZNFR Reads data from the special function modules at remote I O stations GP ZNFR JP ZNTO Writes data to the special Jn 51 52 D function module at remote I O 4 G ZNTO Un S1 S2 D station 4GP ZNTO Un S1 S2 D Reads the word devi
139. END D21 D20 Integer DO conversion 25915 6796 gt Floating decimal point type real number BIN value Integer Dal pa conversion 33562 3211 Floating decimal point type real number Because the set data is less than 32768 an operation error is returned 2 The following program converts the floating decimal point type real number at D20 and D21 to BIN 32 bit data and stores the result at and D1 Ladder Mode List Mode Steps Instruction Device 0 LD SM400 1 DINTP D20 DO 4 END D21 D20 Integer D1 D0 conversion 574968 321 a gt 574968 Floating decimal point type real number BIN value 214748364922 Because the set data is larger than 2147483647 an operation error is returned Floating decimal point type real number 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Lee 2002027 Process CPU Cn 6 3 5 Conversion from BIN 16 bit to BIN 32 bi dat data OBLI DBLP Usable Devices Internal Devices MELSECNET 10 H Special Index x Br User File IN Eu E Function Constant Das Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition Command DBL f Set Data Set Data Head number of device where BIN 16 bit data is stored BIN 16 bits Head number of device where BIN 32 bit data is stored after conversion BIN 32 bits Funct
140. H Special Inda xn BE s User File E X EH 1 Function Register Register Module Instruction Symbol Execution Condition SET input sr gt Set Data Meaning Bit device number to be set ON Word device bit designation Bit Functions 1 When SET input is ON the designated devices respond as follows Device Device Status Bit device Coils and contacts turned ON du designation has been made for word Designation bit set at 1 2 Devices turned ON will stay ON even if SET input goes to OFF Devices turned ON by the SET instruction can be turned OFF by the RST instruction a SET input ON X5 E fy r SET Y10 X5 OFF ON X7 RST Y10 X7 OFF RST input ON Y10 OFF 8 Device status does not change when SET input is OFF 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Operation Errors 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 Steps Instruction Device 0 LD X8 1 SET Y8B 2 LD X9 3 RST Y8B 4 END 2 The following program sets the value of DO bit 5 b5 to 1 when X8 goes ON and set the bit value to 0 when X9 goes ON Ladder Mode List Mode SET 00 5 Steps Instruction Device Sets value of b5 of DO at 1 0 LD X8 o qm Sets value of Br
141. I Usable Devices Set Internal Devices MELSECNET 10 H Special index Data ee ioe User File ie ES Function Nr Register Register Module UG Zn DX BL Instruction Symbol Execution Condition PAR Bit device number Bit designation of word device X D0 1 5 X2 D0 2 X2 D0 2 Set Data Set Data mee O O l Bt Functions LD LDI 1 LD is the A contact operation start instruction and LDI is the B contact operation start instruction They read ON OFF information from the designated device if a word device bit has been designated this becomes the 1 0 status of the designated bit and use that as an operation result 5 2 5 2 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 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 if a bit designation has been made for a word device the 1 0 status of the designated bit is read perform an AND operation on that data and the operation result to that point and take this value as the operation result 2 There are no restrictions on the use of AND or ANI but the following applies with a peripheral device used in the ladder mode a Write When AND and ANI are connected in series a ladder with up
142. INSTRUCTIONS MELSEC Q QnA QCPU a Process CPU Cin lt OO 97357 6 1 3 Floating decimal point data comparisons E E gt E E E E gt Usable Devices Internal Devices MELSECNET 10 H Special een MEI User File E pu 1 Function Register Register Instruction Symbol Execution Condition C indicates the signs E E lt gt E lt E lt or E gt on gt J Set Data Meaning 9 Comparative data or device number where comparative data is stored Real number Set Data Functions 1 The floating decimal point data from device designated by 6 and floating decimal point data from device designated by 62 as A contact and performs comparison operation 2 The results of the comparison operations for the individual instructions are as follows Instruction Comparison Instruction Comparison Symbol Condition Operation Condition Operation Result i Result Non continuity Note that use of the instruction can on occasion result in situations where errors cause the two values to not be equal Example EMOV E123 Dt E DO E4 56 D2 E D2 po Something not equal 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the E E gt E E lt E lt or E gt instructions
143. LSECNET H Network system MELSECNET 10 mode MELSECNET 10 Network system MELSECNET 10 Ethermet interf ace module Ethernet interface Ethernet interface module module Control and Communication Link System CC Link module CC Link module Master Local Module MELSECNET 10 H Q00JCPU PLC CPU QOOCPU PLC CPU Q01CPU PLC CPU Q02CPU PLC CPU QO2HCPU PLC CPU QO6HCPU PLC CPU Q12HCPU PLC CPU Q25HCPU PLC CPU Q12PHCPU PLC CPU Q25PHCPU PLC CPU Q00JCPU PLC CPU QOOCPU PLC CPU Basic model QCPU Basic model QCPU Q01CPU PLC CPU QO2CPU PLC CPU High Performance High Performance model QCPU model QCPU Q12HCPU PLC CPU Q25HCPU PLC CPU Q25PHCPU PLC CPU Q2ACPU S1 PLC CPU Q8ACPU PLC CPU QnACPU Q4ACPU PLC CPU 3 PLC CPU 2 INSTRUCTION TABLES MELSEC Q QnA 2 INSTRUCTION TABLES 2 1 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 2 Table 2 1 Types of Instructions Contact instruction Operation start series connection parallel connection MNT Ladder block connection creation of pulses from operation results store read Connection instructions operation results Output instruction Bit device output pulse output output reversal Shift instruction Bit device shift M
144. N1 H ZMO X1 X3 M7 X1 X3 M7 HI 5 IH 53 mp Executed only M5 3 M5 when is ON Y4F 5 t lt yar 54 X6 X4 X6 X4 H I H I XOF XF HELL vio Hew 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA When programming in the ladder mode of a peripheral device it is not necessary to input contacts on the vertical bus These will be automatically displayed when the conversion operation is conducted after the creation of the ladder and then read mode is set MC 1 If the ON OFF command of the MC instruction is ON when master control is commenced the operation result between the MC instruction and MCR instruction will be exactly as the instruction ladder shows If the MC ON OFF indicator is OFF the operation result between the MC and MCR instructions will be as shown below Device Status T Speen Count value goes to 0 coils and contacts all go OFF Low speed timer High speed retentive timer Low speed retentive timer Coils go OFF but counter values and contacts all maintain current status Devices INNE Maintain current status Basic Application following instructions 2 Even when the MC instruction is OFF instructions from the MC instruction to the MCR instruction will be executed so scan time will not be shortened If there are unnecessary contact instructions FOR NEXT El DI etc in ladders which use master controls the CPU module w
145. NB 5 LD X4 6 AND X5 7 ORB 8 OUT MO 9 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Se e eee 5 2 2 Operation results push read pop MPS MRD MPP Usable Devices Internal Devices MELSECNET 10 H Special Index eo Br s User File zs pon E Function Constant Dara Register Other Register Module K H UA Zn Instruction Symbol Execution Condition MPS MRD and MPP are not displayed as a part of the ladder display A Functions MPS 1 Stores in memory the operation result ON or OFF immediately prior to the MPS instruction 2 Up to 16 MPS instructions can be used successively However only up to 11 can be created in the ladder mode If an MPP instruction is used during this process the number of uses calculated for the MPS instruction will be decremented by one MRD 1 Reads the operation result stored for the MPS instruction and uses that result to perform the operation in the next step MPP 1 Reads the operation result stored for the MPS instruction and uses that result to perform the operation in the next step 2 Clears the operation results stored by the MPS instruction 3 Subtracts 1 from the number of MPS instruction times of use 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 1 The following shows ladders both using and not using the MPS MRD and MPP instruction
146. ND a D100 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin K CO Ey 6 3 8 Conversion of Gray code to BIN 16 and 32 bit data GBIN GBINP DGBIN DGBINP Usable Devices Internal Devices MELSECNET 10 H Special Index zu NE User File Eu Bo P Function Constant Dus Register Other Register Module K H UA Zn Instruction Symbol Execution Condition L indicates GBIN or DGBIN Command GBIN DGBIN Command GBINP DGBINP f Set Data Set Data Data Meaning DataType Type Gray code data or the head number of device where Gray code data is Gray code EXC stored Head number of the device to store BIN data after conversion BIN 16 32 bits Functions Converts Gray code data at device designated by S to BIN 16 bit data and stores at device designated by D code 1234 11 1 1 BIN 1234 0 1 0 0 1 1 0 1 0 01110 Converts Gray code data at device designated by to BIN 32 bit data and stores at device designated by D 1 upper 16 bits lower 16 bits Gray code 305419896 ojojo 1 1 o 1 1 o o 1 o 11 1 o o 1 1 11 1 o 1 o 1 o o o 1 o o
147. Q QnA 2 2 The number of steps may vary depending on the device and type of CPU module being used Component Nomber of basic steps 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification Constant No limitations High Performance model QCPU Process CPU 2 When using devices other than 1 QnCPU Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 3 3 The subset is effective only with QCPU 2 5 2 Rotation instructions Category Table 2 19 Rotation Instructions Execution Processing Details Condition Instruction Number of Basic Steps Description SM700 b15 D e Rotates n bits to the left D Rotates n bits to the D 1 D b31 to b16 b15 to b0 Rotates n bits to the right D 1 D b31 to b16 b15 to bO SM700 Rotat
148. QCPU Q Mode QnACPU MITSUBISHI Common Instructions Mitsubishi Programmable Logic Controller Lo 7 e SAFETY PRECAUTIONS e 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 REVISIONS The manual number is given on the bottom left of the back cover Print Date Manual Number Dec 1999 SH NA 080039 A First edition Jun 2000 SH NA 080039 B Addition APPENDIX5 Correction CONTENTS Section 3 4 6 6 1 6 8 6 6 8 8 6 8 9 7 6 8 9 8 10 3 11 2 APP 1 2 APP 4 Sep 2000 SH NA 080039 C Section 9 9 9 10 9 11 Correction Jun 2001 SH NA 080039 D Q00JCPU Q00CPU Q01CPU Section 3 9 11 2 1 11 2 2 APP 1 3 APP 3 1 APP 3 2 APP 4 1 APP 42 CONTENTS Section 1 1 5 3 8 5 7 1 6 1 5 6 5 2 6 6 1 6 8 1 6 8 2 6 8 4 6 8 7 6 8 8 6 8 9 7 1 2 7 1 4 7 1 6 7 1 8 7 2 1 7 2 2 7 2 3 7 2 4 7 4 2 7 5 12 7 6 6 7 6 7 7 6 9 7 6 10 7 7 1 7 7 2 7 7 3 7 7 4 7 9 8 7 14 1 9 4 11 2 2 APP 1 2 APP 1 3 APP 2 1 APP2 1 4 APP 3 2 Mar 2002 SH NA 080039 E Addition model This manual confers no industrial property rights or any rights of any other kind nor does it confer any p
149. S1 Store value of S1 1 S1 at When S1 1 S1 S3 1 S3 lt 2 1 S2 Store value of S3 1 S3 at D 1 D DLIMITP When S2 S2 1 S3 S3 1 Store value of S2 1 S2 at D 1 D Category Instruction Symbols Number of Basic Steps See for Description D When S2 53 D When 51 1 S1 lt S3 1 S3 lt S2 1 S2 0 gt 0 1 0 When S3 1 S3 lt S1 1 S1 S3 1 S3 81 S1 D 1 D When S2 1 S2 lt S3 1 S3 DBANDP S3 1 S3 S2 1 S2 D 1 D S2 D 1 gt D DZONEP 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 14 Switching instructions Table 2 31 Switching Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description _ Converts extension file register block HSET number to number designated by S RSETP RSETP S C ODRSET Fie Name Sets file names used as file registers E ile set z 000881 fGGDSET Fie Name Sets file names used as comment files QCDSETP File Name n number of file name characters 2 indic
150. S2 Non Conductive status when S141 S1 gt S21 S2 Conductive status when S141 S1 gt S21 S2 Non Conductive status when S141 S1 lt S21 S2 2 INSTRUCTION TABLES MELSEC Q QnA 1 The number of steps may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR High Performance model QCPU Bit device Devices whose device Nos are multiples of 16 whose digit Process CPU designation is K8 and which use no index modification Constant No limitations 2 When using devices other than 1 QnCPU Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 10 Comparison Operation Instructions Continued Execution Processing Details Condition Category Instruction Number of Basic Steps See for Description Conductive status when S141 S1 S21 S2 Non Conductive status when S141 S1 8241 S2 Conductive status when S141 S1 8241 S2 Non Conductive status when S141 S1 S241 S2
151. SFC QCPU Q mode Programming Manual MELSAP L Describes MELSAP L 1 GENERAL DESCRIPTION 4 Q2ACPU Q3ACPU Q4ACPU Q4ARCPU Q2AS H CPU MELSEC Q QnA QnACPU Programming Describes the executable programs I O processing Manual and device names of QnACPU Fundamentals This manual Y QCPU mode QnACPU QCPU Q mode QnACPU Proqrammin QnACPU QnACPU QCPU Q mode Programming 9 9 Programming Programming QnACPU Manual Manual Special Manual Manual Programming Common P AD57 Command PID Manual SFC Function Modules Instructions Control Instructions Describes the instructions Describes the instructions other than described in the for special function modules such as AJ71QC24 and AJ71PT32 S3 manuals on the right Describes AD57 command to control AD57 AD58 Describes the instructions to perform PID control Describes SFC Q4ARCPU Programming Manual Application PID Instructions Describes the instructions for application PID control 1 GENERAL DESCRIPTION MELSEC Q QnA 1 2 Abbreviation and Generic Name module names are abbreviated as follows Module sABbrevidion Abbreviaton in Tables Genere Name Name Abbreviation Abbreviation in Tables Generic Name loMARCPUPLCCPU PLC CPU Q4ARCPU MELSECNET H Network system MELSECNET H mode MELSECNET H ME
152. Set Data Meaning Data Type BIN 16 bits Head number of device conducting INC add 1 or DEC subtract 1 operation Functions 1 Adds 1 to device designated by 16 bit data 5678 BIN 441 gt 5679 BIN 2 If the contents of the device designated by D were 32767 and the INC or INCP instruction were executed on that device the value 32768 would be stored in the device designated by DEC 1 Subtracts 1 from device designated by 16 bit data b15 b0 b15 b0 5678 BIN 4 gt 5677 BIN 2 If the contents of the device designated by were 0 and the DEC or DECP instruction were executed on that device the value 1 would be stored in the device designated by Operation Errors 1 There are no operation errors associated with the INC INCP DEC or DECP instructions 6 53 6 53 6 BASIC INSTRUCTIONS MELSEC Q QnA Program Example 1 The present value stored in counter CO to C20 is output to Y30 to as BCD data when X8 is on When present value is less than 9999 Ladder Mode X8 P 0 BCD COZ1 K4Y30 Outputs the present value of C D Z1 to Y30 to as BCD Executes Z1 1 With Z1 21 or X7 reset input sets Z to 0 END List Mode Steps Instruction Device 0 LD X8 1 BCDP COZ1 K4Y30 4 INCP 71 6 LD K21 71 9 OR XT 10 RST Zi 12 END 2 The following is a down counter program
153. Source S data Fig 3 2 Ladder Example and Processing Conducted c In cases where digit designation is made at the destination D the number of points designated are used as the destination Bit devices below the number of points designated as digits do not change Ladder Example Processing When source S data is a numerical value X010 MOV H1234 K2M0 Destination D When source S data is a word device X10 _ vov K2M100 K2M100 Destination Do not change Fig 3 3 Ladder Example and Processing Conducted 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 2 When using word devices Word devices are designated in 1 point 16 bits units MO 4 vovkio po mE 1 DO point 16 bits is word device 1 When digit designation processing is conducted a random value can be used for the bit device initial device number 2 Digit designation cannot be made for the direct device designation DX and DY 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 e Decimal constants K 2147483648 to K2147483647 e Hexadecimal constants H00000000 t
154. Special Function Instructions Continued Instruction Number of Basic Steps Description BDSQR BDSQR Integer part Decimal fraction part BDSQRP BDSQRP S m s D A SiD D Sin S D 0 Sign 1 Integer part 2 Decimal fraction part BSIN s p BSINP BSINP S D BCOS BcOS S D Se Integer part BCOSP JOSEP USA Decimal traction pa BTAN TBTAN S D sign Integer part BTANP BTANP S D Decimal fraction part s D s D s D s D s D Trigono metric function BASIN BASIN Sign Integer part BASINP BASINP Decimal fraction part BACOS BACOS Sign Integer part BACOSP BACOSP Decimal fraction part Tan S D 0 Sign BATAN BATAN 1 Integer part 3 7 272 2 Decimal fraction part BATANP BATANP S D T Em 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 13 Data control instructions Table 2 30 Data Control Instructions Execution Processing Details Condition When 53 lt 1 LIMIT LIMIT S1S2 S3 D Store value of 51 at D When S1 S3 S2 Store value of S3 at D LIMITP LIMITP S1S2 S3 D When S2 lt S3 Store value of S2 at D When S3 1 S3 S1 1
155. T 8 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin or p ee p e 16x 6 5 2 Jump to END GOEND Usable Devices Internal Devices MELSECNET 10 H Special Index eo Br s User File zs pen 3 Function Constant Dara Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition Command see Functions 1 Jumps to FEND or END instruction in the same program file Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO A GOEND instruction has been executed after the execution of a CALL ECALL instruction and prior to the execution of the RET instruction Error code 4211 A GOEND instruction has been executed after the execution of a FOR instruction and prior to the execution of the NEXT instruction Error code 4200 A GOEND instruction has been executed during an interrupt program but prior to the execution of the IRET instruction Error code 4221 A GOEND instruction was executed between the CHKCIR and CHKEND instruction block Error code 4230 A GOEND instruction was executed between the IX and IXEND instruction block Error code 4231 Program Example 1 The following program jumps to the END instruction if DO holds a negative number Ladder Mode List Mode p lt DO GOEND H Steps I
156. T C23 K16 10 RST T225 14 LD C23 15 OUT Y55 16 LD X5 17 RST C23 21 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA m prc OS 5 3 7 Setting and resetting the annunciators SET F RST F Usable NER Set Internal Devices MELSECNET 10 H Special index Other eo BE User File IN Hen Function Constant ORIS Register Module Register K H Word Zn es Instruction Symbol Execution Condition SET input SET RST input c RST Set Data Instruction Name SetData Number of annunciator to be set F number Number of annunciator to be reset F number Functions SET 1 Annunciator designated by D goes ON when SET input goes ON 2 The following responses occur when the annunciator F goes ON The annunciator number is displayed at the LED display device at the front of the CPU module or the USER LED goes ON The numbers F numbers of the annunciators turned ON are stored successively at the special registers SD63 to SD79 The value of SD63 is incremented by 1 3 If the value of SD63 is 16 which happens when 16 annunciators are already ON even if a new annunciator is turned ON its number will not be stored at SD64 to SD79 RST 1 Annunciators designated by are turned OFF when RST input goes ON 2 The annunciator numbers F numbers of annunciators that have gone OFF
157. ade on the basis of the most significant bit b31 A sign is used with both the quotient and the remainder o Positive eis Negative Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO Attempt to divide 62 by 0 Error code 4100 Program Example 1 The following program divides the BIN data at D7 and D8 by the BIN data at D18 and D19 when X5 is ON and stores the result at D1 to D4 Ladder Mode List Mode 0 8 E D7 D8 D Steps Instruction Device 0 LD X5 1 D P 5 END D 5 END 2 The following program outputs the value resulting when the data at X8 to XF is multiplied by 3 14 to Y30 to Y3F when X3 is ON Ladder Mode List Mode F 0 a K2X8 K314 DO Steps Instruction Device P 0 LD x3 y m 1 DO 5 D P DO MV D2 K4Y30 K100 D2 10 MOVP D2 K4Y30 13 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Lem p Process CPU 6 2 5 BCD 4 digit addition and T operations ns B B B BP P Usable Devices Internal Devices MELSECNET 10 H Special Index ea ur User File es Eu E Function Constant Data Register Other Register Module K H Word Ua Zn Instruction Symbol Execution Condition L indicates the signs B or B Command NE Command P
158. alent basic instructions or application instructions where the same instruction can be designated for either execution at ON or leading edge execution a P is added after the instruction name to specify the condition for execution Instruction to be executed at ON Instruction to be executed at leading edge P Execution at ON and execution at leading edge for the MOV instruction are designated as follow MOV K4X0 Execution at Execution at leading edge 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 8 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 The basic number of steps for basic instructions and application instructions is calculated by adding the device number and 1 For example the instruction would be calculated as follows T Spo RO Indicates the number of devices gt 3 steps H H Do D10 RO 4 steps 1 Conditions for increasing the number of steps The number of steps is increased over the number of basic steps in cases where a device is used that is designated indirectly or for which the number of steps is increased a When device is designated indirectly In cases where indirect designation is done by 1 step over the number of basic steps For examp
159. am file from next scan when jump command goes from OFF to ON 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 Executes next step in program when jump command is OFF or when it goes from ON to OFF ON Jump command OFF Executed each 1 scan Scan SCJ JMP 1 Unconditionally executes program of designated pointer number within the same program file POINTS 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 2 Scan time is shortened if the CJ SCJ or JMP instruction is used to force a jump to the OUT instruction 8 Scan time is shortened if the CJ SCJ or JMP instruction is used to force a jump to the rear 4 The CJ SCJ and JMP instructions can be used to jump to a step prior to the step currently being executed However it is necessary to consider methods to get out of the loop so that the watchdog timer does not time out in the process Ps X0 gt Y40 5 Closed X7 loop when CJ P9 X3 is ON 4 ou x Ecc v42 gt b The device to which a jump has been made with CJ SCJ or JMP does not change XB CJ P19 Jumps to label P19 when XB goes ON XC Y43 gt Y43 and Y49 do not change regardless xB of whether XC is ON or OFF during Y
160. an accurate count 4 The UDCNT1 instruction can be used as many as 6 times within all the programs being executed The seventh and the subsequent UDCNT1 instructions are not processed Operation Errors 1 There are no operation errors associated with the UDCNT1 instruction Program Example 1 This program uses up and down counter to count the number of times XO goes from off to ON after X20 has gone ON Ladder Mode List Mode 0 Iwer X0 5 Steps Instruction Device 0 LD X20 1 UDCNT1 X0 co K5 5 END Operation X20 JJ XO _ x1 Up Down Up Present value of COM 0 1234567654321 0 1 2 3 2 10 1 1 contact 6 114 6 114 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin ppp 6 8 2 Counter 2 phase input up or down UDCNT2 Usable Devices Internal Devices MELSECNET 10 H Special Index E BE User File ES pen E Function Constant Dara Register Other Register Module K H UA Zn LIEN TEM nc Instruction Symbol Execution Condition Command UDCNT2 UDCNT2 Set Data Data Type Input number for count input S 0 A phase pulse Input number for count input S 1 B phase pulse e Number of counter that will perform count onUDCNT2 instruction BIN1
161. and BCD data designated by 62 and stores the result in the device designated by 6 63 Quotient 1 Remainder 51617 81 0 8 7 6 0 0 0 6 0 4 2 2 Digits higher than those which were designated will be read as 0 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 Uses 32 bits to store the result of the division as quotient and remainder Quotient BCD 4 digits Stored at the lower 16 bits Remainder BCD 4 digits Stored at the upper 16 bits 3 If D has been designated as a bit device the remainder of the operation will not be stored Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The or 6 data is outside the 0 to 9999 range Error code 4100 Attempt to divide by 0 Error code 4100 Program Example 1 The following program multiplies the BCD data at to and the BCD data at D8 when goes ON and stores the result at DO and D1 Ladder Mode List Mode DE T5 D8 Do Steps Instruction Device 0 LD 1 D8 5 END D1 Upper 4 digits DO Lower 4 digits 9 7 5 3 8 6 4 2 4 218 514126 Multiplicand Multiplie Multiplication result 2 The following program divides 5678 by the BCD data 1234 stores the
162. are deleted from the special registers SD64 to SD79 and the value of SD63 is decremented by 1 1 Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU module or QnACPU Programming Manual Fundamentals Section 4 2 5 for details of annunciators 5 32 5 32 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 2 The table below shows which CPU module features either the LED display device on front of the CPU module or USER LED Type of LED CPU module Type Name LED displaydevice __ Q4A Q4AR USER LED Q2A S1 Q2AS S1 Q2ASH S1 QCPU 3 If when the value of SD63 is 16 and annunciator numbers are deleted from SD64 to SD79 by use of the RST instruction annunciators whose numbers are not registered in SD64 to SD79 are then turned ON the numbers of these annunciators 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 LED will be turned OFF Operations which take place when SD63 is 16 F30 turned ON F90 is reset SD63 16 16 16 5064 233 8064 233 5064 233 SD65 90 SD65 90 SD65 700 The SD67 SDee 700 SD66 700 SD66 28 lt F number is stored SD77 145 5078 145 5078 145 5078 1027 5079 1027 5079 1027 SD79 30 The contents of SD63 F30 which is ON and SD64 to is stored at SD79 SD79 are not changed Operati
163. as 0 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 The values for S and can be between 0 to 99999999 BCD 8 digit 3 The following will result if an underflow is generated by the subtraction operation The carry flag in this case does not go ON 112 3 5 6 7 8 1 a s 4 s e e r gt 9 9 9 9 9 9 9 9 Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The or D BCD data is outside the 0 to 99999999 range Error code 4100 Program Example 1 The following program adds the BCD data 12345600 and 34567000 stores the result at D887 and D888 and at the same time outputs them to from Y30 to Y4F Ladder Mode SM400 P 0 DMOV H12345600 1887 Stores 12345600 at D887 D888 as BCD P 08 H34567000 D887 Adds BCD 34567000 and D887 D888 and stores the result D887 D888 DMOV 0887 K8Y30 Outputs data at D887 D888 to Y30 to Y4F List Mode Steps Instruction Device 0 LD SM400 1 DMOVP H12345600 D887 5 DB P H34567000 D887 9 DMOVP D887 K8Y30 12 END 2 The following program subtracts the BCD data 98765432 from 12345678 stores the result at D100 and D101 and at the same time outputs it from Y30 to Y4F Ladder Mode SM400 P 0 DMOV H98765432 D100 Stores 98765432 at D100 D101 as BCD data P DB H
164. aster control instruction Master control Termination instruction Program termination Program stop instructions such as no operation which do not fit in the above Other instructions categories Instructions for Counter increment decrement teaching timer special function timer rotary table shortest direction control etc Data processing instructions 16 bit data searches data processing such as decoding and encoding m Repeated operation subroutine program calls Index modification in ladder Structure creation instructions units Table operation instruction Read Write of FIFO table Buffer memory access instruction Data read write for special function modules Display instructions Print ASCII code LED character display etc P ebugging ang fale diagnosis Check status check sampling trace program trace instructions Conversion between BIN BCD and ASCII conversion between BIN and character string conversion between floating decimal point data and character strings character string processing etc Trigonometric functions conversion between angles and radians exponential operations automatic logarithms square roots Data control instructions Upper and lower limit controls dead band controls zone controls Switching instructions File register block No switches designation of file registers and comment files Read write of year month day hour minute second and day of the week conversion between time statement
165. at SDO The range n points from the or D device exceeds the relevant device The data n points at the S device is outside the 0 to 9999 range The and devices overlap Program Example 1 The following program converts BCD data the number of points from D100 corresponding to the value stored at DO to BIN data when X20 goes ON and stores the result from D200 onward Ladder Mode List Mode 0 dps BKBIN 100 0200 00 Steps Instruction Device 0 LD X20 1 BKBINP D100 END 5 D100 BCD 8080 110 0 0 0 0 0 0 1 0 0 0 0 0 0 0 D101 BCD 7654 0111 0 11 00 10 1 0 1 070 D102 BCD 9999 1 0 01 1 0 0 1 17070 1 1 070 1 END BIN conversions when 00 3 TNO OO lt f N LO N OMT 00 f N 0 00 1 1 1 1 1 1 0 0 1 0 00 0 D200 BIN 8080 D201 BIN 7654 D202 BIN 9999 D200 DO 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin one C px qu 6 4 Data Transfer Instructions 6 4 1 16 bit and 32 bit data transfers MOV MOVP DMOV DMOVP Usable Devices Internal Devices MELSECNET 10 H Special Index rS BUS User File EX EE Function Constant ind Register Other Register Module K H Word Word UA Zn Instruction Symbol Execution Condition L indicates MOV DMOV Command E GZ aos Command MOVP DMOVP PP
166. at SDO A direct access output number designated by D has exceeded the CPU output range Error code 4101 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 Output of preset instruction List Mode Steps Instruction Device 0 LD X20 1 DMOVP K0 U0 G1 6 DELTAP DY11 9 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU ONA ope epo pee P o L OSO 5 4 Shift Instruction 5 4 1 Bit device shift SFT SFTP Usable Devices Internal Devices MELSECNET 10 H Special index Other ra Br User File EX Function Constant Dai Register Module Register K H 9 Word UM Zn Other than Instruction Symbol Execution Condition Shift command SFT SFTP Shift command Set Data Meaning Number of device to shift L t Functions 1 When bit device is used a Shifts to a device designated by D the ON OFF status of the device immediately prior to the one designated and turns the prior device OFF For example if M11 has been designated by the SFT instruction when the SFT instruction is executed it will shift the ON OFF status of M10 to M11 and turn M10 OFF b Turn the first device to be shifted ON with the SET instruction c When the SFT a
167. atch save or recovery of index register ZPUSH ZPUSHP ZPOP ZPOPP 7 328 7 18 8 Batch write operation to E2PROM file register EROMWR 7 332 8 INSTRUCTIONS FOR DATA LINK 8 1t08 103 8 1 Network Refresh Instruction uuu nnns 8 6 8 1 1 Network refresh ZCOM l T 8 6 8 2 Instructions Dedicated to QnA Links L tnnt ennt nnns 8 12 8 2 1 Reading word device data from another station READ u 8 12 8 2 2 Reading word device data from another station SREAD sse 8 18 8 2 3 Device data write to station on MELSECNET 10 network WRITE 8 24 8 2 4 Writing device data to other stations SWRITE sse 8 31 8 2 5 Sending data to other stations SEND sse nennen 8 38 8 2 6 Receiving data from another station REOCV sse 8 46 8 2 7 Transient requests from other stations read write clock data remote RUN STOP REQ 8 52 8 2 8 Reading data from special function modules at remote I O stations ZNFR 8 64 8 2 9 Writing data to special function module of remote I O station ZNTO 8 69 8 3 Instructions for A Series Compatible Link essent 8 74 8 3 1 Reading device data from
168. ated by D and a floating decimal point type real number designated by S and stores the result at a device designated by Q4 Q4 Q i Can C J e Sh Ww Floating decimal point Floating decimal point Floating decimal point type real number type real number type real number 2 Values which can be designated at S and D and which can be stored are as follows 0 4p 126 lt Designated value stored value 2128 Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The contents of the designated device or the result of the addition or subtraction operation are not or not within the following range Error code 4100 12 1 6 Contents of designated device operation result 2128 When the specified device contains 0 Q4ARCPU Operation error does not occur even if 0 is stored if SM707 is turned on Error code 4100 Program Example 1 The following program adds the floating decimal point type real numbers at D3 and D4 and the floating decimal point type real numbers at D10 and D11 when X20 goes ON and stores the result at D3 and D4 Ladder Mode List Mode 0 03 Steps Instruction Device E 1 4 END p 4 END D4 D3 D11 D10 D4 D3 590601437 120032 gt 1796464 2 The following program subtracts the floating decimal point type
169. ated by n1 the number of times designated by n2 to the output module with the output signal Y designated by D1 2 Frequencies between 1 to 100 Hz can be designated by n1 If n1 is other than 1 to 100 Hz the PLSY instruction will not be executed 3 The number of outputs that can be designated by n2 is between 1 to 65535 0000 to OFFFFH 4 Only an output number corresponding to the output module can designated for pulse output at 5 Pulse output commences with the command leading edge of the PLSY instruction Do not turn the command of the PLSY instruction OFF during pulse output Pulse output is suspended when the PLSY instruction command goes OFF 6 128 6 128 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 The PLSY instruction registers the argument device data in the CPU module work area and the actual output operation is processed during system interrupts The device data registered to the work area of the CPU module are cleared when the command input is turned OFF or when the CPU module is STOPped and then RUN Therefore to count the pulses it is necessary to provide their ON and OFF time as long as the interrupt time of the CPU module or longer The interrupt time of individual CPU module is shown below CPU module Type Name Interrupt Time High Performance model QCPU Process CPU OnACPU 2 Do not change the argument of the PLSY instruction during pulse output by the PLAY instruction while the command input
170. atent Japanese Manual Version SH 080021 E 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 1999 MITSUBISHI ELECTRIC CORPORATION INTRODUCTION Thank you for purchasing the Mitsubishi MELSEC Q Series mode and MELSEC QnA Series of Programmable Logic Controllers Before using the product please read this manual carefully to develop full familiarity with the functions and performance of the Programmable Logic Controller Q Series Q mode QnA Series you have purchased so as to ensure correct use A copy of this manual should be forwarded to the end User CONTENTS 1 GENERAL DESCRIPTION 1 1to1 4 1 1 Related Programming Manuals eene nennen nnne rennen ennt 1 1 1 2 Abbreviation and Generic Name sse nennen ttes trennen nnns nnne nnne nnns 1 4 2 INSTRUCTION TABLES 2 1102 49 2 1 Types of InstructiOris a aska a squa us b as 2 1 2 2 How to Read Instruction Tables aio edt tete cate ate adecuado tates 2 2 2 3 5equence INSTHUCHONS iat laku aska shi 2 4 2 31 Contact Instr ctiori u eo Liven view Aarau a I ee Aion a ee eie ida non ven ee 2 4 2 3 2 Connection instructions I nn 2 5 2 3 3 OULDULINSIMUICHONS 2
171. ates a step Decimal fractions are rounded up 2 INSTRUCTION TABLES 2 5 15 Clock instructions Category Table 2 32 Clock Instructions Instruction Symbols Processing Details e Clock device DATERD DATERD DATERDP DATERDP D DATEWR DATEWR S DATEWRP DATEWRP S S Year Month Day Hour Minute Sec Day of week Year Month Day Hour Minute Sec Day of week Clock device Execution Condition 1S2 D 51 52 Hour Minute Minute Minute Sec Sec Sec SECOND s D s D s D HOUR 5 D Hour Sec lower level Minute Sec upper level Sec S D Sec lower level Hour Sec upper level Minute Sec Number of Basic Steps MELSEC Q QnA Description 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 16 Peripheral device instructions Table 2 33 Peripheral Device Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description
172. be exchanged BIN 16 bits ous of INumberofexchanges 20 E Functions 1 Exchanges 16 bit data n points from device designated by 6 and 16 bit data n points from device designated by 63 b15 b8b7 bO b15 b8b7 b0 0101010 11 11 070 000 411 131 lt 010 1 4 0 014 4 0101 11 1 010 114 4 1 Qi 01100 00111 17101000711 2 0 0 00 00 00 1 1Tt 11t1 63 2 1111 1111 0 0 0 0 0 0 0 0 n 2 1101 110 1 0 110 10 110 110110 63 2 1113 194 t 1111111 n 1 0 tro 1 0101 0 too 101 n 1 o o o o ororo o 1 1 11 n n n n 2 1 Gy V b15 b8b7 b0 b15 b8b7 b 0 ortit o 011 0001 001 1 0101010 1111111701010 0 1111 1 1110 0 00 11 111 0 0 00 1 1 63 1 1t 1 1 0T07070 0 707070 6542 1111 11 11 00 00 0 00 0 2 0000000011111111 i n n 2 1 01 01 01 0 1101 0 110 1 0 n 1 011101110 1 0 11011 0 10110 1 2 tirai 1 o 0 00 00000 1 1 t1 titii 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The range n points from the 6 or 62 devices exceeds relevant device Error code 410
173. been made according to the following format Table 2 2 How to Read Instruction Tables Execution Condition Symbol Processing Details Instruction Number of Basic Steps Description IT t Description Onari Classifies instructions according to their application OPNE Indicates the instruction symbol added to the instruction in a program Instruction code is built around the 16 bit instruction The following notations are used to mark 32 bit instructions instructions executed only at the leading edge of OFF to ON real number instructions and character string instructions 32 bit instruction The letter D is added to the first line of the instruction Example wj D Y Y 16 bit instruction 32 bit instruction Instructions executed only at the leading edge of OFF to ON The letter P is added to the end of the instruction Example Y Y Instructions Instructions executed only at the executed when ON leading edge of OFF to ON e Real number instructions The letter E is added to the first line of the instruction Example E Real number instructions Character string instructions A dollar sign is added to the first line of the instruction Example gt Y Character string instructions 2 INSTRUCTION TABLE STRUCTIO 5 MELSEC Q QnA
174. c Steps Description c 2 E 7 2 3 6 Termination instruction Table 2 8 Termination Instructions Execution Category Condition FEND FEND Termination of main aa Program end END Termination of sequence program of sequence program 2 3 7 Other instructions Processing Details Instruction Number of Basic Steps Description Table 2 9 Other Instructions Execution Category Condition Terminates sequence operation after input condition has been met Stop STOP STOP Sequence program is executed by placing the RUN STOP key switch back in the RUN position Processing Details Instruction Number of Basic Steps Description Pent For program deletion or space Ignored To change pages during Ignored NOPLF NOPLF printouts PAGE PAGE Ignored Subsequent programs will be controlled from step 0 of page n 2 INSTRUCTION TABLE L MELSEC Q QnA 2 4 Basic Instructions 2 4 1 Comparison operation instruction Table 2 10 Comparison Operation Instruction Execution Category Condition Processing Details Instruction Number of Basic Steps Description Conductive status when S1 S2 Non conductive status when S1 S2 Conductive status when S1 S2 Non conductive status when S1 S
175. ce data of other station to host station JP ZNRD J ZNWR Ji 2 z the Gale of host station to the word device of other Reads data from the special function module at remote I O station GP RFRP Writes data to the special function module at remote I O station GP RTOP TARITREAD Reads data set at routing routing RTREAD arameters 7 8 96 ZP RTREAD n D HP i 4 Z RTWRITE n S H Writes routing data to the area RTWRITE designated by routing 4 ZP RTWRITE n S H parameters 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 20 QCPU instructions Table 2 37 QCPU Instructions Execution Category Condition Processing Details NIRD NIRD Intl D Ino Reads the module information stored in U LY n n the area starting from the I O No designated by n by the points designated by n2 and stores it in the area starting from the device designated by d Stores trace data set at a peripheral device to trace file in IC memory card by the designated number when SM800 SM801 and SM802 turns ON TRACER TRACER Resets the data set by TRACE L 4 instruction SP FWRITE Writes data to the designated file Instruction Number of Basic Steps Description
176. characters in character string designated by S at a device designated by D Converts a 1 word BIN value designated by S2 to a decimal character string with the total number of digits and the number of decimal fraction digits designated by S1 and stores them at a device designated by D Converts a 2 word BIN value designated by S2 to a decimal character string with the total number of digits and the number of decimal fraction digits designated by S1 and stores them at a device designated by D Converts a character string including decimal point designated by S to a 1 word BIN value and the number of decimal fraction digits and stores them at devices designated by D1 and D2 Converts a character string including decimal point designated by S to a 2 word BIN value and the number of decimal fraction digits and stores them at devices designated by D1 and D2 Converts floating decimal point data designated by S1 to character string and stores them in a device designated by D Converts character string designated by S to floating decimal point data and stores them in a device designated by D Execution Condition Number of Basic Steps 2 37 MELSEC Q QnA Description 2 Category INSTRUCTION TABLES Table 2 28 Character String Processing Instructions Continued Instruction
177. conversion MEP MEF Usable Devices Internal Devices MELSECNET 10 H Special File E pen 1 Function Constant per baia Register K H Register Module Word Word UA Zn Instruction Symbol Execution Condition Functions MEP 1 If operation results up to instruction are leading edge from OFF to ON goes ON continuity status If operation results up to MEP instruction are anything other than leading edge goes OFF non continuity status 2 Use of the MEP instruction simplifies pulse conversion processing when multiple contacts are connected in series MEF 1 If operation results up to MEF instruction are trailing edge from ON to OFF goes ON continuity status If operation results up to MEF instruction are anything other than trailing edge goes OFF non continuity status 2 Use of the MEF instruction simplifies pulse conversion processing when multiple contacts are connected in series Operation Errors 1 There are no operation errors associated with the MEP or MEF instructions Program Example 1 A program which performs pulse conversion on the operation results of X0 and X1 Ladder Mode List Mode 0 py qst M0 Steps Instruction Device 0 X0 4 END 1 AND 2 3 SET MO 4 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 1 The MEP and MEF instructions will occasionally not function properly when pulse conversion
178. cture Creation Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps See for Description Executes n times between NEXT Forcibly ends the execution of the FOR to NEXT cycle and jumps pointer to Pn BREAKP BREAKP Executes sub routine program Pn when CALL CALL S1toSn 1 input condition is met S1 to Sn are arguments sent to sub Returns from sub routine program FCALL Performs non execution processing on sub routine program Pn if input Executes sub routine program Pn from within designated program name when routine Program Name input condition is met program 51 to Sn are arguments sent to sub calls ECALLP 51 10 SH routine program 0 n 5 Sub ECALL n S1 to Sn Program Name EFCALL 51 to Sn Performs non execution processing of EFCALL sub routine program Pn from within Program Name designated program name if input condition is not met EFCALLP S1 to Sn EFCALLP Program Name Performs link refresh and general data processing Conducts index modification for individual devices used in device modification ladder Stores modificati
179. d Sequence program DI Even though an interrupt condition might be generated between the DI and El Sequence program instructions the interrupt program will be held until the entire cycle from DI to El has been processed In FEND Interrupt program 6 106 6 106 6 BASIC INSTRUCTIONS MELSEC Q QnA 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 015 614 b13 612 bii b10 b9 b8 b7 b6 b5 b4 b3 b2 bl bO 115 1114 1 113 1 H2 111 1 110 19 18 I7 116 1105 1 14 1 I8 12 1110 131 1 130 1 129 1 128 1 127 1 126 1 125 1 124 1 123 1 122 1 121 1 120 1 191 1181 1171 116 2 1471146 1 145 1144 1 143 1 M2 1 141 1 140 1 139 1 138 1137 1 136 1 1351 1341 1331 132 3 When the power is turned ON or when the CPU module has been reset interrupt programs from 10 to 131 are in the execution enabled state and interrupt programs from 132 to 147 are in the execution disabled state 4 The statuses of the S S 1 and S 2 devices are stored from SD715 to SD717 the IMASK instruction mask pattern storage area POINTS 1 An int
180. d D3 DO K2Y38 Steps Instruction Device 0 LD X5 1 P D3 K2Y38 5 END 2 The following program outputs the difference between the set value for timer T3 and its present value to Y40 to Y53 Ladder Mode List Mode 0 Be Steps Instruction Device 0 LD a 18000 5 k18000 T3 D3 1800 6 K18000 T3 M D0 23 K5Y40 D3 10 DBCD D3 K5Y40 13 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Ie 2002027 Process CPU ONA 6 2 2 BIN 32 bit addition and subtraction D D D D D D 5B Usable Devices Internal Devices MELSECNET 10 H Special Index x Br User File Eu E Function Constant Das Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition Ll indicates the signs D D Command Set Data Meaning Data Type or subtraction data or first number of device storing addition or subtraction data BIN 32 Data to be added to or subtracted from or first number of device storing Ses such data Functions 1 Adds 32 bit BIN data designated by to 32 bit BIN data designated by and stores the result of the addition at the device designated by Qu 1 1 b31 b16 b15 bO b31 b16b15 bO 631 b16 b15 bO 567890 BIN 123456 BIN gt 691346 BIN 2 The values for and can be
181. d small values cannot be performed correctly 6 4 6 4 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the lt gt gt lt lt or gt instructions Program Example 1 The following program compares the data at to with the data at and turns Y33 ON if the data is identical Ladder Mode List Mode p K8O 03 C133 Steps Instruction Device 0 LDD K8X0 D3 4 END 1 Y33 2 The following program compares BIN value K38000 to the data at D3 and D4 and establishes continuity if the data in D3 and D4 is something other than 38000 Ladder Mode List Mode M3 0 LT K38000 D3 C133 Steps Instruction Device 0 LD M3 1 ANDD lt gt 5 OUT 6 END 3 The following program compares BIN value K 80000 to the data at D3 and D4 and establishes continuity if the data in D3 and D4 is less than 80000 Ladder Mode List Mode 0 D K 80000 D3 133 Steps Instruction Device 1 tbo I 80000 3 M8 D3 5 OR M8 6 ANB T OUT Y33 8 END 4 The following program compares the data in DO and D1 with the data in D3 and D4 and establishes continuity if the data in DO and D1 is equal to or less than the data in D3 and D4 Ladder Mode List Mode 0 pf 133 Steps Instruction Device 0 LD M3 1 AND M8 D lt DO D3 2 ORD lt w 5 QUT Y33 6 END 6 END 6 BASIC
182. de 00k 1 When designated character is the NULL code One word is used to store the NULL code MO Ai ov s Do H MEN NULL NULL code 00x designation Character string data transfer 2 When character string is even Uses number of characters 2 1 words and stores character string and NULL code For example if ABCD is transferred to DO the character string ABCD is stored at DO and D1 and the NULL code is stored at D2 MO I swov ABCD n 42H 41H Di 44H 43H D2 NULL Designation of an even number character string Character string data transfer 3 When number of characters is odd Uses number of characters 2 words rounds up decimal fractions and stores the character string and NULL code For example if ABCDE is transferred to DO the character string ABCDE and the NULL code are stored from DO to D2 MO sMov 42H 41H D1 44H 43H D2 NULL 45H Designation of an odd number character string Character string data transfer 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 3 3 Index Modification 1 Index modification a Index modification is an indirect setting made by using an index register When an index modification is used in a sequence program the device to be used will become the device number designated directly plus the contents of the index register For exampl
183. designated annunciator 2 The following responses occur when an annunciator F is turned ON With Q3A Q4A or Q4ARCPU The annunciator number is displayed at the LED display device on the front of the CPU module and the USER LED goes ON The annunciator numbers which are ON F numbers are stored in special registers SD64 to SD79 The value of SD63 is incremented by 1 With CPUs other than above The USER LED goes ON The annunciator numbers which are ON F numbers are stored in special registers SD64 to SD79 The value of SD63 is incremented by 1 3 If the value of SD63 is 16 which happens when 16 annunciators are already ON even if a new annunciator is turned ON its number will not be stored at SD64 to SD79 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 4 The following responses occur when the annunciator is turned OFF by the OUT instruction With or Q4ARCPU The coil goes OFF but there are no changes in the LED display device on the front of the CPU module the status of the USER LED and the contents of the values stored in SD63 to SD79 e Use the RST F t 2 instruction to turn OFF the LED display device on the front of the CPU module and USER LED and to delete the annunciator which was turned OFF by the OUT F instruction from SD63 to SD79 With CPUs other than above The coil goes OFF but there are no changes in the status of the USER ERR LED and the
184. designated at between 2147483648 and 2147483647 BIN 32 bits 3 Judgment of whether the data is positive or negative is made on the basis of the most significant bit 031 e inse Positive 1 Negative 6 BASIC INSTRUCTIONS MELSEC Q QnA 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 K2147483647 2 K 2147483647 Because b31 is 1 H7FFFFFFF H2 H80000001 the value is negative e K 2147483648 2 2147483646 Because b31 is 0 H80000000 HFFFE H7FFFFFFE the value is positive 1 Subtracts 32 bit BIN data designated by from 32 bit BIN data designated by and stores the result of the subtraction at the device designated by Q O4 Q 1 f b31 b16 b15 b0 b31 b16 b15 b0 b31 b16 b15 b0 567890 BIN 123456 BIN gt 444434 BIN 2 The values for S and can be designated at between 2147483648 and 2147483647 BIN 32 bits 8 Judgment of whether the data is positive or negative is made on the basis of the most significant bit 031 0 Positive eu Negative 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 2147483648 K2 2147483646 Because b31 is 0 H80000000 H2 H7FFFFFFE th
185. designation index modification 2 Both I O numbers and buffer memories can be index modified with special function module devices vov 1021 0022 Do H If Z1 2 and Z2 8 then U 10 2 G 0 8 U12 G8 3 Both network numbers and device numbers can be index modified with link direct devices Mov 121 4 022 Do If Z1 2 and Z2 8 then J 142 K4X 0 8 J3 K4X8 1 1 Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU module or QnACPU Programming Manual Fundamentals for special function module device 2 2 Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU module or QnACPU Programming Manual Fundamentals for link direct devices 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 3 4 Indirect Designation 1 Indirect Designation a Indirect designation is a way of using a word device to designate a device address that will be used in a sequence program This method can be used when the index register is insufficient b The device which designates the designated device address is designated by Q word device number For example designation of D100 will make the contents of D100 D101 the device address c The address of the device performing indirect designation can be confirmed with the ADRSET instruction _ ADRSET W100 D100 W100 address is stored at D101 and D100
186. e if D2Z2 has been designated the designated device is calculated as follows D 2 3 D5 and the content of Z2 is 3 become the designated device b There are 16 index registers from ZO to Z15 Each index register can be set between 32768 and 32767 MOV K 20 The value 1 is stored at ZO The data 01020 D 10 1 MOV PINEN S D9 is stored at DO L Index modification Example A case where index modification has been performed and the actual process device would be as follows When 20 20 and Z1 5 Ladder Example Actual Process Device MOV K20 xi L _ vov K120 W04E Description K100Z K 100 20 K120 W 53 5 W4E MOV K 5 MOV K100Z0 W53Z1 Hexadecimal number MOV K20 L MOV K2X64 K1M33 l MOV K 5 z Description L y K2X50Z K2X 50 14 K2X64 X1 _ 2 K20 is converted to hexadecimal t KJ 2 5020 K1M38Z1 K1M38 K1M 38 5 K1M33 MOV K20 ZO X1 H _ MOV D20 K3Y1 a Description Me m D0Z D 0 20 020 K3Y12F K3Y 12F 5 K3Y12A 4 _ mov DOZO 12 21 number Fig 3 7 Ladder Example and Actual Process Device 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 2 Devices which can be index modified With the exception of the restrictions noted below index modification can be used with devices used with contacts coils basic instructions and application instruct
187. e carry flag in this case does not go ON e 32767 K2 32767 negative value is generated if b15 is 1 H7FFF H0002 H8001 e K 32768 K 2 K32766 A positive value is generated if b15 is 0 H8000 HFFFE H7FFE 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Subtracts 16 bit BIN data designated by 6 from 16 bit BIN data designated by 62 and stores the result of the subtraction at the device designated by M N b15 bO b15 bO b15 5678 BIN 1234 gt 4444 BIN 2 Values for 6 and D can be designated from 32768 and 32767 BIN 16 bits 3 The judgment of whether data is positive or negative is made by the most significant bit b15 0 Positive di E Negative 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 e K 32768 K2 K32766 A positive value is generated if b15 is 0 H8000 H0002 H7FFE e K32767 2 K 32767 A negative value is generated if b15 is 1 H7FFF H0002 H8001 Operation Errors 1 There are no operation errors associated with the P or P instructions Program Example 1 The following program adds the contents of D3 and the contents of DO when X5 goes ON and outputs result to Y38 to Ladder Mode List Mode 0 E m
188. e device in one scan the specified device will be OFF if any one of the RST commands is ON c When the SET instruction and RST instruction using the same device are programmed in one scan the SET instruction turns ON the specified device when the SET command is ON and the RST instruction turns OFF the specified device when the RST command is ON When both the SET and RST commands are OFF the ON OFF status of the specified device will not be changed 5 M0 H X1 Rsr mH Timing Chart Circuit ON Mo OFF i turns OFF RST remains the same ON because X1 is OFF because X1 is ON SET MO remains the same ON MO turns ON because is ON because X0 is OFF 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 8 PLS instructions using the same device The PLS instruction turns ON the specified device when the PLS command turns ON from OFF It turns OFF the specified device at any other time OFF OFF ON gt ON and ON gt OFF When two or more PLS instructions using the same device are programmed in one scan each PLS instruction turns ON the specified device when the corresponding PLS command turns ON from OFF and it turns OFF the specified device at any other time For this reason when two or more PLS instructions using the same device are programmed in one scan the device that has been turned ON by the PLS command may not turn ON again throughout the scan
189. e rewritten the data 4 The value of n2 should be less than the number of table divisions that were designated by n1 5 0 and D 1 are A and B phase input signals that are used to detect whether the direction of the rotary table rotation is forward or reverse 6 122 6 122 6 BASIC INSTRUCTIONS MELSEC Q QnA The direction of rotation is judged by whether the B phase pulse is at its leading or trailing edge when the A phase pulse is ON When the B phase is at the leading edge Forward rotation clockwise rotation When the B phase is at the trailing edge Reverse rotation counterclockwise rotation 6 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 S 0 is cleared It is best to perform this clear operation first then to begin near path rotation with the ROTC instruction 7 The data from D 3 to D 7 consists of output signals needed to control the table s operation The output signal of one of the devices from D 3 to 7 will go ON in response to the execution results of the ROTC instruction 8 If operation results immediately prior to the ROTC instruction are OFF all signals from D 3 to D 7 will be OFF without near path rotation controls having been performed 9 The ROTC instruction can be used only one time in all programs where it is execut
190. e t fn e tpi e 11 46 APPENDIX1 OPERATION PROCESSING TIME sss APP 1 il 3l Definition uiae et etr d ede c Wed He t Het Hd ELEME xe dtd APP 1 1 2 Operation Processing Times of Basic model QCPU APP 2 1 3 Operation Processing Times of High Performance model QCPU Process CPU QnACPU APP 14 APPENDIX 2 COMPARISON OF PERFORMANCE BETWEEN 05 APP 40 2 1 Comparison of Q QnACPU with AnNCPU AnACPU and AnUCPU APP 40 2A Usable devices oit APP 40 Ps nex e erotrol roe Tr 41 2 1 3 Data That Be Used by Instructions APP 41 21 4 Timer GCompariSOD a amc tier ocn eer Dp rg D te E Dg e ege c eid APP 42 2 1 5 Comparison of APP 43 2 1 6 Comparison of Display Instructions APP 43 2 1 7 Instructions Whose Designation Format Has Changed Except Dedicated Instructions for ANACPU and AnUCPU APP 44 2 1 8 ANACPU and AnUCPU Dedicated Instructions APP 45 2 1 9 Instructions Which Can Be Programmed Only in the General Purpose Mode APP 45 APPENDIX 3 SPECIAL RELAY LIST ipunin una mnnn
191. e used by any other instruction If they are used by other instructions they will not be capable of returning an accurate count 4 The UDCNT2 instruction can be used as many as 5 times within all the programs being executed The sixth and the subsequent UDCNT2 instructions are not processed Operation Errors 1 There are no operation errors associated with the UDCNT2 instruction Program Example 1 The following program performs a count operation as instructed by CO count up or down on the status of XO and X1 after X20 has gone ON Ladder Mode List Mode 0 et purevr2 X0 K3 Steps Instruction Device 0 LD X20 1 UDCNT2 3 5 END i 5 END Operation X20 PR L ii LJ xi Present CO contact _ 6 116 6 116 value of COM 01 2 8 4 5 4 3 2 1 o 1 2 1 1 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA pepe EO 6 8 3 Teaching timer TTMR Usable Devices Internal Devices MELSECNET 10 H Special inda ea User File EON Eu 1 Function Constant Register Other Register Module Zn K H UL AG 2 Instruction Symbol Execution Condition Measurement command Set Data Meaning D 0 Storage device for measurement value 1 For CPU module system use BIN 16 bits Functions 1 The
192. e value is positive e K2147483647 K 2 K 2147483647 Because b31 is 1 H7FFFFFFF HFFFE 80000001 the value is negative Operation Errors 1 There are no operation errors associated with the or P instructions 6 BASIC INSTRUCTIONS MELSEC Q QnA Usable Devices Internal Devices MELSECNET 10 H Special Index E EE User File EX Fry 1 Function Constant ban Register Other d Register d Module K H UL AGL i Instruction Symbol Execution Condition L indicates the signs D D Command B Command D P D P u gt Set Data Set Data Meaning amp Data to be added to or subtracted from or the first number of the device storing such data amp Addition or subtraction data or first number of device storing addition or BIN 32 bits subtraction data First number of device storing addition or subtraction data Functions 1 Adds 32 bit BIN data designated by to 32 bit BIN data designated by 62 and stores at the device designated by D Q4 Q4 Q4 NO LY S b31 b16 b15 b0 b31 b16 b15 b0 b31 b16 b15 b0 567890 BIN 123456 BIN gt 691346 BIN 2 The values for 6 629 and D can be designated at between 2147483648 and 2147483647 BIN 32 bits 3 Judgment of whether the data is positive or negative is made on the basis of the most sign
193. ecuted regardless of whether SM722 is turned ON or OFF if the designated value is out of the available range For BCDP DBCDP instructions the next operation is disabled regardless of the presence of errors unless the execution condition is turned from OFF to ON Operation Example 1 The following program converts the BCD data at X10 to X1B to BIN when X8 is ON and stores it at D8 3 3E switch BCD Can be z used at Input other 28888 9828 E powef 4 4 supply Ladder Mode List Mode Steps Instruction Device 0 LD X8 1 BINP hee 4 END 2 The following program converts the BCD data at X10 to X37 to BIN when X8 is ON and stores itat DO and D1 BCD digital switch LI LI Input power supply X37 to X34 X33 to X30 X2F to X2C X2B to X28 X27 to X24 X23 to X20 X1F to X1C X1B to X18 X17 to X14 X13 to X10 PLC Output Module Ladder Mode List Mode 0 DN K6X20 D9 Steps Instruction Device 0 LD X8 1 DBINP Dra D 09 D10000 D5 je he D10000 D5 BIN K4X10 D3 8 BIN 11 MOV K0 D4 13 D D3 D5 DO 17 END If the data set at X10 to X37 is a BCD value which exceeds 2147483647 the value at DO and D1 will be a negative value because it exceeds the range of numerical values that can be handled by a 32 bit de
194. ed Attempts to use it more than one time will result in inaccurate operations 10 No processing is performed when the value of 0 to S2 or the value of n2 is greater than ni Operation Errors 1 There are no errors associated with the ROTC instruction Program Example 1 The following program deposits the item at section D2 on a 10 division rotary table at the station at section D1 and the two sections ahead and behind this determine the rotation direction and control speed of the motor when the table is being rotated at low speed Ladder Mode List Mode 0 nor M Steps Instruction Device 0 LD X0 H 2 oD Xi 2 i 3 QUT Ml 4 LD X x 5 OUT M2 4r4t 6 LD X10 7 ROTC DO K10 X10 K2 6 Rore DO KIO K2 MO MO 12 END 12 6 123 6 123 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA pepe EO 6 8 6 Ramp signal RAMP Usable Devices Internal Devices MELSECNET 10 H Special Index ea Br s User File EN ru E Function Constant Dara Register Other W Register Word Module K H U AG mo on o AM Instruction Symbol Execution Condition Command RAMP I RAMP ni n2 n3 H Set Data Set Data Meaning BIN 16 bits 0 1 Number of times executed for system use n3 k Number of times moved 62 0 Completion device E o 02 1 Selected bit where data is to be saved at completion Functions
195. eds the range of that device e The device range for n points starting from the device designated by overlaps with the device range for n points starting from the device designated by Error code 4101 The device range for n points starting from the device designated by 6 overlaps with the device range for n points starting from the device designated by Error code 4101 The device range for n points starting from the device designated by overlaps with the device range for n points starting from the device designated by 6 Error code 4101 6 47 6 BASIC INSTRUCTIONS MELSEC Q QnA Program Example 1 When X20 is ON the program performs additions of the following data The data in the number value stored in DO of devices starting from D100 The data in the number value stored in DO of devices starting from R100 Then the program stores the addition results at the number value stored in DO of devices starting from D200 Ladder Mode List Mode 0 eco ae D100 RO D200 DO Steps Instruction Device 0 LD X20 1 D100 RO D200 0 6 END b15 b15 0100 RO 1234 BIN D200 8023 D101 R1 2032 BIN 0201 0102 R2 3252 BIN D202 2180 D103 R3 1000 BIN D203 2520 2 When X1C is ON the following program subtracts the constant 8765 from the data in three devices starting from D100 Then the program stores the subtraction
196. ee Section 3 6 for errors not included here Indicates whether the instruction can be used with each CPU module type be used A Can be used with restrictions function version software version x Cannot be used 9 Indicates both ladder and list for simple program example Also indicates the types of individual devices used when the program is executed 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 5 SEQUENCE INSTRUCTIONS Sequence instructions include instructions for relay control ladders and the like They are divided into the following categories Instruction Reference Contact instruction Operation start series connection parallel connection start series connection parallel connection Chapter 5 1 Ladder block connection creation of pulses from operation Connection Instruction Chapter 5 2 results store read operation results Output instruction Bit device output pulse output output reversal Chapter 5 3 Shift instruction Bit device shift Chapter 5 4 Master control instruction Master control Chapter 5 5 Termination instruction Program termination Chapter 5 6 i Program stop instructions such as no operation which do not fit Other instructions Chapter 5 7 in the above categories 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLC CPU Process CPU QnA Q4AR 5 1 Contact Instructions 5 1 1 Operation start series connection parallel connection LD LDI AND ANI OR OR
197. el QCPU Process CPU 1 to 65535 00014 to OFFFFH QnACPU 5 to 65535 0005 to OFFFFH The value designated for n1 should be the same as the value designated for n2 or smaller 6 130 6 130 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the PWM instruction POINT 1 The PWM instruction registers the designated device data to the work area of the CPU module The actual output operation is processed as the interruption by the CPU module The device data registered to the work area of the CPU module is cleared when the command input is turned OFF or when the CPU module is STOPped and then RUN The interrupt time of individual CPU module is shown below CPU module Type Name Interrupt Time High Performance model QCPU Process CPU GnAGPU For this reason the PWM instruction can be used only once within all the programs being executed by the CPU module 2 The instruction is not processed in the following cases When both n1 and n2 are 0 When n1 and n2 are not multiples of 5 only when QnACPU is used When n22 n1 8 Do not change the arguments of the PWM instruction while pulses are being output by the PWM instruction while the command input is ON Before changing the arguments turn OFF the command input Program Example 1 The following program outputs a 100 ms pulse once each second to Y20 when is ON Ladder Mode List Mode
198. el connection Trailing edge pulse parallel connection Instruction Number of Basic Steps Description 1 1 The number of steps may vary depending on the device being used 2 2 The number of steps may vary depending on the device and type of CPU module being used Number of Steps QCPU QnACPU Internal device file register RO to R32767 1 Device Direct access input DX 2 Devices other than above 3 3 3 The subset is effective only with QCPU 2 INSTRUCTION TABLES MELSEC Q QnA 2 3 2 Connection instructions Table 2 4 Connection Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description AND between logical blocks Series connection between logical blocks OR between logical blocks Series connection between logical blocks Memory storage of operation results storage of operation results Read of results stored with 5 with MPS instruction Conversion of operation result to leading edge pulse Ss O Conversion of operation result to trailing edge pulse Conversion of operation result to leading d edge pulse 1 Stored at Vn 5 16 Conversion of operation result to trailing edge pulse Stored at Vn REMARKS 1 The number of steps may vary depending on the type of CPU module being used High Per
199. er 4 digits Upper 4 digits Lower 4 digits a c lojo ojoj o ojo ejjoja 2 8 1 8 3 3 D 8 ie Quotient Remainder 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Lem 202027 Process CPU 6 2 9 Addition and subtraction of floating point Xin oaa Es Es EB P Usable Devices Internal Devices MELSECNET 10 H Special inda ea User File EN Hen 1 Function Register Register Instruction Symbol Execution Condition L indicates the signs E or E Command Set Data Addition or subtraction data or head number of device storing additon or subtractraction data Real number Data to be added to or subtracted from or head number of device storing such data Functions 1 Adds the floating decimal point type real number designated at and the floating decimal point type real number designated at and stores the sum in the device designated at Q4 0 _ O4 O 18 Y te 8 d Floating decimal point Floating decimal point Floating decimal point type real number type real number type real number 2 Values which can be designated at and and which can be stored are as follows 0 271264 Designated value stored value lt 2128 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Subtracts a floating decimal point type real number design
200. er strings are different the character string with the larger character code will be the larger b15 b8 b7 b15 b8 b7 42H B 41H A 42H B 41 A 1 44H D 43H C 6 1 44 D 43H 2 00H 46H F 2 45H E ABCDF ABCDE Instruction Symbol Comparison Operation Result Continuit Instruction Symbol Comparison Operation Result Continuit c If the character strings are different the first different sized character code will determine whether the character string is larger or smaller b15 b8 b7 bO b15 b8 b7 bO 2 2 31H 1 6 32H 2 31H 1 1 33H 3 34H 4 G341 34H 4 33H 3 6242 00H 35H 5 G3 2 00H 85H 5 12435 Instruction Symbol Comparison Operation int J Result Neeenimiy Continuity Continuity 12345 Instruction Symbol Comparison Operation Result 4 If the character strings designated by and 6 are of different lengths the data with the longer character string will be larger b15 b8 b7 b0 b15 b8 b7 b0 32H 2 31H 1 G 32H 2 31H 1 1 34H 4 33H 3 1 34H 4 33 3 2 36H 6 35H 5 2 36H 6 35H 5 6 3 00H 37H 7 3 00H OOH 1234567 123456 Instruction Symbol
201. erminated by use of just the lowest nesting number N 1 1 md VC NO vc NO v15 055 M15 NO M15 lt lt 2 x2 H Mc Nt M16 Mc N1 Mte N17 M16 N1 zc 16 I M gt Pt gt Ex Mc N2 M17 N2 M17 N27 M17 N27 M17 lt lt gt MCR N2 MCR No MCR N1 I lt gt No H LH gt 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin ope epo pes cope p 5 6 Termination Instructions 5 6 1 End main routine program FEND Usable Devices Internal Devices MELSECNET 10 H Special Index Fu Br User File EX EE P Function i d Register Constant Other Register Module UA Zn Instruction Symbol Execution Condition FEND Functions 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 2 Execution of the FEND instruction will cause the CPU module to terminate the program it was executing 3 Even sequence programs following the FEND instruction can be displayed in ladder displa
202. errupt pointer occupies 1 step T10 Stored at step 50 xs 20 53 55 2 Refer to the QnACPU Programming Manual Fundamentals for interrupt conditions 3 The DI state interrupt disabled is active during the execution of an interrupt program Do not insert El instructions in interrupt programs to attempt the execution of multiple interrupts with interrupt programs running inside interrupt programs 4 If there are El and DI instructions within a master control these instructions will be executed regardless of the execution non execution status of the MC instruction 6 107 6 107 6 BASIC INSTRUCTIONS Operation Errors MELSEC Q QnA 1 There are no operation errors associated with the DI and EI instructions 2 There are no operation errors associated with the IMASK instruction Program Example 1 The following program creates an execution enabled state for the interrupt program marked by the interrupt pointer number when is ON Ladder Mode P10 MOVP HOA MOVP HO P20 0100 6 108 D10 List Mode Steps Instruction Device 0 LD XO 1 CJ P10 3 DI 4 P10 5 LD X1 6 CJ P20 8 LD 9 MOVP HOA D10 12 MOVP HO D11 15 MOVP HO D12 18 IMASK D10 20 El 21 P20 22 LD MO 23 OUT Y20 24 FEND 25 11 26 LD M10 27 MOVP K10 D100 30 IRET 31 13 32 LD M11 33 P D100 D200 36 IRET 37 END 6 108 6 BASIC INSTRUCTIONS MELSEC Q QnA
203. errupt time of individual CPU module is shown below 2 When QCPU is used The instruction is not processed when n 0 When QnACPU is used The instruction is not processed when 0 or when n is not a multiple of 5 3 The SPD instruction can be used as many as 6 times within all the programs being executed The seventh and the subsequent SPD instructions are not processed Operation Errors 1 There are no operation errors associated with the SPD instruction Program Example 1 The following program measures the pulses input to for a period of 500 ms when X10 goes ON and stores the result at DO Ladder Mode List Mode 0 E LL sep X0 K500 00 Steps Instruction Device 0 LD X10 a oc S00 5 END E 5 END 6 127 6 127 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA pego pO 6 8 8 Fixed cycle pulse output PLSY Usable Devices Internal Devices MELSECNET 10 H Special Index ea Br s User File EN L 1 Function baia Register Constant Other Register Module Word UA Zn E Ec cum Only output Y can be used Instruction Symbol Execution Condition Command Set Data Set Data Meaning Data Type Number of device where frequency is set BIN 16 bits m Device No of device that sets the number of outputs Number of device where pulse output is conducted Functions 1 Outputs a pulse at a frequency design
204. es n bits to the right 1 SM700 b31 to b16 b15 to bO Rotates n bits to the left D 1 D SM700 031 to b16 b15 to b0 E Rotates n bits to the left 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 3 Shift instructions Table 2 20 Shift Instructions Execution Category Condition Processing Details Instruction Number of Basic Steps Description S SFL SFLP SFLP M D D BSFRP BSFRP D D D R n n L n n FR n n n SFR n n n n F F S S D D D D BSFLP BSFLP 1 bit shift DSFRP DSFRP 1 word shift DSFL DSFL D DSFLP DSFLP D 2 5 4 Bit processing instructions Table 2 21 Bit processing instructions Execution Symbol Processing Details Condition Instruction Number of Basic Steps Description BRST BRST BRSTP BRSTP BSET BSET Din BSETP BSETP Din Bit set reset Di
205. esignated for and D then and should always have the same number of digits 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The device range n points from exceeds the device range Error code 4101 The number of transfers exceeds 6144 when a special direct device is used QnACPU Error code 4101 Program Example 1 The following program outputs the lower 4 bits of DO when XA goes ON to Y10 to Y23 in 4 bit units Ladder Mode List Mode 0 Ls jov DO K1Y10 K5 Steps Instruction Device 0 LD 1 FMOVP DO K1Y10 5 5 END bi5 cmm b4b3b2 b1 bO 00 11 01 1 01 11 001 1 011 1 0 1 1 Y13to Y10 Ignored 1 0 1 1 Y17toYt4 2411101 1 11Y1Bto Y18 5 points Transmission 1 0 1 1 Y1F to Y1C 1 0 1 1 Y23to Y20 2 The following program outputs the data at X20 through X23 to D100 through D103 when XA goes ON Ladder Mode List Mode 0 m K1X20 D100 K4 Steps Instruction Device 0 LD X0A 1 FMOVP K1X20 D100 K4 5 END X2F X2C X2B X28X27 X24X23 X20 Before execution 1 0 11 1 01 1 1 0 0 1 0 1 1 1 0 Ignored After execution transfer destination ee b4b3 b0 gt 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 D100 gt 0 0 0 0 0 0 0 0 01010 0 1117110 0101 4 points
206. esignation of bit devices can be done in 4 point 4 bit units and designation can be made for K1 to K4 For link direct devices designation is done by J N Initial number of bit device F When X100 to X10F are designated for Network No 2 it is done by J2 K4X100 For example if XO is designated for digit designation the following points would be designated e K1X0 The 4 points to are designated e K2X0 The 8 points to X7 are designated e The 12 points to XB are designated KAXO The 16 points to are designated 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA XF to XC XB to X8 X7 to X4 X3 to K1 designation range 4 points K2 designation range 8 points designation range 12 points K4 designation range 16 points Fig 3 1 Digit Designation Setting Range for 16 Bit Instruction b In cases where digit designation has been made at the source S the numeric values shown in Table 3 1 are those which can be dealt with as source data Table 3 1 List of Numeric Values that Can Be Dealt with as Digit Designation In cases where the source is a bit device designated by digit designation and the destination is a word device the word device for the destination becomes 0 following the bit designated by digit designation at the source Ladder Example With 16 bit instruction X010 _
207. esult at a device designated by D Devices can be designated in the range from 32768 to 32767 Qu The upper 16 bits The lower 16 bits BIN 16 bit data gt BIN 32 bit data Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The contents of the data designated by S 1 and S are outside the 32768 and 32767 range Error code 4100 Program Example 1 The following program converts the BIN 32 bit data at R100 and R101 to BIN 16 bit data when X20 is ON and stores it at D100 Ladder Mode List Mode 0 i E R100 D100 Steps Instruction Device 0 LD X20 1 WORD P R100 D100 4 END R101 R100 D100 FFFF8253H gt 8253H 32173 32173 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin S L G sP S 6 3 7 Conversion from BIN 16 and 32 bit data to Gray code GRY GRYP DGRY DGRYP Usable Devices Internal Devices MELSECNET 10 H Special Index zu BE User File Eu Bo P Function Constant Dus Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition Ll indicates GRY or DGRY Command GRY DGRY D Command GRYP DGRYP Set Data Set Data Meaning BIN data or head number of the device
208. except for annunciators RST 5 30 5 3 7 Setting and resetting the annunciators SET RST F sss 5 32 5 3 8 Leading edge and trailing edge output PLS PLF sse 5 34 5 3 9 Bit device output reverse FF nennen nennen enr nnns 5 36 5 3 10 Pulse conversion of direct output DELTA 5 38 AC IAU O ilo DP M lees 5 40 5 4 1 Bit device shift SF TSF PP siti nap atai 5 40 5 5 Master Control Instructions U 5 42 5 5 1 Setting and resetting the master control MCR 5 42 5 6 Termination Instructioris 2 5 n pipe ep hoi pede bed dasdaade hued lg deaf b ipe tud ed 5 46 5 6 1 End main routine program FEND uu l nnne 5 46 5 6 2 End sequence program END uuu uu uu u uuu ua a 5 48 5 7 Other Instr ctioris ava A awaqa aa 5 50 5 7 1 Sequence program stop STOP a 5 50 5 7 2 No operation NOPLF PAGE n 5 52 6 BASIC INSTRUCTIONS 6 1to6 133 6 1 Comparison Operation Instruction naa 6 2 6 1 1 BIN 16 bit data comparisons lt gt gt lt gt 6 2 6 1 2 BIN 32 bit data comparisons D D lt gt D gt D lt D lt D 2 sees 6 4 6 1
209. f Set Data SetData Data Meaning DataType Type Data to be added to or subtracted from or the head number of the device storing such data BCD 4 digit Addition or subtraction data or head number of device storing addition or subtraction data Head number of device storing addition or subtraction data Functions 1 Adds the BCD 4 digit data designated by and the BCD 4 digit data designated by 63 and stores the result of the addition at the device designated by f X w 5 6 7 8 1 2 3 4 D gt 6 9 1 2 2 The values for 63 and can be between 0 to 9999 BCD 4 digit data 3 If the result of the addition operation exceeds 9999 the higher bits are ignored The carry flag in this case does not go ON 6 4 3 2 3 51813 r gt o o 1 5 1 Subtracts the BCD 4 digit data designated by and the BCD 4 digit data designated by 69 and stores the result of the subtraction at the device designated by A A 0 6 7 8 0 2 3 4 gt 0 4 4 4 gt Digits higher than those which were designated will be read as O 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 The values for and D can be between 0 to 9999 BCD 4 digit data 3 The following will result if an underflow is generated by the subtraction operation The carry flag in this case does not go ON oT 9
210. formance model QCPU Process CPU 1 QnACPU Basic model QCPU 2 2 INSTRUCTION TABLES MELSEC Q QnA 2 3 3 Output instructions Table 2 5 Output Instructions 0 S 2 22 s 5 2 e Execution 00 o amp Category 5 Symbol Processing Details Condition o 2 36 gt 5 ajag o z a ie _ 650 88 2 5 28 SET SET D i Set device f 5 32 2 E _ Generates 1 cycle program pulse at E DES leading edge of input signal 2 5 34 Generates 1 cycle program pulse at trailing edge of input signal DELTA DELTA D Pulse conversion of direct output DELTAP DELTAP D 1 1 The number of steps may vary depending on the device in use See description pages of individual instructions for number of steps 2 2 The f execution condition applies only when an annunciator F is in use 2 3 4 Shift instructions Table 2 6 Shift Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps See for Description 1 bit shift of device 2 INSTRUCTION TABLES MELSEC Q QnA 2 3 5 Master control instructions Table 2 7 Master Control Instructions Execution Condition Starts master control E Resets mastercontol master control Category Processing Details Number of Basi
211. g addition or BIN 16 bi subtraction data its Head number of the devices where the operation results are stored n Number of addition subtraction data blocks Functions BK 1 Adds n points of BIN data from the device designated by and n points of BIN data from the device designated by 6 and stores the result from the device designated by onward b15 b0 b15 bO b15 b0 1234 BIN 4000 BIN 5234 BIN 6 1 4567 BIN Q1 1234 BIN O 5801 BIN 2 2000 BIN 2 1234 BIN 2 3234 BIN rJ a 220 ES A n 2 1234 BIN G3 n 2 5000 BIN n 2 3766 BIN n 1 4000 BIN n 1 4321 BIN n 1 8321 BIN 2 Block addition is performed in 16 bit units 6 BASIC INSTRUCTIONS MELSEC Q QnA 3 The constant designated by 63 can be between 32768 to 32767 BIN 16 bits b15 b15 1234 BIN 5555 BIN 1 4567 BIN bi5 bo 1 8888 BIN 2 2000 BIN 4321 BIN D 2 2321 BIN LA LA n 2 1234 BIN D n 2 3087 BIN n 1 4000 BIN D 1 8321 BIN 4 The following happens if an underflow or overflow is generated in the operation results The carry flag in this case does not go ON e K32767 4K2 K 32767 H7FFF H0002 H8001 K 32767 K 2
212. gent function module special function module FROM FROMP DERO DFROP etait ee ded 7 134 7 8 2 Writing 1 2 word data to intelligent function module special function module TO TOP DIO DIOP nis ut rer e eee ed epe nets 7 137 79 Display Instructions 3 a AA A AE 7 140 7 9 1 Print ASCII code instruction PR esteet eaae u a Saaai Eaa aaae Ea iaaa 7 140 7 9 2 Print comment instruction PRO L nne trit 7 143 7 9 3 ASCII code LED display instruction LED sess 7 148 7 9 4 LED display instruction for comments LEDC a 7 150 7 9 5 Error display and annunciator reset instruction LEDR eee 7 152 7 10 Debugging and Failure Diagnosis Instructions sse 7 155 7 10 1 Special format failure checks CHKST CHK U a 7 155 7 10 2 Changing check format of CHK instruction CHKCIR 7 159 7 10 3 Setting and resetting status latch SLT SLTR 7 167 7 10 4 Setting and resetting sampling trace STRA 7 169 7 10 5 Execution setting and resetting of program trace PTRAEXE PTRAEXEP PTRA PTRAR u u aa u ua ua Ska a u Sk 7 171 7 11 Character String Pr
213. hapter 6 7 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU ope epo pee qo 6 1 Comparison Operation Instruction 6 1 1 BIN 16 bit data comparisons lt gt gt lt lt gt Usable Devices Internal Devices MELSECNET 10 H Special Index FS BU User File EX EUE Function Constant ind Register Other Register Module K H Word UA Zn Ta Instruction Symbol Execution Condition indicates the signs lt gt gt lt lt Or gt LD gt gt 8 lt lt Set Data Set Data Meaning Data Type Comparative data or device number where comparative data is stored BIN 16 bits Functions 1 Treats BIN 16 bit data from device designated by and BIN 16 bit data from device designated by 6 as an A contact and performs comparison operation 2 The results of the comparison operations for the individual instructions are as follows Instruction Comparison Instruction Comparison Symbol Condition Operation Symbol Condition Operation Result in Result Non continuity 3 In cases where hexadecimal constants have been designated by and 62 or when a numerical value 8 to F where the highest bit 615 will be 1 has been designated the value will be read as a negative BIN value number for purposes of the comparison
214. ht be generated between the DI and EI Sequence program instructions the interrupt program will be held until the entire cycle from DI to El has been processed El In FEND Interrupt program 6 100 6 100 6 BASIC INSTRUCTIONS MELSEC Q QnA IMASK 1 Enables disables the execution of the interrupt program marked by the designated interrupt pointer by using the bit pattern of 8 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 015 614 b13 612 0611 b10 b9 b8 b7 b6 b5 b4 b3 b2 bi bO 15111411131112 1111 1 HO 19 1 18 I7 1 I6 115 14 IB 1 I2 1 Hor 10 1 1311130 1 129 11281127 26 1 125 1 124 11231122 1 121 1 120 1 1191 1181 171 116 2 147 1 146 1 145 144 1 143 42 1 141 1 140 139 1 138 137 136 135 1341 1331 132 6 3 16311621161 1160 159 1 158 1 157 1156 155 1154 1153 1152 1 1511 1501 149 148 4 179 1178 1177 1176 175 74 1 173 1172 1 171 1 170 1169 168 167 166 165 164 90 189 1188 1187 186 185 184 1 1831 1821 1811 180 94 5 1951194 1193 11921191 6 11111111011109111081110711106111051110411103111021110111100 19911981 1971 196 7 1127111261112511124 11123111221
215. ice 0 m E D3 D10 RO 0 LD X20 1 E P m END 5 J RO 5 END D4 D3 D11 D10 3 D4 D 5961 437 12003 2 E gt 17964 64 2 The following programs subtracts the floating decimal point type real numbers at D20 and D21 from the floating decimal point type real numbers at D11 and D10 and stores the result at D30 and D31 Ladder Mode List Mode SM400 Steps Instruction Device 0 LD SM400 1 EP D10 D20 D30 5 END D11 D10 D21 D20 D21 D20 973652 76598 gt 21305441 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG gru Process CPU p 6 2 10 Multiplication and division of floating decimal point data Ex E E P Usable Devices Internal Devices MELSECNET 10 H Special inda x WEE User File Function Register Instruction Symbol Execution Condition L indicates the signs E or E Command Ex E L3 9 O Command EEP fo 9 18 34 Oy Set Data Meaning Data that will be multiplied or divided or the head number of the device storing data that will be multiplied or divided Data to multiply or divide by or the head number of device storing such Esa numb data Head number of the device storing the operation results of multiplication or division operation Functions 1 Multiplies the floating decimal point type real numbers designated by and the floating decimal poin
216. ice range as the result of index modification d Device range checks are conducted when index modification 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 The carry flag does not go on at such times either b When using BCD data 1 Each digit is check for BCD value 0 to 9 An operation error is returned if individual digits are outside the 0 to 9 A to F range 2 No error is returned even if the operation results in overflow or underflow The carry flag does not go on at such times either c When using floating decimal point data Operation errors are returned in the following cases When value of floating decimal point data is 0 When the absolute value of the floating decimal point data is 1 0 x 271 or lower When absolute value of floating decimal point data is 1 0 x 2128 or higher d When using character string data No data check is conducted 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 If internal user device allocation is changed by parameter device allocation such allocations are made in the device order indicated below If the allocation of the device used is less than 28 75 k words the area following the device used will be empty Initial address
217. ificant bit 031 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 e K2147483647 2 K 2147483647 Because b31 is 0 H7FFFFFFF H2 H80000001 the value is positive e K 2147483648 2 K2147483646 Because b31 is 1 H80000000 HFFFE HFFFE the value is negative 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Subtracts 32 bit BIN data designated by 6 from 32 bit BIN data designated by 62 and stores the result of the subtraction at the device designated by 6241 62 1 62 D 1 D b31 b16 b15 b0 b31 b16 b15 b0 b31 b16 b15 b0 567890 BIN 123456 BIN gt 444434 BIN 2 The values for 63 and be designated at between 2147483648 and 2147483647 BIN 32 bits 3 Judgment of whether the data is positive or negative is made on the basis of the most significant bit 031 Positive s pere Negative 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 e K 2147483648 K2 K2147483646 Because b31 is 0 H80000000 H2 H7FFFFFFE the value is positive e 2147483647 K 2 2147483647 Because b31 is 1 H7FFFFFFF HFFFE HFFFE the value is negateve Operation Errors 1 There are no operation errors associated with the
218. ill execute these instructions regardless of the ON OFF state of the MC instruction 3 By changing the device designated by D the MC instruction can use the same nesting N number as often as desired 4 Coils from devices designated by D are turned ON when the MC instruction is ON Further using these same devices with the OUT instruction or other instructions will cause them to become double coils so devices designated by D should not be used within other instructions MCR 1 This is the instruction for recovery from the master control and indicates the end of the master control range of operation 2 Do not place contact instructions before the MCR instruction Operation Errors 1 There are no operation errors associated with the MC or MCR instructions 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 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 NO to N14 The use of nesting enables the creation of ladders which successively limit the execution condition of the program A ladder using nesting would appear as shown below Ladder as displayed in the GPP ladder mode Ladder as it actually operates A A Mns NO M15 NO M15 li Executed O when A J is ON B B MC Nt Mi6
219. iming Chart ON OFF b10 of D10 0 1 0 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU a Process CPU Cin p o pe 6p 5 3 10 Pulse conversion of direct output DELTA DELTAP Usable Devices Set Internal Devices MELSECNET 10 H Special index Other ea Br s User File Ea pen 3 Function Constant Date Register Module Register H g U AGO Zn Instruction Symbol Execution Condition Command DELTA DELTA Command DELTAP f DELTAP Set Data Set Data Meaning Data Type Bit for which pulse conversion is to be conducted Functions 1 Conducts pulse output of direct access output DY designated by If DELTA DYO has been designated the resulting operation will be identical to the ladder shown below which uses the SET RST instructions Ladder created by the DELTA instructions Ladder using the SET RST instruction X100 X100 DELTA DYO H gt SET DYO RST DYO Operation END processing P 2 DELTA d DELTA DYO ON x100 OFF ON ON OFF 2 The DELTA P instruction is used by commands for leading edge execution for an intelligent function module special function module 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored
220. ins ON Executed during OFF instruction is executed only while the precondition is OFF If the precondition is ON the instruction is not executed and no processing is conducted Executed once at OFF instruction executed only at trailing edge when precondition goes from ON to OFF Following execution instruction will not be executed and no processing conducted even if condition remains OFF Indicates the basic number of steps for individual instructions See Section 3 8 for a description of the number of steps OC ENSE The mark indicates instructions for which subset processing is possible See Section 3 5 for details on subset processing des Indicates the page numbers where the individual instructions are explained 2 INSTRUCTION TABLES MELSEC Q QnA 2 3 Sequence Instructions 2 3 1 Contact Instruction Table 2 3 Contact Instructions Execution Condition Category Processing Details Starts logic operation Starts a contact logic operation Starts logical NOT operation Starts b contact logic operation Logical product a contact series connection Logical product NOT b contact series connection Logical sum a contact parallel connection Logical sum NOT b contact parallel connection Starts leading edge pulse operation Starts trailing edge pulse operation Leading edge pulse series connection Trailing edge pulse series connection Leading edge pulse parall
221. ion 6 BASIC INSTRUCTIONS MELSEC Q QnA Program Example 1 The following program stores the real numbers at D10 and D11 at DO and D1 Ladder Mode List Mode Steps Instruction Device SM400 D10 00 0 LD 1 EMOVP 4 END D11 D10 D1 DO 2 The following program stores the real number 1 23 at D10 and D11 when X8 is ON Ladder Mode List Mode Steps Instruction Device 0 LD X8 1 EMOVP E 1 23 D10 5 END D11 D10 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA _ O S j CS l o l I 6 4 3 Character string transfers 8MOV MOVP Usable Devices MELSECNET 10 H Special ie System User File Direct JL N a Function MICH Register Module Register Bit Word Instruction Symbol Execution Condition Command MOV MOVP ap Command Set Data Character string to be transferred maximum number of characters in a string 16 characters for QnA Q4AR 32 characters for QCPU or the head number of the device storing character string Head number of device to store transferred character string Character string Functions 1 Transfers character string data stored from device number designated by from device number designated by onward A character string transfer involves the transfer of data from the device number designated by to the device number storing the 00H code in
222. ion start instruction and is ON only at the leading edge of the designated bit device when it goes from OFF to ON If a word device has been designated it is ON only when the designated bit changes from 0 to 1 In cases where there is only an LDP instruction it acts identically to instructions for the creation of a pulse that are executed during 1 P A ladder using an LDP instruction A ladder not using an LDP instruction X0 X0 HIA KO DO Hc Hit move KO DO H f lt w ph HI ese 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 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 ANDP ANDF 1 ANDP is a leading edge pulse series connection instruction and ANDF is a trailing edge pulse series connection instruction They perform an AND operation with the operation result to that point and take the resulting value as the operation result The ON OFF data used by ANDP and ANDF are indicated in the table below Devices Designated by ANDP Devices Designated by ANDF Word Device Bit ANDP State Word Device ANDF State oon o gt oN OFF ON E SENE ON OFF on gt orrF imo o ORP ORF 1 ORP is a
223. ions a Devices which cannot use index modification Bebtcnsent Floating point data E pweieamde 700 interrupt pointers used as labels Index register IS Step relay SFC transfer devices 1 B pronoxdmee i esae b Devices with limits for use with index registers Application Example Only Z0 and Z1 can be used for timer contacts and coils K100 Only ZO and Z1 can be used for counter UE C1Z0 contacts and coils 1 1 SFC transfer devices and SFC block devices are devices for SFC use Refer to the QCPU mode QnACPU Programming Manual SFC for information on how to use these devices 2 For timer and counter present values there are no limits on index register numbers used x Set value of timer X0 K100 Index modification not possible Present value of timer SM400 BCD 024 Set value of counter K10 Index modification not possible H cio Present value of counter SM400 BCD 10026 K2Y40 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA c Other 1 Bit data Device numbers can be index modified when performing digit designation However index modification is not possible by digit designation H BN 22 Setting that enables device number index modification If Z2 3 then X 0 3 H BIN Setting that cannot enable digit
224. ions Converts BIN 16 bit data at device designated by S to BIN 32 bit data with sign and stores the result at a device designated by D Q L The upper 16 bits The lower 16 bits 32 bit BIN data Operation Errors 1 There are no errors associated with the DBL P instruction Program Example 1 The following program converts the BIN 16 bit data stored at D100 to BIN 32 bit data when X20 is ON and stores at R100 and R101 Ladder Mode List Mode 0 n D100 100 Steps Instruction Device 0 LD X20 1 DBLP D100 R100 4 END D100 R101 R100 2 gt 2 1234 1234 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU 1 1 PLG Lee 202027 Process CPU ONA 6 3 6 Conversion from BIN 32 bit to BIN 16 6 bit dat data WORD WORDE WORDP Internal Devices n x stem User ERAN Other 9 Eos Usable Devices MELSECNET 10 H qI 3 Special Function Module Uc AG 2 Index Register Word Zn Instruction Symbol Execution Condition Command ISIN Kf WORD Command Set Data Set Data Meaning Head number of device where BIN 32 bit data is stored BIN 32 bits Head number of device where BIN 16 bit data will be stored after BIN 16 bits conversion Functions Converts BIN 32 bit data at device designated by to BIN 16 bit data with sign and stores the r
225. is ON Turn OFF the command input before changing the argument 3 For this reason the PLSY instruction can be used only once in the entire program executed by the CPU module Operation Errors 1 There are no operation errors associated with the PLSY instruction Program Example 1 The following program outputs a 10 Hz pulse 5 times to Y20 when is ON Ladder Mode List Mode 0 H PLSY K10 K5 Y20 Steps Instruction Device 0 LD 1 PLSY K10 K5 Y20 5 END 6 129 6 129 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA pepe EO 6 8 9 Pulse width modulation PWM Usable Devices Internal Devices MELSECNET 10 H Special Index ea Br s User File EN L 1 Function baia Register Constant Other Register Module Word UA Zn Ec Only output Y be used Instruction Symbol Execution Condition Command PWM PWM ni n2 Set Data Meaning n1 Number of device where ON time is set BIN 16 bits Number of device where cycle is set Number of device which will perform pulse output Functions 1 Outputs the pulse of the cycle set by n2 for the amount of time ON designated by n1 to the output module designated by n2 2 The setting ranges for n1 and n2 are shown below CPU module Type Name Setting Range for n1 and n2 ms High Performance mod
226. is conducted for a contact that has been indexed by a sub routine program or by the FOR to NEXT instructions If pulse conversion is to be conducted for a contact that has been indexed by a sub routine program or by the FOR to NEXT instructions use the EGP EGF instructions 2 Because the MEP and MEF instructions operate with the operation results immediately prior to the MEP and MEF instructions the AND instruction should be used at the same position The MEP and MEF instructions cannot be used at the LD or OR position 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Le 2002027 Process CPU 5 2 5 Pulse conversion of edge relay operation AEE Jis EGP EGF EGF Usable Devices Set Internal Devices MELSECNET 10 H Special index Other ea Br s User File zs E 3 Function Constant pata Register Module Register K H 9 Zn Instruction Symbol Execution Condition Command I Command Set Data Meaning Edge relay number where operation results are stored Bit Functions EGP 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 If the operation result up to the EGP instruction is other than a leading edge i e from ON to ON ON to OFF or OFF to OFF it goes OFF non continuity status 8 The
227. ition indicates CML or DCML Command cmt oom CMLP DCMLP _ 0 Set Data Set Data 9 Datato be inverted ber of device storing this dat 9 ata to Sinvere or er of device Sonn is data BIN 16 32 bits Number of device that will store results of inversion Functions 1 Inverts 16 bit data designated by 9 bit by bit and transfers the result to the device designated by Before execution S Be UE 00 After execution 0 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1 DCML 1 Inverts 32 bit data designated by bit by bit and transfers the result to the device designated by bis a b0biB Before execution S 0 0 BIE 0 0 D 1 Inversion After execution DELEI iioo DE 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the CML P or DCML P instructions Program Example 1 The following program inverts the data from XO to X7 and transfers result to DO Ladder Mode List Mode OL DO Steps Instruction Device 0 ID 9402 1 CML K2X0 DO 4 When the number of bits at is less than the number of bits at 7 XO po 1111010010 1111 2 The following program inverts the da
228. le when a 3 step MOV instruction is designated indirectly example MOV K4X0 D0 one step is added and the instruction becomes 4 steps p 00004 the number of steps is increased kusatan b Devices where number of steps increases Devices Where Number of Steps Added Steps Increases Intelligent function module device special function module MOV U4 G10 D device Link direct devices MOV J3 B20 DO Serial number access file registers MOV ZR123 DO 32 bit constants DMOV K123 DO Real number constant E0 1 DO For even numbers number of characters 2 For odd numbers number of characters 1 2 Character string constant MOV 123 DO c In cases where the conditions described in a and b above overlap the number of steps becomes a culmination of the two For example if MOV U1 G10 ZR123 has been designated 1 step is added for buffer register designation and 1 step is added for serial number access file register designation making a total of 2 steps added 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA 3 9 Operation when OUT SET RST or PLS PLF Instructions Use the Same Device The following describes the operation for executing multiple instructions of 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 If the OUT instructions using the same device are program
229. mance model QCPU Q mode User s Manual Hardware design Maintenance and Inspection SH 080037 Describes the specifications of the CPU module power supply module base unit extension cables and 13JL97 memory card Sold separately High Performance model QCPU Q mode User s Manual Functions Explanation Programming Fundamentals SH 080038 Describes the functions programming method and devices to create programs with High Performance model 13JL98 QCPU Q mode Sold separately Process CPU User s Manual Hardware Design Maintenance and Inspection SH 080314E Describes the specifications of the CPU module power supply module base unit extension cables and memory card Sold separately 13JR55 Process CPU User s Manual Functions Explanation Programming Fundamentals SH 080315E Describes the functions programming method and devices that are required to create programs Sold separately 13JR56 QCPU Q mode QnACPU Programming Manual SFC SH 080041 Describes the system configuration performance specifications functions programming debugging and error codes for MELSAP3 Sold separately QCPU Q mode Programming Manual MELSAP L SH 080076 Describes the system configuration performance specifications functions programming debugging and error codes for MELSAP L Sold separately 13JF61 13JF60 QCPU Q mode QnACPU Programming Manual PID Control Instructions SH 080040 Describes the dedicated inst
230. med in one scan the specified device will turn ON or OFF every time the OUT instruction is executed depending on the operation result of the program up to the relevant OUT instruction Since turning ON or OFF of the device is determined when each OUT instruction is executed the device may turn ON and OFF repeatedly during one scan The following diagram shows an example of a circuit that turns the same internal relay MO with inputs X0 and X1 ON and OFF X1 uw Timing Chart Circuit ON M0 _ OFF MO turns ON because MO turns OFF because X1 is OFF X1 is ON MO turns ON because is ON remains OFF because is OFF With the refresh type CPU module when the output Y is specified by the OUT instruction the ON OFF status of the last OUT instruction of the scan will be output NFI RATION OF INSTRUCTION 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 2 SET RST instructions using the same device a The SET instruction turns ON the specified device when the SET command is ON and does not do anything when the SET command is OFF For this reason when two or more SET instructions use the same device in one scan the specified device will be ON if any one of the SET commands is ON b The RST instruction turns OFF the specified device when the RST command is ON and does not anything when the RST command is OFF For this reason when two or more RST instructions use the sam
231. merunt erue 6 124 6 8 7 Pulse density measurement SPD L nennen nnns 6 126 6 8 8 Fixed cycle pulse output PLSY 6 128 6 8 9 Pulse width modulation PWM sess nennen nennt nennen nnns 6 130 6 8 10 Matrix input MB s i iss ee EP pp pP pp p EI p p 6 132 7 1 Logical Operation Instructions nennen nnne tnnt 7 2 7 1 1 Logical products with 16 bit and 32 bit data WAND WANDP DAND DANDP 7 3 7 1 2 Block logical products BKAND BKANDP U 7 8 7 1 3 Logical sums of 16 bit and 32 bit data WOR WORP DOR DORP 7 10 7 1 4 Block logical sum operations BKOR BKORP L nennen nnne 7 14 7 1 5 16 bit and 32 bit exclusive OR operations WXOR WXORP DXOR DXORP 7 16 7 1 6 Block exclusive OR operations BKXOR BKXORTP sse 7 20 7 1 7 16 bit and 32 bit data non exclusive logical sum operations WXNR WXNRP DXNR DXNRP L inne 7 22 7 1 8 Block non exclusive logical sum operations BKXNR 7 28 6 6 7 2 Rotatior InstructiQrn pese ee eet e rece e e eee e ede ee 7 30 7 2 1 Right rotation of 16 bit data ROR RORP RCR
232. n Din 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 21 Bit processing Instructions Continued I Execution Symbol Processing Details Condition Instruction Number of Basic Steps Description S1S2 D TEST TEST Bit tests 2 5 5 Data processing instructions SERP Data searches 32 bits D 51 Match No D 1 Number of matches S 1 5 Table 2 22 Data Processing Instructions Execution Processing Details Condition Instruction Number of Basic Steps Description D Number of 1s Decode from 8 to 256 Decode Decode from 256 to 8 S qns 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 22 Data Processing Instructions Continued Execution Processing Details Condition Category Instruction Number of Basic Steps Description b3 to b0 S DU 7SEG F G SEGP DIS UNI UNIP NDISP NUNI BTOW Separates 16 bit data designated by S into 4 bit units and stores at
233. n a word device has been used 3 The values for and can be designated at between 32768 and 32767 BIN 16 bits 4 Judgment whether values for 629 and are positive or negative is made on the basis of the most significant bit 615 for 6 and 62 and b15 for 05 Positive 93s Negative Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO Attempt to divide 62 by 0 Error code 4100 Program Example 1 The following program divides 5678 by 1234 when X5 goes ON and stores the result at D3 and D4 Ladder Mode List Mode of yy s 5 K5678 Ki234 D3 Steps Instruction Device 0 LD X5 1 K5678 K1234 D3 5 END 2 The following program divides BIN data at X8 to XF by BIN data at X10 to X1B and outputs the result of the division operation to Y30 to Y3F Ladder Mode List Mode SM402 Steps instructi Devi 0 KS K3X10 K4Y30 ps nstruction evice 0 LD SM402 1 2 8 K3X10 K4Y30 5 END 3 The following program outputs the value resulting when the data at X8 to is divided by 3 14 to Y30 to when is ON Ladder Mode List Mode 0 E K2X8 K100 DO Steps Instruction Device 0 LD 1 P K2X8 D K314 K4Y30 n 5 P DO K314 K4Y30 9 END 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Lee 202027 Process CPU
234. n loop BREAK 7 89 7 6 3 Sub routine program calls CALL CALLP 7 91 7 6 4 Return from sub routine programs nennen 7 94 7 6 5 Sub routine program output OFF calls FCALL FCALLP sse 7 95 7 6 6 Sub routine calls between program files ECALL ECALLP eee 7 99 7 6 7 Sub routine output OFF calls between program files EFCALL EFCALLP 7 102 7 6 8 Refresh instruction COM cccceccecceseeeeceeceeeesecaeceeeeaesaecaeceeeeaeeaecaeseaeeaesaeseeseaesaesaeseeseaeeeseeeeaneaes 7 106 7 6 9 Index modification of entire ladder IX IXEND 7 112 7 6 10 Designation of modification values in index modification of entire ladders IXDEV IXSET 7 120 7 7 Data Table Operation Instructions essent nnne nnns 7 125 7 7 1 Writing data to the data table FIFW FIFWP u 7 125 7 7 2 Reading oldest data from tables FIFR FIFRP seen 7 127 7 7 3 Reading newest data from data tables FPOP FPOPP sse 7 129 7 7 4 Deleting and inserting data from and in data tables FDEL FDELP FINS FINSP 7 181 7 8 Buffer Memory Access Instruction sese nns 7 134 7 8 1 Reading 1 2 word data from the intelli
235. n subtraction of 32 bit data is required The following is the ladder used for the addition subtraction of the address of the device stored in D1 and DO for indirect designation To add 1 to the address of the device for indirect designation LN Device used for indirect designation 32 bit instruction To subtract 1 from the address of the device for indirect designation E _ ppEcP H Device used for indirect designation 32 bit instruction 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 5 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 Designates a bit device number in a factor of 16 Bit device Only K4 can be designated for digit designation Does not conduct index modification Word device Internal device File register ZR is not included Constants No limitations b When using double word data Designates a bit device number in a factor of 32 Bit device Only K8 can be designated for digit designation Does not conduct index modification Worddevice Internal device File register ZR is not included Constants No limitations
236. nated I O No when using a link device 1 When a file register setting has been made but no memory card has been installed or when no file register setting has been made no error will be returned even if an attempt is made to write to the file register However FFFFH will be stored if an attempt is made to read from the file register at which this write operation was attempted 1 Device range check Device range checks for the devices used by basic instructions and application instructions in CPU module are as indicated below a No device range check is made for instructions dealing with fixed length devices MOV DMOV etc In cases where the corresponding device range is exceeded data is written to other devices For example in a case where the data register has been allocated 12 k points there will be no error even if it exceeds 012287 1 DMOV K100 es D12287 and D12288 have been 2 indicated here but because D12288 does not exist the contents of some other device will be destroyed Device range checks are not conducted also in cases where index modification is being performed b Device range checks are conducted for instructions dealing with variable length devices BMOV FMOV and others which designate transfer numbers In cases where the corresponding device range has been exceeded an operation error will be returned For example in a case where the data register has been allocated 12 k points the
237. nd Cr RFs x K1 HhRereshes xo vao 4 Command H c RFS YO Refreshes Y20 Program based on DX and DY Direct access input ue Direct access output Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The range n points from the device designated by exceeds the proximate I O range Program Example 1 The following program refreshes X100 to X11F and Y200 to Y23F when MO goes ON Ladder Mode List Mode 0 pars X100 H2O Steps Instruction Device 0 LD MO 1 RFSP x100 RFS Y200 HO 4 RFSP 1200 H40 7 END 7 FIT END 6 112 6 112 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU a Process CPU Cin 6 8 Other Convenient Instructions 6 8 1 Count 1 phase input up or down UDCNT1 Usable Devices Internal Devices MELSECNET 10 H Special Index ES Br User File ES A Function Constant ind Register Other Register Module K H Word Zn CIT 7 BON 9 wa EN EARANN Local devices and the file registers set for individual programs cannot be used Instruction Symbol Execution Condition Command uoentt f L Set Data SetData Data Meaning DataType Type S 0 Input number for count input 1 For setting count upper down
238. nd subtraction operations D 1 D S 1 S gt D 1 D 0 1 D S 1 S gt 0 1 D S1 1 S1 S2 1 S2 gt D 1 D E EN E 141 1 S2 1 S2 gt 0 1 D 81 52 D 1 D gt 8141 S1 8241 52 0 3 D 2 D 1 D S141 S1 S241 S2 Quotient 0 1 D Remainder D 3 D 2 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 11 Arithmetic Operation Instructions Continued Execution Processing Details Condition Category Instruction Number of Basic Steps See for Description e 0 1 D S 1 S 0 1 D e S11 S1 S241 S2 gt 0 1 D Floating decimal point data E D 1 D S 1 S 0 1 D traction operations e S141 51 52 1 S2 0 1 D e 8141 S1 S241 52 gt D 1 D e S121 S1 S2 1 S2 gt Quotient D 1 D Adds data of n points from S1 and data of n points from S2 in batch Subtracts data of n points from S1 and data of n points from S2 in batch Links character string designated with S to characte
239. nd SFTP are to be used consecutively the program starts from the device with the larger number Shift range a Shift input 0 M15M14M13M12M11M10 M9 M8 SFTP M14 o o o o 0 0 X02 ON 0 0101 0 1 0 After first shift input SFTP M13 0 1 0 0 After second shift input sP m2 amp o jo o t o 0 X02 ON 1 0 01 1 0 1 0 After third shift input SFTP M11 O A e lo Jo 0 1 0 1 0 0 1 O After fourth shift input X2 A 0 H H ser M10 0 1 0 0 0 1 After fitth shit input At M8 to 16 1 indicates ON and 0 First device to shift as indicates OFF 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 2 When word device bit designation is used a Shifts to a bit in the device designated by D the 1 0 status of the bit immediately prior to the one designated and turns the prior bit to 0 For example if 00 5 bit 5 b5 of DO has been designated by the SFT instruction when the SFT instruction is executed it will shift the 1 0 status of b4 of DO to b5 and turn b4 to 0 b15 to b5b4 to bO Prior to shift 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 execution 0 After shift execution Operation Errors 1 There are no operation errors associated with the SFT P instruction Program Example 1 The following
240. ng decimal point data uses two word devices and is expressed in the following manner 1 Variable part x 2 exponent part The bit configuration and meaning of the internal representation of floating decimal point data is as follows b31 b30 to b23 b22 to b16 b15 to bO b23 to b30 b0 to b22 Exponent part Variable part b31 Sign for variable part e Sign for variable part The sign for the variable part is represented at b31 0 Positive 1 Negative Exponent part The n of 2 is represented from b23 to b30 Depending on the BIN value of b23 to b30 the value of n is as follows b23 to b30 FFH FEH FDH 81H 80H 7FH 7EH 02H 01H 00H 27 126 2 1 0 1 125 126 Nonnumeric n Nonnumeric Exponent part The 23 bits from bO to b22 represents the XXXXXX at binary 1 XXXXXX POINT The CPU module floating decimal point data can be monitored using the monitoring function of a peripheral device When this is expressed as 0 all data from bO to b31 will be 0 The setting range of real numbers is 0 and 2 2 lt value lt 275 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA 3 2 5 Using character string data Character string data is character data used by basic instructions and application instructions It encompasses all data from the designated character to the NULL co
241. ns 3276816384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 BIN9999 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1 Converts BCD data 0 to 99999999 at device designated by to BIN data and stores at the Always set these to 0 device designated by Ou amp amp amp x x x x x x x x 00 x QE CO sf QE 00 sf 00 sf t cN BCD 99999999 1 0 0 1 1 0 0 1 1 0 0 1 1 00 1 1 0 0 1 1 0 0 1 1 00 1 1 0 0 1 Ten millions Millions Hundred Ten Thousands Hundreds Ten digits Ones digits digits digits thousands thousands digits digits digits digits BIN conversions 1 6 NN S Q Q Q Q Q Q SES TOL Z Qo oc ow AAAAAAAAAAAAAAAAANAAAAAAAAA G N D BIN 99999999 oo ooo 1 0 1 4 4 1 0 0 tt 4 4 4 41 4 Always set these to 0 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON an error code is stored in SDO and the instruction is not executed When values other than 0 to 9 are designated to any digits of When QCPU is used When QCPU is used the error above can be suppressed by turning ON SM722 However the instruction is not ex
242. nstruction Device 0 LD lt D0 K0 3 GOEND 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Gn aan uu pee sp C S LS 6 6 Program Execution Control Instructions 6 6 1 Interrupt disable enable instructions interrupt program mask DI El IMASK 1 When Basic model QCPU is used Usable Devices Internal Devices MELSECNET 10 H Special Index E EE User File uu 1 Function Constant a Register Other Register Module K H Word U Aen Zn Instruction Symbol Execution Condition Sequence program Set Data Interrupt mask data or head number of device where interrupt mask data BIN 16 bits is being stored Functions DI 1 Disables the execution of an interrupt program until the El instruction has been executed even if a start cause for the interrupt program occurs 2 A DI state is entered when power is turned ON or when the system has been reset El 1 The El instruction is used to clear the interrupt disable state resulting from the execution of the Dl instruction and to create a state in which the interrupt program designated by the interrupt pointer number certified by the IMASK instruction can be executed When the IMASK instruction is not executed 132 to 147 are disabled 2 Be sure to execute the El instruction before executing a periodic program Sequence program DI Even though an interrupt condition mig
243. o HFFFFFFFF Word devices and bit devices designated by digit designation can be used as double word data For direct access input DX and direct access output DY designation of double word data is not possible by digit designation 1 When using bit devices a Digit designation can be used to enable a bit device to deal with double word data Digit designation of bit devices is done by designating Number of digits Digit designation of bit devices can be done in 4 point 4 bit units and designation can be made for K1 to K8 For link direct devices designation is done by J Initial number of bit device When X100 to X11F are designated for Network No 2 it is done by J2 K8X100 For example if XO is designated for digit designation the following points would be designated e K1X0 The 4 points to X3 are designated K2X0 The 8 points to X7 are designated e K3X0 The 12 points to XB are designated KAXO The 16 points to XF are designated e K5X0 The 20 points to X13 are designated e K6X0 The 24 points XO to X17 are designated e K7XO The 28 points to X1B are designated e K8X0 The 32 points to X1F are designated 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA X1F_X1C X1B X18X17 X14X13 X10XF XCXB X8X7 X4X3 XO K1 designation range 4 points K2 designation range 8 points K3 designation range 12 points
244. ocessing Instructions L L 7 173 7 11 1 Conversion from BIN 16 bit or 32 bit to decimal ASCII BINDA BINDAP DBINDA DBINDAP L an 7 173 7 11 2 Conversion from BIN 16 bit or 32 bit data to hexadecimal ASCII BINHA BINHAP DBINHA DBINHAP U n 7 176 7 11 3 Conversion from BCD 4 digit and 8 digit to decimal ASCII data BCDDA BCDDAP DBCDDA DBCDDAP rennen nnne nnns 7 179 7 11 4 Conversion from decimal ASCII to BIN 16 bit and 32 bit data DABIN DABINP DDABIN DDABINP L nnns 7 182 7 11 5 Conversion from hexadecimal ASCII to BIN 16 bit and 32 bit data HABIN HABINP DHABIN DHABINP L a a 7 185 7 11 6 Conversion from decimal ASCII to BCD 4 digit or 8 digit data DABCD DABCDP DDABCD DDABCDP L L 7 187 7 11 7 Reading device comment data COMRD COMRDP sse 7 190 7 11 8 Character string length detection LEN LENP sse 7 194 7 11 9 Conversion from BIN 16 bit or 32 bit to character string STR STRP DSTR DSTRP 7 196 7 11 10 Conversion from character string to BIN 16 bit or 32 bit data VAL VALPP DVAL DVALP sian ie ti pad ER LER aed e e a 7 202 7 11 11 Conversion from floating decimal point to character string data ESTR ESTRP 7 207 7 11 12 Conversion from character
245. ociated with the XCH P and DXCH P instructions Program Example 1 The following program exchanges the present value of TO with the contents of DO when X8 goes ON Ladder Mode List Mode 0 m per xai T0 DO Steps Instruction Device 0 LD X8 1 XCHP 10 4 END i ae 2 The following program exchanges the contents of DO with the data from M16 to M31 when X10 goes ON Ladder Mode List Mode 20 D Steps Instruction Device 0 LD X10 ud Kante 1 Ex 4 END 3 The following program exchanges the contents of DO and D1 with the data at M16 to M47 when X10 goes ON Ladder Mode List Mode 0 x10 D0 K8M16 Steps Instruction Device 0 LD X10 1 DXCHP D0 4 END K8M16 4 The following program exchanges the contents of DO and D1 with those of D9 and D10 when MO goes ON Ladder Mode List Mode 0 Mo i DO D9 Steps Instruction Device 1 D 4 END d 09 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA Bee C a ee OS eel 6 4 8 Block 16 bit data exchanges BXCH BXCHP Usable Devices Internal Devices MELSECNET 10 H Special inda System User File Direct JL N a Function Constant Register Module Hegister K H Ld Instruction Symbol Execution Condition Command 1 Command excHE Set Data h f h ead number of device storing data to
246. oes ON Ladder Mode X 8 0 1 4 STP X0A 2 gt H T S A E X0B 4 w K V ry as1 D YWX23 List Steps Instruction Device LD gt Coro e 3 MELSEC Q QnA Causes programmable controller to stop when X8 goes ON Sequence program 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU CS QS p e a 5 7 2 No operation NOP NOPLF PAGE n Usable Devices Internal Devices MELSECNET 10 H Special Index xn Br s User File I pen 3 Function Constant Dara Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition is not displayed in ladder display NOP gt NOPLE H PAGE n Functions NOP 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 b To delete an instruction without having to change the number of steps Replace the instruction with NOP c To temporarily delete an instruction NOPLF 1 This is a no operation instruction that has no impact on any operations up to that point 2 The NOPLF instruction is used when printing from a peripheral device to force a page change at any desired location
247. oes ON at the trailing edge of the timer coil and after the trailing edge of the command for the SRMR instruction goes OFF when the amount of time designated by n has passed 6 119 6 119 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 The timer coil designated by S goes ON at the leading edge of the command for the STMR instruction and begins the measurement of the present value The timer coil measures to the point where the value reaches the set value designated by n then enters a time up state and goes OFF If the command for the SRMR instruction goes OFF before the timer coil reaches the time up state it will remain ON Timer measurement is suspended at this time When the STRM instruction command goes ON once again the present value will be cleared to 0 and measurement will begin once again 8 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 a m S Contact _ i jl l 1 i 1 0 OFF delay timer One shot timer D 1 l after OFF r1 One shot timer 1 1 2 after ON 1 l l 1 3
248. on Errors 1 There are no operation errors associated with the SET F Li or RST 2 instructions Program Example 1 The following program turns annunciator F11 ON when X1 goes ON and stores the value 11 at the special register SD64 to SD79 Further the program resets annunciator F11 if X2 goes ON and deletes the value 11 from the special registers SD64 to SD79 Ladder Mode List Mode Steps Instruction Device 0 ID Xl 1 SET Fil 3 ID X2 4 RST F11 6 END When X1 is ON When X2 is ON o 4991 q Subtracis 1 spes 75 SDe4 0 SD64 11 SDe4 0 SD65 o SD65 0 MPO 0 SD66 0 SD66 0 SD66 O0 SD67 0 SD67 0 SD78 O SD78 O0 SD78 O0 SD79 oO SD79 O0 SD79 O 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin Lures epo oe spei pr 5 3 8 Leading edge and trailing edge output PLS PLF Usable Devices Internal Devices MELSECNET 10 H Special mel File ERES Function und Constant Other woa iid Word Word 109049 Zn don DY Instruction Symbol Execution Condition PLS command PLF Command Set Data Meaning Data Type Pulse conversion device Bit Functions PLS 1 When turned from OFF to ON the PLS command turns ON the specified device and other than when turned from OFF to ON i e from ON
249. on value used for index modification performed between IX IXEND in the device below that designated by D 1 n indicates number of arguments for sub routine program 2 nindicates the total of the number of arguments used in the sub routine program and the number of program name steps The number of program name steps is calculated as number of characters in the program 2 decimal fraction is rounded up 2 32 2 32 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 7 Table operation instructions Table 2 24 Table Operation Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description Pointer Pointer 1 _ 4a device Pointer Pointer 1 Pointer 1 D Pointer Pointer 1 D E T Designated by n 2 INSTRUCTION TABLES MELSEC Q QnA 2 5 8 Buffer memory access instructions Table 2 25 Buffer Memory Access Instructions Execution Processing Details Condition Category Instruction Number of Basic Steps Description Reads data in 16 bit units from special function module Data read
250. ondition CHKCIR CHKCIR CHKEND CHKEND atch SLTR SLTR STRA STRA STRAR _STRAR PTRA PTRA PTRAR PTRAR Program trace PTRAEXE PTRAEXE Cu PTRAEXEP Execution Processing Details Condition Number of Basic Steps Description CHK instruction is executed when CHKST is executable Jumps to the step following the CHK instruction when CHKST is in a non executable status During normal conditions SM80 OFF SD80 0 During abnormal conditions SM80 ON SD80 Failure No Starts update in ladder pattern being checked by CHK instruction Ends update in ladder pattern being checked by CHK instruction pU C U status latch _ 22686 status latch to enable re execution Applies trigger to sampling trace Resets sampling trace to enable re execution Applies trigger to program trace Resets program trace to enable re execution Executes program trace 2 INSTRUCTION TABLES 2 5 11 Character string processing instructions Category Hexadeci Instruction BINDA BINDAP DBINDA DBINDAP BINHA BINHAP DBINHA DBINHAP BCDDA BCDDAP DBCDDA DBCDDAP DABIN DABINP DDABIN DDABINP HABIN HABINP DHABIN DHABINP Table 2 28 Character String Processing Instructions BINDA BINDAP DBINDA DBINDAP
251. one operation b15 b8b7 b0 b15 b8b7 b0 2nd character 1st character 2nd character 1st character 1 4th character 3rd character ES 1 4th character 3rd character 2 6th character 5th character 6th character 5th character f 5 00H i nth character 00H i nth character Indicates end of character string 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 Processing will be performed without error even in cases where the range for the devices storing the character data to be transferred to n overlaps with the range of the devices which will store the character string data after it has been transferred to Dn The following occurs when the character string data that had been stored from D10 to D13 is transferred to D11 to D14 b15 b8b7 b0 b15 b8b7 b0 D10 32H 2 31H 1 gt gt _D10 32H 2 81H 1 as the D11 34H 4 33H 3 D11 32H 2 31H 1 character string D12 36 6 35H 5 E D12 34H 4 33H 3 it was prior to D13 00H D13 36H 6 35H 5 transfer D14 77 7 D14 00H 3 If the 00H code is being stored at lower bytes of n 00 will be stored at both the higher bytes and the lower bytes of 615 b8b7 b0 615 b8b7 b0 42H B 41H A A 1 D
252. or occurs and the error flag goes ON The entire character string linked from the device number designated by D to the final device number of the relevant device cannot be stored The storage device numbers for the character strings designated by or 62 overlap with those for D Program Example 1 The following program links the character string stored from D10 to D12 with the character string ABCD when is ON and stores them in D100 onwards Ladder Mode List Mode 0 a DO ABCD D100 Steps Instruction Device 0 ID X0 1 D10 ABCD D100 END b15 b8b7 bO b15 b8b7 bO D10 62H b 61H D100 624 b 61H a D11 644 d 634 ABCD gt D101 644 d 634 c Di2 00H 654 D102 414 A 65 e D103 434 C 42 D104 O04 44 D Automatically stores 004 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin K C CS S C e Po L O 6 2 13 Incrementing and decrementing 16 bit BIN data INC INCP DEC DECP Usable Devices Internal Devices MELSECNET 10 H Special Set Index E NF User File EH B P Function Constant Data Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition indicates INC or DEC INC DEC Command INCP DECP Command
253. ored if SM707 is turned on Error code 4100 Program Example 1 The following program multiplies the floating decimal point real numbers at D3 and D4 and the floating decimal point real numbers at D10 and D11 and stores the result at RO and R1 Ladder Mode List Mode Steps Instruction Device 0 LD X20 1 E P 03 110 RO 5 END D4 D3 D11 D10 R1 RO 36 78965 1192786 c 4388218 2 The following program divides the floating decimal point real numbers at D10 and D11 by the floating decimal point real numbers at D20 and D21 and stores the result at D30 and D31 Ladder Mode List Mode Steps Instruction Device 0 LD SM400 1 E P D10 020 D30 5 END D11 D10 D21 D20 D31 52171 39 9 73521 gt 5359 041 030 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Ie pen Process CPU Cn tA 6 2 11 Block addition and subtraction BIGP BK P BK BK BK E Usable Devices Internal Devices MELSECNET 10 H Special inda ea User File Ka pen 1 Function Register Register Instruction Symbol Execution Condition L indicates the signs BK or BK Command BK BK BK P BK P Set Data Meaning Data to be added to or subtracted from or head number of device storing such data Addition or subtraction data or head number of device storin
254. outine programs subroutine programs and interrupt programs Main routine program FEND gt FEND instruction is necessary Subroutine program Main sequence program area Interrupt program END gt END instruction is necessary Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO An END instruction was executed before the execution of the RET instruction and after the execution of the CALL FCALL ECALL or EFCALL instruction Error code 4211 An END instruction was executed before the execution of a NEXT instruction and after the execution of the FOR instruction Error code 4200 An END instruction was executed during an interrupt program prior to the execution of the IRET instruction Error code 4221 An END instruction was executed within the CHKCIR to CHKEND instruction loop Error code 4230 An END instruction was executed within the IX to IXEND instruction loop Error code 4231 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin ope epo pes cope p 5 7 Other Instructions 5 7 1 Sequence program stop STOP Usable Devices Internal Devices MELSECNET 10 H Special index Other ra Br User File EX EE p Function Constant Daa Register Module Register H 9 Word U AGO Zn Instruction Symbol Execution Condition Stop
255. pe operations BATAN 7 272 7 13 Data Control INsttuctOnS ide Sau qa doe i 7 274 7 13 1 Upper and lower limit controls for BIN 16 bit and BIN 32 bit data LIMIT LIMITP DLIMIT DLIMITP L n 7 274 7 13 2 BIN 16 bit and 32 bit dead band controls BAND BANDP DBAND DBANDP 7 277 7 13 3 Zone control for BIN 16 bit and BIN 32 bit data ZONE ZONEP DZONE DZONEP 7 280 7 14 File Register Switching Instructions sss 7 283 7 14 1 Switching file register numbers RSET RSETP 7 283 7 14 2 Setting files for file register use QDRSET QDRSETP sese 7 285 7 14 3 File setting for comments QCDSET QCDSETP 7 287 un crie Die eode c I Gua eec ne ee edn ee dee 7 289 7 15 1 Reading clock data DATERD DATERDP sss rennen 7 289 7 15 2 Writing clock data DATEWR DATEWRP L 7 293 7 15 3 Clock data addition operation DATE DATE P sse 7 297 7 15 4 Clock data subtraction operation DATE DATE P 7 299 7 15 5 Changing time data formats SECOND SECONDP HOUR HOURP 7 301
256. program shifts Y57 to 5 when X8 goes ON Ladder Mode Shifts Y57 to Y5B when X8 goes ON Begin program from larger device number Y57 turned ON when X7 goes ON Timing Chart List Mode 0 Steps Instruction Device am 1 EE i X7 GEE h l SFT Y58 10 LDP OFF Y57 Y58 OFF OFF Y59 OFF Y5A ON N N Y5B OFF 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin op ee epo pes o L O 5 5 Master Control Instructions 5 5 1 Setting and resetting the master control MC MCR Usable Devices Internal Devices MELSECNET 10 H Special Set i Index Data ra User File EX UE Function Henister Register Module 9 Word U 3e Instruction Symbol Execution Condition Command MC Set Data Set Data Nesting NO to N14 Number of device to turn ON Functions The master control instruction is used to enable the creation of highly efficient ladder switching sequence programs through the opening and closing of a common bus for ladders A ladder using the master control would look as shown below Ladder as displayed in GPP Ladder Mode Ladder as it actually operates ett N1 Mo HH tH
257. programs 132 to 147 is disabled 4 The statuses of devices 1 2 and 3 to 15 are stored in SD715 to SD717 and SD781 to SD793 storage area for IMASK instruction mask pattern 5 Although the special registers are separated as SD715 to SD717 and SD781 to SD793 device numbers should be designated as to 15 successively POINTS 1 An interrupt pointer occupies 1 step 110 Stored at step 50 zs 50 53 55 2 Refer to the User s Manual Function Explanation Program Fundamentals of the CPU module in use for interrupt conditions 3 The DI state interrupt disabled is active during the execution of an interrupt program Do not insert El instructions in interrupt programs to attempt the execution of multiple interrupts with interrupt programs running inside interrupt programs 4 If there are El and DI instructions within a master control these instructions will be executed regardless of the execution non execution status of the MC instruction 6 104 6 104 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no operation errors associated with the DI and EI instructions 2 There are no operation errors associated with the IMASK instruction Program Example 1 The following program creates an execution enabled state for the interrupt program marked by the interrupt pointer number when is ON Ladder Mode List Mode jn 2 oe Step
258. r of transfers designate the numbers of devices and transfers used by instructions involving multiple devices Example Block transfer instruction Designates the number of transfers used by a BMOV instruction b The number of devices or number of transfers can be set between 0 and 32767 However if the number is 0 the instruction will be a no operation instruction 3 2 Designating Data The following five types of data can be used with CPU module instructions Data that can be U Bit data handled by CPU Numeric data Integer data Word data Double word data Real number floating decimal point data Character string data 3 2 1 Using bit data Bit data is data used in one bit units such as for contact points or coils Bit devices and Bit designated word devices can be used as bit data 1 When using bit devices Bit devices are designated in one point units The 1 point MO is a bit device MO _ Y10 The 1 point Y10 is a bit device 2 Using word devices a Word devices enable the use of a designated bit number 1 0 as bit data by the designation of that bit number b15 to Word device 1 0 1 0 1 0 1 0 1 0 11 0 1 0 11 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Each bit can be used as 1 for ON and 0 for OFF 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q OnA b Word device bit designation is done by designating
259. r string designated with D and stores the result from D onward Links character string designated with S2 to character string designated with S1 and stores the result from D onward 2 INSTRUCTION TABLES Category BIN data increment MELSEC Q QnA Table 2 11 Arithmetic Operation Instructions Continued Execution Processing Details Condition Instruction Number of Basic Steps See for Description 0 1 0 1 gt 0 1 D 0 1 0 1 D D 1 1 The number of steps may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification Constant No limitations High Performance model QCPU Process CPU 2 When using devices other than 1 bi 2 Basic model QCPU QnCPU 2 Note 2 Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 2 INSTRUCTION TABLES MELSEC Q QnA 2 4 3 Data conversion instructions Table 2 12 Data Conversion Instruction
260. re will be an error if it exceeds D12287 BMov H D12287 and D12288 have been indicated here but because D12288 does not exist an operation error is returned 1 See section 3 4 3 for the internal user device allocation order 3 CONFIGURATION OF INSTRUCTIONS MELSEC Q QnA Device range checks are also conducted when index modification is performed However if index modification has been conducted there will be no error returned if the initial device number exceeds the relevant device range H H mov zi H p12285z1 K2 D12287 and D12288 have been indicated here but because D12288 does not exist an operation error is returned B HH BMov K100 01228721 K2 Because the initial device number is D12289 and that exceeds gt the device range the initial device number is made WO the operation is conducted and no error is returned c Because all character string data is of variable length device range checks are performed In cases where the corresponding device range has been exceeded an operation error will be returned For example in a case where the data register has been allocated 12 k points there will be an error if it exceeds D12287 H 4 smov ABC esr D12287 and D12288 have been indicated here but because D12288 does not exist an operation error is returned Note that an operation error does not occur even if the head device number exceeds the dev
261. rom the device designated by 6 6 Only device numbers divisible by 16 can be designated for 6 and 62 7 The value for n2 is not between 2 to 8 Error No 4100 6 132 6 132 6 BASIC INSTRUCTIONS MELSEC Q QnA 8 No processing is performed in the following cases The device number designated by S or 62 is not divisible by 16 The device designated by is outside the actual input range The device designated by 6 is outside the actual output range e The space 16 x n points following the device designated by 62 exceeds the relevant device range The value for n2 is not between 2 and 8 Operation Errors 1 There are no errors associated with the MTR instruction Program Example 1 The following program fetches 16 points x 3 rows starting from X10 when is ON and stores it from M30 onward Ladder Mode List Mode 0 z MTR X10 Y20 M30 K3 i Steps Instruction Device 0 LD X0 1 MTR X10 6 END M62 M63 M64 M65 M66 M67 M68 M69 M70 M71 M72 M74 M75 M77 Y20 Y21 Y22 Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y X011 X012 X013 X014 X015 X016 X017 X018 X019 1 X01B X01C X01D XO1E X01F Second row X011 X012 X013 X014 015 X016 X017 X018 X019 1 X01B X01C X01D 1 X01F First row a e e M 20 gt ol o o o M37 o M38 o M39 j e gt
262. rom the execution of the DI instruction and to create a state in which the interrupt program designated by the interrupt pointer number certified by the IMASK instruction can be executed When the IMASK instruction is not executed 132 to 147 are disabled 2 Be sure to execute the El instruction before executing a periodic program Sequence program Dr Even though an interrupt condition might be generated between the DI and El Sequence program instructions the interrupt program will be held until the entire cycle from DI to EI E has been processed Interrupt program 6 103 6 103 6 BASIC INSTRUCTIONS MELSEC Q QnA IMASK 1 Enables disables the execution of the interrupt program marked by the designated interrupt pointer by using the bit pattern of 16 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 015 614 b13 612 bii b10 b9 b8 b7 b6 b5 b4 b3 b2 bi b0 15111411131112 1 1111110 191 18 I7 116 1 I5 1 I4 1 I8 121 H 10 1 13111301 129 128 1 127 26 1 125 1 124 1 123 1 122 1 121 1 120 1 1191 1181 1171 116 2 1471146 1145 1144 1 143 42 1 141 1 140 1139 1188 137 1 1361 1351 1341 1331 132 63 1162 1 161 1160 1159 1 158 1 157 1 156 1155 1
263. rror occurs the error flag SM0 turns ON and an error code is stored at SD0 The or D BCD data is outside the 0 to 9999 range Error code 4100 Program Example 1 The following program adds BCD data 5678 and 1234 stores it at D993 and at the same time outputs it to from Y30 to Ladder Mode P MOV H5678 0993 Stores 5678 at D993 P B Hi234 D993 Adds BCD 1234 and D993 and stores the result in D993 P MOV 0993 K4Y30 Outputs data at D993 to Y30 to Y3F List Mode Steps Instruction Device 0 LD SM400 1 5678 D993 4 B P H1234 D993 7 MOVP D993 K4Y30 10 END 2 The following program subtracts the BCD data 4321 from 7654 stores the result at D10 and at the same time outputs it to Y30 to Y3F Ladder Mode SM400 P 0 MOV H7654 D10 Stores 7654 at D10 as BCD P B 4321 010 Subtracts data 010 from BCD 4321 and stores result at 010 P MOV D10 K4Y30 Outputs data at D10 to Y30 to Y3F List Mode Steps Instruction Device 0 LD SM400 1 MOVP H7654 4 B P H4321 D10 7 MOVP D10 K4Y30 10 END 6 BASIC INSTRUCTIONS MELSEC Q QnA Usable Devices Internal Devices MELSECNET 10 H Special Index E EE User File EX rs E Function Constant ban Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition Cl indicates the signs B or B Command 10 B P B P 6 O
264. rrors associated with the OUT C 2 instruction Program Example 1 The following program turns Y30 ON after has gone ON 10 times and resets the counter when X1 goes ON Ladder Mode List Mode Steps Instruction Device 0 LD X0 1 OUT C10 K10 5 LD C10 6 OUT Y30 7 LD Xi 8 RST C10 12 END 2 The following program sets the value for C10 at 10 when goes ON and at 20 when X1 goes ON Ladder Mode Stores 10 at DO when goes ON Stores 20 at when X1 goes ON C10 takes data stored at DO as set value and counts gt Y30 goes ON when C10 reaches count out state List Mode Steps Instruction Device 0 LD X0 1 ANI 2 MOVP K10 00 5 LD Xl 6 ANI X0 1 MOVP K20 DO 10 LD 1 OUT C10 DO 15 LD C10 16 OUT Y30 17 END The number of basic steps of the OUT 2 instruction is 4 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin or p ee p e 16x 5 3 4 Annunciator output OUT F Usable Devices Internal Devices MELSECNET 10 H Special Set Index ea BI User File zs pen E Function Constant Data Register Other Register Module K H Word Word Zn Instruction Symbol Execution Condition F35 a SSS Number Set Data Set Data Meaning Number of annunciator to be turned ON O Functions 1 Operation results up to the OUT instruction are output to the
265. ructions for PID control Sold separately 13JF59 QnPHCPU Programming Manual Process Control Instructions SH 080316E Describes the dedicated instructions for performing process control Sold separately 13JR67 QnACPU Guidebook Aimed at people using QnACPU for the first time Describes procedures for everything from creating programs 18 66606 and writing created programs to the CPU module to debugging 13JF10 Also describes how to use the QnACPU most effectively Q2A S1 Q3A Q4ACPU User s Manual IB 66608 Describes the performance functions and handling of the Q2ACPU S1 Q3ACPU and Q4ACPU and the specifications and handling of memory cards and base units Sold separately 131821 Model Q2AS H CPU S1 User s Manual Describes performance functions and handling of the Q2ASCPU Q2ASCPU S1 Q2ASHCPU and SH 3599 Q2ASHCPU S1 power supply module memory card specifications and handling of the base unit 13858 Sold separately Manual Number vod Goa Q4ARCPU User s Manual Describes the Q4ARCPU features functions and usage Also describes the specification and usage of the IB G6BES bus switching module system management module power supply module memory card and base unit 13852 Sold separately QnACPU Programming Manual Fundamentals IB 66614 Describes how to create programs the names of devices parameters and types of program Sold separately 13 46 QnACPU Programming Manual Special Function Mod
266. s Instruction Device 0 LD p 1 CJ P10 X1 3 DI s LA P20 4 P10 5 LD X1 xo 6 CJ P20 MOVP D10 8 LD X0 9 MOVP HOA 10 FMOVP KO 011 K15 12 FMOVP KO 15 16 D10 IMASK D10 18 ae 20 LD MO it 21 OUT Y20 22 FEND f 23 11 24 LD M10 25 MOVP K10 D100 FEND 28 IRET 10 29 13 Hoyr D100 30 LD M11 31 P D100 D200 34 IRET IRET 35 END F O U lt D100 0200 6 105 6 105 6 BASIC INSTRUCTIONS MELSEC Q QnA 8 When QnACPU is used Usable Devices Internal Devices MELSECNET 10 H Special index System User File Direct JLA Function Constant Register Other Register Module UL AG a Instruction Symbol Execution Condition Sequence program IMASK Set Data Interrupt mask data or head number of device where interrupt mask data BIN 16 bits is being stored Functions DI 1 Disables the execution of an interrupt program until the El instruction has been executed even if a start cause for the interrupt program occurs 2 A DI state is entered when power is turned ON or when the system has been reset El The El instruction is used to clear the interrupt disable state resulting from the execution of the Dl instruction and to create a state in which the interrupt program designated by the interrupt pointer number certified by the IMASK instruction can be execute
267. s Ladder Using the MPS MRD and MPP Instruction Ladder not Using MPS and MPP Instructions XO X2 HH H vo gt X 4 HHHH gt 5 gt 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 eripheral device 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA Operation Errors 1 There are no errors associated with the MPS MRD or MPP instructions Program Example 1 A program using the MPS MRD and MPP instructions Ladder Mode List Mode ED CD M8 Steps Instruction Device 0 LD xic _ 1 ws 2 1 3 O Y30 4 MPP M9 4 M68 3 OUT 6 T 6 LD XID QT MPS u 10 __ 3 gt ION AND M68 eh M 15 MPP OF QUT Y34 2 19 MPS P B E 8 22 MRD AND N97 e ot 24 QUT Y36 25 MRD 26 AND N98 Qi dd 29 QUT Y38 30 END 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 2 A program using MPS and MPP instructions successively Ladder Mode X0 X1 2 x3 X4 X5 X6 XT X8 X9 0 140 41 Y42 43 44 45 146 Y47 C148 149 END List Mode Steps Instruction Device 0 LD X0 1 MPS 2 AND 3 MPS 4 AND X2 5 MPS 6 AND X3 7 MPS 8 AND X4 9 MPS 10 AND X5 11 MPS 12 AND X6 13 MPS 14 AND XT 15
268. s Execution Processing Details Condition Category Instruction Symbols Number of Description BCD conversion S D BIN 0 to 9999 BCD conversion e S44 S D 1 D BIN 0 to 99999999 BIN conversion S 9 D BCD 0 to 9999 BIN conversion 9 1 S D41 D BCD 0 to 99999999 Conversion to floating decimal point e S44 S D BIN 32768 to 32767 Conversion to floating decimal point e 44 S _ gt D 1 D Real number 2147483648 to 2147483647 Conversion to BIN 41 S gt D Real number 32768 to 32767 Conversion to BIN 41 S 9 D 1 D Real number 5 0 2147483648 2147483647 Conversion SID s D 1 D Ee 32768 to 32767 DBLP SID Conversion WORD SID S 1 S p BIN 327 2767 Conversion to gray code SD SID RY GRYP GRYP BIN 32768 to 32767 gray code DGRY DGRY 841 S D 1 D 3 6 67 BIN DR ped SiD 2147483648 to RE Conversion to gray code 3 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 12 Data Conversion Instructions Con
269. s 2 Functions 1 When the operation results up to the OUT instruction change from OFF to ON 1 is added to the present value count value and the count up status present value set value and the contacts respond as follows 2 Counter value cannot be set by indirect designation Indirect designation not possible See Section 3 4 for further information on indirect designations Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU module or QnACPU Programming Manual Fundamentals for counter counting methods 1 Counter value can be set only with a decimal constant A hexadecimal constant H or a real number cannot be used for the counter value setting 3 The file register cannot be used in the QOOJCPU 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 2 No count is conducted with the operation results at ON There is no need to perform pulse conversion on count input 3 After the count up status is reached there is no change in the count value or the contacts until the RST instruction is executed 4 A negative number 32768 to 1 cannot be set as the setting value for the timer If the set value is 0 the processing is identical to that which takes place for 1 b Index modification for the counter coil and contact can use only ZO and Z1 Index modification cannot be performed for the counter setting Operation Errors 1 There are no operation e
270. s may vary depending on the device and type of CPU module being used 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification Constant No limitations High Performance model QCPU Process CPU 2 When using devices other than 1 Basic model QCPU QnCPU Note 1 With High Performance module QCPU 1 requires more number of steps while it can process the steps faster as compared with 2 Note 2 The number of steps may increase due to the conditions described in Section 3 8 4 3 3 The number of steps may vary depending on the device and type of CPU module being used Component Nomber of basic steps 1 When using the following devices only Word device Internal device except for file register ZR Bit device Devices whose device Nos are multiples of 16 whose digit designation is K8 and which use no index modification Constant No limitations 2 When using devices other than 1 4 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 11 Arithmetic Operation Instructions Continued a 0 5 PEIEE 5 os Execution 9 d Ta Category 2t Processing Details o 5 E Condition Q 5 gt 5 o9 o 2 9 BCD 4 digit addition a
271. storing addition or subtraction data BCD 8 digit Data to be added to or subtracted from or head number of device storing such data Functions DB 1 Adds the BCD 8 digit data designated by and the BCD 8 digit data designated by and stores the result of the addition at the device designated by Q1 941 1 Y Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits 09871 068 0032 34 56 gt 10 1 9 4 524 gt Digits higher than those which were designated will be read as 0 2 The values for S and D can be between 0 to 99999999 BCD 8 digit data 3 If the result of the addition operation exceeds 99999999 the upper bits will be ignored The carry flag in this case does not go ON 9 ejo o o o o o o t e s 4 s 2 1 gt o o e 5 4 s 2 1 1 Subtracts the BCD 8 digit data designated by D and the BCD 8 digit data designated by S and stores the result of the subtraction at the device designated by 1 1 D Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits Upper 4 digits Lower 4 digits lo 987 10618 0 03 2 3 4 576 gt 0 9 5 4 7 6 1 2 gt Digits higher than those which were designated will be read
272. t decimal ASCII value designated by S to a 2 word BIN value and stores it at a word device number designated by D Converts a 4 digit hexadecimal ASCII value designated by S to a 1 word BIN value and stores it at a word device number designated by D Converts an 8 digit hexadecimal ASCII designated by S value to a 2 word BIN value and stores it at a word device number designated by D Execution Condition Number of Basic Steps MELSEC Q QnA Description 2 INSTRUCTION TABLES Category 2 97 Instruction DABCD DABCDP DDABCD DDABCDP DDABCDP S D COMRD COMRDP Table 2 28 Character String Processing Instructions Continued Symbol pABCD S D DABCDP S D DDABCD S D LEN SD S 52 52 52 52 Processing Details Converts a 4 digit decimal ASCII value designated by S to a 1 word BCD value and stores it at a word device number designated by D Converts an 8 digit decimal ASCII designated by S value to a 2 word BCD value and stores it at a word device number designated by D Stores comment from device designated by S at a device designated by D Stores data length number of
273. t change 5 When the command is turned OFF during the execution of this instruction the contents of 0 will not change following this When the command goes ON again the RAMP instruction will begin a new move from the present value at 67 0 6 Do not change the specified values in n1 and n2 before the completion device specified in 634 0 turns ON Since the same expression is used every scan to calculate the value stored in 1 changing n1 n2 may cause a sudden variation Operation Errors 1 There are no operation errors associated with the RAMP instruction Program Example 1 The following program changes the contents of DO from 10 to 100 in a total of 6 scans and saves the contents of DO when the move has been completed Ladder Mode List Mode 0 SET MI Steps Instruction Device 0 LD 0 F RAMP K10 100 00 K6 MO ne DO K6 I END MO 8 END Operation ON OFF DO 25 40 55 gt 70 85 100 01 1 2 3 4 5 6 1 scan 1 scan 1 scan 1 scan 1 scan ON MO OFF ON OFF 6 125 6 125 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG SEM Process CPU Cn tA ppp j r j 6 8 7 Pulse density measurement SPD Usable Devices Internal Devices MELSECNET 10 H Special Index ee NE S User File EN pen 1 Function baia Register Constant Other Register Module Word Word
274. t type real numbers designated by 63 and stores the product at the device designated by 1 1 1 ae ER ESL E b d Floating decimal point Floating decimal point Floating decimal point type real number type real number type real number 2 Values that can be designated by 6 or and values that can be stored are as follows 0 2196 lt Designated value stored value 212 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Divides floating decimal point type real numbers designated by 6 by floating decimal point type real numbers designated by amp 3 and stores the result in the device designated by 1 1 62 1 Ww gt lt Floating decimal point Floating decimal point Floating decimal point type real number type real number type real number 2 Values that can be designated by 6 or and values that can be stored are as follows 0 LE Designated value stored value 2128 Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The contents of the designated device or the result of the multiplication or division operation are not or not within the following range Error code 4100 0 127126 lt Contents of designated device results of operation lt 2128 When the specified device contains 0 Q4ARCPU Operation error does not occur even if 0 is st
275. ta at M16 to M23 and transfers the result to Y40 to Y47 Ladder Mode List Mode 0 ERN CML K2M16 K3Y40 Steps Instruction Device 0 LD SM402 1 CML K2M16 K3Y40 4 END When the number of bits at S is less than the number of bits at D These bits are all read as 0 gt Y4B Y48Y47 Y40 1 1 11 1 0110 0 01111 3 The following program inverts the data at DO when is ON and stores the result at D16 Ladder Mode List Mode 0 E T DO D16 Steps Instruction Device 0 LD X3 1 CMLP DO amm 4 END bi5 b8b7 bO DO Huron moon torto b15 b8b7 b0 D16 0 0 1 0 0 1 1 00 1 011 0 0 0 0 6 BASIC INSTRUCTIONS MELSEC Q QnA 4 The following program inverts the data at to X1F and transfers results to DO and D1 Ladder Mode List Mode 0 Lo NN DCML K8X0 DO Steps Instruction Device 0 LD SM402 1 DCML K8X0 D0 4 END When the number of bits at is less than the number of bits at D These bits are all read asO 0100 V ot t 1 oo t o t 10 0 b31 b28 b27 b24 b8 b7 1 1 1 1110011 1 0 0 0 1 1 0 110 0 111 b The following program inverts the data at M16 to M35 and transfers it to Y40 to Y63 Ladder Mode List Mode 0 DCML K5M16 K6Y40 Steps Instruction Device 0 LD SM402 m
276. termines the longest character string Smaller string If the character strings are different determines the string with the smallest number of character codes If the lengths of the character strings are different determines the shortest character string 2 12 2 12 2 INSTRUCTION TABLES MELSEC Q QnA Table 2 10 Comparison Operation Instructions Continued 0 S o8 _ 5 8 Execution 5 amp 25 Category BE Processing Details tion 9 5 gt Condition S 2 amp amp Compares n points of data from S1 with n points of data from S2 in 1 word units and stores the results of the comparison at n points from the bit device designated by D BKCMP BKCMP S1 S2 D n BKCMP lt gt BKCMP lt gt S1S2 D n gt S1IS2D n BKCMP BKCMP lt S1S2 D n BKCMP lt BKCMP lt S1S2 D n S1S2 D n 5 6 12 1 S2 D n Block data IBKCMP gt BKCMP gt compari sons BKCMP P BKCMP P BKCMP lt gt BKCMP lt gt P S 11521 5152 0 n S2 D n BKCMP P BKCMP lt P 2 INSTRUCTION TABLES MELSEC Q QnA 2 4 2 Arithmetic operation instructions Table 2 11 Arithmetic Operation Instructions Execution Category Condition Instruction Number of
277. time that the measurement command is on is measured in units of seconds then multiplied by the multiplier designated by n and the product is stored at the device designated by D 2 When the measurement command goes from OFF to ON the device designated by or 1 is cleared 3 The multipliers that can be designated by n are as shown below Multiplier owo E 6 117 6 117 6 BASIC INSTRUCTIONS MELSEC Q QnA 1 Time measurements are conducted when the TTMR instruction is executed Using the JMP or similar instruction to jump the TTMR instruction will make it impossible to get an accurate measurement 2 Do not change the multiplier designated by n while the TTMR instruction is being executed Changing this multiplier will result in an inaccurate value being returned 3 The TTMR instruction can also be used in low speed type programs 4 The device designated by D 1 is used by the CPU system so users should not change its value If users do change this value the value stored in the device designated by D will no longer be accurate 4 No processing is performed when the value specified by n is other than 0 to 2 Operation Errors 1 There are no errors associated with the TTMR instruction Program example 1 The following program stores the amount of time that is ON at DO Ladder Mode List Mode 0 um TTMR DO K0 Steps Instruction Device 0 LD X0 1
278. tinued Execution Processing Details Condition Category Instruction Number of Basic Steps Description Conversion to BIN data S D Gray code 32768 to 32767 Conversion to BIN data S41 S D 1 D Gray code 2147483648 to 2147483647 BIN data BIN data D 1 D D 1 D Real number data Batch converts BIN data n points from S to BCD data and stores the result from D onward Block con versions BKBIN S Batch converts BCD data n points from S to BIN data and stores the result from D onward BKBINP BKBINP 5 D n BKBCDP S D Din 2 INSTRUCTION TABLES MELSEC Q QnA 2 4 4 Data transfer instructions Table 2 13 Data Transfer Instructions Execution Processing Details Condition Category Instruction Symbols Number of Description 16 bit data e 9 1 S 0 1 D 5 1 FREU SL D Real number data Transfers character string designated by S to device designated by D onward
279. tion Device 0 LD X20 SM704 1 BKCMP lt D10 6 H M0V ALL ON D100 MIO K3 LD 9 704 M0V ALL ON D100 END D10 1234 BIN D30 4321 BIN M100 ON SM704 D11 5678 BIN lt D31 5678 BIN C gt D12 9876 BIN 032 9999 BIN M102 ON b15 b8b7 bO 4CH L 41H A 20H 4CH L 4EH N 4FH MOV D100 D101 D102 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cin epo pee cope qo 6 2 Arithmetic Operation Instructions 6 2 1 BIN 16 bit addition and subtraction operations P P Usable Devices Internal Devices MELSECNET 10 H Special Set i Index ES BE User File EX FUE Function Constant Data Register Other Register Module K H Zn Instruction Symbol Execution Condition indicates the signs Command J m Command Set Data SetData Data Meaning DataType Type or subtraction data or first number of device storing addition or subtraction data BIN 16 bits Data to be added to or subtracted from or first number of device storing such data Functions 1 Adds 16 bit BIN data designated by to 16 bit BIN data designated by and stores the result of the addition at the device designated by D 5678 BIN
280. tion errors associated with the SWAP P instruction Program Example 1 The following program exchanges the higher 8 bits and lower 8 bits of R10 when X10 goes ON Ladder Mode List Mode 0 2 an R10 Steps Instruction Device 0 LD X10 1 SWAPP R10 3 END 3 END b15 b12b11 b8b7 b4b3 b0O R10 0 0 0 0 0 00 0 1717 17111717171 p b15 b12b11 b8b7 b4b3 b0 R10 1111 1 1 1 1 0 0 0 0 0 0 010 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU ope epo pee cope qo 6 5 Program Branch Instruction 6 5 1 Pointer branch instructions CJ SCJ JMP Usable Devices Internal Devices MELSECNET 10 H Special index Other ra Br User File EX EUE p Function Constant Data Register Module Register K H Word Word Zn KS Instruction Symbol Execution Condition Command CJ m I 3 c SJ c Command SCJ D d SCJ d Label Set Data Set Data Meaning Pointer number of jump destination Functions CJ 1 Executes program of designated pointer number within the same program file when jump command is ON 2 Executes next step in program when jump command is OFF ON Jump command OFF CJ Executed each scan 3 SCJ 1 Executes program of designated pointer number within the same progr
281. tions Functions 1 When the operation results up to the OUT instruction are ON the timer coil goes ON and the timer counts up to the value that has been set when the time up status total numeric value is equal to or greater than the setting value the contact responds as follows 2 The contact responds as follows when the operation result up to the OUT instruction is a change from ON to OFF Present Prior to Time Up After Time Up T f Ti Ti Coil Val f DUM qum auo 2 A Contact B Contact A Contact B Contact Timer speed retentive timer Maintains the present value Non m eee Non E Has Continuity Continuity High speed retentive timer continuity continuity The present value is cleared from low speed retentive timers and high speed retentive timers and the contact is reset by use of the RST instruction 8 To clear the present value of a retentive timer and turn the contact OFF after time up use the RST instruction 4 A negative number 32768 to 1 cannot be set as the setting value for the timer If the setting value is 0 the timer will time out when the time the OUT instruction is executed b The following processing is conducted when the OUT instruction is executed e OUT T Li coil turned ON or OFF e OUT T i contact turned ON or OFF e OUT T ci present value updated In cases where a JMP instruction or the like is used to jump to an OUT T 1 instruction while the OUT T Ci ins
282. tions 6 3 1 Conversion from BIN data to 4 digit and 8 digit BCD BCD BCDP DBCD DBCDP Usable Devices Internal Devices MELSECNET 10 H Special x1 Index E dU User File Direct JL X 1 Function Constant bod Register Other Register Module K H Word UA Zn Instruction Symbol Execution Condition Ll indicates BCD or DBCD Command BCD DBCD FEA Command Set Data Set Data Meaning BIN data or head number of the device where BIN data is stored BIN 16 32 bits Head number of the device that will store BCD data BCD 4 8 digits Functions BCD Converts BIN data 0 to 9999 at the device designated by to BCD data and stores it at the device designated by D 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 ie 5904 BIN9999 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1 7 These should be set to 0 BCD conversions 8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1 BCD9999 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 Thousands Hundreds Tens Ones digits digits digits digits Converts BIN data 0 to 99999999 at the device designated by S to BCD data and stores it at the device designated by 1 Upper 16 bits S Lower 16 bits TIPY s ss a ARN NN S BIN 99999999 0 01019 110 0111111 100000111111111111 These shou should be set to 0 7 BCD Upper 5 bits conversions
283. to 21 stages can be generated b Read When AND and ANI are connected in series a ladder with up to 24 stages can be displayed If the number exceeds 24 stages up to 24 will be displayed OR ORI 1 OR is the A contact single parallel connection instruction and ORI is the B contact single parallel connection instruction They read ON OFF information from the designated device if a word device bit has been designated this becomes the 1 0 status of the designated bit and perform an OR operation with the operation results to that point and use the resulting value as the operation result 2 There are no limits on the use of OR or ORI but the following applies with a peripheral device used in the ladder mode a Write OR and ORI can be used to create connections of up to 23 ladders b Read Up to 23 ladders connected with OR or ORI can be displayed The 24th or subsequent ladders cannot be displayed properly Word device bit designations are made in hexadecimal Bit b11 of DO would be DO OB See Section 3 2 1 for more information on word device bit designation 5 SEQUENCE INSTRUCTIONS Operation Errors 1 There are no operation errors with LD LDI AND ANI OR or ORI instructions Program Example 1 A program using LD AND OR and ORI instructions Ladder Mode 33 MELSEC Q QnA List Mode Steps Instruction Device 0 1
284. to enable the execution of only the interrupt programs having the interrupt pointer numbers 11 and I3 while is ON Ladder Mode List Mode E en ore Steps Instruction Device 0 LD 1 CJ P10 Xi 3 DI kias P20 4 P10 5 LD X1 xo 6 CJ P20 MOVP D10 8 LD 9 HOA 10 FMOVP D11 K7 12 FMOVP KO Dii K7 16 IMASK D10 18 El IMASK D10 19 P20 20 LD MO YI 21 OUT Y20 22 FEND f 23 11 24 10 MIO 25 MOVP K10 D100 FEND 28 IRET 10 29 13 Hoyr D100 30 LD M11 31 P D100 D200 34 IRET IRET 35 END c D100 D200 6 102 6 102 6 BASIC INSTRUCTIONS MELSEC Q QnA 2 When the High Performance model QCPU Process CPU is used Usable Devices Internal Devices MELSECNET 10 H Special Index bus NEUE User File E a Function Redi ter Register Module 9 Word r Zn ME Seales UL AG 2 Instruction Symbol Execution Condition Sequence program Set Data Interrupt mask data or head number of device where interrupt mask data is being stored BIN 16 bits Functions DI 1 Disables the execution of an interrupt program until the El instruction has been executed even if a start cause for the interrupt program occurs 2 A DI state is entered when power is turned ON or when the system has been reset EI 1 The El instruction is used to clear the interrupt disable state resulting f
285. truction is ON no present value update or contact ON OFF operation is conducted Also if the same OUT T i instruction is conducted two or more times during the same scan the present value of the number of repetitions executed will be updated 6 Index modification for timer coils or contacts can be conducted only by 20 or Z1 Index modification cannot be conducted for the set value for the timer 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA 1 The default value for the low speed timer and low speed retentive timer time limit is 100 ms The time limit for the low speed timer and low speed retentive timer can be set in the parameter mode PLC system settings area in increments of 10 ms between the limits of 10 ms to 1 second 2 The default value for time limits for the high speed timer and the high speed retentive timer is 10 ms The time limits for the high speed timer and the high speed retentive timer can be set in the parameter mode PLC system settings area in increments of 1 ms between the limits of 10 ms and 100 ms 3 Refer to the User s Manual Functions Explanation Programming Fundamentals of the used CPU module or QnACPU Programming Manual Fundamentals for information on timer counting methods Cautions 1 When creating a program in which the operation of the timer contacttriggers the operation of other timer create the program according to the operation order of the timers create the program for the timer that operates
286. tructions using the same device are programmed in one scan the device that has been turned ON by the PLF command may not turn ON again throughout the scan Circuit H 1 c Pr mH Timing Chart The ON OFF timing of the and X1 is different The specified device does not turn ON throughout the scan Pr Mo Pe MoH X1 xi HPF MoH END END END OFF ON X OFF Mo OFF MO turns OFF because X1 is MO turns OFF because X1 not turning OFF from ON turns OFF from ON MO turns ON because X0 MO stays OFF turns OFF from ON turns OFF because is not turning OFF from ON MO stays OFF The and X1 turn ur from ON at the same time I mo pe mo END e An E MoH LON Mo OFF MO turhs OFF because X1 is not turning OFF from ON MO stays OFF MO turns ON because MO turns OFF because is not turning turns OFF from ON OFF from ON MO turns ON because X1 turns OFF from ON MO stays ON 4 HOW TO READ INSTRUCTIONS MELSEC Q QnA 4 HOW TO READ INSTRUCTIONS The description of instructions that are contained in the following chapters are presented in the following format 6 BASIC INSTRUCTIONS QCPU 6 L 0 Lo L OSO T GJ 2 6 4 Data Transfer Instructions 6 4 1 16 bit and 32 bit data transfers MOV MOVP DMOV DMOVP Usable Devices Internal Devices MELSECNET 10 H Special Index
287. ule SH 4013 Describes the dedicated instructions for special function modules available when using the Q2ACPU S1 Q3ACPU and Q4ACPU Sold separately 13JF56 QnACPU Programming Manual AD57 Instructions 18 66617 Describes the dedicated instructions for controlling AD57 S1 type CRT controller module available when using the Q2ACPU S1 Q3ACPU or Q4ACPU Sold separately 13JF49 QnACPU Programming Manual PID Control Instructions IB 66618 Describes the dedicated instructions for PID control available when using the Q2ACPU S1 Q3ACPU or Q4ACPU Sold separately 13JF50 QnACPU Programming Manual SFC 18 66619 Describes the system configuration performance specifications functions programming debugging error codes for MELSAP3 Sold separately 13051 For QnA Q4AR MELSECNET 10 Network System Reference Manual IB 66690 Describes the general concept specifications and part names and settings for MELSECNET 10 Sold separately 13 78 type MELSECNET B Data Link System Reference Manual 18 66350 Describes the general concept specifications and part names and settings for MELSECNET and MELSECNET B Sold separately 13JF70 GX Developer Version 7 Operating Manual SH 080166 Describes the online functions of GX Developer Version 7 including the programming procedure printing out procedure monitoring procedure and debugging procedure Sold separately 13JU14 Type SW2IVD GPPQ
288. umber of points from RO equivalent to the value stored in DO and stores the result from M10 onward Ladder Mode List Mode 0 TEES BKCHP D100 RO 00 Steps Instruction Device 0 LD X20 1 BKCMP P D100 RO M10 DO 6 END b15 bO bl5 b0 D100 1000 1000 BIN M10 ON D101 2000 2000 BIN M11 ON D102 3000 5000 BIN M12 OFF D103 4000 4000 BIN M13 ON DO 4 2 The following program performs a comparison operation when X1C goes ON comparing the constant K1000 with the data 4 points from D10 and stores the result in b4 to b7 of DO Ladder Mode List Mode xi 0 H BKCMP lt gt K1000 010 00 4 K4 Steps Instruction Device 0 LD XIC 1 lt gt K1000 D10 D0 4 K4 6 END b0 D10 2000 BIN ot mz DH 1000 BN EN D12 1000 BIN D13 2222 BIN DO after the operation 0 1 0000 110 110 1 110 0 0 0 met already in this state do not change See Function 6 6 BASIC INSTRUCTIONS MELSEC Q QnA 8 When X20 goes ON compares the data 3 points from D10 with the data 3 points from D30 and stores the result from M100 onward The following program transfers the character string ALL ON to D100 onward when all devices from M100 onward have reached the 1 ON state Ladder Mode List Mode X20 e 0 I BKCMP x 010 D30 100 Steps Instruc
289. vero 2 28 2 5 4 Bit processing instructions I nennen nnne nnne rnnt nnne 2 28 2 5 5 Data processing u nennen nennen nnne nnne 2 29 2 5 6 Structure creation instructions J U 2 32 2 5 7 Table operation instructions 2 33 2 5 8 Buffer memory access instructions L 2 34 2 5 9 Display InStructions 2 uy ee vag gies Pee ute casei e e eee p Re Pe e a RE ee ee has 2 934 2 5 10 Debugging and failure diagnosis instructions u 2 935 2 5 11 Character string processing instructions 2 36 3 3 2 5 12 Special function instructions sse enne 2 39 2 5 13 Data control instructions U entente nnne tnter nnns 2 41 2514 Switching instructors mh ee pneri ae enna ia 2 42 2 5 15 Clock IDSIUCliOris 2 43 2 5 16 Peripheral device instructions L 2 44 2 5 17 Program instructions eee te ede ee i e cle ed tee e ta E cbe ra c e ceu 2 45 2 5 18 Other Instl UCliOns eit t rre i Rr HR TE UP ECT EE UA ER RAE UE E FER CR De 2 45 2 5 19 Instructions for data link a 2 4
290. vice 6 60 6 60 6 BASIC INSTRUCTIONS MELSEC Q QnA QCPU PLG Process CPU Cn 6 3 3 Conversion from BIN 16 and 32 bit data to floating decimal point FLT FLTP DFLT DFLTP Usable Devices Internal Devices MELSECNET 10 H Special Index E co NEUE User File uu ER P Function Reaister Register MU Ier 9 Instruction Symbol Execution Condition indicates FLT DFLT Command FLT DFLT FLTP DFLTP Command Set Data Meaning Head device number where integer data for the purpose of conversion to BIN 16 32 bits floating decimal point data is being stored Head device number that will store converted floating decimal point data Functions FLT 1 Converts 16 bit BIN data designated by to floating decimal point type real number and stores at device number designated by gt FS Floating decimal point type real number 2 BIN values between 32768 to 32767 can be designated by 1 Converts 32 bit BIN data designated by to floating decimal point type real number and stores at device number designated by 941 1 The upper 16 bits The lower 16 bits gt Wy BIN 32 bits Floating decimal point type real number 2 BIN values between 2147483648 to 2147483647 can be designated by 1 and 6 BASIC INSTRUCTIONS MELSEC Q QnA 3 Due to
291. where BIN data is stored BIN 16 32 bits Head number of device to store Gray code after conversion Functions GRY Converts BIN 16 bit data at the device designated by S to Gray code and stores result at device designated by 16 bits lt gt bibes Sates SUE e eS See eae SSeS b0 BIN 1234 10 0 1 1 1 0 10 Gray code 1234 Converts BIN 32 bit data at the device designated by S to Gray code and stores result at device designated by 1 upper 16 bits lower 16 bits BIN 305419896 DECIDES b31 SD RR ER Gray code 305419896 0 O 6 BASIC INSTRUCTIONS MELSEC Q QnA Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO The data at S is a negative number Program Example 1 The following program converts the BIN data at D100 to Gray code when X10 is ON and stores result at D200 Ladder Mode List Mode 0 S p 4 mu D100 200 Steps Instruction Device 0 LD X10 1 GRYP D100 D200 4 END 2 The following program converts the BIN data at D10 and D11 to Gray code when X1C is ON and stores it at D100 and D101 Ladder Mode List Mode 0 M a DIO 0100 Steps Instruction Device i M 00 4 E
292. y at a peripheral devices Peripheral devices continue to display ladders until encountering an END instruction Main routine 4 program Jump caused by Main routine the CJ instruction program Main routine Operation FEND program Operations when the CJ instruction is not executed performed when the CJ instruction was executed Subroutine program Interrupt program END a When using the CJ instruction b When there is a subroutine or interrupt program Operation Errors 1 In the following cases an operation error occurs the error flag SMO turns ON and an error code is stored at SDO A FEND instruction is executed after the execution of a CALL FCALL ECALL or EFCALL instruction and before the execution of the RET instruction Error code 4211 A FEND instruction is executed after the execution of a FOR instruction and before the execution of a NEXT instruction Error code 4200 5 46 5 46 5 SEQUENCE INSTRUCTIONS MELSEC Q QnA A FEND instruction is executed during an interrupt program and before the execution of an IRET instruction Error code 4221 A FEND instruction is executed between the CHKCIR and CHKEND instructions Error code 4230 A FEND instruction is executed between the IX and IXEND instructions Error code 4231 Program Example 1 The following program uses the CJ instruction Ladder Mode

Download Pdf Manuals

image

Related Search

Related Contents

FRONTSEITE RÜCKSEITE  取扱説明書 - Panasonic  2010年11月4日  取扱説明書  MI 45TA+ - Migros  White Rodgers 37-7248A Thermostat User Manual  ISO/IEC 15693 Protocol HF Tag Reader RR9036 User's Manual V3.80  CAPSLink User Manual  Samsung 4 Discos de indução Vitrocerâmica Indução CTN264EA01  Manual - Sierra Chest  

Copyright © All rights reserved.
Failed to retrieve file