The text of a manual · part 17 of 60
C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 154 to 163
Pages 154 to 163 of 586
The original document is the PDF (3.4 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 C200HE-CPU42-E
Page 154
5-16 Data Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-1 MOVE – MOV(21) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-2 MOVE NOT – MVN(22) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-3 BLOCK SET – BSET(71) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-4 BLOCK TRANSFER – XFER(70) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-5 DATA EXCHANGE – XCHG(73) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-6 SINGLE WORD DISTRIBUTE – DIST(80) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-7 DATA COLLECT – COLL(81) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-8 MOVE BIT – MOVB(82) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-9 MOVE DIGIT – MOVD(83) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-10 TRANSFER BITS – XFRB(62) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-11 EM BLOCK TRANSFER – XFR2(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-12 EM BANK TRANSFER – BXF2(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17 Data Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-1 MULTI-WORD COMPARE – MCMP(19) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-2 COMPARE – CMP(20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-3 DOUBLE COMPARE – CMPL(60) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-4 BLOCK COMPARE – BCMP(68) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-5 TABLE COMPARE – TCMP(85) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-6 AREA RANGE COMPARE – ZCP(88) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-7 DOUBLE AREA RANGE COMPARE – ZCPL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-8 SIGNED BINARY COMPARE – CPS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-9 DOUBLE SIGNED BINARY COMPARE – CPSL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18 Data Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-1 BCD-TO-BINARY – BIN(23) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-2 DOUBLE BCD-TO-DOUBLE BINARY – BINL(58) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-3 BINARY-TO-BCD – BCD(24) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-4 DOUBLE BINARY-TO-DOUBLE BCD – BCDL(59) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-5 HOURS-TO-SECONDS – SEC(65) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-6 SECONDS-TO-HOURS – HMS(66) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-7 4-TO-16/8-TO-256 DECODER – MLPX(76) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-8 16-TO-4/256-TO-8 ENCODER – DMPX(77) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-9 7-SEGMENT DECODER – SDEC(78) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-10 ASCII CONVERT – ASC(86) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-11 ASCII-TO-HEXADECIMAL – HEX(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-12 SCALING – SCL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-13 COLUMN TO LINE – LINE(63) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-14 LINE TO COLUMN – COLM(64) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-15 2’S COMPLEMENT – NEG(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-16 DOUBLE 2’S COMPLEMENT – NEGL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19 BCD Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-1 INCREMENT – INC(38) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-2 DECREMENT – DEC(39) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-3 SET CARRY – STC(40) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-4 CLEAR CARRY – CLC(41) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-5 BCD ADD – ADD(30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-6 DOUBLE BCD ADD – ADDL(54) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-7 BCD SUBTRACT – SUB(31) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-8 DOUBLE BCD SUBTRACT – SUBL(55) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-9 BCD MULTIPLY – MUL(32) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-10 DOUBLE BCD MULTIPLY – MULL(56) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-11 BCD DIVIDE – DIV(33) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-12 DOUBLE BCD DIVIDE – DIVL(57) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-13 FLOATING POINT DIVIDE – FDIV(79) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-14 SQUARE ROOT – ROOT(72) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20 Binary Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-1 BINARY ADD – ADB(50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-2 BINARY SUBTRACT – SBB(51) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-3 BINARY MULTIPLY – MLB(52) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-4 BINARY DIVIDE – DVB(53) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-5 DOUBLE BINARY ADD – ADBL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-6 DOUBLE BINARY SUBTRACT – SBBL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-7 SIGNED BINARY MULTIPLY – MBS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-8 DOUBLE SIGNED BINARY MULTIPLY – MBSL(––) . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-9 SIGNED BINARY DIVIDE – DBS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-10 DOUBLE SIGNED BINARY DIVIDE – DBSL(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
136
180 180 180 181 182 183 183 185 187 188 189 190 191 192 192 193 196 197 199 200 201 202 203 204 204 205 205 206 207 208 209 212 215 218 219 222 224 225 226 227 228 228 228 229 229 229 230 231 233 235 236 236 237 238 241 243 243 245 248 248 249 251 253 254 255 256
Page 155
5-21 Special Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-1 FIND MAXIMUM – MAX(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-2 FIND MINIMUM – MIN(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-3 AVERAGE VALUE – AVG(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-4 SUM – SUM(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-5 ARITHMETIC PROCESS – APR(69) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-6 PID CONTROL – PID(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22 Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-1 COMPLEMENT – COM(29) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-2 LOGICAL AND – ANDW(34) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-3 LOGICAL OR – ORW(35) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-4 EXCLUSIVE OR – XORW(36) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-5 EXCLUSIVE NOR – XNRW(37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 Subroutines and Interrupt Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-1 Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-2 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-3 SUBROUTINE ENTER – SBS(91) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-4 SUBROUTINE DEFINE and RETURN – SBN(92)/RET(93) . . . . . . . . . . . . . . . . . . . . . 5-23-5 MACRO – MCRO(99) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-6 INTERRUPT CONTROL – INT(89) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-7 Processing the Same Memory Locations with the Main Program and Interrupt Subroutines 5-24 Step Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-1 STEP DEFINE and STEP START–STEP(08)/SNXT(09) . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 Special Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-1 FAILURE ALARM – FAL(06) and SEVERE FAILURE ALARM – FALS(07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-2 CYCLE TIME – SCAN(18) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-3 TRACE MEMORY SAMPLING – TRSM(45) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-4 MESSAGE DISPLAY – MSG(46) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-5 LONG MESSAGE – LMSG(47) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-6 TERMINAL MODE – TERM(48) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-7 WATCHDOG TIMER REFRESH – WDT(94) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-8 I/O REFRESH – IORF(97) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-9 GROUP-2 HIGH-DENSITY I/O REFRESH – MPRF(61) . . . . . . . . . . . . . . . . . . . . . . . . 5-25-10 BIT COUNTER – BCNT(67) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-11 FRAME CHECKSUM – FCS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-12 FAILURE POINT DETECTION – FPD(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-13 DATA SEARCH – SRCH(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-14 EXPANSION DM READ – XDMR(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-15 INDIRECT EM ADDRESSING – IEMS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-16 SELECT EM BANK – EMBC(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26 Network Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-1 NETWORK SEND – SEND(90) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-2 NETWORK RECEIVE – RECV(98) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-3 About Network Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27 Serial Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-1 RECEIVE – RXD(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-2 TRANSMIT – TXD(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-3 CHANGE RS-232C SETUP – STUP(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-4 PROTOCOL MACRO – PMCR(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28 Advanced I/O Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-1 7-SEGMENT DISPLAY OUTPUT – 7SEG(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-2 DIGITAL SWITCH INPUT – DSW(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-3 HEXADECIMAL KEY INPUT – HKY(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-4 TEN KEY INPUT – TKY(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-5 MATRIX INPUT – MTR(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29 Special I/O Unit Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-1 SPECIAL I/O UNIT READ – IORD(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-2 SPECIAL I/O UNIT WRITE – IOWR(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-3 PCMCIA CARD MACRO – CMCR(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
257 257 258 259 261 263 266 277 277 278 279 280 281 281 281 282 285 286 287 289 292 295 295 304 304 305 306 307 308 309 310 310 311 312 312 314 318 319 320 321 322 322 327 331 333 333 335 337 339 340 340 343 347 350 352 354 354 355 357
137
Page 156
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 B 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 and are described briefly below and in more detail in 4-7 Inputting, Modifying, and Checking the Program. A table of instructions listed in order of function codes, is also provided in Appendix B. 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. Also, not all words in the SR and DM areas are writeable as operands (see Section 3 Memory Areas for details.) 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.
138
Page 157
Section 5-3
Data Areas, Definer Values, and Flags ! Caution
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. The Flags subsection lists flags that are affected by execution of an instruction. These flags include the following SR area flags. Abbreviation ER CY GR EQ LE N OF UF
Name Instruction Execution Error Flag Carry Flag Greater Than Flag Equals Flag Less Than Flag Negative Flag Overflow Flag Underflow Flag
Bit 25503 25504 25505 25506 25507 25402 25404 25405
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 C 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: 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, 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) 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 0000 would have to be in BCD between 0000 and 6655. The IEMS(––) instruction can be used to change the destination of from the DM area to one of the banks in the EM area. Refer to 5-25-15 INDIRECT EM ADDRESSING – IEMS(––) for details. 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.
139
Page 158
Section 5-4
Differentiated Instructions
5-4
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 cycled 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 cycled, 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 cycled 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-10 INTERLOCK and INTERLOCK CLEAR – IL(02) and IL(03) for the effects of interlocks on differentiated instructions. The C200HX/HG/HE PCs also provide 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-9-2 DIFFERENTIATE UP and DOWN - DIFU(13) and DIFD(14) for details. Note Do not use SR 25313 and SR 25315 for differentiated instructions. These bits never change status and will not trigger differentiated instructions.
140
Page 159
Section 5-5
Expansion Instructions
5-5
Expansion Instructions The C200HX/HG/HE PCs have more instructions that require function codes (121) than function codes (100), so some instructions do not have fixed function codes. These instructions, called expansion instructions, are listed in the following table. Default function codes are given for the instructions that have them. An expansion instruction can be assigned one of 18 function codes using the Programming Console’s Expansion Instruction Function Code Assignments operation. The 18 function codes are: 17, 18, 19, 47, 48, 60 to 69, 87, 88, and 89. Refer to 7-2-14 Expansion Instruction Function Code Assignments for details on assigning function codes. Code
Mnemonic
Name
Page
17
(@)ASFT
ASYNCHRONOUS SHIFT REGISTER
178
18
(@)SCAN
CYCLE TIME
305
19
(@)MCMP
MULTI-WORD COMPARE
192
47
(@)LMSG
32-CHARACTER MESSAGE
308
48
(@)TERM
TERMINAL MODE
309
60
CMPL
DOUBLE COMPARE
196
61
(@)MPRF
GROUP-2 HIGH-DENSITY I/O REFRESH
311
62
(@)XFRB
TRANSFER BITS
189
63
(@)LINE
COLUMN TO LINE
224
64
(@)COLM
LINE TO COLUMN
225
65
(@)SEC
HOURS TO SECONDS
207
66
(@)HMS
SECONDS TO HOURS
208
67
(@)BCNT
BIT COUNTER
312
68
(@)BCMP
BLOCK COMPARE
197
69
(@)APR
ARITHMETIC PROCESS
263
87
TTIM
TOTALIZING TIMER
165
88
ZCP
AREA RANGE COMPARE
200
89
(@)INT
INTERRUPT CONTROL
289
---
7SEG
7-SEGMENT DISPLAY OUTPUT
340
---
(@)ADBL
DOUBLE BINARY ADD
249
---
AVG
AVERAGE VALUE
259
---
(@)BXF2
EM BANK TRANSFER
191
---
CPS
SIGNED BINARY COMPARE
202
---
CPSL
DOUBLE SIGNED BINARY COMPARE
203
---
CMCR
PCMCIA CARD MACRO
357
---
(@)DBS
SIGNED BINARY DIVIDE
255
---
(@)DBSL
DOUBLE SIGNED BINARY DIVIDE
256
---
DSW
DIGITAL SWITCH INPUT
343
---
@EMBC
SELECT EM BANK
321
---
(@)FCS
FCS CALCULATE
312
---
FPD
FAILURE POINT DETECT
314
---
(@)HEX
ASCII-TO-HEXADECIMAL
219
---
HKY
HEXADECIMAL KEY INPUT
347
---
(@)IEMS
INDIRECT EM ADDRESSING
320
---
(@)IORD
SPECIAL I/O UNIT READ
354
---
(@)IOWR
SPECIAL I/O UNIT WRITE
355
---
(@)MAX
FIND MAXIMUM
257
---
(@)MBS
SIGNED BINARY MULTIPLY
253
---
(@)MBSL
DOUBLE SIGNED BINARY MULTIPLY
254
141
Page 160
Section 5-6
Coding Right-hand Instructions Code
5-6
Mnemonic
Name
Page
---
(@)MIN
FIND MINIMUM
258
---
MTR
MATRIX INPUT
352
---
(@)NEG
2’S COMPLEMENT
226
---
(@)NEGL
DOUBLE 2’S COMPLEMENT
227
---
PID
PID CONTROL
266
---
(@)PMCR
PROTOCOL MACRO
339
---
(@)RXD
RECEIVE
333
---
(@)SBBL
DOUBLE BINARY SUBTRACT
251
---
(@)SCL
SCALING
222
---
(@)SRCH
DATA SEARCH
318
---
(@)STUP
CHANGE RS-232C SETUP
337
---
(@)SUM
SUM CALCULATE
261
---
(@)TKY
TEN KEY INPUT
350
---
(@)TXD
TRANSMIT
335
---
(@)XDMR
EXPANSION DM READ
319
---
(@)XFR2
EM BLOCK TRANSFER
190
---
ZCPL
DOUBLE AREA RANGE COMPARE
201
Coding Right-hand Instructions Writing mnemonic code for ladder instructions is described in Section 4 Writing and Inputting the Program. 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. 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 place 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.
142
Page 161
Section 5-6
Coding Right-hand Instructions
The following diagram and corresponding mnemonic code illustrates the points described above. 00000
Address Instruction
00001 DIFU(13) 22500 00002
00100
00200
22500 BCNT(67)
01001 01002
LR 6300
Data
00000
LD
00000
00001
AND
00001
00002
OR
00002
00003
DIFU(13)
22500
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 –– 22500
#0150 TIM 000
–– #
MOV(21)
0001 004
HR 00
HR
LR 00
HR 0015
00012
LD
00013
TIM
00500
00014
LD
00015
MOV(21)
00016
LD
00017
OUT NOT
00 00005 000
#
0150
TIM
000 ––
HR
00
LR
00
HR
0015 00500
143
Page 162
Section 5-6
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
22500
R
HR 00
00500
144
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)
LR 6300
HR 0015
END(01)
Data
00000
00011
LD
00012
OUT NOT
01002 LR
6300 –– 22500 ––
HR
00
HR
00
HR
0015 00500
When you have finished coding the program, make sure you have placed END(01) at the last address.
Page 163
Section 5-7
Instruction Set Lists
5-7
Instruction Set Lists This section provides tables of the instructions available in the C200HX/HG/HE. The first table can be used to find instructions by function code. The second table can be used to find instruction by mnemonic. In both tables, the @ symbol indicates instructions with differentiated variations. Note Refer to 5-5 Expansion Instructions for a list of the expansion instructions.
5-7-1 Function Codes The following table lists the 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
9
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
(@) SCAN CYCLE TIME
(@) 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
(@) MSG MESSAGE DISPLAY
(@) LMSG LONG MESSAGE
(@) TERM TERMINAL MODE
---
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
(@) MPRF GROUP-2 HIGH-DENSITY I/O REFRESH
(@) XFRB TRANSFER BITS
(@) LINE COLUMN TO LINE
(@) COLM LINE TO COLUMN
(@) SEC HOURS-TOSECONDS
(@) HMS SECONDSTO-HOURS
(@) BCNT BIT COUNTER
(@) BCMP BLOCK COMPARE
(@) APR ARITHMETIC PROCESS
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/ 8-TO-256 DECODER
(@) DMPX 16-TO-4/ 256-TO-8 ENCODER
(@) SDEC 7-SEGMENT DECODER
(@) FDIV FLOATING POINT DIVIDE
8
(@) DIST SINGLE WORD DISTRIBUTE
(@) COLL DATA COLLECT
(@) MOVB MOVE BIT
(@) MOVD MOVE DIGIT
(@) SFTR REVERSIBLE SHIFT REGISTER
(@) TCMP TABLE COMPARE
(@) ASC ASCII CONVERT
TTIM TOTALIZING COUNTER
ZCP AREA RANGE COMPARE
(@) INT INTERRUPT CONTROL
9
(@) SEND NETWORK SEND
(@) SBS SUBROUTINE ENTRY
SBN SUBROUTINE DEFINE
RET SUBROUTINE RETURN
(@) WDT WATCHDOG TIMER REFRESH
---
---
(@) IORF I/O REFRESH
(@) RECV NETWORK RECEIVE
(@) MCRO MACRO
5-7-2 Alphabetic List by Mnemonic Mnemonic
Code
Words
Name
Page
7SEG
––
4
7-SEGMENT DISPLAY OUTPUT
340
ADB (@)
50
4
BINARY ADD
243
ADBL (@)
––
4
DOUBLE BINARY ADD
249
ADD (@)
30
4
BCD ADD
229
ADDL (@)
54
4
DOUBLE BCD ADD
230
AND
None
1
AND
149
AND LD
None
1
AND LOAD
150
AND NOT
None
1
AND NOT
149
ANDW (@)
34
4
LOGICAL AND
278
APR (@)
69
4
ARITHMETIC PROCESS
263
ASC (@)
86
4
ASCII CONVERT
218
145