The text of a manual · part 29 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 5 Instruction Set, pages 259 to 268
Pages 259 to 268 of 520, from SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual
The original document is the PDF (2.1 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Omron CQM1-CPU21
Page 259
Section 5-17
Data Movement Instructions 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 DM word is not BCD, or the DM area boundary has been exceeded.)
5-17-10 TRANSFER BITS – XFRB(––) Ladder Symbols
Operand Data Areas
XFRB(––)
@XFRB(––)
C
C
S
S
D
D
C: Control word IR, SR, AR, DM, TC, HR, LR, # S: First source word IR, SR, AR, DM, TC, HR, LR D: First destination word IR, SR, AR, DM, HR, LR
Limitations
This instruction is available in the only. The specified source bits must be in the same data area. The specified destination bits must be in the same data area. DM 6144 to DM 6655 cannot be used for D.
Description
When the execution condition is OFF, XFRB(––) is not executed. When the execution condition is ON, XFRB(––) 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 (00 to FF)
Note Up to 255 (FF) bits can be copied at one time.
241
Page 260
Section 5-18
Comparison Instructions Example
In the following example, XFRB(––) is used to transfer 5 bits from IR 020 and IR 021 to LR 00 and LR 01. The starting bit in IR 020 is D (13), and the starting bit in LR 00 is E (14), so IR 02013 to IR 02101 are copied to LR 0014 to LR 0102. 00001 XFRB(––)
Address
Instruction
00000 00001
LD XFRB(––)
#05ED 020
Operands 00001 #
LR 00
05ED 020 00
LR
Bit 15
Flags
Bit 00
S+1: 021
Bit 15
Bit 00
S: 020
0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0
1 1 1 1 0 1 0 0 0 0 0 1 0 1 0 0
1 1 1 0 0 0 0 1 0 0 1 1 1 1 0 1
1 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1
Bit 15
Bit 15
Bit 00
D+1: LR 01 ER:
Bit 00
D: LR 00
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 DM word is not BCD, or the DM area boundary has been exceeded.)
5-18 Comparison Instructions 5-18-1 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.
Flags
ER: EQ: LE: GR:
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) ON if Cp1 equals Cp2. ON if Cp1 is less than Cp2. ON if Cp1 is greater than Cp2. Flag
242
Address
C1 < C2
C1 = C2
C1 > C2
GR
25505
OFF
OFF
ON
EQ
25506
OFF
ON
OFF
LE
25507
ON
OFF
OFF
Page 261
Section 5-18
Comparison Instructions
The following example shows how to save the comparison result immediately. If the content of HR 09 is greater than that of 010, 10200 is turned ON; if the two contents are equal, 10201 is turned ON; if content of HR 09 is less than that of 010, 10202 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, 10200, 10201, and 10202 are changed only when CMP(20) is executed.
Example: Saving CMP(20) Results
00000
TR 0 CMP(20) HR 09 010
25505 10200
Greater Than
10201
Equal
10202
Less Than
25506
25507
Address
Instruction
00000 00001 00002
LD OUT CMP(20)
Operands 00000 0
TR HR
00003 00004
AND OUT
09 010 25505 10200
Address
Instruction
00005 00006 00007 00008 00009 00010
LD AND OUT LD AND OUT
Operands TR
TR
0 25506 10201 0 25507 10202
5-18-2 TABLE COMPARE – TCMP(85) Operand Data Areas CD: Compare data
Ladder Symbols
IR, SR, DM, HR, TC, LR, # TCMP(85)
@TCMP(85)
CD
CD
TB
TB
R
R
TB: First comparison table word IR, SR, DM, HR, TC, LR R: Result word IR, SR, DM, HR, TC, LR
Limitations
DM 6144 to DM 6655 cannot be used for R.
Description
When the execution condition is OFF, TCMP(85) is not executed. When the execution condition is ON, TCMP(85) compares CD to the content of TB, TB+1, TB+2, ..., and TB+15. If CD is equal to the content of any of these words, the corresponding bit in R is set, e.g., if the CD equals the content of TB, bit 00 is turned ON, if it equals that of TB+1, bit 01 is turned ON, etc. The rest of the bits in R will be turned OFF.
Flags
ER:
The comparison table (i.e., TB through TB+15) exceeds the data area. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
243
Page 262
Section 5-18
Comparison Instructions
The following example shows the comparisons made and the results provided for TCMP(85). Here, the comparison is made during each cycle when IR 00000 is ON.
Example
00000 TCMP(85) 001
Address
Instruction
00000 00001
LD TCMP(85)
Operands 00000
DM 0000 216
CD: 001 IR
001
DM
Upper limits 0210
DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005 DM 0006 DM 0007 DM 0008 DM 0009 DM 0010 DM 0011 DM 0012 DM 0013 DM 0014 DM 0015
Compare the data in IR 001 with the given ranges.
001 0000 216
R: 216 0100 0200 0210 0400 0500 0600 0210 0800 0900 1000 0210 1200 1300 1400 0210 1600
IR 21600 IR 21601 IR 21602 IR 21603 IR 21604 IR 21605 IR 21606 IR 21607 IR 21608 IR 21609 IR 21610 IR 21611 IR 21612 IR 21613 IR 21614 IR 21615
0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0
5-18-3 BLOCK COMPARE – BCMP(68) Operand Data Areas CD: Compare data
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, # BCMP(68)
@BCMP(68)
CD
CD
CB
CB
R
R
CB: First comparison block word IR, SR, DM, HR, TC, LR R: Result word IR, SR, AR, DM, HR, TC, LR
Note BCMP(68) is an expansion instruction for the SRM1. The function code 68 is the factory setting and can be changed for the SRM1 if desired. Limitations
Each lower limit word in the comparison block must be less than or equal to the upper limit. DM 6144 to DM 6655 cannot be used for R.
Description
When the execution condition is OFF, BCMP(68) is not executed. When the execution condition is ON, BCMP(68) compares CD to the ranges defined by a block consisting of CB, CB+1, CB+2, ..., CB+31. Each range is defined by two words, the first one providing the lower limit and the second word providing the upper limit. If CD is found to be within any of these ranges (inclusive of the upper and lower limits), the corresponding bit in R is set. The comparisons that are
244
Page 263
Section 5-18
Comparison Instructions made and the corresponding bit in R that is set for each true comparison are shown below. The rest of the bits in R will be turned OFF. CB ≤ CD ≤ CB+1 CB+2 ≤ CD ≤ CB+3 CB+4 ≤ CD ≤ CB+5 CB+6 ≤ CD ≤ CB+7 CB+8 ≤ CD ≤ CB+9 CB+10 ≤ CD ≤ CB+11 CB+12 ≤ CD ≤ CB+13 CB+14 ≤ CD ≤ CB+15 CB+16 ≤ CD ≤ CB+17 CB+18 ≤ CD ≤ CB+19 CB+20 ≤ CD ≤ CB+21 CB+22 ≤ CD ≤ CB+23 CB+24 ≤ CD ≤ CB+25 CB+26 ≤ CD ≤ CB+27 CB+28 ≤ CD ≤ CB+29 CB+30 ≤ CD ≤ CB+31
Flags
ER:
Bit 00 Bit 01 Bit 02 Bit 03 Bit 04 Bit 05 Bit 06 Bit 07 Bit 08 Bit 09 Bit 10 Bit 11 Bit 12 Bit 13 Bit 14 Bit 15
The comparison block (i.e., CB through CB+31) exceeds the data area. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
Example
The following example shows the comparisons made and the results provided for BCMP(68). Here, the comparison is made during each cycle when IR 00000 is ON.
00000 BCMP(68) 001 DM 0010
Address
Instruction
00000 00001
LD BCMP(68)
Operands 00000
LR 05
DM LR
CD 001 001
Lower limits 0210
Compare data in IR 001 (which contains 0210) with the given ranges.
DM 0010 DM 0012 DM 0014 DM 0016 DM 0018 DM 0020 DM 0022 DM 0024 DM 0026 DM 0028 DM 0030 DM 0032 DM 0034 DM 0036 DM 0038 DM 0040
0000 0101 0201 0301 0401 0501 0601 0701 0801 0901 1001 1101 1201 1301 1401 1501
Upper limits DM 0011 DM 0013 DM 0015 DM 0017 DM 0019 DM 0021 DM 0023 DM 0025 DM 0027 DM 0029 DM 0031 DM 0033 DM 0035 DM 0037 DM 0039 DM 0041
001 0010 05
R:LR 05 0100 0200 0300 0400 0500 0600 0700 0800 0900 1000 1100 1200 1300 1400 1500 1600
LR 0500 LR 0501 LR 0502 LR 0503 LR 0504 LR 0505 LR 0506 LR 0507 LR 0508 LR 0509 LR 0510 LR 0511 LR 0512 LR 0513 LR 0514 LR 0515
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
245
Page 264
Section 5-18
Comparison Instructions
5-18-4 DOUBLE COMPARE – CMPL(60) Ladder Symbols
Operand Data Areas Cp1: First word of first compare word pair
CMPL(60) IR, SR, AR, DM, HR, TC, LR Cp1 Cp2: First word of second compare word pair Cp2
IR, SR, AR, DM, HR, TC, LR
––
Note CMPL(60) is an expansion instruction for the SRM1. The function code 60 is the factory setting and can be changed for the SRM1 if desired. Limitations
Cp1 and Cp1+1 must be in the same data area. Cp2 and Cp2+1 must be in the same data area. Set the third operand to 000.
Description
When the execution condition is OFF, CMPL(60) is not executed. When the execution condition is ON, CMPL(60) joins the 4-digit hexadecimal content of Cp1+1 with that of Cp1, and that of Cp2+1 with that of Cp2 to create two 8-digit hexadecimal numbers, Cp+1,Cp1 and Cp2+1,Cp2. The two 8-digit numbers are then compared and the result is output to the GR, EQ, and LE flags in the SR area.
Precautions
Placing other instructions between CMPL(60) 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.
Flags
ER: GR: EQ: LE:
Example: Saving CMPL(60) Results
00000
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) ON if Cp1+1,Cp1 is greater than Cp2+1,Cp2. ON if Cp1+1,Cp1 equals Cp2+1,Cp2. ON if Cp1+1,Cp1 is less than Cp2+1,Cp2.
The following example shows how to save the comparison result immediately. If the content of HR 10, HR 09 is greater than that of 011, 010, then 10000 is turned ON; if the two contents are equal, 10001 is turned ON; if content of HR 10, HR 09 is less than that of 011, 010, then 10002 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, 10000, 10001, and 10002 are changed only when CMPL(60) is executed.
TR 0 CMPL(60) HR 09 010
Address
Instruction
00000 00001 00002
LD OUT CMPL(60)
Operands
TR HR
---
00000 0 09 010
25505 10000
Greater Than
10001
Equal
10002
Less Than
25506
25507
246
00003 00004 00005 00006 00007 00008 00009 00010
AND OUT LD AND OUT LD AND OUT
TR
TR
25505 10000 0 25506 10001 0 25507 10002
Page 265
Section 5-18
Comparison Instructions
5-18-5 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, SR, AR, DM, HR, TC, LR
Limitations
This instruction is available in the CQM1 only. TB1 and TB1+15 must be in the same data area. TB2 and TB2+15 must be in the same data area. DM 6144 to DM 6655 cannot be used for R.
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 DM word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON if the entire contents of both tables are equal and R=0000.
247
Page 266
Section 5-18
Comparison Instructions 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)
Address
Instruction
00000 00001
LD MCMP(19)
100 DM 0200
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 0700 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-18-6 SIGNED BINARY COMPARE – CPS(––) Ladder Symbols
Operand Data Areas Cp1: First compare word
CPS(––) IR, SR, AR, DM, HR, TC, LR, # Cp1 Cp2: Second compare word Cp2 000
IR, SR, AR, DM, HR, TC, LR, # 000 Not used. Set to 000.
Limitations
This instruction is available in the only.
Description
When the execution condition is OFF, CPS(––) is not executed. When the execution condition is ON, CPS(––) compares the 16-bit (4-digit) signed binary contents in Cp1 and Cp2 and outputs the result to the GR, EQ, and LE flags in the SR area.
Precautions
Placing other instructions between CPS(––) 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.
248
Page 267
Section 5-18
Comparison Instructions Flags
ER:
Indirectly addressed DM word is non-existent. (Content of DM 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 status
Comparison result
Example
Cp1 < Cp2
GR (SR 25505) EQ (SR 25506) 0 0
LE (SR 25507) 1
Cp1 = Cp2
0
1
0
Cp1 > Cp2
1
0
0
In the following example, the content of 102 is greater than that of DM 0020, so 10000 is turned ON and the other bits, 10001 and 10002, are turned OFF.
00500
TR 0 CPS(––) 102 DM 0020
Address
Instruction
00000 00001 00002
LD OUT CPS(––)
Operands 00500 0
TR
000
102 0020 000 25505 10000 0 25506 10001 0 25507 10002
DM
25505 10000
Greater Than
10001
Equal
25506
25507
6
10002
Less Than
Cp1: 102 F A
4
(28,580 decimal)
>
00003 00004 00005 00006 00007 00008 00009 00010
AND OUT LD AND OUT LD AND OUT
TR
TR
Cp2: DM 0020 A E 3 5 (–20,939 decimal)
5-18-7 DOUBLE SIGNED BINARY COMPARE – CPSL(––) Ladder Symbols
Operand Data Areas Cp1: First compare word
CPSL(––) IR, SR, AR, DM, HR, TC, LR, # Cp1 Cp2: Second compare word Cp2 000
IR, SR, AR, DM, HR, TC, LR, # 000 Not used. Set to 000.
Limitations
This instruction is available in the only.
Description
When the execution condition is OFF, CPSL(––) is not executed. When the execution condition is ON, CPSL(––) compares the 32-bit (8-digit) signed binary contents in Cp1+1, Cp1 and Cp2+1, Cp2 and outputs the result to the GR, EQ, and LE flags in the SR area.
249
Page 268
Section 5-18
Comparison Instructions Precautions
Placing other instructions between CPSL(––) 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.
Flags
ER:
Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) ON if Cp1+1, Cp1 equals Cp2+1, Cp2. ON if Cp1+1, Cp1 is less than Cp2+1, Cp2. ON if Cp1+1, Cp1 is greater than Cp2+1, Cp2.
EQ: LE: GR:
Flag status
Comparison result
Example
Cp1+1, Cp1 < Cp2+1, Cp2
GR (SR 25505) EQ (SR 25506) 0 0
LE (SR 25507) 1
Cp1+1, Cp1 = Cp2+1, Cp2
0
1
0
Cp1+1, Cp1 > Cp2+1, Cp2
1
0
0
In the following example, the content of 103, 102 is less than that of DM 0021, DM 0020, so 10002 is turned ON and the other bits, 10000 and 10001, are turned OFF.
00500
TR 0 CPSL(––) 102 DM 0020
Address
Instruction
00000 00001 00002
LD OUT CPSL(––)
000
Operands
TR
DM
25505 10000
Greater Than
10001
Equal
25506
25507
8
Cp1+1: 103 2 B 6
F
10002
Less Than
Cp1: 102 5 7
B
<
00003 00004 00005 00006 00007 00008 00009 00010
AND OUT LD AND OUT LD AND OUT
TR
TR
Cp2+1: DM 0021 0 5 6 A
(–2,101,938,823 decimal)
00500 0 102 0020 000 25505 10000 0 25506 10001 0 25507 10002
Cp2: DM 0020 9 9 D B
(90,872,283 decimal)
5-18-8 AREA RANGE COMPARE – ZCP(––) Operand Data Areas Ladder Symbol
CD: Compare data IR, SR, AR, DM, HR, TC, LR, #
ZCP(––) LL: Lower limit of range CD LL UL
Limitations
250
IR, SR, AR, DM, HR, TC, LR, # UL: Upper limit of range IR, SR, AR, DM, HR, TC, LR, #
This instruction is available in the only. LL must be less than or equal to UL.