The text of a manual · part 22 of 60
C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 204 to 213
Pages 204 to 213 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 204
Section 5-16
Data Movement Example
In the following example, the content of C (HR 00) is 9010, and COLL(81) is used to copy the oldest entries from a10-word stack (IR 001 to IR 010) to LR 20. 00001 DIST(80) 001 HR 00
Address
Instruction
00000 00001
LD COLL(81)
Operands 00001 001 00 20
LR 20
HR LR
Before execution IR 001 Stack pointer
Stack pointer decremented
0 0 0 2
After one execution IR 001
Stack pointer decremented
After two executions IR 001
0 0 0 1
0 0 0 0 IR 002
IR 002
IR 002
1 2 3 4
A B C D
IR 003
IR 003
IR 003
IR 010
IR 010
A B C D Stack area
IR 010
Output
LIFO Stack Operation (C=8000 to 8999)
Output
LR 20
LR 20
1 2 3 4
A B C D
When the execution condition is OFF, COLL(81) is not executed. When the execution condition is ON, COLL(81) copies the data most recently recorded in the stack to D. The stack pointer, SBs, is then decremented by 1. Digits of C:
3 2 1 0
Specifies the stack length (000 to 999). A value of 8 indicates LIFO stack operation.
Data can be added to the stack until it is full. DIST(80)’s stack operation can be used together with COLL(81)’s read stack operation. COLL(81) can be set to read on a FIFO or LIFO basis. Refer to 5-16-6 SINGLE WORD DISTRIBUTE (80) for details. Note LIFO stands for Last-In-First-Out.
186
Page 205
Section 5-16
Data Movement Example
In the following example, the content of C (HR 00) is 8010, and COLL(81) is used to copy the most recent entries from a 10-word stack (IR 001 to IR 010) to LR 20. 00001 COLL(81) 001 HR 00
Address
Instruction
00000 00001
LD COLL(81)
Operands 00001
LR 20
HR LR
Before execution IR 001 Stack pointer
Stack pointer decremented
0 0 0 2
After one execution IR 001
Stack pointer decremented
001 00 20
After two executions IR 001
0 0 0 1
0 0 0 0 IR 002
IR 002
IR 002
1 2 3 4
1 2 3 4
IR 003
IR 003
IR 003
IR 010
IR 010
A B C D Stack area
IR 010
Flags
ER:
Output
Output
LR 20
LR 20
A B C D
1 2 3 4
The content of C is not BCD or 6655<C<8000. When C≤6655, DBs and DBs+C are not in the same data area. When C≥8000, the beginning and end of the stack are not in the same data area or the value of the stack pointer exceeds the length of the stack. Indirectly addressed DM word is non-existent. (Content of ∗DM word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON when the transferred data is zero; otherwise OFF.
5-16-8 MOVE BIT – MOVB(82) Operand Data Areas S: Source word
Ladder Symbols
IR, SR, AR, DM, HR, LR, # MOVB(82)
@MOVB(82)
S
S
Bi
Bi
D
D
Bi: Bit designator (BCD)
Limitations
IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, LR
The rightmost two digits and the leftmost two digits of Bi must each be between 00 and 15.
187
Page 206
Section 5-16
Data Movement Description
When the execution condition is OFF, MOVB(82) is not executed. When the execution condition is ON, MOVB(82) copies the specified bit of S to the specified bit in D. The bits in S and D are specified by Bi. The rightmost two digits of Bi designate the source bit; the leftmost two bits designate the destination bit. Bit 15
Bi
Bi MSB 1
2
0
1
0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 Bit 15
LSB
S
Bit 00
1
2
0
1
Bit 00
0 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1
Source bit (00 to 15) Bit 15
Destination bit (00 to 15)
D Flags
ER:
Bit 00
0 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1
C is not BCD, or it is specifying a non-existent bit (i.e., bit specification must be between 00 and 15). Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
N:
ON if the leftmost bit of the content of word D is 1, otherwise OFF.
5-16-9 MOVE DIGIT – MOVD(83) Operand Data Areas S: Source word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, # MOVD(83)
@MOVD(83)
S
S
Di
Di
D
D
Di: Digit designator (BCD) IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, TC, LR
Limitations
The rightmost three digits of Di must each be between 0 and 3.
Description
When the execution condition is OFF, MOVD(83) is not executed. When the execution condition is ON, MOVD(83) copies the content of the specified digit(s) in S to the specified digit(s) in D. Up to four digits can be transferred at one time. The first digit to be copied, the number of digits to be copied, and the first digit to receive the copy are designated in Di as shown below. Digits from S will be copied to consecutive digits in D starting from the designated first digit and continued for the designated number of digits. If the last digit is reached in either S or D, further digits are used starting back at digit 0. Digit number:
3 2 1 0
First digit in S (0 to 3) Number of digits (0 to 3) 0: 1 digit 1: 2 digits 2: 3 digits 3: 4 digits First digit in D (0 to 3) Not used.
188
Page 207
Data Movement
Section 5-16
Digit Designator
The following show examples of the data movements for various values of Di. Di: 0010
Di: 0030
S
D
S
D
0
0
0
0
1
1
1
1
2
2
2
2
3
3
3
3
S
D
S
D
0
0
0
0
1
1
1
1
2
2
2
2
3
3
3
3
Di: 0031
Flags
ER:
Di: 0023
At least one of the rightmost three digits of Di is not between 0 and 3. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
5-16-10 TRANSFER BITS – XFRB(62) Operand Data Areas C: Control word
Ladder Symbols
IR, SR, AR, DM, TC, HR, LR, # XFRB(62)
@XFRB(62)
C
C
S
S
D
D
S: First source word
Limitations
IR, SR, AR, DM, HR, TC, LR D: First destination word IR, SR, AR, DM, HR, LR
The specified source bits must be in the same data area. The specified destination bits must be in the same data area.
Description
When the execution condition is OFF, XFRB(62) is not executed. When the execution condition is ON, XFRB(62) copies the specified source bits to the specified destination bits. The two rightmost digits of C specify the starting bits in S and D and the leftmost two digits indicate the number of bits that will be copied. C MSB
LSB First bit of S (0 to F) First bit of D (0 to F) Number of bits (01 to FF)
Note Up to 255 (FF) bits can be copied at one time.
189
Page 208
Section 5-16
Data Movement Example
In the following example, XFRB(62) is used to transfer 5 bits from IR 020 to LR 21 when IR 00001 is ON. The starting bit in IR 020 is 0, and the starting bit in LR 21 is 4, so IR 02000 to IR 02004 are copied to LR 2104 to LR 2108. 00001 XFRB(62) #0540 IR 020
Address
Instruction
00000 00001
LD XFRB(62)
Operands 00001 #
LR 21
LR
Bit 00
Bit 15
S (IR 020)
0 1 0 1 0 1 0 0 0 0 0 1 0 1 1 1
Bit 00
Bit 15
D (LR 21)
Flags
ER:
0540 020 21
0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 1
The specified source bits are not all in the same data area. The specified destination bits are not all in the same data area. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
5-16-11 EM BLOCK TRANSFER – XFR2(––) Operand Data Areas N: Number of words (BCD)
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, # XFR2(––)
@XFR2(––)
N
N
S
S
D
D
S: Starting source word
Limitations
IR, SR, AR, DM, HR, TC, LR, # D: Starting destination word IR, SR, AR, DM, HR, TC, LR, #
S and S+N must be in the same data area, as must D and D+N. N must be BCD.
Description
When the execution condition is OFF, XFR2(––) is not executed. When the execution condition is ON, XFR2(––) copies the contents of S, S+1, ..., S+N to D, D+1, ..., D+N. If a constant is used for S or D, the constant specifies an address in the current EM bank.
Flags
ER:
N is not BCD. S and S+N or D and D+N are not in the same data area. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
190
Page 209
Section 5-16
Data Movement Example
The following example copies the contents of the 300 words from DM 0000 through DM 0299 to EM 2000 through EM 2299 in the current EM bank.
00000 XFR2(––) #0300
Address
Instruction
00200 00201
LD XFR2(––)
Operands 00000 # DM #
DM 0000 #2000
0300 0000 2000
5-16-12 EM BANK TRANSFER – BXF2(––) Operand Data Areas C: FIrst control word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, # BXF2(––)
@BXF2(––)
C
C
S
S
D
D
S: Starting source word
Limitations
IR, SR, AR, DM, HR, TC, LR, # D: Starting destination word IR, SR, AR, DM, HR, TC, LR, #
The value in C+1 must be BCD from 1 to 6144. S and S+N must be in the same data area, as must D and D+N.
Description
When the execution condition is OFF, BXF2(––) is not executed. When the execution condition is ON, BXF2(––) copies the contents of S, S+1, ..., S+N to D, D+1, ..., D+N. If a constant is used for S or D, the constant specifies an address in the source or destination EM bank specified in C.
Control Words
C contains the source and destination bank numbers if data is being transferred to or from EM. The bank numbers are ignored unless a constant is used for S or D. C+1 contains the number of words to transfer and must be BCD (1 to 6144). Control word Bits C 0 to 7 8 to 15 C+1 0 to 15
Flags
ER:
Function Specifies the source bank number (00 to 02). Specifies the destination bank number (00 to 02). Specifies the number of words to transfer (1 to 6144).
N is not BCD. S and S+N or D and D+N are not in the same data area. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
191
Page 210
Section 5-17
Data Comparison Example
The following example copies the contents of the 300 words from DM 0000 through DM 0299 to EM 2000 through EM 2299 in the EM bank 01. (EM bank 00 isn’t used as the source because S isn’t a constant.)
00000
Address
Instruction
00200 00201
LD BXF2(––)
BXF2(––) DM 1000
Operands 00000 DM DM #
DM 0000 #2000
C: DM 1000 0
1
0
1000 0000 2000
C+1: DM 1001 0
0
Source bank number (00)
3
0
0
Number of words (300)
Destination bank number (01)
5-17 Data Comparison 5-17-1 MULTI-WORD COMPARE – MCMP(19) Operand Data Areas TB1: First word of table 1
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR MCMP(19)
@MCMP(19)
TB1
TB1
TB2
TB2
R
R
TB2: First word of table 2 IR, SR, AR, DM, HR, TC, LR R: Result word IR, AR, DM, HR, TC, LR
Limitations
TB1 and TB1+15 must be in the same data area, as must TB2 and TB2+15.
Description
When the execution condition is OFF, MCMP(19) is not executed. When the execution condition is ON, MCMP(19) compares the content of TB1 to TB2, TB1+1 to TB2+1, TB1+2 to TB2+2, ..., and TB1+15 to TB2+15. If the first pair is equal, the first bit in R is turned OFF, etc., i.e., if the content of TB1 equals the content of TB2, bit 00 is turned OFF, if the content of TB1+1 equals the content of TB2+1, bit 01 is turned OFF, etc. The rest of the bits in R will be turned ON.
Flags
ER:
One of the tables (i.e., TB1 through TB1+15, or TB2 through TB2+15) exceeds the data area. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
192
Page 211
Section 5-17
Data Comparison Example
The following example shows the comparisons made and the results provided for MCMP(19). Here, the comparison is made during each cycle when 00000 is ON.
00000 MCMP(19) 100 DM 0200
Address
Instruction
00000 00001
LD MCMP(19)
Operands 00000
DM 0300
DM DM
TB1: IR 100 IR 100 IR 101 IR 102 IR 103 IR 104 IR 105 IR 106 IR 107 IR 108 IR 109 IR 110 IR 111 IR 112 IR 113 IR 114 IR 115
TB2: DM 0200
0100 0200 0210 ABCD ABCD ABCD ABCD 0800 0900 1000 ABCD ABCD ABCD 1400 0210 1212
DM 0200 DM 0201 DM 0202 DM 0203 DM 0204 DM 0205 DM 0206 DM 0207 DM 0208 DM 0209 DM 0210 DM 0211 DM 0212 DM 0213 DM 0214 DM 0215
0100 0200 0210 0400 0500 0600 0210 0800 0900 1000 0210 1200 1300 1400 0210 1600
100 0200 0300
R: DM 0300 DM 030000 DM 030001 DM 030002 DM 030003 DM 030004 DM 030005 DM 030006 DM 030007 DM 030008 DM 030009 DM 030010 DM 030011 DM 030012 DM 030013 DM 030014 DM 030015
0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 1
5-17-2 COMPARE – CMP(20) Ladder Symbols
Operand Data Areas Cp1: First compare word
CMP(20) IR, SR, AR, DM, HR, TC, LR, # Cp1 Cp2: Second compare word Cp2
IR, SR, AR, DM, HR, TC, LR, #
Limitations
When comparing a value to the PV of a timer or counter, the value must be in BCD.
Description
When the execution condition is OFF, CMP(20) is not executed. When the execution condition is ON, CMP(20) compares Cp1 and Cp2 and outputs the result to the GR, EQ, and LE flags in the SR area.
Precautions
Placing other instructions between CMP(20) and the operation which accesses the EQ, LE, and GR flags may change the status of these flags. Be sure to access them before the desired status is changed. CMP(20) cannot be used to compare signed binary data. Use CPS(––) instead. Refer to 5-17-8 SIGNED BINARY COMPARE – CPS(––) for details.
193
Page 212
Section 5-17
Data Comparison Flags
ER:
Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON if Cp1 equals Cp2.
LE:
ON if Cp1 is less than Cp2.
GR:
ON if Cp1 is greater than Cp2. Flag
C1 < C2
C1 = C2
C1 > C2
GR
25505
OFF
OFF
ON
EQ
25506
OFF
ON
OFF
LE
25507
ON
OFF
OFF
The following example shows how to save the comparison result immediately. If the content of HR 09 is greater than that of 010, 00200 is turned ON; if the two contents are equal, 00201 is turned ON; if content of HR 09 is less than that of 010, 00202 is turned ON. In some applications, only one of the three OUTs would be necessary, making the use of TR 0 unnecessary. With this type of programming, 00200, 00201, and 00202 are changed only when CMP(20) is executed.
Example 1: Saving CMP(20) Results
00000
Address
TR 0 CMP(20) HR 09 010
25505 00200
Greater Than
00201
Equal
00202
Less Than
25506
25507
Address
Instruction
00000 00001 00002
LD OUT CMP(20)
00003 00004
Example 2: Obtaining Indications during Timer Operation
194
LD AND
Operands
TR
HR TR
00000 0 010 09 0 25505
Address
Instruction
00005 00006 00007 00008 00009 00010 00011
OUT LD AND OUT LD AND OUT
Operands
TR
TR
00200 0 25506 00201 0 25507 00202
The following example uses TIM, CMP(20), and the LE flag (25507) to produce outputs at particular times in the timer’s countdown. The timer is started by turning ON 00000. When 00000 is OFF, TIM 010 is reset and the second two CMP(20)s are not executed (i.e., executed with OFF execution conditions). Output 00200 is produced after 100 seconds; output 00201, after 200 seconds; output 00202, after 300 seconds; and output 00204, after 500 seconds.
Page 213
Section 5-17
Data Comparison
The branching structure of this diagram is important in order to ensure that 00200, 00201, and 00202 are controlled properly as the timer counts down. Because all of the comparisons here use to the timer’s PV as reference, the other operand for each CMP(20) must be in 4-digit BCD. 00000 TIM 010 #5000
500.0 s
CMP(20) TIM 010 #4000 25507 00200
Output at 100 s.
00200 CMP(20) TIM 010 #3000 25507 00201
Output at 200 s.
00201 CMP(20) TIM 010 #2000 25507 00202
Output at 300 s.
00204
Output at 500 s.
TIM 010
Address
Instruction
00000 00001
LD TIM
00002
CMP(20)
Operands
# TIM # 00003 00004 00005 00006
AND OUT LD CMP(20) TIM #
00000 010 5000 010 4000 25507 00200 00200
Address
Instruction
00007 00008 00009 00010
AND OUT LD CMP(20)
Operands 25507 00201 00201 TIM #
00011 00012 00013 00014
AND OUT LD OUT
TIM
010 2000 25507 00202 010 00204
010 3000
195