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

The text of a manual · part 32 of 68

Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 284 to 293

Pages 284 to 293 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 284

Section 5-20

BCD Calculations Description

When the execution condition is OFF, MUL(032) is not executed. When the execution condition is ON, MUL(032) multiplies Md by the content of Mr, and places the result In R and R+1. Md

X R +1

Example

Mr

R

When IR 00000 is ON with the following program, the contents of IR 013 and DM 0005 are multiplied and the result is placed in HR 07 and HR 08. Example data and calculations are shown below the program.

00000 MUL(032) 013 DM 0005

Address

Instruction

00000 00001

LD MUL(032)

Flags

3

Md: IR 013 3 5 6

X

0

Mr: DM 0005 0 2 5

R+1: HR 08 0 0 8

3

R: HR 07 9 0

ER:

00000 013 DM 00005 HR 07

HR 07

0

Operands

0

Md and/or Mr is not BCD. The content of a 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 0.

5-20-10 DOUBLE BCD MULTIPLY – MULL(056) Operand Data Areas Md: First multiplicand word (BCD)

Ladder Symbols

IR, SR, AR, DM, EM, HR, TC, LR MULL(056)

@MULL(056)

Md

Md

Mr

Mr

R

R

Mr: First multiplier word (BCD)

Limitations

IR, SR, AR, DM, EM, HR, TC, LR R: First result word IR, SR, AR, DM, EM, HR LR

Md and Md+1 must be in the same data area, as must Mr and Mr+1. R through R+3 must be in the same data area.

272

Page 285

Section 5-20

BCD Calculations Description

When the execution condition is OFF, MULL(056) is not executed. When the execution condition is ON, MULL(056) multiplies the eight-digit content of Md and Md+1 by the content of Mr and Mr+1, and places the result in R to R+3.

x R+3

Flags

ER:

R+2

Md + 1

Md

Mr + 1

Mr

R+1

R

Md, Md+1,Mr, or Mr+1 is not BCD. 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 0.

5-20-11 BCD DIVIDE – DIV(033) Operand Data Areas Dd: Dividend word (BCD)

Ladder Symbol

IR, SR, AR, DM, EM, HR, TC, LR, # DIV(033)

@DIV(033)

Dd

Dd

Dr

Dr

R

R

Dr: Divisor word (BCD) IR, SR, AR, DM, EM, HR, TC, LR, # R: First result word (BCD) IR, SR, AR, DM, EM, HR, LR

Limitations

R and R+1 must be in the same data area.

Description

When the execution condition is OFF, DIV(033) is not executed and the program moves to the next instruction. When the execution condition is ON, Dd is divided by Dr and the result is placed in R and R + 1: the quotient in R and the remainder in R + 1. Remainder

Quotient

R+1

R

Dr

Flags

ER:

Dd

Dd or Dr is not in BCD or when Dr is #0000. The content of a 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 0.

273

Page 286

Section 5-20

BCD Calculations Example

When IR 00000 is ON with the following program, the content of IR 020 is divided by the content of HR 09 and the result is placed in DM 0017 and DM 0018. Example data and calculations are shown below the program.

00000 DIV(033) 020

Address

Instruction

00000 00001

LD DIV(033)

Operands 00000

HR 09

020 HR 09 DM 0017

DM 0017

1

0

Quotient

Remainder

R: DM 0017 1 5 0

R + 1: DM 0018 0 0 0 2

Dd: HR 09 0 0 3

3

Dd: IR 020 4 5 2

5-20-12 DOUBLE BCD DIVIDE – DIVL(057) Operand Data Areas Dd: First dividend word (BCD)

Ladder Symbols

IR, SR, AR, DM, EM, HR, TC, LR DIVL(057)

@DIVL(057)

Dd

Dd

Dr

Dr

R

R

Dr: First divisor word (BCD)

Limitations

IR, SR, AR, DM, EM, HR, TC, LR R: First result word IR, SR, AR, DM, EM, HR, LR

Dd and Dd+1 must be in the same data area, as must Dr and Dr+1. R through R+3 must be in the same data area.

Description

When the execution condition is OFF, DIVL(057) is not executed. When the execution condition is ON, DIVL(057) the eight-digit content of Dd and D+1 is divided by the content of Dr and Dr+1 and the result is placed in R to R+3: the quotient in R and R+1, the remainder in R+2 and R+3. Remainder R+3

Dr+1

Flags

ER:

R+2

Dr

Quotient R+1

R

Dd+1

Dd

Dr and Dr+1 contain 0. Dd, Dd+1, Dr, or Dr+1 is not BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

EQ:

274

ON when the result is 0.

Page 287

Section 5-20

BCD Calculations

5-20-13 FLOATING POINT DIVIDE – FDIV(079) Operand Data Areas Dd: First dividend word (BCD)

Ladder Symbols

IR, SR, AR, DM, EM, HR, TC, LR FDIV(079)

@FDIV(079)

Dd

Dd

Dr

Dr

R

R

Dr: First divisor word (BCD) IR, SR, AR, DM, EM, HR, TC, LR R: First result word IR, SR, AR, DM, EM, HR, LR

Limitations

Dr and Dr+1 cannot contain zero. Dr and Dr+1 must be in the same data area, as must Dd and Dd+1; R and R+1. The dividend and divisor must be between 0.0000001 x 10–7 and 0.9999999 x 107. The results must be between 0.1 x 10–7 and 0.9999999 x 107.

Description

When the execution condition is OFF, FDIV(079) is not executed. When the execution condition is ON, FDIV(079) divides the floating-point value in Dd and Dd+1 by that in Dr and Dr+1 and places the result in R and R+1. Quotient

Dr+1

Dr

R+1

R

Dd+1

Dd

To represent the floating point values, the rightmost seven digits are used for the mantissa and the leftmost digit is used for the exponent, as shown below. The mantissa is expressed as a value less than one, i.e., to seven decimal places. First word 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 1

0

1

0

0

0

0

1

0 exponent (0 to 7) sign of exponent

0

0

1

0

0

0

1 mantissa (leftmost 3 digits) 0: + 1: –

Second word 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 0

0

0

1

0

0

0

1

0

0

0

1

0

0

0

1 mantissa (leftmost 4 digits)

= 0.1111111 x 10–2 Flags

ER:

Dr and Dr+1 contain 0. Dd, Dd+1, Dr, or Dr+1 is not BCD. The result is not between 0.1 x 10–7 and 0.999999 x 107. The content of a 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 0.

275

Page 288

BCD Calculations Example

276

Section 5-20 The following example shows how to divide two whole four-digit numbers (i.e., numbers without fractions) so that a floating-point value can be obtained. First the original numbers must be placed in floating-point form. Because the numbers are originally without decimal points, the exponent will be 4 (e.g., 3452 would equal 0.3452 x 104). All of the moves are to place the proper data into consecutive words for the final division, including the exponent and zeros. Data movements for Dd and Dd+1 are shown at the right below. Movements for Dr and Dr+1 are basically the same. The original values to be divided are in DM 0000 and DM 0001. The final division is also shown.

Page 289

Section 5-20

BCD Calculations 00000 @MOV(21)

HR 01

#0000

0

HR 00 0 0

0

HR 00 @MOV(21)

0000

#0000 HR 02 @MOV(21)

HR 01 4 0 0 0

#4000

0

HR 00 0 0

0

HR 01 @MOV(21)

4000

#4000 HR 03

DM 0000 3 4 5 2

@MOVD(83) DM 0000 #0021

HR 01 4 3 4 5

HR 01 00000 @MOVD(83)

0

HR 00 0 0

0

DM 0000 3 4 5 2

DM 0000 #0300 HR 00

@MOVD(83)

HR 01 4 3 4 5

2

HR 00 0 0

0

HR 01 4 3 4 5

2

HR 00 0 0

0

HR 03 4 0 0 7

9

HR 02 0 0

0

DM 0003 2 4 3 6

9

DM 0002 6 2 0

DM 0001 #0021 HR 03

@MOVD(83) DM 0001 #0300 HR 02

@FDIV(79)

÷

HR 00 HR 02

0.4369620 x 102

DM 0002

Address

Instruction

00000 00001

LD @MOV(021)

Operands 00000

Address

Instruction

00006

@MOVD(083) DM 0000 #0300 HR 00

#0000 HR 00 00002

@MOV(021)

00007

@MOVD(083)

#0000 HR 02 00003

00004

00008

@MOVD(083) DM 0001 #0300 HR 02

@MOV(021) #4000 HR 03

00005

DM 0001 #0021 HR 03

@MOV(021) #4000 HR 01

@MOVD(083) DM 0000 #0021 HR 01

Operands

00009

@FDIV(079) HR 00 HR 02 DM 0002

277

Page 290

Section 5-20

BCD Calculations

5-20-14 SQUARE ROOT – ROOT(072) Ladder Symbols

Operand Data Areas Sq: First source word (BCD)

ROOT(072)

@ROOT(072)

Sq

Sq

R

R

IR, SR, AR, DM, EM, HR, TC, LR R: Result word IR, SR, AR, DM, EM, HR, LR,

Limitations

Sq and Sq+1 must be in the same data area.

Description

When the execution condition is OFF, ROOT(072) is not executed. When the execution condition is ON, ROOT(072) computes the square root of the eight-digit content of Sq and Sq+1 and places the result in R. The fractional portion is truncated. R

Sq+1

Flags

ER:

Sq

Sq or Sq+1 is not BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

EQ: Example

278

ON when the result is 0.

The following example shows how to take the square root of a four-digit number and then round the result. First the words to be used are cleared to all zeros and then the value whose square root is to be taken is moved to Sq+1. The result, which has twice the number of digits required for the answer (because the number of digits in the original value was doubled), is placed in DM 0102, and the digits are split into two different words, the leftmost two digits to IR 011 for the answer and the rightmost two digits to DM 0103 so that the answer in IR 011 can be rounded up if required. The last step is to compare the value in DM 0103 so that IR 011 can be incremented using the Greater Than flag.

Page 291

Section 5-20

BCD Calculations

In this example, √6017 = 77.56, and 77.56 is rounded off to 78. 00000 @BSET(071)

DM 0101 0 0 0

#0000

0

0

DM 0100 0 0 0

DM 0100 DM 0101

0000

0000 010 6 0 1

@MOV(021) 010

7

DM 0101

DM 0101 6 0 1 7

@ROOT(072)

0

DM 0100 0 0 0

DM 0100

60170000= 77.56932

DM 0102 @MOV(021) #0000

DM 0103 0 0 0

011

0

0

IR 011 0 0

0

@MOV(021)

0000

#0000

0000

DM 0103 @MOVD(083)

DM 0102 7 7 5 6

DM 0102 #0012 011

@MOVD(083)

0 0

DM 0102

IR 011 7 7

5

DM 0103 6 0 0

#0210 DM 0103

@CMP(020)

5600 > 4900

DM 0103 #4900 25505 @INC(038)

0 0

011

Address

Instruction

00000 00001

LD @BSET(071)

Operands 00000 #0000 DM 0100 DM 0101

00002

IR 011 7 8

Address

Instruction

00006

@MOVD(083) DM 0102 #0012 011

00007

@MOVD(083)

@MOV(021)

DM 0102 #0210 DM 0103

010 DM 0101 00003

@ROOT(072)

00008

@CMP(020)

DM 0100 DM 0102 00004

@MOV(021) #0000 011

00005

Operands

00009 00010

LD @INC(038)

DM 0103 #4900 25505 011

@MOV(021) #0000 DM 0103

279

Page 292

Section 5-21

Binary Calculations

5-21 Binary Calculations Binary calculation instructions, ADB(050), SBB(051), MLB(052), DVB(053), ADBL(480), SBBL(481), MBS(484), MBSL(482), DBS(485), and DBSL(483), perform arithmetic operations on hexadecimal data. Four of these instructions (ADB(050), SBB(051), ADBL(480), and SBBL(481)) can act on both normal and signed data, two (MLB(052) and DVB(053)) act only on normal data, and four (MBS(484), MBSL(482), DBS(485), and DBSL(483)) act only on signed binary data. The addition and subtraction instructions include CY in the calculation as well as in the result. Be sure to clear CY if its previous status is not required in the calculation, and to use the result placed in CY, if required, before it is changed by the execution of any other instruction. STC(040) and CLC(041) can be used to control CY. Refer to 5-20 BCD Calculations. Signed binary addition and subtraction instructions use the underflow and overflow flags (UF and OF) to indicate whether the result exceeds the acceptable range for 16-bit or 32-bit signed binary data. Refer to page 30 for details on signed binary data.

5-21-1 BINARY ADD – ADB(050) Operand Data Areas Au: Augend word (binary)

Ladder Symbols

IR, SR, AR, DM, EM, HR, TC, LR, # ADB(050)

@ADB(050)

Au

Au

Ad

Ad

R

R

Ad: Addend word (binary)

Description

IR, SR, AR, DM, EM, HR, TC, LR, # R: Result word IR, SR, AR, DM, EM, HR, LR

When the execution condition is OFF, ADB(050) is not executed. When the execution condition is ON, ADB(050) adds the contents of Au, Ad, and CY, and places the result in R. CY will be set if the result is greater than FFFF.

Au + Ad + CY

CY

R

ADB(050) can also be used to add signed binary data. The overflow and underflow flags (SR 25404 and SR 25405) indicate whether the result has exceeded the lower or upper limits of the 16-bit signed binary data range. Refer to page 30 for details on signed binary data. Flags

280

ER:

The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

CY:

ON when the result is greater than FFFF.

EQ:

ON when the result is 0.

OF:

ON when the result exceeds +32,767 (7FFF).

UF:

ON when the result is below –32,768 (8000).

N:

ON when bit 15 of the result is set to 1.

Page 293

Binary Calculations

Section 5-21

Example 1: Adding Normal Data

The following example shows a four-digit addition with CY used to place either #0000 or #0001 into R+1 to ensure that any carry is preserved.

TR 0 00000 CLC(041)

ADB(050)

Address

Instruction

00000 00001 00002 00003

LD OUT CLC(041) ADB(050)

010 DM 0100 HR 10

=R

25504

00004 00005

MOV(021) #0000 HR 11

AND NOT MOV(021)

= R+1

25504 MOV(021) #0001 HR 11

= R+1

00006 00007 00008

LD AND MOV(021)

Operands 00000 TR 0

010 DM 0100 HR 10 25504 #0000 HR 11 TR 0 25504 #0001 HR 11

In the case below, A6E2 + 80C5 = 127A7. The result is a 5-digit number, so CY (SR 25504) = 1, and the content of R + 1 becomes #0001.

0

A

Au: IR 010 6 E 2

+

8

Ad: DM 0100 0 C 5

R+1: HR 11 0 0 1

2

R: HR 10 7 A

7

Note The UF and OF flags would also be turned ON during this addition, but they can be ignored since they are relevant only in the addition of signed binary data. Example 2: Adding Signed Binary Data

In the following example, ADB(050) is used to add two 16-bit signed binary values. (The 2’s complement is used to express negative values.) The effective range for 16-bit signed binary values is –32,768 (8000) to +32,767 (7FFF). The overflow flag (OF: SR 25404) is turned ON if the result exceeds +32,767 (7FFF) and the underflow flag (UF: SR 25405) is turned ON if the result falls below –32,768 (8000).

00000 CLC(041)

ADB(050) LR 20 DM 0010 DM 0020

Address

Instruction

00000 00001 00002

LD CLC(041) ADB(050)

Operands 00000

LR 20 DM 0010 DM 0020

281