The text of a manual · part 23 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 5 Instruction Set, pages 199 to 208
Pages 199 to 208 of 520, from SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual
The original document is the PDF (2.1 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Omron CQM1-CPU21
Page 199
SECTION 5 Instruction Set The CQM1 and CPM1 have large programming instruction sets that allow for easy programming of complicated control processes. This section explains instructions individually and provides the ladder diagram symbol, data areas, and flags used with each. The many instructions provided by these PCs are organized in the following subsections by instruction group. These groups include Ladder Diagram Instructions, instructions with fixed function codes, and set instructions. Some instructions, such as Timer and Counter instructions, are used to control execution of other instructions, e.g., a TIM Completion Flag might be used to turn ON a bit when the time period set for the timer has expired. Although these other instructions are often used to control output bits through the Output instruction, they can be used to control execution of other instructions as well. The Output instructions used in examples in this manual can therefore generally be replaced by other instructions to modify the program for specific applications other than controlling output bits directly. 5-1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 5-2 Instruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 5-3 Data Areas, Definer Values, and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 5-4 Differentiated Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 5-5 Coding Right-hand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 5-6 Instruction Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 5-6-1 CQM1 Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 5-6-2 CPM1/CPM1A Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 5-6-3 SRM1 Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 5-6-4 Alphabetic List by Mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 5-7 Ladder Diagram Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 5-7-1 LOAD, LOAD NOT, AND, AND NOT, OR, and OR NOT . . . . . . . . . . . . . . . . . 196 5-7-2 AND LOAD and OR LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 5-8 Bit Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 5-8-1 OUTPUT and OUTPUT NOT – OUT and OUT NOT . . . . . . . . . . . . . . . . . . . . . 197 5-8-2 SET and RESET – SET and RSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 5-8-3 KEEP – KEEP(11) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 5-8-4 DIFFERENTIATE UP and DOWN – DIFU(13) and DIFD(14) . . . . . . . . . . . . . . 200 5-9 NO OPERATION – NOP(00) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 5-10 END – END(01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 5-11 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03) . . . . . . . . . . . . . . . . . . . . 201 5-12 JUMP and JUMP END – JMP(04) and JME(05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 5-13 User Error Instructions: FAILURE ALARM AND RESET – FAL(06) and SEVERE FAILURE ALARM – FALS(07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 5-14 Step Instructions: STEP DEFINE and STEP START–STEP(08)/SNXT(09) . . . . . . . . . . . . . . . . . . . . . . . . . . 206 5-15 Timer and Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 5-15-1 TIMER – TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 5-15-2 COUNTER – CNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 5-15-3 REVERSIBLE COUNTER – CNTR(12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 5-15-4 HIGH-SPEED TIMER – TIMH(15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 5-15-5 INTERVAL TIMER – STIM(69) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 5-15-6 REGISTER COMPARISON TABLE – CTBL(63) . . . . . . . . . . . . . . . . . . . . . . . . 215 5-15-7 MODE CONTROL – INI(61) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 5-15-8 HIGH-SPEED COUNTER PV READ – PRV(62) . . . . . . . . . . . . . . . . . . . . . . . . 221 5-16 Shift Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 5-16-1 SHIFT REGISTER – SFT(10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 5-16-2 WORD SHIFT – WSFT(16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 5-16-3 ARITHMETIC SHIFT LEFT – ASL(25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 5-16-4 ARITHMETIC SHIFT RIGHT – ASR(26) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 5-16-5 ROTATE LEFT – ROL(27) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 5-16-6 ROTATE RIGHT – ROR(28) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 5-16-7 ONE DIGIT SHIFT LEFT – SLD(74) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 5-16-8 ONE DIGIT SHIFT RIGHT – SRD(75) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 5-16-9 REVERSIBLE SHIFT REGISTER – SFTR(84) . . . . . . . . . . . . . . . . . . . . . . . . . . 229 5-16-10 ASYNCHRONOUS SHIFT REGISTER – ASFT(17) . . . . . . . . . . . . . . . . . . . . . 230
181
Page 200
Section 5-17 Data Movement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-1 MOVE – MOV(21) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-2 MOVE NOT – MVN(22) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-3 BLOCK TRANSFER – XFER(70) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-4 BLOCK SET – BSET(71) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-5 DATA EXCHANGE – XCHG(73) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-6 SINGLE WORD DISTRIBUTE – DIST(80) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-7 DATA COLLECT – COLL(81) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-8 MOVE BIT – MOVB(82) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-9 MOVE DIGIT – MOVD(83) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-10 TRANSFER BITS – XFRB(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18 Comparison Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-1 COMPARE – CMP(20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-2 TABLE COMPARE – TCMP(85) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-3 BLOCK COMPARE – BCMP(68) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-4 DOUBLE COMPARE – CMPL(60) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-5 MULTI-WORD COMPARE – MCMP(19) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-6 SIGNED BINARY COMPARE – CPS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-7 DOUBLE SIGNED BINARY COMPARE – CPSL(––) . . . . . . . . . . . . . . . . . . . . 5-18-8 AREA RANGE COMPARE – ZCP(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-9 DOUBLE AREA RANGE COMPARE – ZCPL(––) . . . . . . . . . . . . . . . . . . . . . . 5-19 Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-1 BCD-TO-BINARY – BIN(23) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-2 BINARY-TO-BCD – BCD(24) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-3 DOUBLE BCD-TO-DOUBLE BINARY – BINL(58) . . . . . . . . . . . . . . . . . . . . . 5-19-4 DOUBLE BINARY-TO-DOUBLE BCD – BCDL(59) . . . . . . . . . . . . . . . . . . . . . 5-19-5 4-TO-16 DECODER – MLPX(76) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-6 16-TO-4 ENCODER – DMPX(77) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-7 7-SEGMENT DECODER – SDEC(78) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-8 ASCII CONVERT – ASC(86) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-9 ASCII-TO-HEXADECIMAL – HEX(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-10 SCALING – SCL(66) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-11 SIGNED BINARY TO BCD SCALING – SCL2(––) . . . . . . . . . . . . . . . . . . . . . . 5-19-12 BCD TO SIGNED BINARY SCALING – SCL3(––) . . . . . . . . . . . . . . . . . . . . . . 5-19-13 HOURS-TO-SECONDS – SEC(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-14 SECONDS-TO-HOURS – HMS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-15 COLUMN-TO-LINE – LINE(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-16 LINE-TO-COLUMN – COLM(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-17 2’S COMPLEMENT – NEG(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-18 DOUBLE 2’S COMPLEMENT – NEGL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20 BCD Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-1 SET CARRY – STC(40) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-2 CLEAR CARRY – CLC(41) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-3 BCD ADD – ADD(30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-4 BCD SUBTRACT – SUB(31) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-5 BCD MULTIPLY – MUL(32) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-6 BCD DIVIDE – DIV(33) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-7 DOUBLE BCD ADD – ADDL(54) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-8 DOUBLE BCD SUBTRACT – SUBL(55) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-9 DOUBLE BCD MULTIPLY – MULL(56) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-10 DOUBLE BCD DIVIDE – DIVL(57) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-11 SQUARE ROOT – ROOT(72) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
182
232 232 232 233 234 235 235 237 239 240 241 242 242 243 244 246 247 248 249 250 252 252 252 253 254 254 255 257 259 262 263 266 268 269 271 272 273 274 275 276 278 278 278 278 279 281 282 283 285 286 287 288
Page 201
Section 5-21 Binary Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-1 BINARY ADD – ADB(50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-2 BINARY SUBTRACT – SBB(51) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-3 BINARY MULTIPLY – MLB(52) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-4 BINARY DIVIDE – DVB(53) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-5 DOUBLE BINARY ADD – ADBL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-6 DOUBLE BINARY SUBTRACT – SBBL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-7 SIGNED BINARY MULTIPLY – MBS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-8 DOUBLE SIGNED BINARY MULTIPLY – MBSL(––) . . . . . . . . . . . . . . . . . . . 5-21-9 SIGNED BINARY DIVIDE – DBS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-10 DOUBLE SIGNED BINARY DIVIDE – DBSL(––) . . . . . . . . . . . . . . . . . . . . . . 5-22 Special Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-1 FIND MAXIMUM – MAX(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-2 FIND MINIMUM – MIN(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-3 AVERAGE VALUE – AVG(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-4 SUM – SUM(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-5 ARITHMETIC PROCESS – APR(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-1 COMPLEMENT – COM(29) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-2 LOGICAL AND – ANDW(34) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-3 LOGICAL OR – ORW(35) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-4 EXCLUSIVE OR – XORW(36) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-5 EXCLUSIVE NOR – XNRW(37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24 Increment/Decrement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-1 BCD INCREMENT – INC(38) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-2 BCD DECREMENT – DEC(39) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 Subroutine Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-1 SUBROUTINE ENTER – SBS(91) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-2 SUBROUTINE DEFINE and RETURN – SBN(92)/RET(93) . . . . . . . . . . . . . . . 5-26 Special Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-1 TRACE MEMORY SAMPLING – TRSM(45) . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-2 MESSAGE DISPLAY – MSG(46) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-3 I/O REFRESH – IORF(97) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-4 MACRO – MCRO(99) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-5 BIT COUNTER – BCNT(67) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-6 FRAME CHECKSUM – FCS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-7 FAILURE POINT DETECTION – FPD(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-8 INTERRUPT CONTROL – INT(89) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-9 SET PULSES – PULS(65) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-10 SPEED OUTPUT– SPED(64) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-11 PULSE OUTPUT – PLS2(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-12 ACCELERATION CONTROL – ACC(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-13 PULSE WITH VARIABLE DUTY RATIO – PWM(––) . . . . . . . . . . . . . . . . . . . 5-26-14 DATA SEARCH – SRCH(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-15 PID CONTROL – PID(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27 Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-1 RECEIVE – RXD(47) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-2 TRANSMIT – TXD(48) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-3 CHANGE RS-232C SETUP – STUP(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28 Advanced I/O Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-1 7-SEGMENT DISPLAY OUTPUT – 7SEG(88) . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-2 DIGITAL SWITCH INPUT – DSW(87) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-3 HEXADECIMAL KEY INPUT – HKY(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-4 TEN KEY INPUT – TKY(18) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
289 289 290 291 292 293 294 296 297 298 299 300 300 301 302 303 305 308 308 309 309 310 311 311 311 312 313 313 315 315 315 317 318 319 320 321 322 326 328 330 332 334 336 337 338 340 340 342 344 345 345 346 347 347
183
Page 202
Data Areas, Definer Values, and Flags
5-1
Section
5-3
Notation In the remainder of this manual, all instructions will be referred to by their mnemonics. For example, the OUTPUT instruction will be called OUT; the AND LOAD instruction, AND LD. If you’re not sure of the instruction a mnemonic is used for, refer to Appendix A Programming Instructions. If an instruction is assigned a function code, it will be given in parentheses after the mnemonic. These function codes, which are 2-digit decimal numbers, are used to input most instructions into the CPU Unit. A table of instructions listed in order of function codes is also provided in Appendix A Programming Instructions. Lists of instructions are also provided in 5-6 Instruction Tables. An @ before a mnemonic indicates the differentiated version of that instruction. Differentiated instructions are explained in Section 5-4.
5-2
Instruction Format Most instructions have at least one or more operands associated with them. Operands indicate or provide the data on which an instruction is to be performed. These are sometimes input as the actual numeric values (i.e., as constants), but are usually the addresses of data area words or bits that contain the data to be used. A bit whose address is designated as an operand is called an operand bit; a word whose address is designated as an operand is called an operand word. In some instructions, the word address designated in an instruction indicates the first of multiple words containing the desired data. Each instruction requires one or more words in Program Memory. The first word is the instruction word, which specifies the instruction and contains any definers (described below) or operand bits required by the instruction. Other operands required by the instruction are contained in following words, one operand per word. Some instructions require up to four words. A definer is an operand associated with an instruction and contained in the same word as the instruction itself. These operands define the instruction rather than telling what data it is to use. Examples of definers are TC numbers, which are used in timer and counter instructions to create timers and counters, as well as jump numbers (which define which Jump instruction is paired with which Jump End instruction). Bit operands are also contained in the same word as the instruction itself, although these are not considered definers.
5-3
Data Areas, Definer Values, and Flags In this section, each instruction description includes its ladder diagram symbol, the data areas that can be used by its operands, and the values that can be used as definers. Details for the data areas are also specified by the operand names and the type of data required for each operand (i.e., word or bit and, for words, hexadecimal or BCD). Not all addresses in the specified data areas are necessarily allowed for an operand, e.g., if an operand requires two words, the last word in a data area cannot be designated as the first word of the operand because all words for a single operand must be within the same data area. Other specific limitations are given in a Limitations subsection. Refer to Section 3 Memory Areas for addressing conventions and the addresses of flags and control bits. ! Caution
184
The IR and SR areas are considered as separate data areas. If an operand has access to one area, it doesn’t necessarily mean that the same operand will have access to the other area. The border between the IR and SR areas can, however, be crossed for a single operand, i.e., the last bit in the IR area may be specified for an operand that requires more than one word as long as the SR area is also allowed for that operand.
Page 203
Section
Data Areas, Definer Values, and Flags
5-3
The Flags subsection lists flags that are affected by execution of an instruction. These flags include the following SR area flags. Abbreviation
Name
Bit
ER
Instruction Execution Error Flag
25503
CY
Carry Flag
25504
GR
Greater Than Flag
25505
EQ
Equals Flag
25506
LE
Less Than Flag
25507
ER is the flag most commonly used for monitoring an instruction’s execution. When ER goes ON, it indicates that an error has occurred in attempting to execute the current instruction. The Flags subsection of each instruction lists possible reasons for ER being ON. ER will turn ON if operands are not entered correctly. Instructions are not executed when ER is ON. A table of instructions and the flags they affect is provided in Appendix B Error and Arithmetic Flag Operation. Indirect Addressing
When the DM area is specified for an operand, an indirect address can be used. Indirect DM addressing is specified by placing an asterisk before the DM: DM. When an indirect DM address is specified, the designated DM word will contain the address of the DM word that contains the data that will be used as the operand of the instruction. If, for example, DM 0001 was designated as the first operand and LR 00 as the second operand of MOV(21), the contents of DM 0001 was 1111, and DM 1111 contained 5555, the value 5555 would be moved to LR 00.
MOV(21) DM 0001 LR 00
Indirect address
Word DM 0000 DM 0001 DM 0002
Content 4C59 1111 F35A
DM 1111 DM 1113 DM 1114
5555 2506 D541
Indicates DM 1111.
5555 moved to LR 00.
When using indirect addressing, the address of the desired word must be in BCD and it must specify a word within the DM area. In the above example, the content of DM 0000 would have to be in BCD between 0000 and 1999. Designating Constants
Although data area addresses are most often given as operands, many operands and all definers are input as constants. The available value range for a given definer or operand depends on the particular instruction that uses it. Constants must also be entered in the form required by the instruction, i.e., in BCD or in hexadecimal.
185
Page 204
Section
Coding Right-hand Instructions
5-4
5-5
Differentiated Instructions Most instructions are provided in both differentiated and non-differentiated forms. Differentiated instructions are distinguished by an @ in front of the instruction mnemonic. A non-differentiated instruction is executed each time it is scanned as long as its execution condition is ON. A differentiated instruction is executed only once after its execution condition goes from OFF to ON. If the execution condition has not changed or has changed from ON to OFF since the last time the instruction was scanned, the instruction will not be executed. The following two examples show how this works with MOV(21) and @MOV(21), which are used to move the data in the address designated by the first operand to the address designated by the second operand. 00000 MOV(21) HR 10
Diagram A
DM 0000
Address
Instruction
00000 00001
LD MOV(21)
Operands 00000 HR DM
10 0000
00000
Diagram B
@MOV(21)
Address
Instruction
HR 10
00000 00001
LD @MOV(21)
DM 0000
Operands 00000 HR DM
10 0000
In diagram A, the non-differentiated MOV(21) will move the content of HR 10 to DM 0000 whenever it is scanned with 00000. If the cycle time is 80 ms and 00000 remains ON for 2.0 seconds, this move operation will be performed 25 times and only the last value moved to DM 0000 will be preserved there. In diagram B, the differentiated @MOV(21) will move the content of HR 10 to DM 0000 only once after 00000 goes ON. Even if 00000 remains ON for 2.0 seconds with the same 80 ms cycle time, the move operation will be executed only once during the first cycle in which 00000 has changed from OFF to ON. Because the content of HR 10 could very well change during the 2 seconds while 00000 is ON, the final content of DM 0000 after the 2 seconds could be different depending on whether MOV(21) or @MOV(21) was used. All operands, ladder diagram symbols, and other specifications for instructions are the same regardless of whether the differentiated or non-differentiated form of an instruction is used. When inputting, the same function codes are also used, but NOT is input after the function code to designate the differentiated form of an instruction. Most, but not all, instructions have differentiated forms. Refer to 5-11 INTERLOCK and INTERLOCK CLEAR – IL(02) and IL(03) for the effects of interlocks on differentiated instructions. The CQM1 also provides differentiation instructions: DIFU(13) and DIFD(14). DIFU(13) operates the same as a differentiated instruction, but is used to turn ON a bit for one cycle. DIFD(14) also turns ON a bit for one cycle, but does it when the execution condition has changed from ON to OFF. Refer to 5-8-4 DIFFERENTIATE UP and DOWN - DIFU(13) and DIFD(14) for details.
5-5
Coding Right-hand Instructions Writing mnemonic code for ladder instructions is described in Section 4 Ladderdiagram Programming. Converting the information in the ladder diagram symbol for all other instructions follows the same pattern, as described below, and is not specified for each instruction individually.
186
Page 205
Coding Right-hand Instructions
Section
5-5
The first word of any instruction defines the instruction and provides any definers. If the instruction requires only a signal bit operand with no definer, the bit operand is also placed on the same line as the mnemonic. All other operands are placed on lines after the instruction line, one operand per line and in the same order as they appear in the ladder symbol for the instruction. The address and instruction columns of the mnemonic code table are filled in for the instruction word only. For all other lines, the left two columns are left blank. If the instruction requires no definer or bit operand, the data column is left blank for first line. It is a good idea to cross through any blank data column spaces (for all instruction words that do not require data) so that the data column can be quickly scanned to see if any addresses have been left out. If an IR or SR address is used in the data column, the left side of the column is left blank. If any other data area is used, the data area abbreviation is placed on the left side and the address is placed on the right side. If a constant to be input, the number symbol (#) is placed on the left side of the data column and the number to be input is placed on the right side. Any numbers input as definers in the instruction word do not require the number symbol on the right side. TC bits, once defined as a timer or counter, take a TIM (timer) or CNT (counter) prefix. When coding an instruction that has a function code, be sure to write in the function code, which will be necessary when inputting the instruction via the Programming Console. Also be sure to designate the differentiated instruction with the @ symbol. Note The mnemonics of expansion instructions are followed by “(––)” as the function code to indicate that they must be assigned function codes by the user in the instructions table before they can be used in programming. Refer to page 116 for details.
187
Page 206
Section
Coding Right-hand Instructions
5-5
The following diagram and corresponding mnemonic code illustrates the points described above. 00000
Address Instruction
00001 DIFU(13) 21600 00002
00100
00200
21600 BCNT(67)
01001 01002
LR 6300
Data
00000
LD
00000
00001
AND
00001
00002
OR
00002
00003
DIFU(13)
21600
00004
LD
00100
00005
AND NOT
00200
00006
LD
01001
00007
AND NOT
01002
00008
AND NOT
00009
OR LD
00010
AND
00011
BCNT(67)
#0001 004 HR 00
00005 TIM 000
LR
6300 –– 21600
#0150 TIM 000
–– #
MOV(21)
0001 004
HR 00
HR
LR 00
HR 0015
00012
LD
00013
TIM
00500
188
00014
LD
00015
MOV(21)
00016
LD
00017
OUT NOT
00 00005 000
#
0150
TIM
000 ––
HR
00
LR
00
HR
0015 00500
Page 207
Section
Coding Right-hand Instructions Multiple Instruction Lines
00000
If a right-hand instruction requires multiple instruction lines (such as KEEP(11)), all of the lines for the instruction are entered before the right-hand instruction. Each of the lines for the instruction is coded, starting with LD or LD NOT, to form ‘logic blocks’ that are combined by the right-hand instruction. An example of this for SFT(10) is shown below. Address Instruction
00001
I SFT(10)
00002
P HR 00
00100
00200
01001 01002
5-5
21600
R
HR 00
Data
00000
LD
00000
00001
AND
00001
00002
LD
00002
00003
LD
00100
00004
AND NOT
00200
00005
LD
01001
00006
AND NOT
00007
AND NOT
00008
OR LD
00009
AND
00010
SFT(10)
HR HR
00
00011
LD
HR
0015
00012
OUT NOT
LR 6300
HR 0015 00500
01002 LR
6300 –– 21600 00
00500
189
Page 208
Section
Instruction Tables
5-6
5-6
Instruction Tables This section provides tables of the instructions available in the CQM1. The first few tables can be used to find instructions by function code. The last table can be used to find instructions by mnemonic. In both tables, the @ symbol indicates instructions with differentiated forms.
5-6-1 CQM1 Function Codes The following table lists the CQM1 instructions that have fixed function codes. Each instruction is listed by mnemonic and by instruction name. Use the numbers in the leftmost column as the left digit and the number in the column heading as the right digit of the function code. Right digit
Left digit
2
3
5
6
7
8
0
NOP NO OPERATION
0 END END
1
IL INTERLOCK
ILC INTERLOCK CLEAR
JMP JUMP
4
JME JUMP END
(@) FAL FAILURE ALARM AND RESET
FALS SEVERE FAILURE ALARM
STEP STEP DEFINE
SNXT STEP START
1
SFT SHIFT REGISTER
KEEP KEEP
CNTR REVERSIBLE COUNTER
DIFU DIFFERENTIATE UP
DIFD DIFFERENTIATE DOWN
TIMH HIGHSPEED TIMER
(@) WSFT WORD SHIFT
(@) ASFT ASYNCHRONOUS SHIFT REGISTER
(@) TKY TEN KEY INPUT
(@) MCMP MULTIWORD COMPARE
2
CMP COMPARE
(@) MOV MOVE
(@) MVN MOVE NOT
(@) BIN BCD TO BINARY
(@) BCD BINARY TO BCD
(@) ASL SHIFT LEFT
(@) ASR SHIFT RIGHT
(@) ROL ROTATE LEFT
(@) ROR ROTATE RIGHT
(@) COM COMPLEMENT
3
(@) ADD BCD ADD
(@) SUB BCD SUBTRACT
(@) MUL BCD MULTIPLY
(@) DIV BCD DIVIDE
(@) ANDW LOGICAL AND
(@) ORW LOGICAL OR
(@) XORW EXCLUSIVE OR
(@) XNRW EXCLUSIVE NOR
(@) INC INCREMENT
(@) DEC DECREMENT
4
(@) STC SET CARRY
(@) CLC CLEAR CARRY
---
---
---
TRSM TRACE MEMORY SAMPLE (SEE NOTE)
(@) MSG MESSAGE DISPLAY
(@) RXD RECEIVE
(@) TXD TRANSMIT
---
5
(@) ADB BINARY ADD
(@) SBB BINARY SUBTRACT
(@) MLB BINARY MULTIPLY
(@) DVB BINARY DIVIDE
(@) ADDL DOUBLE BCD ADD
(@) SUBL DOUBLE BCD SUBTRACT
(@) MULL DOUBLE BCD MULTIPLY
(@) DIVL DOUBLE BCD DIVIDE
(@) BINL DOUBLE BCD-TODOUBLE BINARY
(@) BCDL DOUBLE BINARY-TODOUBLE BCD
6
CMPL DOUBLE COMPARE
(@) INI MODE CONTROL
(@) PRV HIGHSPEED COUNTER PV READ
(@) CTBL COMPARISON TABLE LOAD
(@) SPED SPEED OUTPUT
(@) PULS SET PULSES
(@) SCL SCALING
(@) BCNT BIT COUNTER
(@) BCMP BLOCK COMPARE
(@) STIM INTERVAL TIMER
7
(@) XFER BLOCK TRANSFER
(@) BSET BLOCK SET
(@) ROOT SQUARE ROOT
(@) XCHG DATA EXCHANGE
(@) SLD ONE DIGIT SHIFT LEFT
(@) SRD ONE DIGIT SHIFT RIGHT
(@) MLPX 4-TO-16 DECODER
(@) DMPX 16-TO-4 ENCODER
(@) SDEC 7-SEGMENT DECODER
---
8
(@) DIST SINGLE WORD DISTRIBUTE
(@) COLL DATA COLLECT
(@) MOVB MOVE BIT
(@) MOVD MOVE DIGIT
(@) SFTR REVERSIBLE SHIFT REGISTER
(@) TCMP TABLE COMPARE
(@) ASC ASCII CONVERT
(@) DSW DIGITAL SWITCH
(@) 7SEG 7-SEGMENT DISPLAY OUTPUT
(@) INT INTERRUPT CONTROL
9
---
(@) SBS SUBROUTINE ENTRY
SBN SUBROUTINE DEFINE
RET SUBROUTINE RETURN
---
---
---
(@) IORF I/O REFRESH
---
(@) MCRO MACRO
Note TRSM(45) cannot be used with the CQM1-CPU11/21-E CPU Units.
190
9