The text of a manual · part 31 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 5 Instruction Set, pages 279 to 288
Pages 279 to 288 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 279
Section 5-19
Conversion Instructions Example
The following example shows the data to produce an 8. The lower case letters show which bits correspond to which segments of the 7-segment display. The table underneath shows the original data and converted code for all hexadecimal digits. 00000 @ SDEC(78) DM 0010 LR 07 100
LR 07 a
IR 100
DM 0010 f 1 a
1
1 b
22
0
1 c
0
23
0
1 d
0
20
0
1 e
21
0
1 f
0
22
0
1 g
0
23
1
0
20
0
21
1
22
1
0
23
1
0
20
1
0
21
0
0
22
1
0
23
1
0
20
0
1
21
0 x100
0 x101
0 x102
0 x103
1: Second digit
0
0: One digit
1
2
0 or 1: 0 Bits 00 through 07 1 Bits 08 through 15.
3
Not used.
Bit 00
8
Bit 07 e c d
0
Digit
Original data Bits
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
0
2
0
0
1
0
0
0
1
1
0
0
1
1
3
0
0
1
1
0
0
1
1
0
0
1
1
4
0
1
0
0
0
0
1
1
0
1
0
0
5
0
1
0
1
0
0
1
1
0
1
0
1
6
0
1
1
0
0
0
1
1
0
1
0
1
7
0
1
1
1
0
0
1
1
0
1
1
1
8
1
0
0
0
0
0
1
1
1
0
0
0
9
1
0
0
1
0
0
1
1
1
0
0
1
A
1
0
1
0
0
1
0
0
0
0
0
1
B
1
0
1
1
0
1
0
0
0
0
1
0
C
1
1
0
0
0
1
0
0
0
0
1
1
D
1
1
0
1
0
1
0
0
0
1
0
0
E
1
1
1
0
0
1
0
0
0
1
0
1
F
1
1
1
1
0
1
0
0
0
1
1
0
– b g
Converted code (segments) g f e d c b
Display a
261
Page 280
Section 5-19
Conversion Instructions Flags
ER:
Incorrect digit designator, or data area for destination exceeded. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
5-19-8 ASCII CONVERT – ASC(86) Operand Data Areas S: Source word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR ASC(86)
@ASC(86)
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, ASC(86) is not executed. When the execution condition is ON, ASC(86) converts the designated digit(s) of S into the equivalent 8-bit ASCII code and places it into the destination word(s) beginning with D. Any or all of the digits in S may be converted in order from the designated first digit. The first digit, the number of digits to be converted, and the half of D to receive the first ASCII 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. Note Refer to Appendix H for a table of ASCII characters.
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 First half of D to be used. 0: Rightmost 8 bits (1st half) 1: Leftmost 8 bits (2nd half) Parity
262
0: none 1: even 2: odd
Page 281
Section 5-19
Conversion Instructions
Some examples of Di values and the 4-bit binary to 8-bit ASCII conversions that they produce are shown below. Di: 0011
Di: 0030
S
D
S
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
Di: 0130
S
D 1st half
S 0
0
1st half
1
2nd half
1
2nd half
D
2
2 D+1
3
D+1
3
1st half
1st half
2nd half
2nd half D+2 1st half 2nd half
Parity
The leftmost bit of each ASCII character (2 digits) can be automatically adjusted for either even or odd parity. If no parity is designated, the leftmost bit will always be zero. When even parity is designated, the leftmost bit will be adjusted so that the total number of ON bits is even, e.g., when adjusted for even parity, ASCII “31” (00110001) will be “B1” (10110001: parity bit turned ON to create an even number of ON bits); ASCII “36” (00110110) will be “36” (00110110: parity bit turned OFF because the number of ON bits is already even). The status of the parity bit does not affect the meaning of the ASCII code. When odd parity is designated, the leftmost bit of each ASCII character will be adjusted so that there is an odd number of ON bits.
Flags
ER:
Incorrect digit designator, or data area for destination exceeded. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
5-19-9 ASCII-TO-HEXADECIMAL – HEX(––) Operand Data Areas S: First source word
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, # HEX(––)
@HEX(––)
S
S
Di
Di
D
D
Di: Digit designator
Limitations
IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, LR
This instruction is available in the CQM1/SRM1 only.
263
Page 282
Section 5-19
Conversion Instructions
Di must be within the values given below. All source words must be in the same data area. Bytes in the source words must contain the ASCII code equivalent of hexadecimal values, i.e., 30 to 39 (0 to 9) or 41 to 46 (A to F). DM 6144 to DM 6655 cannot be used for D. Description
When the execution condition is OFF, HEX(––) is not executed. When the execution condition is ON, HEX(––) converts the designated byte(s) of ASCII code from the source word(s) into the hexadecimal equivalent and places it into D. Up to 4 ASCII codes may be converted beginning with the designated first byte of S. The converted hexadecimal values are then placed in D in order from the designated digit. The first byte (rightmost or leftmost 8 bits), the number of bytes to be converted, and the digit of D to receive the first hexadecimal value are designated in Di. If multiple bytes are designated, they will be converted in order starting from the designated half of S and continuing to S+1 and S+2, if necessary. If more digits are designated than remain in D (counting from the designated first digit), further digits will be used starting back at the beginning of D. Digits in D that do not receive converted data will not be changed.
Digit Designator
The digits of Di are set as shown below. Digit number:
3 2 1 0
Specifies the first digit of D to be used (0 to 3). Number of bytes to be converted (0 to 3) 0: 1 byte (2-digit ASCII code) 1: 2 bytes 2: 3 bytes 3: 4 bytes First byte of S to be used. 0: Rightmost 8 bits (1st byte) 1: Leftmost 8 bits (2nd byte) Parity
264
0: none 1: even 2: odd
Page 283
Section 5-19
Conversion Instructions
Some examples of Di values and the 8-bit ASCII to 4-bit hexadecimal conversions that they produce are shown below. Di: 0011
Di: 0030
S
D
S
D
1st byte
0
1st byte
0
2nd byte
1
2nd byte
1
2
2 S+1
3
3
1st byte 2nd byte Di: 0023
Di: 0133
S
D
1st byte
0
1st byte
D
2nd byte
1
2nd byte
0
S
2 S+1
1 S+1
3
2
1st byte
1st byte
2nd byte
2nd byte
3
S+2 1st byte 2nd byte
ASCII Code Table
The following table shows the ASCII codes before conversion and the hexadecimal values after conversion. Refer to Appendix H for a table of ASCII characters. Original data ASCII Code
Converted data
Bit status (See note.)
Digit
Bits
30
*
0
1
1
0
0
0
0
0
0
0
0
0
31
*
0
1
1
0
0
0
1
1
0
0
0
1
32
*
0
1
1
0
0
1
0
2
0
0
1
0
33
*
0
1
1
0
0
1
1
3
0
0
1
1
34
*
0
1
1
0
1
0
0
4
0
1
0
0
35
*
0
1
1
0
1
0
1
5
0
1
0
1
36
*
0
1
1
0
1
1
0
6
0
1
1
0
37
*
0
1
1
0
1
1
1
7
0
1
1
1
38
*
0
1
1
1
0
0
0
8
1
0
0
0
39
*
0
1
1
1
0
0
1
9
1
0
0
1
41
*
1
0
1
0
0
0
1
A
1
0
1
0
42
*
1
0
1
0
0
1
0
B
1
0
1
1
43
*
1
0
1
0
0
1
1
C
1
1
0
0
44
*
1
0
1
0
1
0
0
D
1
1
0
1
45
*
1
0
1
0
1
0
1
E
1
1
1
0
46
*
1
0
1
0
1
1
0
F
1
1
1
1
Note The leftmost bit of each ASCII code is adjusted for parity. Parity
The leftmost bit of each ASCII character (2 digits) is automatically adjusted for either even or odd parity. With no parity, the leftmost bit should always be zero. With odd or even parity, the leftmost bit of each ASCII character should be adjusted so that there is an odd or even number of ON bits. If the parity of the ASCII code in S does not agree with the parity specified in Di, the ER Flag (SR 25503) will be turned ON and the instruction will not be executed.
265
Page 284
Section 5-19
Conversion Instructions Flags
ER:
Incorrect digit designator, or data area for destination exceeded. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)
In the following example, the 2nd byte of LR 10 and the 1st byte of LR 11 are converted to hexadecimal values and those values are written to the first and second bytes of IR 010.
Example
00000 @HEX(––) LR 10 HR 10
Address
Instruction
00000 00001
LD @HEX(––)
Operands 00000 LR HR
010
10 10 010
HR 10 0 1 1 0
LR 12
3 5 3 4
LR 11
4 2 3 2
LR 10
3 1 3 0 Conversion to hexadecimal
010 0 0 2 1
5-19-10 SCALING – SCL(66) Ladder Symbols
Operand Data Areas S: Source word
SCL(66)
@SCL(66)
S
S
P1
P1
R
R
IR, SR, AR, DM, HR, TC, LR, # P1: First parameter word IR, SR, AR, DM, HR, TC, LR R: Result word IR, SR, AR, DM, HR, LR
Limitations
This instruction is available in the CQM1 only. S must be BCD. P1 through P1+3 must be in the same data area. DM 6144 to DM 6655 cannot be used for P1 through P1+3 or R.
Description
SCL(66) is used to linearly convert a 4-digit hexadecimal value to a 4-digit BCD value. Unlike BCD(24), which converts a 4-digit hexadecimal value to its 4-digit BCD equivalent (Shex → SBCD), SCL(66) can convert the hexadecimal value according to a specified linear relationship. The conversion line is defined by two points specified in the parameter words P1 to P1+3. When the execution condition is OFF, SCL(66) is not executed. When the execution condition is ON, SCL(66) converts the 4-digit hexadecimal value in S to the 4-digit BCD value on the line defined by points (P1, P1+1) and (P1+2, P1+3) and places the results in R. The results is rounded off to the nearest integer. If the results is less than 0000, then 0000 is written to R, and if the result is greater than 9999, then 9999 is written to R.
266
Page 285
Section 5-19
Conversion Instructions
The following table shows the functions and ranges of the parameter words: Function
Range
P1
Parameter
BCD point #1 (AY)
0000 to 9999
---
Comments
P1+1
Hex. point #1 (AX)
0000 to FFFF
Do not set P1+1=P1+3.
P1+2
BCD point #2 (BY)
0000 to 9999
---
P1+3
Hex. point #2 (BX)
0000 to FFFF
Do not set P1+3=P1+1.
The following diagram shows the source word, S, converted to D according to the line defined by points (AY, AX) and (BY, BX). Value after (BCD)
conversion
BY
R AY
AX
S
Value before conversion (Hexadecimal)
BX
The results can be calculated by first converting all values to BCD and then using the following formula. Results = BY – [(BY – AY)/(BX – AX) X (BX – S)] Flags
ER:
The value in P1+1 equals that in P1+3. Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) P1 and P1+3 are not in the same data area, or other setting error.
EQ: Example
ON when the result, R, is 0000.
When 00000 is turned ON in the following example, the BCD source data in DM 0100 (#0100) is converted to hexadecimal according to the parameters in DM 0150 to DM 0153. The result (#0512) is then written to DM 0200. 00000 @SCL(66) DM 0100 DM 0150
Instruction
00000 00001
LD @SCL(66)
Operands 00000 DM DM DM
DM 0200
DM 0150 DM 0151 DM 0152 DM 0153
Address
0010 0005 0050 0019
0100 0150 0200
DM 0100
0100
DM 0200
0512
267
Page 286
Section 5-19
Conversion Instructions
5-19-11 SIGNED BINARY TO BCD SCALING – SCL2(––) Ladder Symbols
Operand Data Areas S: Source word
SCL2(––)
@SCL2(––)
S
S
P1
P1
R
R
IR, SR, AR, DM, HR, LR P1: First parameter word IR, SR, AR, DM, HR, LR R: Result word IR, SR, AR, DM, HR, LR
Limitations
This instruction is available in the only. S must be BCD. P1 through P1+2 must be in the same data area. DM 6144 to DM 6655 cannot be used for R.
Description
SCL2(––) is used to linearly convert a 4-digit signed hexadecimal value to a 4-digit BCD value. Unlike BCD(24), which converts a 4-digit hexadecimal value to its 4-digit BCD equivalent (Shex → SBCD), SCL2(––) can convert the signed hexadecimal value according to a specified linear relationship. The conversion line is defined by the x-intercept and the slope of the line specified in the parameter words P1 to P1+2. When the execution condition is OFF, SCL2(––) is not executed. When the execution condition is ON, SCL2(––) converts the 4-digit signed hexadecimal value in S to the 4-digit BCD value on the line defined by the x-intercept (P1, 0) and the slope (P1+2 ÷ P1+1) and places the results in R. The result is rounded off to the nearest integer. If the result is negative, then CY is set to 1. If the result is less than –9999, then –9999 is written to R. If the result is greater than 9999, then 9999 is written to R. The following table shows the functions and ranges of the parameter words: Parameter
Function
Range
P1 x-intercept (signed hex.)
8000 to 7FFF (–32,768 to 32,767)
P1+1
∆X (signed hex.)
8000 to 7FFF (–32,768 to 32,767)
P1+2
∆Y (BCD)
0000 to 9999
The following diagram shows the source word, S, converted to R according to the line defined by the point (P1, 0) and slope ∆Y/∆X. Value after conversion (BCD) ∆Y ∆X
R
S X-intercept
268
Value before conversion (Signed hexadecimal)
Page 287
Section 5-19
Conversion Instructions
The result can be calculated by first converting all signed hexadecimal values to BCD and then using the following formula. R +
Flags
ER:
(S–P1)
Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) P1 and P1+2 are not in the same data area, or other setting error.
Example
CY:
ON when the result, R, is negative.
EQ:
ON when the result, R, is 0000.
When 05000 is turned ON in the following example, the signed binary source data in 001 (#FFE2) is converted to BCD according to the parameters in DM 0000 to DM 0002. The result (#0018) is then written to LR 00 and CY is turned ON because the result is negative. 05000 @SCL2(––) 001 DM 0000
Address
Instruction
00000 00001
LD @SCL2(––)
Operands 05000
LR 00
DM LR
2 DM 0000 DM 0001 DM 0002
FFFD
FFFD 0003 0002
IR 001
FFE2
LR 00
0018
001 0000 00
3
FFE2 CY=1
–0018
R + 0002 0003 +2 3
(FFE2–FFFD)
CY flag is turned ON because the conversion result is negative.
(–1B) + –18
5-19-12 BCD TO SIGNED BINARY SCALING – SCL3(––) Ladder Symbols
Operand Data Areas S: Source word
SCL3(––)
@SCL3(––)
S
S
P1
P1
R
R
IR, SR, AR, DM, HR, LR P1: First parameter word IR, SR, AR, DM, HR, LR R: Result word IR, SR, AR, DM, HR, LR
Limitations
This instruction is available in the only. P1+1 must be BCD. P1 through P1+4 must be in the same data area. DM 6144 to DM 6655 cannot be used for R.
269
Page 288
Section 5-19
Conversion Instructions Description
SCL3(––) is used to linearly convert a 4-digit 4-digit BCD value to 4-digit signed hexadecimal. SCL3(––) converts the BCD value according to a specified linear relationship. The conversion line is defined by the y-intercept and the slope of the line specified in the parameter words P1 to P1+2. When the execution condition is OFF, SCL3(––) is not executed. When the execution condition is ON, SCL3(––) converts the 4-digit BCD value in S to the 4-digit signed hexadecimal value on the line defined by the y-intercept (0, P1) and the slope (P1+2 ÷ P1+1) and places the result in R. The result is rounded off to the nearest integer. The content of S can be 0000 to 9999, but S will be treated as a negative value if CY=1, so the effective range of S is actually –9999 to 9999. Be sure to set the desired sign in CY using STC(40) or CLC(41). Parameter words P1+3 and P1+4 define upper and lower limits for the result. If the result is greater than the upper limit in P1+3, then the upper limit is written to R. If the result is less than the lower limit in P1+4, then the lower limit is written to R. Note The upper and lower limits for a 12-bit Analog Input Unit would be 07FF and F800. The following table shows the functions and ranges of the parameter words: Parameter
Function
Range
P1 x-intercept (signed hex.)
8000 to 7FFF (–32,768 to 32,767)
P1+1
∆X (BCD)
0000 to 9999
P1+2
∆Y (signed hex.)
8000 to 7FFF (–32,768 to 32,767)
P1+3
Upper limit (signed hex.)
8000 to 7FFF (–32,768 to 32,767)
P1+4
Lower limit (signed hex.)
8000 to 7FFF (–32,768 to 32,767)
The following diagram shows the source word, S, converted to R according to the line defined by the point (0, P1) and slope ∆Y/∆X. Value after conversion (Signed hexadecimal)
∆Y
Upper limit
∆X
R
Y-intercept Value before conversion (BCD)
S
Lower limit
The result can be calculated by first converting all BCD values to signed binary and then using the following formula. R+ Flags
Ǔ
S ) P1
ER:
Indirectly addressed DM word is non-existent. (Content of *DM word is not BCD, or the DM area boundary has been exceeded.) The content of S is not BCD.
CY:
CY is not changed by SCL3(––). (CY shows the sign of S before execution.) ON when the result, R, is 0000.
EQ:
270