The text of a manual · part 24 of 60
C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 224 to 233
Pages 224 to 233 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 224
Section 5-18
Data Conversion
Note 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. Signed Binary Data
BCD(24) cannot be used to convert signed binary data directly to BCD. To convert signed binary data, first determine whether the data is positive or negative. If it is positive, BCD(24) can be used to convert the data to BCD. If it is negative, use the 2’s COMPLEMENT – NEG(––) instruction to convert the data to unsigned binary before executing BCD(24). Refer to page 27 for details on signed binary data.
Flags
ER:
S is greater than 270F. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON when the result is zero.
5-18-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
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. S and S+1 must be in the same data area as must R and R+1.
Description
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. Binary
S+1
S
BCD
R+1
R
Signed Binary Data
BCD(24) cannot be used to convert signed binary data directly to BCD. To convert signed binary data, first determine whether the data is positive or negative. If it is positive, BCD(24) can be used to convert the data to BCD. If it is negative, use the DOUBLE 2’s COMPLEMENT – NEGL(––) instruction to convert the data to unsigned binary before executing BCD(24). Refer to page 27 for details on signed binary data.
Flags
ER:
Content of R and R+1 exceeds 99999999. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ:
206
ON when the result is zero.
Page 225
Section 5-18
Data Conversion
5-18-5 HOURS-TO-SECONDS – SEC(65) Operand Data Areas S: Beginning source word (BCD)
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR SEC(65)
@SEC(65)
S
S
R
R
000
000
R: Beginning result word (BCD) IR, SR, AR, DM, HR, TC, LR 000: Set to 000. ---
Limitations
S and S+1 must be within the same data area. R and R+1 must be within the same data area. S and S+1 must be BCD and must be in the proper hours/minutes/seconds format.
Description
SEC(65) is used to convert time notation in hours/minutes/seconds to an equivalent in just seconds. For the source data, the seconds are designated in bits 00 through 07 and the minutes are designated in bits 08 through 15 of S. The hours are designated in S+1. The maximum is thus 9,999 hours, 59 minutes, and 59 seconds. The result is output to R and R+1. The maximum obtainable value is 35,999,999 seconds.
Flags
ER:
S and S+1 or R and R+1 are not in the same data area. S and/or S+1 do not contain BCD. Number of seconds and/or minutes exceeds 59. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ: Example
Turns ON when the result is zero.
When 00000 is OFF (i.e., when the execution condition is ON), the following instruction would convert the hours, minutes, and seconds given in HR 12 and HR 13 to seconds and store the results in DM 0100 and DM 0101 as shown.
00000 SEC(65) HR 12 DM 0100 000
HR 12
3
2
0
7
HR 13
2
8
1
5
DM 0100
5
9
2
7
DM 0101
1
0
1
3
2,815 hrs, 32 min, 07 s
Address
Instruction
00000 00001
LD NOT SEC(65)
Operands 00000 HR DM
12 0100 000
10,135,927 s
207
Page 226
Section 5-18
Data Conversion
5-18-6 SECONDS-TO-HOURS – HMS(66) Operand Data Areas S: Beginning source word (BCD)
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR HMS(66)
@HMS(66)
S
S
R
R
000
000
R: Beginning result word (BCD) IR, SR, AR, DM, HR, TC, LR 000: Set to 000. ---
Limitations
S and S+1 must be within the same data area. R and R+1 must be within the same data area. S and S+1 must be BCD and must be between 0 and 35,999,999 seconds.
Description
HMS(66) is used to convert time notation in seconds to an equivalent in hours/ minutes/seconds. The number of seconds designated in S and S+1 is converted to hours/minutes/ seconds and placed in R and R+1. For the results, the seconds is placed in bits 00 through 07 and the minutes is placed in bits 08 through 15 of R. The hours is placed in R+1. The maximum will be 9,999 hours, 59 minutes, and 59 seconds.
Flags
ER:
S and S+1 or R and R+1 are not in the same data area. S and/or S+1 do not contain BCD or exceed 36,000,000 seconds. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ: Example
Turns ON when the result is zero.
When 00000 is OFF (i.e., when the execution condition is ON), the following instruction would convert the seconds given in HR 12 and HR 13 to hours, minutes, and seconds and store the results in DM 0100 and DM 0101 as shown.
00000 HMS(66) HR 12 DM 0100 000
208
HR 12
5
9
2
7
HR 13
1
0
1
3
DM 0100
3
2
0
7
DM 0101
2
8
1
5
10,135,927 s
2,815 hrs, 32 min, 07 s
Address
Instruction
00000 00001
LD NOT HMS(66)
Operands 00000 HR DM
12 0100 000
Page 227
Section 5-18
Data Conversion
5-18-7 4-TO-16/8-TO-256 DECODER – MLPX(76) Operand Data Areas S: Source word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR MLPX(76)
@MLPX(76)
S
S
C
C
R
R
C: Control word
Limitations
IR, SR, AR, DM, HR, TC, LR, # R: First result word IR, SR, AR, DM, HR, LR
When the leftmost digit of C is 0, the rightmost two digits of C must each be between 0 and 3. When the leftmost digit of C is 1, the rightmost two digits of C must each be between 0 and 1. All result words must be in the same data area.
Description
Depending on the value of C, MLPX(76) operates as a 4-bit to 16-bit decoder or an 8-bit to 256-bit decoder.
4-bit to 16-bit Decoder
MLPX(76) operates as a 4-bit to 16-bit decoder when the leftmost digit of C is 0. The hexadecimal value of the digits in S are used to specify bits in up to 4 result words. The specified bit in each result word is turned on, and the other 15 bits in each word are turned off. 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.)
Control Word
The digits of C are set as shown below. Set the leftmost digit of C to 0 to specify 4-bit to 16-bit decoding.
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 0. A value of 0 specifies 4-bit to 16-bit decoding.
209
Page 228
Section 5-18
Data Conversion
Some example C values and the digit-to-word conversions that they produce are shown below. C: 0010
C: 0030
S
S
0
R
0
R
1
R+1
1
R+1
2
2
R+2
3
3
R+3
C: 0031
C: 0023
S
S
0
R
0
R
1
R+1
1
R+1
2
R+2
2
R+2
3
R+3
3
The following is an example of a one-digit decode operation from digit number 1 of S, i.e., here C 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
The first digit and the number of digits to be converted are designated in C. 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. 8-bit to 256-bit Decoder
MLPX(76) operates as an 8-bit to 256-bit decoder when the leftmost digit of C is set to 1. The hexadecimal value of the two bytes in S are used to specify a bit in one or two groups of 16 consecutive result words (256 bits). The specified bit in each group is turned on, and the other 255 bits in the group are turned off.
Control Word
The digits of C are set as shown below. Set the leftmost digit of C to 1 to specify 8-bit to 256-bit decoding. Digit number:
3 2 1 0
Specifies the first byte to be converted (0 or 1). 0: Rightmost byte 1: Leftmost byte Number of bytes to be converted (0 or 1). 0: 1 byte 1: 2 bytes Not used. Set to 0. A value of 1 specifies 8-bit to 256-bit decoding.
210
Page 229
Section 5-18
Data Conversion
The 4 possible C values and the conversions that they produce are shown below. (In S, 0 indicates the rightmost byte and 1 indicates the leftmost byte.) C: 1000
C: 1001
S
S
0
R to R+15
0
R to R+15
1
R+16 to R+31
1
R+16 to R+31
C: 1010
C: 1011
S
S
0
R to R+15
0
R to R+15
1
R+16 to R+31
1
R+16 to R+31
The following is an example of a one-byte decode operation from the rightmost byte of S (C would be 1000 in this case). Source word 2
Bit 15 0 0 0
Bit 00
. . . 0 0 0
Bit 15
. . .
Bit Bit 00 15
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R+15 Flags
Bit 2C (i.e., bit number 12 in the third word) turned ON.
C
R+2 ER:
Bit Bit 00 15
Bit 00
. . . 0 0 0 0 0 0 . . . 0 0 0 R+1
R
Undefined control word. The result words 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.)
211
Page 230
Section 5-18
Data Conversion
The following program converts three digits of data from LR 20 to bit positions and turns ON the corresponding bits in three consecutive words starting with HR 10.
Example: 4-bit to 16-bit Decoding
00000 MLPX(76)
Address
Instruction
DM 0020
00000 00001
LD MLPX(76)
#0021
DM 00 DM 01 DM 02 DM 03 DM 04 DM 05 DM 06 DM 07 DM 08 DM 09 DM 10 DM 11 DM 12 DM 13 DM 14 DM 15
R: HR 10
1 1 1 1 0 1 1 0 0 0 0 0
20 21 22 23 20 21 22 23 20 21 22 23 20 21 22 23
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
2
3
15
6
0
R+1: HR 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
00000 LR # HR
HR 10
S: LR 20
Operands
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
20 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-18-8 16-TO-4/256-TO-8 ENCODER – DMPX(77) Operand Data Areas S: First source word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR DMPX(77)
@DMPX(77)
S
S
R
R
C
C
R: Result word
Limitations
IR, SR, AR, DM, HR, LR C: Control Word IR, SR, AR, DM, HR, TC, LR, #
When the leftmost digit of C is 0, the rightmost two digits of C must each be between 0 and 3. When the leftmost digit of C is 1, the rightmost two digits of C must each be between 0 and 1. All source words must be in the same data area.
Description
212
Depending on the value of C, MLPX(76) operates as a 16-bit to 4-bit encoder or an 256-bit to 8-bit encoder.
Page 231
Section 5-18
Data Conversion 16-bit to 4-bit Encoder
DMPX(77) operates as a 16-bit to 4-bit encoder when the leftmost digit of C is 0. 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, then transfers the hexadecimal value to the specified digit in R. The digits to receive the results are specified in C, which also specifies the number of digits to be encoded.
Control Word
The digits of C are set as shown below. Set the leftmost digit of C to 0 to specify 16-bit to 4-bit encoding. Digit number:
3 2 1 0
Specifies the first digit in R 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. Set to 0. A value of 0 specifies 16-bit to 4-bit encoding.
Some example C values and the word-to-digit conversions that they produce are shown below. C: 0011
C: 0030 R
R
S
0
S
0
S+1
1
S+1
1
2
S+2
2
3
S+3
3
C: 0013
C: 0032 R
R 0
S
0
S
S+1
1
S+1
1
2
S+2
2
3
S+3
3
The following is an example of a one-digit encode operation to digit number 1 of R, i.e., here C 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.
213
Page 232
Section 5-18
Data Conversion 256-bit to 8-bit Encoder
DMPX(77) operates as a 256-bit to 8-bit encoder when the leftmost digit of C is set to 1. 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 (leftmost) ON bit in the group of 16 source words from S to S+15 or S+16 to S+31, encodes it into a two-digit hexadecimal value corresponding to the location of the bit among the 256 bits in the group, then transfers the hexadecimal value to the specified byte in R. The byte to receive the result is specified in C, which also specifies the number of bytes to be encoded.
Control Word
The digits of C are set as shown below. Set the leftmost digit of C to 1 to specify 256-bit to 8-bit decoding. Digit number:
3 2 1 0
Specifies the first byte in R to receive converted data (0 or 1). 0: Rightmost byte 1: Leftmost byte Number of bytes to be encoded (0 or 1). 0: 1 byte 1: 2 bytes Not used. Set to 0. A value of 1 specifies 256-bit to 8-bit encoding.
Three possible C values and the conversions that they produce are shown below. (In R, 0 indicates the rightmost byte and 1 indicates the leftmost byte.) C: 1000
C: 1010
R S to S+15 S+16 to S+31
C: 1011
R
R
0
S to S+15
0
S to S+15
0
1
S+16 to S+31
1
S+16 to S+31
1
The following is an example of a one-byte encode operation to the rightmost byte of R (C would be 1000 in this case). Bit 15
Bit Bit 00 15
0 0 0 0 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1
S+15
Bit 00
. . . 0 1 0 S+14
Bit 15
. . .
1 1 1
Bit 00
. . . 0 0 0 S
Result word F
Flags
B
ER:
Bit FB (bit 251 of 0 to 255) is the highest ON bit of the 16-word group, so FB is written to the rightmost bit of R.
Undefined control word. The source words are not all in the same data area. Content of the source words is zero. (There isn’t an ON bit in the source words.) Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
214
Page 233
Section 5-18
Data Conversion
When 00000 is ON, the following diagram encodes IR words 010 and 011 to the first two digits of HR 20 and then encodes LR 10 and 11 to the last two digits of HR 20. 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: 16-bit to 4-bit Encoding
00000 DMPX(77)
Address
Instruction
010
00000 00001
LD DMPX(77)
HR 20
Operands 00000
HR #
010 20 0010
LR HR #
10 20 0012
#0010
DMPX(77)
00002
LR 10
DMPX(77)
HR 20 #0012
IR 010
IR 011
01000
01100
:
:
01011
1
01109
1
01012
0
01110
0
: :
:
: :
:
01015
0
01115
0
HR 20 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 1015 0
:
LR 1115 0
5-18-9 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.
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.
215