The text of a manual · part 34 of 68
Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 304 to 313
Pages 304 to 313 of 613, from Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual
The original document is the PDF (3.8 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.
Filed in the catalog under the Omron C200H-SP001 and Omron C200HW-PA204
Page 304
Section 5-21
Binary Calculations Flags
Example
ER:
The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
EQ:
ON when the result is zero (content of R+3 through R all zeroes), otherwise OFF.
N:
ON when bit 15 of R+3 is set to 1.
In the following example, MBSL(482) is used to multiply the signed binary contents of IR 101 and IR 100 with the signed binary contents of DM 0021 and DM 0020 and output the result to LR 24 through LR 21.
00000
Address
Instruction
00000 00001
LD MBSL(482)
MBSL(482) 100
Operands
100 DM 0020 LR 21
DM 0020 LR 21
Md+1: IR 101 0 0 8
7
Md: IR 100 9 3 8
(555,320)
Mr+1: DM 0021 F F F 0
A
Mr: DM 0020 8 1 2
(–1,005,550)
R+1: LR 22 C A 5
4
0
X F
R+3: LR 24 F F F
F
R+2: LR 23 F 7 D
F
00000
R: LR 21 5 F
(–558,402,026,000)
0
5-21-9 SIGNED BINARY DIVIDE – DBS(485) Operand Data Areas Dd: Dividend word
Ladder Symbols
IR, SR, AR, DM, EM, HR, TC, LR, # DBS(485)
@DBS(485)
Dd
Dd
Dr
Dr
R
R
Dr: Divisor word IR, SR, AR, DM, EM, HR, TC, LR, # R: First result word IR, SR, AR, DM, EM, HR LR
Limitations
R and R+1 must be in the same data area. DBS(485) is an expansion instruction. A Programming Device can be used to reassign function code 485 to another expansion instruction.
Description
DBS(485) divides the signed binary content of Dd by the signed binary content of Dr, and outputs the 8-digit signed binary result to R+1 and R. The quotient is placed in R, and the remainder is placed in R+1. Refer to page 30 for details on signed binary data. Quotient R
Dr
Flags
292
ER:
Dr contains 0.
Dd
Remainder R+1
Page 305
Section 5-21
Binary Calculations
The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
Example
EQ:
ON when the content of R (the quotient) is 0000, otherwise OFF.
N:
ON when bit 15 of R is set to 1.
In the following example, DBS(485) is used to divide the signed binary contents of IR 001 with the signed binary contents of DM 0020 and output the result to LR 21 and LR 22.
00000 DBS(485) 001
Address
Instruction
00000 00001
LD DBS(485)
Operands
001 DM 0020 LR 21
DM 0020 LR 21
÷ F
R+1: LR 22 F F A
00000
D
Dd: IR 001 D D A
(–8,742)
0
Dr: DM 0020 0 1 A
(26)
F
R: LR 21 E B
Remainder (–6)
0
(–336 and –6)
Quotient (–336)
5-21-10 DOUBLE SIGNED BINARY DIVIDE – DBSL(483) Operand Data Areas Dd: Dividend word (binary)
Ladder Symbols
IR, SR, AR, DM, EM, HR, TC, LR DBSL(483)
@DBSL(483)
Dd
Dd
Dr
Dr
R
R
Dr: Divisor word (binary) IR, SR, AR, DM, EM, HR, TC, LR R: First result word IR, SR, AR, DM, EM, HR LR
Limitations
Dd and Dd+1 must be in the same data area, as must Dr and Dr+1, and R through R+3. DBSL(483) is an expansion instruction. A Programming Device can be used to reassign function code 483 to another expansion instruction.
Description
DBS(485) divides the 32-bit (8-digit) signed binary data in Dd+1 and Dd by the 32-bit signed binary data in Dr+1 and Dr, and outputs the 16-digit signed binary result to R+3 through R. The quotient is placed in R+1 and R, and the remainder is placed in R+3 and R+2. Refer to page 30 for details on signed binary data. Remainder R+3
Dr+1
R+2
Dr
Quotient R+1
R
Dd+1
Dd
293
Page 306
Section 5-22
Special Math Instructions Flags
ER:
Dr+1 and Dr contain 0. The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
Example
EQ:
ON when the content of R+1 and R (the quotient) is 0, otherwise OFF.
N:
ON when bit 15 of R+1 is set to 1.
In the following example, DBSL(483) is used to divide the signed binary contents of IR 002 and IR 001 with the signed binary contents of DM 0021 and DM 0020 and output the result to LR 24 through LR 21.
00000
Address
Instruction
00000 00001
LD DBSL(483)
DBSL(483) 001
Operands
001 DM 0020 LR 21
DM 0020 LR 21
Dd+1: IR 002 F 7 A
B
Dd: IR 001 1 5 C
(–8,736,420)
Dr+1: DM 0021 0 0 0 0
0
Dr: DM 0020 0 1 A
(26)
R+1: LR 22 F F A
D
R: LR 21 F 7
F
F
R+3: LR 24 F F F
F
R+2: LR 23 F F C
F
Remainder (–4)
00000
0
(–336,016 and –4)
Quotient (–336,016)
5-22 Special Math Instructions 5-22-1 FIND MAXIMUM – MAX(182) Ladder Symbols
Operand Data Areas C: Control data
MAX(182)
@MAX(182)
C
C
R1
R1
D
D
IR, SR, AR, DM, EM, HR, LR, # R1: First word in range IR, SR, AR, DM, EM, HR, TC, LR D: Destination word IR, SR, AR, DM, EM, HR, LR
Limitations
N in C must be BCD between 001 to 999. R1 and R1+N–1 must be in the same data area. MAX(182) is an expansion instruction. A Programming Device can be used to reassign function code 182 to another expansion instruction.
Description
294
When the execution condition is OFF, MAX(182) is not executed. When the execution condition is ON, MAX(182) searches the range of memory from R1 to R1+N–1 for the address that contains the maximum value and outputs the maximum value to the destination word (D).
Page 307
Section 5-22
Special Math Instructions
If bit 14 of C is ON, MAX(182) identifies the address of the word containing the maximum value in D+1. The address is identified differently for the DM area: 1, 2, 3...
1. For an address in the DM area, the word address is written to D+1. For example, if the address containing the maximum value is DM 0114, then #0114 is written in D+1. 2. For an address in another data area, the number of addresses from the beginning of the search is written to D+1. For example, if the address containing the maximum value is IR 114 and the first word in the search range is IR 014, then #0100 is written in D+1. If bit 14 of C is ON and more than one address contains the same maximum value, the position of the lowest of the addresses will be output to D+1. The number of words within the range (N) is contained in the 3 rightmost digits of C, which must be BCD between 001 and 999. When bit 15 of C is OFF, data within the range is treated as normal binary and when it is ON the data is treated as signed binary. C:
15 14 13 12 11
00 Number of words in range (N) Not used – set to zero. Output address to D+1? 1 (ON): Yes. 0 (OFF): No.
Data type 1 (ON): Signed binary 0 (OFF): Normal binary
! Caution
Flags
If bit 15 of C is ON, values above #8000 are treated as negative numbers, so the results will differ depending on the specified data type. Be sure that the correct data type is specified. ER:
The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded. The number of words specified in C is not BCD (000 to 999). R1 and R1+N–1 are not in the same data area.
EQ:
ON when the maximum value is #0000.
N:
ON when bit 15 of D is set to 1.
5-22-2 FIND MINIMUM – MIN(183) Ladder Symbols
Operand Data Areas C: Control data
MIN(183)
@MIN(183)
C
C
R1
R1
D
D
IR, SR, AR, DM, EM, HR, LR, # R1: First word in range IR, SR, AR, DM, EM, HR, TC, LR D: Destination word IR, SR, AR, DM, EM, HR, LR
Limitations
N in C must be BCD between 001 to 999. R1 and R1+N–1 must be in the same data area.
295
Page 308
Section 5-22
Special Math Instructions
MIN(183) is an expansion instruction. A Programming Device can be used to reassign function code 183 to another expansion instruction. Description
When the execution condition is OFF, MIN(183) is not executed. When the execution condition is ON, MIN(183) searches the range of memory from R1 to R1+N–1 for the address that contains the minimum value and outputs the minimum value to the destination word (D). If bit 14 of C is ON, MIN(183) identifies the address of the word containing the minimum value in D+1. The address is identified differently for the DM area: 1, 2, 3...
1. For an address in the DM area, the word address is written to D+1. For example, if the address containing the minimum value is DM 0114, then #0114 is written in D+1. 2. For an address in another data area, the number of addresses from the beginning of the search is written to D+1. For example, if the address containing the minimum value is IR 114 and the first word in the search range is IR 014, then #0100 is written in D+1. If bit 14 of C is ON and more than one address contains the same minimum value, the position of the lowest of the addresses will be output to D+1. The number of words within the range (N) is contained in the 3 rightmost digits of C, which must be BCD between 001 and 999. When bit 15 of C is OFF, data within the range is treated as unsigned binary and when it is ON the data is treated as signed binary. Refer to page 30 for details on signed binary data.
C:
15 14 13 12 11
00 Number of words in range (N) Not used – set to zero.
Data type 1 (ON): Signed binary 0 (OFF): Unsigned binary
! Caution
Flags
Output address to D+1? 1 (ON): Yes. 0 (OFF): No.
If bit 15 of C is ON, values above #8000 are treated as negative numbers, so the results will differ depending on the specified data type. Be sure that the correct data type is specified.
ER:
The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded. The number of words specified in C is not BCD (000 to 999). R1 and R1+N–1 are not in the same data area.
296
EQ:
ON when the minimum value is #0000.
N:
ON when bit 15 of D is set to 1.
Page 309
Section 5-22
Special Math Instructions
5-22-3 AVERAGE VALUE – AVG(195) Operand Data Areas
Ladder Symbols AVG(195)
@AVG(195)
S
S
N
N
D
D
S: Source word IR, SR, AR, DM, EM, HR, TC, LR, # N: Number of cycles IR, SR, AR, DM, EM, HR, TC, LR, # D: First destination word IR, SR, AR, DM, EM, HR, LR
Limitations
Data of S must be hexadecimal. N must be BCD from #0001 to #0064. D and D+N+1 must be in the same data area. AVG(195) is an expansion instruction. A Programming Device can be used to reassign function code 195 to another expansion instruction.
Description
AVG(195) is used to calculate the average value of S over N cycles. When the execution condition is OFF, AVG(195) is not executed. For the first N–1 cycles when the execution condition is ON, AVG(195) writes the value of S to D. Each time that AVG(195) is executed, the previous value of S is stored in words D+2 to D+N+1. The first 2 digits of D+1 are incremented with each execution and act as a pointer to indicate where the previous value is stored. Bit 15 of D+1 remains OFF for the first N–1 cycles. On the Nth cycle, the previous value of S is written to last word in the range D+2 to D+N+1. The average value of the previous values stored in D+2 to D+N+1 is calculated and written to D, bit 15 of D+1 is turned ON, and the previous value pointer (the first 2 digits of D+1) is reset to zero. Each time that AVG(195) is executed, the previous value of S overwrites the content of the word indicated by the pointer and the new average value is calculated and written to D. The pointer will be reset again after reaching N–1. The following diagram shows the function of words D to D+N+1. D D+1 D+2 D+3
Average value (after N or more cycles) Previous value pointer and cycle indicator Previous value #1 Previous value #2
D+N+1
Previous value #N
The function of bits in D+1 are shown in the following diagram and explained in more detail below. D+1:
15 14
08 07
Not used. Set to zero.
00 Previous value pointer (2-digit hexadecimal from 0 to N–1.)
Cycle indicator 0 (OFF): cycles since execution of AVG(195) < N. 1 (ON): cycles since execution of AVG(195) ≥ N.
297
Page 310
Section 5-22
Special Math Instructions Previous Value Pointer
The previous value pointer indicates the location where the most recent value of S was stored relative to D+2, i.e., a pointer value of 0 indicates D+2, a value of 1 indicates D+3, etc.
Cycle Indicator
The cycle indicator is turned ON after AVG(195) has been executed N times. At this point, D will contain the average value of the contents of words D+2 through D+N+1. The average value is 4-digit hexadecimal and is rounded off to the nearest integer value.
Flags
ER:
The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded. One or more operands have been set incorrectly.
Example
In the following example, the content of IR 040 is set to #0000 and then incremented by 1 each cycle. For the first two cycles, AVG(195) moves the content of IR 040 to DM 1002 and DM 1003. The contents of DM 1001 will also change (which can be used to confirm that the results of AVG(195) has changed). On the third and later cycles AVG(195) calculates the average value of the contents of DM 1002 to DM 1004 and writes that average value to DM 1000.
00001 @MOV(021)
Address
Instruction
00000 00001
LD @MOV(021)
Operands
#0000 040
00001 #0000 040
AVG(195) 040
00002
AVG(195)
#0003
040 #0003 DM 1000
DM 1000
00003 00004
CLC(041)
CLC(041) ADB(050) 040 #0001 040
ADB(050) 040 #0001 040
298
IR 40
1st cycle 0000
2nd cycle 0001
3rd cycle 0002
4th cycle 0003
DM 1000 DM 1001 DM 1002 DM 1003 DM 1004
1st cycle 0000 0001 0000 -----
2nd cycle 0001 0002 0000 0001 ---
3rd cycle 0001 8000 0000 0001 0002
4th cycle 0002 8001 0003 0001 0002
Average Pointer 3 previous values of IR 40
Page 311
Section 5-22
Special Math Instructions
5-22-4 SUM – SUM(184) Operand Data Areas
Ladder Symbols SUM(184)
@SUM(184)
C
C
R1
R1
D
D
C: Control data IR, SR, AR, DM, EM, HR, LR, # R1: First word in range IR, SR, AR, DM, EM, HR, TC, LR D: First destination word IR, SR, AR, DM, EM, HR, LR
Limitations
The 3 rightmost digits of C must be BCD between 001 and 999. If bit 14 of C is OFF (setting for BCD data), all data within the range R1 to R1+N–1 must be BCD. SUM(184) is an expansion instruction. A Programming Device can be used to reassign function code 184 to another expansion instruction.
Description
When the execution condition is OFF, SUM(184) is not executed. When the execution condition is ON, SUM(184) adds either the contents of words R1 to R1+N–1 or the bytes in words R1 to R1+N/2–1 and outputs that value to the destination words (D and D+1). The data can be summed as binary or BCD and will be output in the same form. Binary data can be either signed or unsigned. The function of bits in C are shown in the following diagram and explained in more detail below. C:
15 14 13 12 11
00 Number of items in range (N, BCD) Number of words or number of bytes 001 to 999 Starting byte in R1 (when bit 13 is ON) 1 (ON): Rightmost 0 (OFF): Leftmost
Data type 1 (ON): Binary 0 (OFF): BCD
Addition units 1 (ON): Bytes 0 (OFF): Words
Data type (when bit 14 is ON) 1 (ON): Signed binary 0 (OFF): Unsigned binary
Number of Items in Range
The number of items within the range (N) is contained in the 3 rightmost digits of C, which must be BCD between 001 and 999. This number will indicate the number of words or the number of bytes depending the items being summed.
Addition Units
Words will be added if bit 13 is OFF and bytes will be added if bit 13 is ON. If bytes are specified, the range can begin with the leftmost or rightmost byte of R1. The leftmost byte of R1 will not be added if bit 12 is ON. R1 R1+1 R1+2 R1+3
MSB LSB 1 2 3 4 5 6 7 8
299
Page 312
Section 5-22
Special Math Instructions
The bytes will be added in this order when bit 12 is OFF: 1+2+3+4.... The bytes will be added in this order when bit 12 is ON: 2+3+4.... Data Type
Data within the range is treated as unsigned binary when bit 14 of C is ON and bit 15 is OFF, and it is treated as signed binary when both bits 14 and 15 are ON. Refer to page 30 for details on signed binary data. Data within the range is treated as BCD when bit 14 of C is OFF, regardless of the status of bit 15.
Flags
ER:
The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded. R1 and R1+N–1 are not in the same data area. The number of items in C is not BCD between 001 and 999. The data being summed is not BCD when BCD was designated.
Example
EQ:
ON when the result is zero.
N:
ON when bit 15 of D is set to 1.
In the following example, the BCD contents of the 10 words from DM 0000 to DM 0009 are added when IR 00001 is ON and the result is written to DM 0100 and DM 0101. 00001 @SUM(184) #4010 DM 0000
Address
Instruction
00000 00001
LD @SUM(184)
Operands 00001 #4010 DM 0000 DM 0100
DM 0100
DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005 DM 0006 DM 0007 DM 0008 DM 0009
3F2A 51C3 E02A 7C9F 2A20 A827 2A20 E02A C755 94DC
DM 0100 DM 0101
2678 0005
5-22-5 ARITHMETIC PROCESS – APR(069) Operand Data Areas
Ladder Symbols
C: Control word APR(069)
@APR(069)
C
C
S
S
D
D
IR, SR, AR, DM, EM, HR, TC, LR, # S: Input data source word IR, SR, AR, DM, EM, HR, TC, LR D: Result destination word IR, SR, AR, DM, EM, HR,TC, LR
Limitations
300
For trigonometric functions S must be BCD from 0000 to 0900 (0°≤ ≤ 90°). APR(069) is an expansion instruction. A Programming Device can be used to reassign function code 069 to another expansion instruction.
Page 313
Section 5-22
Special Math Instructions Description
When the execution condition is OFF, APR(069) is not executed. When the execution condition is ON, the operation of APR(069) depends on the control word C. If C is #0000 or #0001, APR(069) computes or The BCD value of S specifies in tenths of degrees. If C is an address, APR(069) computes f(x) of the function entered in advance beginning at word C. The function is a series of line segments (which can approximate a curve) determined by the operator. The BCD or hexadecimal value of S specifies x.
Flags
ER:
EQ: N:
The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded. For trigonometric functions, x > 0900. (x is the content of S.) A constant other than #0000 or #0001 was designated for C. The linear approximation data is not readable. The result is 0000. ON when bit 15 of D is set to 1.
Examples Sine Function
The following example demonstrates the use of the APR(069) sine function to calculate the sine of 30°. The sine function is specified when C is #0000.
00000 APR(069) #0000
Address
Instruction
00000 00001
LD APR(069)
DM 0000
0 0
S: DM 0000 100 101 3 0
Result data 10–1 0
Enter input data not exceeding #0900 in BCD.
Cosine Function
10–1 5
D: DM 0100 10–2 10–3 0 0
10–4 0
Result data has four significant digits, fifth and higher digits are ignored. The result for sin(90) will be 0.9999, not 1.
The following example demonstrates the use of the APR(069) cosine function to calculate the cosine of 30°. The cosine function is specified when C is #0001.
00000 APR(069) #0001 DM 0010 DM 0110
Input data, x 0 0
S: DM 0010 101 100 3 0
00000 #0000 DM 0000 DM 0100
DM 0100
Input data, x
Operands
Address
Instruction
00000 00001
LD APR(069)
Operands 00000 #0001 DM 0010 DM 0110
Result data 10–1 0
Enter input data not exceeding #0900 in BCD.
10–1 8
D: DM 0110 10–2 10–3 6 6
10–4 0
Result data has four significant digits, fifth and higher digits are ignored. The result for cos(0) will be 0.9999, not 1.
301