Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 29 of 60

C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 274 to 283

Pages 274 to 283 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 274

Section 5-20

Binary Calculations Example

In the following example, DBS(––) 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(––) 001

Address

Instruction

00000 00001

LD DBS(––)

Operands 00000

DM 0020

DM LR

LR 21

÷ F

R+1: LR 22 F F A

Remainder (–6)

D

Dd: IR 001 D D A

(–8,742)

0

Dr: DM 0020 0 1 A

(26)

F

R: LR 21 E B

0

001 0020 21

(–336 and –6)

Quotient (–336)

5-20-10 DOUBLE SIGNED BINARY DIVIDE – DBSL(––) Operand Data Areas Dd: Dividend word (binary)

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR DBSL(––)

@DBSL(––)

Dd

Dd

Dr

Dr

R

R

Dr: Divisor word (binary) IR, SR, AR, DM, HR, TC, LR R: First result word IR, SR, AR, DM, 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.

Description

DBS(––) 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 27 for details on signed binary data. Remainder R+3

Dr+1

Flags

ER:

R+2

Dr

Quotient R+1

R

Dd+1

Dd

Dr+1 and Dr contain 0. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)

256

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.

Page 275

Section 5-21

Special Math Instructions Example

In the following example, DBSL(––) 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(––)

DBSL(––) 001

Operands 00000

DM 0020

DM LR

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)

0

001 0020 21

(–336,016 and –4)

Quotient (–336,016)

5-21 Special Math Instructions 5-21-1 FIND MAXIMUM – MAX(––) Ladder Symbols

Operand Data Areas C: Control data

MAX(––)

@MAX(––)

C

C

R1

R1

D

D

IR, SR, AR, DM, HR, LR, # R1: First word in range IR, SR, AR, DM, HR, TC, LR D: Destination word IR, SR, AR, DM, 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.

Description

When the execution condition is OFF, MAX(––) is not executed. When the execution condition is ON, MAX(––) 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). If bit 14 of C is ON, MAX(––) 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.

257

Page 276

Section 5-21

Special Math Instructions

If bit 15 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.

Data type 1 (ON): Signed binary 0 (OFF): Normal binary

! Caution

Flags

Output address to D+1? 1 (ON): Yes. 0 (OFF): No.

If bit 14 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:

Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM 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-21-2 FIND MINIMUM – MIN(––) Ladder Symbols

Operand Data Areas C: Control data

MIN(––)

@MIN(––)

C

C

R1

R1

D

D

IR, SR, AR, DM, HR, LR, # R1: First word in range IR, SR, AR, DM, HR, TC, LR D: Destination word IR, SR, AR, DM, 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.

Description

When the execution condition is OFF, MIN(––) is not executed. When the execution condition is ON, MIN(––) 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(––) 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...

258

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.

Page 277

Section 5-21

Special Math Instructions

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 27 for details on signed binary data. 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): Unsigned binary

! Caution

Flags

If bit 14 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. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)

ER:

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 minimum value is #0000.

N:

ON when bit 15 of D is set to 1.

5-21-3 AVERAGE VALUE – AVG(––) Operand Data Areas

Ladder Symbols AVG(––)

@AVG(––)

S

S

N

N

D

D

S: Source word IR, SR, AR, DM, HR, TC, LR, # N: Number of cycles IR, SR, AR, DM, HR, TC, LR, # D: First destination word IR, SR, AR, DM, 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.

Description

AVG(––) is used to calculate the average value of S over N cycles. When the execution condition is OFF, AVG(––) is not executed.

259

Page 278

Section 5-21

Special Math Instructions

For the first N–1 cycles when the execution condition is ON, AVG(––) writes the value of S to D. Each time that AVG(––) 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(––) 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(––) < N. 1 (ON): cycles since execution of AVG(––) ≥ N.

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(––) 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:

Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.) One or more operands have been set incorrectly.

260

Page 279

Section 5-21

Special Math Instructions 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(––) 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(––) has changed). On the third and later cycles AVG(––) calculates the average value of the contents of DM 1002 to DM 1004 and writes that average value to DM 1000.

00001 @MOV(21)

Address

Instruction

00000 00001

LD @MOV(21)

Operands

#0000 040

00001 #

AVG(––) 040

00002

AVG(––)

#0003

# DM

DM 1000

00003 00004

CLC(41)

0000 040 040 0003 1000

CLC(41) ADB(50)

ADB(50)

#

040

040 0001 040

#0001 040

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

5-21-4 SUM – SUM(––) Operand Data Areas

Ladder Symbols SUM(––)

@SUM(––)

C

C

R1

R1

D

D

C: Control data IR, SR, AR, DM, HR, LR, # R1: First word in range IR, SR, AR, DM, HR, TC, LR D: First destination word IR, SR, AR, DM, 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.

261

Page 280

Section 5-21

Special Math Instructions Description

When the execution condition is OFF, SUM(––) is not executed. When the execution condition is ON, SUM(––) 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

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 27 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:

Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM 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.

262

EQ:

ON when the result is zero.

N:

ON when bit 15 of D is set to 1.

Page 281

Section 5-21

Special Math Instructions Example

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(––)

Address

Instruction

00000 00001

LD @SUM(––)

#4010 DM 0000

Operands 00001 # DM DM

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

4010 0000 0100

2678 0005

5-21-5 ARITHMETIC PROCESS – APR(69) Operand Data Areas

Ladder Symbols

C: Control word APR(69)

@APR(69)

C

C

S

S

D

D

IR, SR, AR, DM, HR, TC, LR, # S: Input data source word IR, SR, AR, DM, HR, TC, LR D: Result destination word IR, SR, AR, DM, HR,TC, LR

Limitations

For trigonometric functions S must be BCD from 0000 to 0900 (0°≤ ≤ 90°).

Description

When the execution condition is OFF, APR(69) is not executed. When the execution condition is ON, the operation of APR(69) depends on the control word C. If C is #0000 or #0001, APR(69) computes or The BCD value of S specifies in tenths of degrees. If C is an address, APR(69) 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:

Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM 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.

EQ:

The result is 0000.

N:

ON when bit 15 of D is set to 1.

263

Page 282

Section 5-21

Special Math Instructions Examples Sine Function

The following example demonstrates the use of the APR(69) sine function to calculate the sine of 30°. The sine function is specified when C is #0000.

00000 APR(69) #0000

Address

Instruction

00000 00001

LD APR(69)

00000

DM 0000

# DM DM

DM 0100

Input data, x 0 0

S: DM 0000 101 100 3 0

10–1 0

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(69) cosine function to calculate the cosine of 30°. The cosine function is specified when C is #0001.

00000 APR(69) #0001 DM 0010 DM 0110

Input data, x 0 0

Address

Instruction

00000 00001

LD APR(69)

Operands 00000 # DM DM

0001 0010 0110

Result data 10–1 0

Enter input data not exceeding #0900 in BCD.

Linear Approximation

0000 0000 0100

Result data

Enter input data not exceeding #0900 in BCD.

S: DM 0010 101 100 3 0

Operands

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.

APR(69) linear approximation is specified when C is a memory address. Word C is the first word of the continuous block of memory containing the linear approximation data. The content of word C specifies the number of line segments in the approximation, and whether the input and output are in BCD or BIN form. Bits 00 to 07 contain the number of line segments less 1, m–1, as binary data. Bits 14 and 15 determine, respectively, the output and input forms: 0 specifies BCD and 1 specifies BIN. C: 15 14

Not used.

07 06 05 04 03 02 01 00

Number of coordinates minus one (m–1) Output form Input form

264

Page 283

Section 5-21

Special Math Instructions

Enter the coordinates of the m+1 end-points, which define the m line segments, as shown in the following table. Enter all coordinates in BIN form. Always enter the coordinates from the lowest X value (X1) to the highest (Xm). X0 is 0000, and does not have to be entered.

Y

Word

Ym Y4

Coordinate

C+1

Xm (max. X value)

C+2

Y0

C+3

X1

Y3

C+4

Y1

Y1

C+5

X2

C+6

Y2

Y2 Y0

X X0

X1

X2 X3

X4

↓

↓

C+(2m+1)

Xm

C+(2m+2)

Ym

Xm

If bit 13 of C is set to 1, the graph will be reflected from left to right, as shown in the following diagram. Y

Y

X0

Xm

X

Xm

X

X0

The following example demonstrates the construction of a linear approximation with 12 line segments. The block of data is continuous, as it must be, from DM 0000 to DM 0026 (C to C + (2 × 12 + 2)). The input data is taken from IR 010, and the result is output to IR 011.

00000 APR(69) DM 0000

Address

Instruction

00000 00001

LD APR(69)

Operands 00000

010

DM

011

Content Coordinate

Bit 15

DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005 DM 0006

$C00B $05F0 $0000 $0005 $0F00 $001A $0402

1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1

↓

↓

↓

DM 0025 DM 0026

$05F0 $1F20

X12 Y12

X12 Y0 X1 Y1 X2 Y2

(Output and input both BIN)

0000 010 011

Bit 00

(m–1 = 11: 12 line segments)

265