The text of a manual · part 30 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 5 Instruction Set, pages 269 to 278
Pages 269 to 278 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 269
Section 5-18
Comparison Instructions Description
When the execution condition is OFF, ZCP(––) is not executed. When the execution condition is ON, ZCP(––) compares CD to the range defined by lower limit LL and upper limit UL and outputs the result to the GR, EQ, and LE flags in the SR area. The resulting flag status is shown in the following table. Flag status
Comparison result CD < LL
GR (SR 25505) EQ (SR 25506) 0 0
LE (SR 25507) 1
LL ≤ CD ≤ UL
0
1
0
UL < CD
1
0
0
Precautions
Placing other instructions between ZCP(––) 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.) LL is greater than UL.
Example
EQ:
ON if LL ≤ CD ≤ UL
LE:
ON if CD < LL.
GR:
ON if CD > UL.
In the following example, the content of IR 002 (#6FA4) is compared to the range #0010 to #AB1F. Since #0010 ≤ #6FA4 ≤ #AB1F, the EQ flag and IR 10001 are turned ON.
00000
TR 0 ZCP(––) 002 #0010 #AB1F
25505 10000
Greater Than (above range)
10001
Equal (within range)
10002
Less Than (below range)
25506
25507
Address
Instruction
00000 00001 00002
LD OUT ZCP(––)
Operands 00000 0
TR
002 0010 AB1F 25505
# # 00003
AND
LL: #0010 0 0 1 0
<
6
CD: 002 F A
4
Address
Instruction
00004 00005 00006 00007 00008 00009 00010
OUT LD AND OUT LD AND OUT
<
UL: #AB1F A B 1 F
Operands
TR
TR
10000 0 25506 10001 0 25507 10002
10000: OFF 10001: ON 10002: OFF
251
Page 270
Section 5-19
Conversion Instructions
5-18-9 DOUBLE AREA RANGE COMPARE – ZCPL(––) Operand Data Areas CD: Compare data
Ladder Symbol
IR, SR, AR, DM, HR, LR ZCPL(––) LL: Lower limit of range CD
IR, SR, AR, DM, HR, LR
LL
UL: Upper limit of range
UL
Limitations
IR, SR, AR, DM, HR, LR
This instruction is available in the only. The 8-digit value in LL+1,LL must be less than or equal to UL+1,UL.
Description
When the execution condition is OFF, ZCPL(––) is not executed. When the execution condition is ON, ZCPL(––) compares the 8-digit value in CD, CD+1 to the range defined by lower limit LL+1,LL and upper limit UL+1,UL and outputs the result to the GR, EQ, and LE flags in the SR area. The resulting flag status is shown in the following table. Flag status
Comparison result GR (SR 25505)
EQ (SR 25506)
LE (SR 25507)
CD , CD+1< LL+1,LL
0
0
1
LL+1,LL ≤ CD, CD+1 ≤ UL+1,UL
0
1
0
UL+1,UL < CD, CD+1
1
0
0
Precautions
Placing other instructions between ZCPL(––) 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.) LL+1,LL is greater than UL+1,UL.
EQ:
ON if LL+1,LL ≤ CD, CD+1 ≤ UL+1,UL
LE:
ON if CD, CD+1 < LL+1,LL.
GR:
ON if CD, CD+1 > UL+1,UL.
5-19 Conversion Instructions 5-19-1 BCD-TO-BINARY – BIN(23) Ladder Symbols
Operand Data Areas S: Source word (BCD)
BIN(23)
@BIN(23)
S
S
R
R
IR, SR, AR, DM, HR, TC, LR R: Result word
Limitations
252
DM 6144 to DM 6655 cannot be used for R.
IR, SR, AR, DM, HR, LR
Page 271
Section 5-19
Conversion Instructions Description
When the execution condition is OFF, BIN(23) is not executed. When the execution condition is ON, BIN(23) converts the BCD content of S into the numerically equivalent binary bits, and outputs the binary value to R. Only the content of R is changed; the content of S is left unchanged. BCD
S
Binary
R
BIN(23) can be used to convert BCD to binary so that displays on the Programming Console or any other programming device will appear in hexadecimal rather than decimal. It can also be used to convert to binary to perform binary arithmetic operations rather than BCD arithmetic operations, e.g., when BCD and binary values must be added. Flags
ER:
The content of S is not BCD. 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 result is zero.
5-19-2 BINARY-TO-BCD – BCD(24) Ladder Symbols
Operand Data Areas S: Source word (binary)
BCD(24)
@BCD(24)
S
S
R
R
IR, SR, AR, DM, HR, LR R: Result word IR, SR, AR, DM, HR, LR
Limitations
If the content of S exceeds 270F, the converted result would exceed 9999 and BCD(24) will not be executed. When the instruction is not executed, the content of R remains unchanged. DM 6144 to DM 6655 cannot be used for R.
Description
BCD(24) converts the binary (hexadecimal) content of S into the numerically equivalent BCD bits, and outputs the BCD bits to R. Only the content of R is changed; the content of S is left unchanged. Binary
S
BCD
R
BCD(24) can be used to convert binary to BCD so that displays on the Programming Console or any other programming device will appear in decimal rather than hexadecimal. It can also be used to convert to BCD to perform BCD arithmetic operations rather than binary arithmetic operations, e.g., when BCD and binary values must be added.
253
Page 272
Section 5-19
Conversion 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 when the result is zero.
5-19-3 DOUBLE BCD-TO-DOUBLE BINARY – BINL(58) Ladder Symbols
Operand Data Areas S: First source word (BCD)
BINL(58)
@BINL(58)
S
S
R
R
IR, SR, AR, DM, HR, TC, LR R: First result word
Limitations
IR, SR, AR, DM, HR, LR
This instruction is available in the CQM1 only. DM 6143 to DM 6655 cannot be used for R.
Description
Flags
When the execution condition is OFF, BINL(58) is not executed. When the execution condition is ON, BINL(58) converts an eight-digit number in S and S+1 into 32-bit binary data, and outputs the converted data to R and R+1.
ER:
BCD
S+1
S
Binary
R+1
R
The contents of S and/or S+1 words are not BCD. 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 result is zero.
5-19-4 DOUBLE BINARY-TO-DOUBLE BCD – BCDL(59) Ladder Symbols
Operand Data Areas S: First source word (binary)
BCDL(59)
@BCDL(59)
S
S
R
R
IR, SR, AR, DM, HR, LR R: First result word
Limitations
IR, SR, AR, DM, HR, LR
This instruction is available in the CQM1 only. If the content of S exceeds 05F5E0FF, the converted result would exceed 99999999 and BCDL(59) will not be executed. When the instruction is not executed, the content of R and R+1 remain unchanged. DM 6143 to DM 6655 cannot be used for R.
254
Page 273
Section 5-19
Conversion Instructions Description
Flags
BCDL(59) converts the 32-bit binary content of S and S+1 into eight digits of BCD data, and outputs the converted data to R and R+1.
ER:
Binary
S+1
S
BCD
R+1
R
Content of R and R+1 exceeds 99999999. 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 result is zero.
5-19-5 4-TO-16 DECODER – MLPX(76) Operand Data Areas S: Source word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR MLPX(76)
@MLPX(76)
S
S
Di
Di
R
R
Di: Digit designator
Limitations
IR, SR, AR, DM, HR, TC, LR, # R: First result word IR, SR, AR, DM, HR, LR
The rightmost two digits of Di must each be between 0 and 3. All result words must be in the same data area. DM 6144 to DM 6655 cannot be used for R.
Description
When the execution condition is OFF, MLPX(76) is not executed. When the execution condition is ON, MLPX(76) converts up to four, four-bit hexadecimal digits from S into decimal values from 0 to 15, each of which is used to indicate a bit position. The bit whose number corresponds to each converted value is then turned ON in a result word. If more than one digit is specified, then one bit will be turned ON in each of consecutive words beginning with R. (See examples, below.) The following is an example of a one-digit decode operation from digit number 1 of S, i.e., here Di would be 0001. Source word C
Bit C (i.e., bit number 12) turned ON. First result word 0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
255
Page 274
Section 5-19
Conversion Instructions
The first digit and the number of digits to be converted are designated in Di. If more digits are designated than remain in S (counting from the designated first digit), the remaining digits will be taken starting back at the beginning of S. The final word required to store the converted result (R plus the number of digits to be converted) must be in the same data area as R, e.g., if two digits are converted, the last word address in a data area cannot be designated; if three digits are converted, the last two words in a data area cannot be designated. Digit Designator
The digits of Di are set as shown below. Digit number:
3 2 1 0
Specifies the first digit to be converted (0 to 3) Number of digits to be converted (0 to 3) 0: 1 digit 1: 2 digits 2: 3 digits 3: 4 digits Not used (Set to zero)
Some example Di values and the digit-to-word conversions that they produce are shown below. Di: 0010
Di: 0030
S
S
0
R
0
R
1
R+1
1
R+1
2
2
R+2
3
3
R+3
Di: 0031
Di: 0023
S 0
Flags
ER:
S R
0
R
1
R+1
1
R+1
2
R+2
2
R+2
3
R+3
3
Undefined digit designator, or R plus number of digits exceeds a data area. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD or the DM area boundary has been exceeded.)
256
Page 275
Section 5-19
Conversion Instructions
The following program converts digits 1 to 3 of data from DM 0020 to bit positions and turns ON the corresponding bits in three consecutive words starting with HR 10. Digit 0 is not converted.
Example
00000 MLPX(76)
Address
Instruction
DM 0020
00000 00001
LD MLPX(76)
#0021
Operands 00000 DM # HR
HR 10
S: DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020 DM 0020
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
R: HR 10 HR 1000 HR 1001 HR 1002 HR 1003 HR 1004 HR 1005 HR 1006 HR 1007 HR 1008 HR 1009 HR 1010 HR 1011 HR 1012 HR 1013 HR 1014 HR 1015
Not Converted 1 1 1 1 0 1 1 0 0 0 0 0
15
6
0
R+1: HR 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
HR 1100 HR 1101 HR 1102 HR 1103 HR 1104 HR 1105 HR 1106 HR 1107 HR 1108 HR 1109 HR 1110 HR 1111 HR 1112 HR 1113 HR 1114 HR 1115
0020 0021 10
R+2: HR 12 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
HR 1200 HR 1201 HR 1202 HR 1203 HR 1204 HR 1205 HR 1206 HR 1207 HR 1208 HR 1209 HR 1210 HR 1211 HR 1212 HR 1213 HR 1214 HR 1215
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5-19-6 16-TO-4 ENCODER – DMPX(77) Operand Data Areas SB: First source word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR DMPX(77)
@DMPX(77)
SB
SB
R
R
Di
Di
R: Result word
Limitations
IR, SR, AR, DM, HR, LR Di: Digit designator IR, SR, AR, DM, HR, TC, LR, #
The rightmost two digits of Di must each be between 0 and 3. All source words must be in the same data area. DM 6144 to DM 6655 cannot be used for SB, R, or Di.
Description
When the execution condition is OFF, DMPX(77) is not executed. When the execution condition is ON, DMPX(77) determines the position of the highest ON bit in S, encodes it into single-digit hexadecimal value corresponding to the bit number of the highest ON bit number, then transfers the hexadecimal value to the specified digit in R. The digits to receive the results are specified in Di, which also specifies the number of digits to be encoded.
257
Page 276
Section 5-19
Conversion Instructions
The following is an example of a one-digit encode operation to digit number 1 of R, i.e., here Di would be 0001. First source word 0
0
0
1
0
0
0
1
0
0
0
1
0
1
1
0
C transferred to indicate bit number 12 as the highest ON bit. Result word C
Up to four digits from four consecutive source words starting with S may be encoded and the digits written to R in order from the designated first digit. If more digits are designated than remain in R (counting from the designated first digit), the remaining digits will be placed at digits starting back at the beginning of R. The final word to be converted (S plus the number of digits to be converted) must be in the same data area as SB. Digit Designator
The digits of Di are set as shown below. Digit numbers: 3 2 1 0
Specifies the first digit to receive converted data (0 to 3). Number of words to be converted (0 to 3) 0: 1 word 1: 2 words 2: 3 words 3: 4 words Not used.
Some example Di values and the word-to-digit conversions that they produce are shown below. Di: 0011
Di: 0030 R
R
S
0
S
0
S+1
1
S+1
1
2
S+2
2
3
S+3
3
Di: 0013
Di: 0032 R
Flags
ER:
S
0
S
R 0
S+1
1
S+1
1
2
S+2
2
3
S+3
3
Undefined digit designator, or S plus number of digits exceeds a data area. Content of a source word is zero. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
258
Page 277
Section 5-19
Conversion Instructions
When 00000 is ON, the following diagram encodes IR words 010 and 011 to the first two digits of HR 10 and then encodes LR 10 and 11 to the last two digits of HR 10. Although the status of each source word bit is not shown, it is assumed that the bit with status 1 (ON) shown is the highest bit that is ON in the word.
Example
00000 DMPX(77)
Address
Instruction
010
00000 00001
LD DMPX(77)
HR 10
Operands 00000
HR #
010 10 0010
LR HR #
10 10 0012
#0010
DMPX(77)
00002
LR 10
DMPX(77)
HR 10 #0012
IR 010
IR 011
01000
01100
:
:
01011
1
01109
1
01012
0
01110
0
: :
:
: :
:
01015
0
01115
0
HR 10 Digit 0
B
Digit 1
9
LR 10
LR 11
Digit 2
1
LR 1000
LR 1100
Digit 3
8
LR 1001 1
:
LR 1002 0
LR 1108 1
: :
:
LR 1109 0
: :
:
: :
:
LR 1115 0
LR 1015 0
5-19-7 7-SEGMENT DECODER – SDEC(78) Operand Data Areas S: Source word (binary)
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR SDEC(78)
@SDEC(78)
S
S
Di
Di
D
D
Di: Digit designator
Limitations
IR, SR, AR, DM, HR, TC, LR, # D: First destination word IR, SR, AR, DM, HR, LR
Di must be within the values given below. All destination words must be in the same data area. DM 6144 to DM 6655 cannot be used for D.
Description
When the execution condition is OFF, SDEC(78) is not executed. When the execution condition is ON, SDEC(78) converts the designated digit(s) of S into the equivalent 8-bit, 7-segment display code and places it into the destination word(s) beginning with D.
259
Page 278
Section 5-19
Conversion Instructions
Any or all of the digits in S may be converted in sequence from the designated first digit. The first digit, the number of digits to be converted, and the half of D to receive the first 7-segment display code (rightmost or leftmost 8 bits) are designated in Di. If multiple digits are designated, they will be placed in order starting from the designated half of D, each requiring two digits. If more digits are designated than remain in S (counting from the designated first digit), further digits will be used starting back at the beginning of S. Digit Designator
The digits of Di are set as shown below. Digit number:
3 2 1 0
Specifies the first digit of S to be converted (0 to 3). Number of digits to be converted (0 to 3) 0: 1 digit 1: 2 digits 2: 3 digits 3: 4 digits First half of D to be used. 0: Rightmost 8 bits (1st half) 1: Leftmost 8 bits (2nd half) Not used; set to 0.
Some example Di values and the 4-bit binary to 7-segment display conversions that they produce are shown below. Di: 0011 S digits
Di: 0030 D
S digits
D
0
1st half
0
1st half
1
2nd half
1
2nd half
2
2
3
3
D+1 1st half 2nd half
Di: 0112 S digits
D
0
1st half
1
2nd half
2 3
D+1
Di: 0130 S digits 0 1 2 3
D 1st half 2nd half D+1
1st half
1st half
2nd half
2nd half D+2 1st half 2nd half
260