The text of a manual · part 18 of 60
C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 164 to 173
Pages 164 to 173 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 164
Section 5-7
Instruction Set Lists Mnemonic
Code
Words
ASFT(@)
17
4
ASYNCHRONOUS SHIFT REGISTER
178
ASL (@)
25
2
ARITHMETIC SHIFT LEFT
175
ASR (@)
26
2
ARITHMETIC SHIFT RIGHT
175
AVG (@)
––
4
AVERAGE VALUE
259
BCD (@)
24
3
BINARY TO BCD
205
BCDL (@)
59
3
DOUBLE BINARY-TO-DOUBLE BCD
206
BCMP (@)
68
4
BLOCK COMPARE
197
BCNT (@)
67
4
BIT COUNTER
312
BIN (@)
23
3
BCD-TO-BINARY
204
BINL (@)
58
3
DOUBLE BCD-TO-DOUBLE BINARY
205
BSET (@)
71
4
BLOCK SET
181
BXF2 (@)
––
4
EM BLOCK TRANSFER
190
CLC (@)
41
1
CLEAR CARRY
229
CMCR (@)
––
4
PCMCIA CARD MACRO
357
CMP
20
3
COMPARE
193
CMPL
60
4
DOUBLE COMPARE
196
CNT
None
2
COUNTER
166
CNTR
12
3
REVERSIBLE COUNTER
169
COLL (@)
81
4
DATA COLLECT
185
COLM(@)
64
4
LINE TO COLUMN
225
COM (@)
29
2
COMPLEMENT
277
CPS
––
4
SIGNED BINARY COMPARE
202
CPSL
––
4
DOUBLE SIGNED BINARY COMPARE
203
DBS (@)
––
4
SIGNED BINARY DIVIDE
255
DBSL (@)
––
4
DOUBLE SIGNED BINARY DIVIDE
256
DEC (@)
39
2
BCD DECREMENT
228
DIFD
14
2
DIFFERENTIATE DOWN
151
DIFU
13
2
DIFFERENTIATE UP
151
DIST (@)
80
4
SINGLE WORD DISTRIBUTE
183
DIV (@)
33
4
BCD DIVIDE
236
DIVL (@)
57
4
DOUBLE BCD DIVIDE
237
DMPX (@)
77
4
16-TO-4/256-TO-8 ENCODER
212
DSW
––
4
DIGITAL SWITCH
343
DVB (@)
53
4
BINARY DIVIDE
248
EMBC (@)
––
2
SELECT EM BANK
321
END
01
1
END
158
FAL (@)
06
2
FAILURE ALARM AND RESET
304
FALS
07
2
SEVERE FAILURE ALARM
304
FCS (@)
––
4
FCS CALCULATE
312
FDIV (@)
79
4
FLOATING POINT DIVIDE
238
FPD
––
4
FAILURE POINT DETECT
314
HEX (@)
––
4
ASCII-TO-HEXADECIMAL
219
HKY
––
4
HEXADECIMAL KEY INPUT
347
HMS (@)
66
4
SECONDS TO HOURS
208
IEMS (@)
––
2
INDIRECT EM ADDRESSING
320
IL
02
1
INTERLOCK
155
ILC
03
1
INTERLOCK CLEAR
155
INC (@)
38
2
INCREMENT
228
INT (@)
89
4
INTERRUPT CONTROL
289
146
Name
Page
Page 165
Section 5-7
Instruction Set Lists Mnemonic
Code
Words
Name
Page
IORD (@)
––
4
SPECIAL I/O UNIT READ
354
IORF (@)
97
3
I/O REFRESH
310
IOWR (@)
––
4
SPECIAL I/O UNIT WRITE
355
JME
05
2
JUMP END
157
JMP
04
2
JUMP
157
KEEP
11
2
KEEP
154
LD
None
1
LOAD
149
LD NOT
None
1
LOAD NOT
149
LINE (@)
63
4
COLUMN TO LINE
224
LMSG (@)
47
4
32-CHARACTER MESSAGE
308
MAX (@)
––
4
FIND MAXIMUM
257
MBS (@)
––
4
SIGNED BINARY MULTIPLY
253
MBSL (@)
––
4
DOUBLE SIGNED BINARY MULTIPLY
254
MCMP (@)
19
4
MULTI-WORD COMPARE
192
MCRO (@)
99
4
MACRO
287
MIN (@)
––
4
FIND MINIMUM
258
MLB (@)
52
4
BINARY MULTIPLY
248
MLPX (@)
76
4
4-TO-16/8-TO-256 DECODER
209
MOV (@)
21
3
MOVE
180
MOVB (@)
82
4
MOVE BIT
187
MOVD (@)
83
4
MOVE DIGIT
188
MPRF (@)
61
4
GROUP-2 HIGH-DENSITY I/O REFRESH
311
MSG (@)
46
2
MESSAGE
307
MTR
––
4
MATRIX INPUT
352
MUL (@)
32
4
BCD MULTIPLY
235
MULL (@)
56
4
DOUBLE BCD MULTIPLY
236
MVN (@)
22
3
MOVE NOT
180
NEG
––
4
2’S COMPLEMENT
226
NEGL
––
4
DOUBLE 2’S COMPLEMENT
227
NOP
00
1
NO OPERATION
158
OR
None
1
OR
149
OR LD
None
1
OR LOAD
150
OR NOT
None
1
OR NOT
149
ORW (@)
35
4
LOGICAL OR
279
OUT
None
2
OUTPUT
150
OUT NOT
None
2
OUTPUT NOT
150
PID (@)
––
4
PID CONTROL
266
PMCR (@)
––
4
PROTOCOL MACRO
339
RECV (@)
98
4
NETWORK RECEIVE
327
RET
93
1
SUBROUTINE RETURN
286
ROL (@)
27
2
ROTATE LEFT
176
ROOT (@)
72
3
SQUARE ROOT
241
ROR (@)
28
2
ROTATE RIGHT
176
RSET
None
2
RESET
153
RXD(@)
––
4
RECEIVE
333
SBB (@)
51
4
BINARY SUBTRACT
245
SBBL (@)
––
4
DOUBLE BINARY SUBTRACT
251
SBN
92
2
SUBROUTINE DEFINE
286
SBS (@)
91
2
SUBROUTINE ENTRY
285
147
Page 166
Section 5-7
Instruction Set Lists Mnemonic
Code
Words
SCAN (@)
18
4
CYCLE TIME
305
SCL (@)
––
4
SCALING
222
SDEC (@)
78
4
7-SEGMENT DECODER
215
SEC (@)
65
4
HOURS TO SECONDS
207
SEND (@)
90
4
NETWORK SEND
322
SET
None
2
SET
153
SFT
10
3
SHIFT REGISTER
171
SFTR (@)
84
4
REVERSIBLE SHIFT REGISTER
173
SLD (@)
74
3
ONE DIGIT SHIFT LEFT
177
SNXT
09
2
STEP START
295
SRCH (@)
––
4
DATA SEARCH
318
SRD (@)
75
3
ONE DIGIT SHIFT RIGHT
177
STC (@)
40
1
SET CARRY
229
STEP
08
2
STEP DEFINE
295
STUP (@)
––
2
CHANGE RS-232C SETUP
337
SUB (@)
31
4
BCD SUBTRACT
231
SUBL (@)
55
4
DOUBLE BCD SUBTRACT
233
SUM (@)
––
4
SUM CALCULATION
261
TCMP (@)
85
4
TABLE COMPARE
199
TERM (@)
48
4
TERMINAL MODE
309
TIM
None
2
TIMER
159
TIMH
15
3
HIGH-SPEED TIMER
164
TKY (@)
––
4
TEN KEY INPUT
350
TRSM
45
1
TRACE MEMORY SAMPLE
306
TTIM
87
4
TOTALIZING TIMER
165
TXD (@)
––
4
TRANSMIT
335
WDT (@)
94
2
WATCHDOG TIMER REFRESH
310
WSFT (@)
16
3
WORD SHIFT
178
XCHG (@)
73
3
DATA EXCHANGE
183
XDMR (@)
––
4
EXPANSION DM READ
319
XFER (@)
70
4
BLOCK TRANSFER
182
XFR2 (@)
––
4
EM BLOCK TRANSFER
190
XFRB (@)
62
4
TRANSFER BITS
189
XNRW (@)
37
4
EXCLUSIVE NOR
281
XORW (@)
36
4
EXCLUSIVE OR
280
ZCP
88
4
AREA RANGE COMPARE
200
ZCPL
––
4
DOUBLE AREA RANGE COMPARE
201
148
Name
Page
Page 167
Section 5-8
Ladder Diagram Instructions
5-8
Ladder Diagram Instructions Ladder Diagram instructions include Ladder instructions and Logic Block instructions and correspond to the conditions on the ladder diagram. Logic block instructions are used to relate more complex parts.
5-8-1 LOAD, LOAD NOT, AND, AND NOT, OR, and OR NOT Ladder Symbols
Operand Data Areas
B
B: Bit
LOAD – LD
IR, SR, AR, HR, TC, LR, TR
B: Bit
B
LOAD NOT – LD NOT
IR, SR, AR, HR, TC, LR
B: Bit
B
AND – AND IR, SR, AR, HR, TC, LR
B: Bit
B
AND NOT – AND NOT
IR, SR, AR, HR, TC, LR
B: Bit
OR – OR
B
OR NOT – OR NOT
B
IR, SR, AR, HR, TC, LR
B: Bit IR, SR, AR, HR, TC, LR
Limitations
There is no limit to the number of any of these instructions, or restrictions in the order in which they must be used, as long as the memory capacity of the PC is not exceeded.
Description
These six basic instructions correspond to the conditions on a ladder diagram. As described in Section 4 Writing and Inputting the Program, the status of the bits assigned to each instruction determines the execution conditions for all other instructions. Each of these instructions and each bit address can be used as many times as required. Each can be used in as many of these instructions as required. The status of the bit operand (B) assigned to LD or LD NOT determines the first execution condition. AND takes the logical AND between the execution condition and the status of its bit operand; AND NOT, the logical AND between the execution condition and the inverse of the status of its bit operand. OR takes the logical OR between the execution condition and the status of its bit operand; OR NOT, the logical OR between the execution condition and the inverse of the status of its bit operand. The ladder symbol for loading TR bits is different from that shown above. Refer to 4-4-3 Ladder Instructions for details.
Flags
There are no flags affected by these instructions.
149
Page 168
Section 5-9
Bit Control Instructions
5-8-2 AND LOAD and OR LOAD AND LOAD – AND LD Ladder Symbol
00000
00002
00001
00003
OR LOAD – OR LD 00000
00001
00002
00003
Ladder Symbol
Description
When instructions are combined into blocks that cannot be logically combined using only OR and AND operations, AND LD and OR LD are used. Whereas AND and OR operations logically combine a bit status and an execution condition, AND LD and OR LD logically combine two execution conditions, the current one and the last unused one. In order to draw ladder diagrams, it is not necessary to use AND LD and OR LD instructions, nor are they necessary when inputting ladder diagrams directly, as is possible from SSS. They are required, however, to convert the program to and input it in mnemonic form. The procedures for these, limitations for different procedures, and examples are provided in 4-7 Inputting, Modifying, and Checking the Program. In order to reduce the number of programming instructions required, a basic understanding of logic block instructions is required. For an introduction to logic blocks, refer to 4-4-6 Logic Block Instructions.
Flags
There are no flags affected by these instructions.
5-9
Bit Control Instructions There are five instructions that can be used generally to control individual bit status. These are OUT, OUT NOT, DIFU(13), DIFD(14), and KEEP(11). These instructions are used to turn bits ON and OFF in different ways.
5-9-1 OUTPUT and OUTPUT NOT – OUT and OUT NOT OUTPUT – OUT
Ladder Symbol
Operand Data Areas B: Bit B
OUTPUT NOT – OUT NOT
Ladder Symbol
IR, SR, AR, HR, TC, LR, TR
Operand Data Areas B: Bit B
IR, SR, AR, HR, TC, LR
Limitations
Any output bit can generally be used in only one instruction that controls its status. Refer to 3-3 IR Area for details.
Description
OUT and OUT NOT are used to control the status of the designated bit according to the execution condition.
150
Page 169
Section 5-9
Bit Control Instructions
OUT turns ON the designated bit for an ON execution condition, and turns OFF the designated bit for an OFF execution condition. With a TR bit, OUT appears at a branching point rather than at the end of an instruction line. Refer to 4-7-7 Branching Instruction Lines for details. OUT NOT turns ON the designated bit for a OFF execution condition, and turns OFF the designated bit for an ON execution condition. OUT and OUT NOT can be used to control execution by turning ON and OFF bits that are assigned to conditions on the ladder diagram, thus determining execution conditions for other instructions. This is particularly helpful and allows a complex set of conditions to be used to control the status of a single work bit, and then that work bit can be used to control other instructions. The length of time that a bit is ON or OFF can be controlled by combining the OUT or OUT NOT with TIM. Refer to Examples under 5-14-1 TIMER – TIM for details. Flags
There are no flags affected by these instructions.
5-9-2 DIFFERENTIATE UP and DOWN – DIFU(13) and DIFD(14) Ladder Symbols
Operand Data Areas
DIFU(13) B
B: Bit IR, AR, HR, LR
DIFD(14) B
B: Bit IR, AR, HR, LR
Limitations
Any output bit can generally be used in only one instruction that controls its status. Refer to 3-3 IR Area for details.
Description
DIFU(13) and DIFD(14) are used to turn the designated bit ON for one cycle only. Whenever executed, DIFU(13) compares its current execution with the previous execution condition. If the previous execution condition was OFF and the current one is ON, DIFU(13) will turn ON the designated bit. If the previous execution condition was ON and the current execution condition is either ON or OFF, DIFU(13) will either turn the designated bit OFF or leave it OFF (i.e., if the designated bit is already OFF). The designated bit will thus never be ON for longer than one cycle, assuming it is executed each cycle (see Precautions, below). Whenever executed, DIFD(14) compares its current execution with the previous execution condition. If the previous execution condition was ON and the current one is OFF, DIFD(14) will turn ON the designated bit. If the previous execution condition was OFF and the current execution condition is either ON or OFF, DIFD(14) will either turn the designated bit OFF or leave it OFF. The designated bit will thus never be ON for longer than one cycle, assuming it is executed each cycle (see Precautions, below). These instructions are used when differentiated instructions (i.e., those prefixed with an @) are not available and single-cycle execution of a particular instruction is desired. They can also be used with non-differentiated forms of instructions that have differentiated forms when their use will simplify programming. Examples of these are shown below.
Flags
There are no flags affected by these instructions.
151
Page 170
Section 5-9
Bit Control Instructions Precautions
DIFU(13) and DIFD(14) operation can be uncertain when the instructions are programmed between IL and ILC, between JMP and JME, or in subroutines. Refer to 5-10 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03), 5-11 JUMP and JUMP END – JMP(04) and JME(05), and 5-23 Subroutines and Interrupt Control for details.
Example 1: When There is No Differentiated Instruction
In diagram A, below, whenever CMP(20) is executed with an ON execution condition it will compare the contents of the two operand words (HR 10 and DM 0000) and set the arithmetic flags (GR, EQ, and LE) accordingly. If the execution condition remains ON, flag status may be changed each cycle if the content of one or both operands change. Diagram B, however, is an example of how DIFU(13) can be used to ensure that CMP(20) is executed only once each time the desired execution condition goes ON.
00000 CMP(20) HR 10
Diagram A
DM 0000
Address
Instruction
00000 00001
LD CMP(20)
Operands 00000 HR DM
10 0000
00000 DIFU(13) 22500 22500 CMP(20) HR 10
Diagram B
DM 0000
Address
Instruction
00000 00001 00002 00003
LD DIFU(13) LD CMP(20)
Operands 00000 22500 22500 HR DM
Example 2: Simplifying Programming
Although a differentiated form of MOV(21) is available, the following diagram would be very complicated to draw using it because only one of the conditions determining the execution condition for MOV(21) requires differentiated treatment.
00000 DIFU(13) 22500 22500 MOV(21) 00001
00002
00003
HR 10 DM 0000
00004
00005
Address
Instruction
00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010
LD DIFU(13) LD LD AND NOT AND NOT OR LD LD AND NOT OR LD MOV(21)
Operands 00000 22500 22500 00001 00002 00003 --00004 00005 --HR DM
152
10 0000
10 0000
Page 171
Section 5-9
Bit Control Instructions
5-9-3 SET and RESET – SET and RSET Ladder Symbols
Operand Data Areas B: Bit
SET B
IR, SR, AR, HR, LR
B: Bit
RSET B
IR, SR, AR, HR, LR
Description
SET turns the operand bit ON when the execution condition is ON, and does not affect the status of the operand bit when the execution condition is OFF. RSET turns the operand bit OFF when the execution condition is ON, and does not affect the status of the operand bit when the execution condition is OFF. The operation of SET differs from that of OUT because the OUT instruction turns the operand bit OFF when its execution condition is OFF. Likewise, RSET differs from OUT NOT because OUT NOT turns the operand bit ON when its execution condition is OFF. Note The instructions SET and RESET are input as follows: Operand SET: RESET:
Operand
Precautions
The status of operand bits for SET and RSET programmed between IL(02) and ILC(03) or JMP(04) and JME(05) will not change when the interlock or jump condition is met (i.e., when IL(02) or JMP(04) is executed with an OFF execution condition).
Flags
There are no flags affected by these instructions.
Examples
The following examples demonstrate the difference between OUT and SET/ RSET. In the first example (Diagram A), IR 10000 will be turned ON or OFF whenever IR 00000 goes ON or OFF. In the second example (Diagram B), IR 10000 will be turned ON when IR 00001 goes ON and will remain ON (even if IR 00001 goes OFF) until IR 00002 goes ON. 00000 10000
Diagram A
Address
Instruction
00000 00001
LD OUT
Address
Instruction
00000 00001 00002 00003
LD SET LD RSET
Operands 00000 10000
00001 SET 10000 00002 RSET 10000
Diagram B
Operands 00001 10000 00002 10000
153
Page 172
Section 5-9
Bit Control Instructions
5-9-4 KEEP – KEEP(11) Ladder Symbol
Operand Data Areas S
B: Bit
KEEP(11) B
IR, AR, HR, LR
R
Limitations
Any output bit can generally be used in only one instruction that controls its status. Refer to 3-3 IR Area for details.
Description
KEEP(11) is used to maintain the status of the designated bit based on two execution conditions. These execution conditions are labeled S and R. S is the set input; R, the reset input. KEEP(11) operates like a latching relay that is set by S and reset by R. When S turns ON, the designated bit will go ON and stay ON until reset, regardless of whether S stays ON or goes OFF. When R turns ON, the designated bit will go OFF and stay OFF until reset, regardless of whether R stays ON or goes OFF. The relationship between execution conditions and KEEP(11) bit status is shown below. S execution condition R execution condition
Status of B
KEEP(11) operates like the self-maintaining bit described in 4-8-3 Self-maintaining Bits. The following two diagrams would function identically, though the one using KEEP(11) requires one less instruction to program and would maintain status even in an interlocked program section. 00002
00003
Address
Instruction
00000 00001 00002 00003
LD OR AND NOT OUT
S
Address
Instruction
R
00000 00001 00002
LD LD KEEP(11)
00500 00500
00002
KEEP(11) 00500
00003
Operands 00002 00500 00003 00500
Operands 00002 00003 00500
Flags
There are no flags affected by this instruction.
Precautions
Exercise caution when using a KEEP reset line that is controlled by an external normally closed device. Never use an input bit in an inverse condition on the reset (R) for KEEP(11) when the input device uses an AC power supply. The delay in shutting down the PC’s DC power supply (relative to the AC power supply to
154
Page 173
Section 5-10
INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03)
the input device) can cause the designated bit of KEEP(11) to be reset. This situation is shown below. Input Unit A
S KEEP(11)
NEVER
B
A R
Bits used in KEEP are not reset in interlocks. Refer to the 5-10 INTERLOCK – and INTERLOCK CLEAR IL(02) and ILC(03) for details. Example
If a HR bit or an AR bit is used, bit status will be retained even during a power interruption. KEEP(11) can thus be used to program bits that will maintain status after restarting the PC following a power interruption. An example of this that can be used to produce a warning display following a system shutdown for an emergency situation is shown below. Bits 00002, 00003, and 00004 would be turned ON to indicate some type of error. Bit 00005 would be turned ON to reset the warning display. HR 0000, which is turned ON when any one of the three bits indicates an emergency situation, is used to turn ON the warning indicator through 00500.
00002
S KEEP(11)
00003
Indicates emergency situation
HR 0000
00004 R Reset input 00005
HR 0000 00500
Address
Instruction
00000 00001 00002 00003 00004 00005 00006
LD OR OR LD KEEP(11) LD OUT
Operands
HR HR
00002 00003 00004 00005 0000 0000 00500
Activates warning display
KEEP(11) can also be combined with TIM to produce delays in turning bits ON and OFF. Refer to 5-14-1 TIMER – TIM for details.
5-10 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03)
Description
Ladder Symbol
IL(02)
Ladder Symbol
ILC(03)
IL(02) is always used in conjunction with ILC(03) to create interlocks. Interlocks are used to enable branching in the same way as can be achieved with TR bits, but treatment of instructions between IL(02) and ILC(03) differs from that with TR bits when the execution condition for IL(02) is OFF. If the execution condition of IL(02) is ON, the program will be executed as written, with an ON execution condition used to start each instruction line from the point where IL(02) is located through the next ILC(03). Refer to 4-7-7 Branching Instruction Lines for basic descriptions of both methods. If the execution condition for IL(02) is OFF, the interlocked section between IL(02) and ILC(03) will be treated as shown in the following table:
155