The text of a manual · part 19 of 68
Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 155 to 163
Pages 155 to 163 of 613, from Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual
The original document is the PDF (3.8 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.
Filed in the catalog under the Omron C200H-SP001 and Omron C200HW-PA204
Page 155
SECTION 5 Instruction Set The C200HX/HG/HE PCs 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 the C200HX/HG/HE PCs are organized in the following subsections by instruction group. These groups include Ladder Diagram Instructions, Bit Control Instructions, Timer and Counter Instructions, Data Shifting Instructions, Data Movement Instructions, Data Comparison Instructions, Data Conversion Instructions, BCD Calculation Instructions, Binary Calculation Instructions, Symbol Math Instructions, Logic Instructions, Subroutines, Special Instructions, Network Instructions, Serial Communications Instructions, Advanced I/O Instructions, and Special I/O Unit 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 5-2 Instruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 5-3 Data Areas, Definer Values, and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 5-4 Differentiated Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 5-5 Expansion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 5-6 Coding Right-hand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 5-7 Instruction Set Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 5-7-1 Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 5-7-2 Alphabetic List by Mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 5-8 Ladder Diagram Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 5-8-1 LOAD, LOAD NOT, AND, AND NOT, OR, and OR NOT . . . . . . . . . . . . . . . . . 160 5-8-2 AND LOAD and OR LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 5-9 Bit Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 5-9-1 OUTPUT and OUTPUT NOT – OUT and OUT NOT . . . . . . . . . . . . . . . . . . . . . 161 5-9-2 DIFFERENTIATE UP and DOWN – DIFU(013) and DIFD(014) . . . . . . . . . . . . 162 5-9-3 SET and RESET – SET and RSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 5-9-4 KEEP – KEEP(011) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 5-9-5 BIT TEST: TST(350) and TSTN(351) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 5-10 INTERLOCK and INTERLOCK CLEAR – IL(002) and ILC(003) . . . . . . . . . . . . . . . . . . 167 5-11 JUMP and JUMP END – JMP(004) and JME(005) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 5-12 END – END(001) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 5-13 NO OPERATION – NOP(000) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 5-14 Timer and Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 5-14-1 TIMER – TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 5-14-2 HIGH-SPEED TIMER – TIMH(015) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 5-14-3 TOTALIZING TIMER – TTIM(087) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 5-14-4 COUNTER – CNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 5-14-5 REVERSIBLE COUNTER – CNTR(012) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 5-15 Data Shifting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 5-15-1 SHIFT REGISTER – SFT(010) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 5-15-2 REVERSIBLE SHIFT REGISTER – SFTR(084) . . . . . . . . . . . . . . . . . . . . . . . . . 185 5-15-3 ARITHMETIC SHIFT LEFT – ASL(025) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 5-15-4 ARITHMETIC SHIFT RIGHT – ASR(026) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 5-15-5 ROTATE LEFT – ROL(027) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 5-15-6 ROTATE RIGHT – ROR(028) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 5-15-7 ONE DIGIT SHIFT LEFT – SLD(074) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 5-15-8 ONE DIGIT SHIFT RIGHT – SRD(075) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
143
Page 156
Section 5-15-9 WORD SHIFT – WSFT(016) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-10 ASYNCHRONOUS SHIFT REGISTER – ASFT(017) . . . . . . . . . . . . . . . . . . . . 5-16 Data Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-1 MOVE – MOV(021) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-2 MOVE NOT – MVN(022) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-3 BLOCK SET – BSET(071) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-4 BLOCK TRANSFER – XFER(070) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-5 DATA EXCHANGE – XCHG(073) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-6 SINGLE WORD DISTRIBUTE – DIST(080) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-7 DATA COLLECT – COLL(081) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-8 MOVE BIT – MOVB(082) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-9 MOVE DIGIT – MOVD(083) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-10 TRANSFER BITS – XFRB(062) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-11 EM BLOCK TRANSFER – XFR2(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16-12 BLOCK TRANSFER TO OTHER EM BANK – BXF2(––) . . . . . . . . . . . . . . . . 5-16-13 EM BANK TRANSFER – BXFR(125) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17 Data Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-1 MULTI-WORD COMPARE – MCMP(019) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-2 COMPARE – CMP(020) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-3 DOUBLE COMPARE – CMPL(060) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-4 BLOCK COMPARE – BCMP(068) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-5 TABLE COMPARE – TCMP(085) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-6 AREA RANGE COMPARE – ZCP(088) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-7 DOUBLE AREA RANGE COMPARE – ZCPL(116) . . . . . . . . . . . . . . . . . . . . . 5-17-8 SIGNED BINARY COMPARE – CPS(114) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17-9 DOUBLE SIGNED BINARY COMPARE – CPSL(115) . . . . . . . . . . . . . . . . . . . 5-17-10 Input Comparison Instructions (300 to 328) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18 Data Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-1 BCD-TO-BINARY – BIN(023) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-2 DOUBLE BCD-TO-DOUBLE BINARY – BINL(058) . . . . . . . . . . . . . . . . . . . . 5-18-3 BINARY-TO-BCD – BCD(024) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-4 DOUBLE BINARY-TO-DOUBLE BCD – BCDL(059) . . . . . . . . . . . . . . . . . . . . 5-18-5 HOURS-TO-SECONDS – SEC(065) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-6 SECONDS-TO-HOURS – HMS(066) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-7 4-TO-16/8-TO-256 DECODER – MLPX(076) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-8 16-TO-4/256-TO-8 ENCODER – DMPX(077) . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-9 7-SEGMENT DECODER – SDEC(078) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-10 ASCII CONVERT – ASC(086) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-11 ASCII-TO-HEXADECIMAL – HEX(162) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-12 SCALING – SCL(194) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-13 COLUMN TO LINE – LINE(063) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-14 LINE TO COLUMN – COLM(064) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-15 2’S COMPLEMENT – NEG(160) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18-16 DOUBLE 2’S COMPLEMENT – NEGL(161) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19 Symbol Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-1 Binary Addition: +(400)/+L(401)/+C(402)/+CL(403) . . . . . . . . . . . . . . . . . . . . . 5-19-2 BCD Addition: +B(404)/ +BL(405)/+BC(406)/+BCL(407) . . . . . . . . . . . . . . . . . 5-19-3 Binary Subtraction: –(410)/ –L(411)/–C(412)/–CL(413) . . . . . . . . . . . . . . . . . . . 5-19-4 BCD Subtraction: –B(414)/ –BL(415)/–BC(416)/–BCL(417) . . . . . . . . . . . . . . . 5-19-5 Binary Multiplication: *(420)/ *L(421)/*U(422)/*UL(423) . . . . . . . . . . . . . . . . . 5-19-6 BCD Multiplication: *B(424)/ *BL(425) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19-7 Binary Division: /(430)/ /L(431)//U(432)//UL(433) . . . . . . . . . . . . . . . . . . . . . . . 5-19-8 BCD Division: /B(434)/ /BL(435) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
144
190 191 192 192 193 193 195 195 196 197 200 200 201 202 203 204 205 205 206 209 210 212 213 214 215 216 217 220 220 221 221 222 223 224 225 228 231 234 235 238 240 241 242 243 244 244 246 248 253 257 259 261 263
Page 157
Section 5-20 BCD Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-1 INCREMENT – INC(038) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-2 DECREMENT – DEC(039) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-3 SET CARRY – STC(040) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-4 CLEAR CARRY – CLC(041) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-5 BCD ADD – ADD(030) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-6 DOUBLE BCD ADD – ADDL(054) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-7 BCD SUBTRACT – SUB(031) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-8 DOUBLE BCD SUBTRACT – SUBL(055) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-9 BCD MULTIPLY – MUL(032) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-10 DOUBLE BCD MULTIPLY – MULL(056) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-11 BCD DIVIDE – DIV(033) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-12 DOUBLE BCD DIVIDE – DIVL(057) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-13 FLOATING POINT DIVIDE – FDIV(079) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20-14 SQUARE ROOT – ROOT(072) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21 Binary Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-1 BINARY ADD – ADB(050) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-2 BINARY SUBTRACT – SBB(051) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-3 BINARY MULTIPLY – MLB(052) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-4 BINARY DIVIDE – DVB(053) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-5 DOUBLE BINARY ADD – ADBL(480) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-6 DOUBLE BINARY SUBTRACT – SBBL(481) . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-7 SIGNED BINARY MULTIPLY – MBS(484) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-8 DOUBLE SIGNED BINARY MULTIPLY – MBSL(482) . . . . . . . . . . . . . . . . . . 5-21-9 SIGNED BINARY DIVIDE – DBS(485) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21-10 DOUBLE SIGNED BINARY DIVIDE – DBSL(483) . . . . . . . . . . . . . . . . . . . . . 5-22 Special Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-1 FIND MAXIMUM – MAX(182) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-2 FIND MINIMUM – MIN(183) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-3 AVERAGE VALUE – AVG(195) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-4 SUM – SUM(184) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-5 ARITHMETIC PROCESS – APR(069) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22-6 PID CONTROL – PID(190) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-1 COMPLEMENT – COM(029) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-2 LOGICAL AND – ANDW(034) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-3 LOGICAL OR – ORW(035) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-4 EXCLUSIVE OR – XORW(036) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23-5 EXCLUSIVE NOR – XNRW(037) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24 Subroutines and Interrupt Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-1 Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-2 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-3 SUBROUTINE ENTER – SBS(091) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-4 SUBROUTINE DEFINE and RETURN – SBN(092)/RET(093) . . . . . . . . . . . . . 5-24-5 MACRO – MCRO(099) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24-6 INTERRUPT CONTROL – INT(089) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 Step Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25-1 STEP DEFINE and STEP START–STEP(008)/SNXT(009) . . . . . . . . . . . . . . . . 5-26 Special Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-1 FAILURE ALARM – FAL(006) and SEVERE FAILURE ALARM – FALS(007) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-2 CYCLE TIME – SCAN(018) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-3 TRACE MEMORY SAMPLING – TRSM(045) . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-4 MESSAGE DISPLAY – MSG(046) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
264 265 265 265 265 266 267 268 270 271 272 273 274 275 278 280 280 282 285 285 286 288 290 291 292 293 294 294 295 297 299 300 303 313 313 314 315 316 317 317 317 318 321 322 323 325 329 329 338 338 339 340 341
145
Page 158
Section 5-26-5 LONG MESSAGE – LMSG(047) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-6 TERMINAL MODE – TERM(048) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-7 WATCHDOG TIMER REFRESH – WDT(094) . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-8 I/O REFRESH – IORF(097) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-9 GROUP-2 HIGH-DENSITY I/O REFRESH – MPRF(061) . . . . . . . . . . . . . . . . . 5-26-10 BIT COUNTER – BCNT(067) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-11 FRAME CHECKSUM – FCS(180) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-12 FAILURE POINT DETECTION – FPD(269) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-13 DATA SEARCH – SRCH(181) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-14 EXPANSION DM READ – XDMR(280) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-15 INDIRECT EM ADDRESSING – IEMS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26-16 SELECT EM BANK – EMBC(281) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27 Network Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-1 NETWORK SEND – SEND(090) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-2 NETWORK RECEIVE – RECV(098) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27-3 About Network Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28 Serial Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-1 RECEIVE – RXD(235) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-2 TRANSMIT – TXD(236) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-3 CHANGE RS-232C SETUP – STUP(237) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28-4 PROTOCOL MACRO – PMCR(260) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29 Advanced I/O Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-1 DIGITAL SWITCH INPUT – DSW(210) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-2 TEN KEY INPUT – TKY(211) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-3 HEXADECIMAL KEY INPUT – HKY(212) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-4 MATRIX INPUT – MTR(213) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29-5 7-SEGMENT DISPLAY OUTPUT – 7SEG(214) . . . . . . . . . . . . . . . . . . . . . . . . . 5-30 Special I/O Unit Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30-1 SPECIAL I/O UNIT READ – IORD(222) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30-2 SPECIAL I/O UNIT WRITE – IOWR(223) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30-3 PCMCIA CARD MACRO – CMCR(261) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
146
342 343 344 344 345 346 346 348 352 353 354 355 356 356 362 366 368 368 370 373 374 375 376 380 382 385 387 390 391 392 393
Page 159
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 3-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.
147
Page 160
Section
Data Areas, Definer Values, and Flags ! Caution
5-3
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(021), the contents of DM 0001 was 1111, and DM 1111 contained 5555, the value 5555 would be moved to LR 00. MOV(021) 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-26-15 INDIRECT EM ADDRESSING – IEMS(––) for details. Designating Constants
148
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.
Page 161
Section
Differentiated Instructions
5-4
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(021) and @MOV(021), 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(021) HR 10
Diagram A
DM 0000
Address
Instruction
00000 00001
LD MOV(021)
Operands 00000 HR 10 DM 0000
00000
Diagram B
@MOV(021)
Address
Instruction
HR 10
00000 00001
LD @MOV(021)
DM 0000
Operands 00000 HR 10 DM 0000
In diagram A, the non-differentiated MOV(021) 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(021) 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(021) or @MOV(021) 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(002) and IL(003) for the effects of interlocks on differentiated instructions. The C200HX/HG/HE PCs also provide differentiation instructions: DIFU(013) and DIFD(014). DIFU(013) operates the same as a differentiated instruction, but is used to turn ON a bit for one cycle. DIFD(014) 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(013) and DIFD(014) 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.
149
Page 162
Section
Expansion Instructions
5-5
5-5
Expansion Instructions The expansion instructions are a group of instructions that do not have fixed function codes. The function codes set aside for the expansion instructions can be reassigned to any of the expansion instructions, if desired. Default function codes are given for the instructions that have them. An expansion instruction can be assigned one of available function codes using the Programming Console’s Expansion Instruction Function Code Assignments operation. The function codes are: 017, 018, 019, 047, 048, 060 to 069, 087, 088, 089, 114, 115, 116, 160, 161, 162, 180 to 184, 190, 194, 195, 210 to 214, 222, 223, 235, 236, 237, 260, 261, 269, 280, and 281. Refer to 7-2-14 Expansion Instruction Function Code Assignments for details on assigning function codes. Refer to the manual for the SYSMAC-CPT Support Software for details on setting function codes using the SYSMAC-CPT Support Software. Code
150
Mnemonic
Name
Page
017
(@)ASFT
ASYNCHRONOUS SHIFT REGISTER
191
018
(@)SCAN
CYCLE TIME
339
019
(@)MCMP
MULTI-WORD COMPARE
205
047
(@)LMSG
32-CHARACTER MESSAGE
342
048
(@)TERM
TERMINAL MODE
343
060
CMPL
DOUBLE COMPARE
209
061
(@)MPRF
GROUP-2 HIGH-DENSITY I/O REFRESH
345
062
(@)XFRB
TRANSFER BITS
201
063
(@)LINE
COLUMN TO LINE
240
064
(@)COLM
LINE TO COLUMN
241
065
(@)SEC
HOURS TO SECONDS
223
066
(@)HMS
SECONDS TO HOURS
224
067
(@)BCNT
BIT COUNTER
346
068
(@)BCMP
BLOCK COMPARE
210
069
(@)APR
ARITHMETIC PROCESS
300
087
TTIM
TOTALIZING TIMER
177
088
ZCP
AREA RANGE COMPARE
213
089
(@)INT
INTERRUPT CONTROL
325
114
CPS
SIGNED BINARY COMPARE
215
115
CPSL
DOUBLE SIGNED BINARY COMPARE
216
116
ZCPL
DOUBLE AREA RANGE COMPARE
214
160
(@)NEG
2’S COMPLEMENT
242
161
(@)NEGL
DOUBLE 2’S COMPLEMENT
243
162
(@)HEX
ASCII-TO-HEX CONVERSION
235
180
(@)FCS
FCS CALCULATE
346
181
(@)SRCH
DATA SEARCH
352
182
(@)MAX
FIND MAXIMUM
294
183
(@)MIN
FIND MINIMUM
295
184
(@)SUM
SUM CALCULATE
299
190
PID
PID CONTROL
303
194
(@)SCL
SCALING
238
195
AVG
AVERAGE VALUE
297
210
DSW
DIGITAL SWITCH INPUT
376
211
(@)TKY
TEN KEY INPUT
380
212
HKY
HEXADECIMAL KEY INPUT
382
213
MTR
MATRIX INPUT
385
Page 163
Section
Coding Right-hand Instructions Code
Mnemonic
Name
5-6 Page
214
7SEG
7-SEGMENT DISPLAY OUTPUT
387
222
(@)IORD
SPECIAL I/O UNIT READ
391
223
(@)IOWR
SPECIAL I/O UNIT WRITE
392
235
(@)RXD
RECEIVE
368
236
(@)TXD
TRANSMIT
370
237
(@)STUP
CHANGE RS-232C SETUP
373
260
(@)PMCR
PROTOCOL MACRO
374
269
FPD
FAILURE POINT DETECT
348
280
(@)XDMR
EXPANSION DM READ
353
281
(@)EMBC
SELECT EM BANK
355
The following expansion instructions can also be used if they are allocated any of the above function codes to replace the default instructions. Mnemonic
5-6
Name
Page
(@)ADBL
DOUBLE BINARY ADD
286
(@)SBBL
DOUBLE BINARY SUBTRACT
288
(@)MBSL
DOUBLE SIGNED BINARY MULTIPLY
291
(@)DBSL
DOUBLE SIGNED BINARY DIVIDE
293
(@)MBS
SIGNED BINARY MULTIPLY
290
(@)DBS
SIGNED BINARY DIVIDE
292
(@)BXF2
EM BANK TRANSFER
203
(@)IEMS
INDIRECT EM ADDRESSING
354
(@)XFR2
EM BLOCK TRANSFER
202
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.
151