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

The text of a manual · part 37 of 61

DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 343 to 352

Pages 343 to 352 of 592, from DL205 PLC User Manual, Volume 1 of 2

The original document is the PDF (13 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 PLC Direct D2-08ND3 and Koyo D2-08ND3

Page 343

Chapter 5: Standard RLL Instructions - Transcendental Functions

Transcendental Functions (DL260 only) The DL260 CPU features special numerical functions to complement its real number capability. The transcendental functions include the trigonometric sine, cosine, and tangent, and also their inverses (arc sine, arc cosine, and arc tangent). The square root function is also grouped with these other functions. The transcendental math instructions operate on a real number in the accumulator (it cannot be BCD or binary). The real number result resides in the accumulator. The square root DS Used function operates on the full range of positive real numbers. The sine, cosine and tangent HPP N/A functions require numbers expressed in radians. You can work with angles expressed in degrees by first converting them to radians with the Radian (RADR) instruction, then performing the trig function. All transcendental functions utilize the following flag bits.

230 240 250-1 260

Discrete Bit Flags SP63 SP70 SP72 SP73 SP75

Description On when the result of the instruction causes the value in the accumulator to be zero. On anytime the value in the accumulator is negative. On anytime the value in the accumulator is a valid floating point number. On when a signed addition or subtraction results in a incorrect sign bit. On when a real number instruction is executed and a non-real number was encountered.

Math Function SP53

Range of Argument On when the value of the operand is larger than the accumulator can work with.

Sine Real (SINR) The Sine Real instruction takes the sine of the real number stored in the accumulator. The result resides in the accumulator. Both the original number and the result are in IEEE 32-bit format.

SINR

Cosine Real (COSR) The Cosine Real instruction takes the cosine of the real number stored in the accumulator. The result resides in the accumulator. Both the original number and the result are in IEEE 32-bit format.

COSR

Tangent Real (TANR) The Tangent Real instruction takes the tangent of the real number stored in the accumulator. The result resides in the accumulator. Both the original number and the result are in IEEE 32-bit format.

TANR

Arc Sine Real (ASINR) The Arc Sine Real instruction takes the inverse sine of the real number stored in the accumulator. The result resides in the accumulator. Both the original number and the result are in IEEE 32-bit format.

ASINR

DL205 User Manual, 4th Edition, Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–121

Page 344

Chapter 5: Standard RLL Instructions - Transcendental Functions

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Arc Cosine Real (ACOSR) The Arc Cosine Real instruction takes the inverse cosine of the real number stored in the accumulator. The result resides in the accumulator. Both the original number and the result are in IEEE 32-bit format.

ACOSR

Arc Tangent Real (ATANR) The Arc Tangent Real instruction takes the inverse tangent of the real number stored in the accumulator. The result resides in the accumulator. Both the original number and the result are in IEEE 32-bit format.

ATANR

Square Root Real (SQRTR) The Square Root Real instruction takes the square root of the real number stored in the accumulator. The result resides in the accumulator. Both the original number and the result are in IEEE 32-bit format.

SQRTR

NOTE: The square root function can be useful in several situations. However, if you are trying to do the square-root extract function for an orifice flow meter measurement as the PV to a PID loop, note that the PID loop already has the square-root extract function built in.

DS Used HPP N/A

5–122

The following example takes the sine of 45 degrees. Since these transcendental functions operate only on real numbers, we do a LDR (Load Real) 45. The trig functions operate only in radians, so we must convert the degrees to radians by using the RADR command. After using the SINR (Sine Real) instruction, we use an OUTD (Out Double) instruction to move the result from the accumulator to V-memory. The result is 32-bits wide, requiring the Out Double to move it. Accumulator contents (viewed as real number)

DirectSOFT X1

LDR

Load the real number 45 into the accumulator.

45.000000

RADR

Convert the degrees into radians, leaving the result in the accumulator.

0.7358981

SINR

Take the sine of the number in the accumulator, which is in radians.

0.7071067

Copy the valus in the accumulator to V2000 and V2001.

0.7071067

R45

OUTD V2000

NOTE: The current HPP does not support real number entry with automatic conversion to the 32-bit IEEE format. You must use DirectSOFT for entering real numbers, using the LDR (Load Real) instruction.

DL205 User Manual, 4th Edition, Rev. A

Page 345

Chapter 5: Standard RLL Instructions - Bit Operation

Bit Operation Instructions

1 Sum (SUM) The Sum instruction counts number of bits that are set to “1” 2

SUM in the accumulator. The HEX result resides in the accumulator.

3

Math Function Range of Argument 4 5 In the following example, when X1 is on, the value formed by discrete locations X10–X17 is loaded into the accumulator using the Load Formatted instruction. The number of bits in the accumulator set to “1” is counted using the Sum instruction. The value in the accumulator is 6 copied to V1500 using the Out instruction. 7 8 9 10 11 12 13 14 A B C D 230 240

250-1 260

DS Used HPP Used

SP63

On when the result of the instruction causes the value in the accumulator to be zero.

DirectSOFT

X17 X16 X15 X14 X13 X12 X11 X10

X1

LDF

ON ON OFF OFF ON OFF ON ON

X10

K8

The unused accumulator bits are set to zero

Load the value represented by discrete locations X10–X17 into the accumulator

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

0

0

1 1

0

0

0

0

0

0

0

0

0

0

0

Acc. 0

SUM

0

0

0

0

0

0

0

0

0

0

0

0

0

0

5

0

0

0

5

0

0

0

6 5

0

4 3

2

1

0

0

1 1

1

0

Sum the number of bits in the accumulator set to “1”

OUT

V1500

V1500

Copy the value in the lower 16 bits of the accumulator to V1500

Handheld Programmer Keystrokes $

B

1

STR

SHFT

L ANDST

SHFT

S RST

GX OUT

D

ENT

F

3

SHFT

PREV

B

U

ISG

PREV

A

1

5

M ORST PREV

I

0

8

ENT

ENT

B

F

1

A

5

A

0

0

ENT

DL205 User Manual, 4th Edition, Rev. A

5–123

Page 346

Chapter 5: Standard RLL Instructions - Bit Operation

230 Shift Left is a 32-bit instruction that shifts the bits in the a specified number (Aaaa) of places to the left. 240 accumulator The vacant positions are filled with zeros and the bits shifted 250-1 out of the accumulator are lost. 260 Operand Data Type V-memory Constant

SHFL A aaa

DL230 Range

DL240 Range

DL250-1 Range

A aaa aaa aaa

DL260 Range aaa

V K

All (See page 3 - 53) 1-32

All (See page 3 - 54) 1-32

All (See page 3 - 55) 1-32

All (See page 3 - 56) 1-32

In the following example, when X1 is on, the value in V2000 and V2001 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is shifted 10 bits to the left using the Shift Left instruction. The value in the accumulator is copied to V2010 and V2011 using the Out Double instruction. DS Used HPP Used Direct SOFT

V2001

X1

6

LDD

7

0

V2000 5

3

1

0

1

V2000 Load the value in V2000 and V2001 into the accumulator

SHFL

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

1

0

0

0

0

0

0

1

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

1

1

0

0

1

1

1

0

0

0

0

0

1

0

1

0

0

1

1

0

0

0

KA The bit pattern in the accumulator is shifted 10 bit positions to the left

Shifted out of the accumulator

OUTD V2010 Copy the value in the accumulator to V2010 and V2011

Acc.

0

0

0

1 0

0

1

0

0

1 4

B

$ STR

5–124

1 D

SHFT

L ANDST

SHFT

S RST

SHFT

GX OUT

SHFT

D

ENT D

3

C 3

H

A 2

F 7

5 C

3

1 0

A 2

A 0

L ANDST B 0

1

A 0

0

SHFT

A

A

ENT

0

0

ENT ENT

DL205 User Manual, 4th Edition, Rev. A

1 0

C 4

V2011

Handheld Programmer Keystrokes

Instructions

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Shift Left (SHFL)

0

0

0

1 0

0

0

0

0

0

0

0

1

8

7

6 5

4 3

2

1

0

0

0

0

0

0

0 0

0

0

4

0

0

V2010

0

0

Page 347

Chapter 5: Standard RLL Instructions - Bit Operation

Shift Right (SHFR) Right is a 32-bit instruction that shifts the bits in the 230 Shift accumulator a specified number (Aaaa) of places to the right. 240 The vacant positions are filled with zeros and the bits shifted 250-1 out of the accumulator are lost. 260 Operand Data Type V-memory Constant

SHFR A aaa

DL230 Range

DL240 Range

DL250-1 Range

A aaa aaa aaa

DL260 Range aaa

V K

All (See page 3 - 53) 1-32

All (See page 3 - 54) 1-32

All (See page 3 - 55) 1-32

All (See page 3 - 56) 1-32

In the following example, when X1 is on, the value in V2000 and V2001 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is shifted 10 bits to the right using the Shift Right instruction. The value in the accumulator is copied to V2010 and V2011 using the Out Double instruction. DS Used HPP Used Direct SOFT

V2001

X1

Constant 6

LDD

7

0

V2000 5

3

1

0

1

V2000 Load the value in V2000 and V2001 into the accumulator

SHFR

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

1

0

0

0

0

0

1

1

1

0

0

1

1

1

0

0

0

0

0

1

0

1

0

0

1

1

0

0

0

0

0

KA The bit pattern in the accumulator is shifted 10 bit positions to the right

Shifted out of the accumulator

OUTD V2010

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 Acc. 00

Copy the value in the accumulator to V2010 and V201 1

0

0

0

0

0 1

0 0

0 0

0

1

0

V2011

9

0

1 01 0

0

0

1 0

1 1

0

0 0

0

0

C

6 5

4 3

2

1

0

1 0

8

7

1

0

1

0

0

1

C

4

0

1

V2010

Handheld Programmer Keystrokes $

B 1

STR SHFT

L ANDST

D

SHFT

S RST

SHFT

SHFT

D

GX OUT

ENT D

3

C 3

H

F 7

5 C

3

A 2

R ORN A

2

A 0

B 0

1

A 0

0

SHFT

A

A

ENT

0

0

ENT ENT

DL205 User Manual, 4th Edition, Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–125

Page 348

Chapter 5: Standard RLL Instructions - Bit Operation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Rotate Left (ROTL) Left is a 32-bit instruction that rotates the bits in the 230 Rotate accumulator a specified number (Aaaa) of places to the left. 240

250-1 Operand Data Type DL250-1 Range DL260 Range 260 A aaa aaa V-memory Constant

DS Used HPP Used

V K

All (See page 3 - 55) 1-32

ROTL A aaa

All (See page 3 - 56) 1-32

In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is rotated 2 bit positions to the left using the Rotate Left instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction.

DirectSOFT V1401

X1

LDD

6 7

V1400

0 5

3 1

0 1

V1400 Load the value in V1400 and V1401 into the accumulator ROTL K2

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6

5

4

3

2

1

0

0

1

0

0

0

0

0

0

0

1

1

1

0

0

1

1

1

0

0

0

0

0

1

0

1

0

0

1

1

0

0

0

The bit pattern in the accumulator is rotated 2 bit positions to the left

OUTD V1500 Copy the value in the accumulator to V1500 and V1501

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6

5

4

3

2

1

0

1

0

0

0

0

0

0

1

0

1

4

0 5

0

0

1

1

1

0

0

0

0

9 C 1 4 V1501

Handheld Programmer Keystrokes $

B STR

1

ENT

SHFT

L ANDST

D 3

3

SHFT

R ORN

O INST#

T MLR

GX OUT

SHFT

D

5–126

D

B L ANDST B

3

E C 2

F 1

A 4

1

A 5

A 0

A 0

0

ENT

ENT

0

ENT

DL205 User Manual, 4th Edition, Rev. A

0

1

0

1

0

0

1

1

0

0

0

1

0

C

V1500

Page 349

Chapter 5: Standard RLL Instructions - Bit Operation

Rotate Right (ROTR) Right is a 32-bit instruction that rotates the bits in the 230 Rotate accumulator a specified number (Aaaa) of places to the right. 240

250-1 Operand Data Type DL250-1 Range DL260 Range 260 A aaa aaa V-memory Constant

V K

All (See page 3 - 55) 1-32

ROTR A aaa

All (See page 3 - 56) 1-32

In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The bit pattern in the accumulator is DS Used rotated 2 bit positions to the right using the Rotate Right instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. HPP Used DirectSOFT

V1401

X1

LDD

6

7

0

V1400 5

3

1

0

1

V1400 Load the value in V1400 and V1401 into the accumulator

ROTR

Acc.

K2

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

1

0

0

0

0

0

0

1

1 1

0

0

1 1 1

0

0

0

0

0

1

0

1

0

0

1 1

0

0

0

0

The bit pattern in the accumulator is rotated 2 bit positions to the right

OUTD V1500 Copy the value in the accumulator to V1500 and V1501

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

1

0

0

0

0

C

4

0

1 0

0

1 10 01 0 10 10 10 00 00 00 00 00 10 0

5

$

B STR

1 L ANDST

D

D 3

3

SHFT

R ORN

O INST#

T MLR

SHFT

D

B

E C 2

F 1

A 4

1 R ORN B

3

C

1

1

0

0

1 1

0

4

0

V1500

ENT

SHFT

GX OUT

9

V1501

Handheld Programmer Keystrokes

0

A 5

A 0

ENT

ENT A

0

0

0

ENT

DL205 User Manual, 4th Edition, Rev. A

0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–127

Page 350

Chapter 5: Standard RLL Instructions - Bit Operation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Encode (ENCO) Encode instruction encodes the bit position in the 230 The accumulator having a value of 1, and returns the appropriate 240 binary representation. If the most significant bit is set to 1 (Bit 250-1 31), the Encode instruction would place the value HEX 1F 260 (decimal 31) in the accumulator. If the value to be encoded is DS Used HPP Used

ENCO

0000 or 0001, the instruction will place a zero in the accumulator. If the value to be encoded has more than one bit position set to a “1”, the least significant “1” will be encoded and SP53 will be set on.

Discrete Bit Flags SP53

Description On when the value of the operand is larger than the accumulator can work with.

NOTE: The status flags are only valid until another instruction that uses the same flags is executed.

In the following example, when X1 is on, The value in V2000 is loaded into the accumulator using the Load instruction. The bit position set to a “1” in the accumulator is encoded to the corresponding 5 bit binary value using the Encode instruction. The value in the lower 16 bits of the accumulator is copied to V2010 using the Out instruction.

DirectSOFT X1

5–128

V2000 1

0

0

0

LD V2000 Load the value in V2000 into the lower 16 bits of the accumulator

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

0

0

0

0

0

0

2

1

0

1 1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

Bit postion 12 is converted to binary ENCO

Encode the bit position set to “1” in the accumulator to a 5 bit binary value

Acc.

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

OUT V2010 Copy the value in the lower 16 bits of the accumulator to V2010 Handheld Programmer Keystrokes $

B STR

1

ENT

SHFT

L ANDST

D

SHFT

E

N TMR

C

SHFT

V AND

GX OUT

4

C 3 2

DL205 User Manual, 4th Edition, Rev. A

0

C

V2010 Binary value for 12.

A

A

2

0

O INST#

ENT

C

A 2

A 0

B 0

0

A 1

0

ENT

ENT

Page 351

Chapter 5: Standard RLL Instructions - Bit Operation

Decode (DECO)

1 2 the value is less than 32 and then the value is decoded. 3 In the following example when X1 is on, the value formed by discrete locations X10–X14 is loaded into the accumulator using the Load Formatted instruction. The five bit binary 4 pattern in the accumulator is decoded by setting the corresponding bit position to a “1” using the Decode instruction. 5 6 7 8 9 10 11 12 13 14 A B C D

Decode instruction decodes a 5 bit binary value of 0 to 31 230 The (0 to 1F HEX) in the accumulator by setting the appropriate 240 bit position to a 1. If the accumulator contains the value F 250-1 (HEX), bit 15 will be set in the accumulator. If the value to be 260 decoded is greater than 31, the number is divided by 32 until DS Used HPP Used

DirectSOFT X1

DECO

X14 X13 X12 X11 X10

LDF

OFF ON OFF ON

X10

ON

K5

Load the value in represented by discrete locations X10–X14 into the accumulator

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

0

0

1 1

Acc.

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

The binary vlaue is converted to bit position 11.

DECO

Decode the five bit binary pattern in the accumulator and set the corresponding bit position to a “1”

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

0

0

0

0

0

Acc.

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

Handheld Programmer Keystrokes $

B

STR

1

SHFT

L ANDST

D

SHFT

D

E

3

ENT

F

3

B

C

4

2

A

1

5

O INST#

F

0

5

ENT

ENT

DL205 User Manual, 4th Edition, Rev. A

5–129

Page 352

Chapter 5: Standard RLL Instructions - Number Conversion

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Number Conversion Instructions (Accumulator) Binary (BIN)

BIN

The Binary instruction converts a BCD value in the accumulator to the equivalent binary value. The result resides 240 in the accumulator. 250-1 In the following example, when X1 is on, the value in V2000 and V2001 is loaded into the 260 accumulator using the Load Double instruction. The BCD value in the accumulator is 230

DS Used HPP Used

5–130 converted to the binary (HEX) equivalent using the BIN instruction. The binary value in the accumulator is copied to V2010 and V2011 using the Out Double instruction. (The handheld programmer will display the binary value in V2010 and V2011 as a HEX value.)

DirectSOFT X1

V2001 LDD

V2000

0

0

0

2

8

5

2

9

V2000 Load the value in V2000 and V2001 into the accumulator

Acc.

8 4

2

1

8

4 2

1

8

4

2 1

8

4

2

1

8 4

2

1

8

4 2

1

8

4

2 1

8

4

2

1

0 0

0

0

0

0 0

0

0

0

0 0

0

0

1

0

1 0

0

0

0

1 0

1

0

0

1 0

1

0

0

1

BCD Value

28529 = 16384 + 8192 + 2048 + 1024 + 512 + 256 + 64 + 32 + 16 + 1 Binary Equivalent Value

BIN

Convert the BCD value in the accumulator to the binary equivalent value

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8

7

6 5

4 3

2

1

0

0

0 0

0

0

0

0 0

0

0

0

0 0

0

0

0

0

1 1

0

1

1

1 1

0

1

1

1 0

0

0

1

2 1 4 7 4 4 8 3 6 4 8

1 0 7 3 7 4 1 8 2 4

2 6 8 4 3 5 4 5 6

1 3 4 2 1 7 7 2 8

6 7 1 0 8 8 6 4

3 3 5 5 4 4 3 2

8 3 8 8 6 0 8

4 1 9 4 3 0 4

2 0 9 7 1 5 2

1 0 4 8 5 7 6

2 6 2 1 4 4

1 3 1 0 7 2

6 5 5 3 6

3 2 7 6 8

1 6 3 8 4

8 1 9 2

4 0 9 6

2 0 4 8

1 0 2 4

5 2 1 5 2 6

1 6 2 4 8

3 2

1 8 6

4

2

1

0

0

6

F

7

1

Acc.

5 3 6 8 7 0 9 1 2

1 6 7 7 7 2 1 6

5 2 4 2 8 8

OUTD V2010 0

Copy the binary data in the accumulator to V2010 and V2011

0

V2011

V2010

The Binary (HEX) value copied to V2010

Handheld Programmer Keystrokes $ STR

B 1

SHFT

L ANDST

D

SHFT

B

I

GX OUT

SHFT

1

ENT D

C

3

3

8

N TMR

D

DL205 User Manual, 4th Edition, Rev. A

A 0

A 0

0

ENT C

3

A 2

A 2

B 0

A 1

0

ENT

ENT