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

The text of a manual · part 36 of 60

DL205 PLC User Manual, Volume 1 of 2, pages 351 to 360

Pages 351 to 360 of 598

The original document is the PDF (12 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 AutomationDirect D2-04TD1, AutomationDirect D2-08TD2, AutomationDirect D2-16ND3-2, AutomationDirect D2-32ND3, Konnect-It D2-04TD1, Koyo D2-04TD1, Konnect-It D2-08TD2, Koyo D2-08TD2, and 5 more models

Page 351

Chapter 5: Standard RLL Instructions

Rotate Right (ROTR)

1 2 3 In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the 4 accumulator using the Load Double instruction. The bit pattern in the accumulator is rotated 2 bit positions to the right using the Rotate Right instruction. The value in the accumulator is 5 copied to V1500 and V1501 using the Out Double instruction. 6 7 8 9 10 11 12 13 14 A B C D

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

DS Used HPP Used DirectSOFT X1

V K

All (See page 3-55) 1-32

ROTR A aaa

All (See page 3-56) 1-32

V1401

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

$

STR

B

1

SHFT

L ANDST

D

SHFT

R ORN

O INST#

SHFT

D

GX OUT

3

3

9

C

V1501

Handheld Programmer Keystrokes

1

0

1

0

0

1 1

0

4

0

0

V1500

ENT

D

B

3

T MLR

1

R ORN B

1

E

C

F

5

A

4 2 0

A

0

A

0

ENT

ENT

A

0

ENT

DL205 User Manual, 4th Edition, Rev. D

5-127

Page 352

Chapter 5: Standard RLL Instructions

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 250-1 1 (Bit 31), the Encode instruction would place the value 260 HEX 1F (decimal 31) in the accumulator. If the value to be DS Used HPP Used

ENCO encoded is 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. V2000

DirectSOFT X1

5-128

1

LD

0

0

0

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. D

0

C

V2010 Binary value for 12.

2

A

0

O INST#

ENT

C

A

2

0

A

B

0

1

A

A

0

0

ENT

ENT

Page 353

Chapter 5: Standard RLL Instructions

Decode (DECO)

1 2 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 5-bit binary pattern in the accumulator is decoded by setting the corresponding bit position to a “1” using the Decode 4 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 bit 240 position to a 1. If the accumulator contains the value F (HEX), 250-1 bit 15 will be set in the accumulator. If the value to be decoded 260 is greater than 31, the number is divided by 32 until the value is DS Used HPP Used

DirectSOFT X1

DECO

X14 X13 X12 X11 X10

LDF

OFF ON OFF ON ON

X10

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

SHFT

L ANDST

D

SHFT

D

E

3

1

3 4

ENT

F

C

B

5 2

O INST#

1

A

0

F

5

ENT

ENT

DL205 User Manual, 4th Edition, Rev. D

5-129

Page 354

Chapter 5: Standard RLL Instructions

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

Binary instruction converts a BCD value in the 230 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 260 and V2001 is loaded into the accumulator using the Load Double instruction. The BCD value DS Used HPP Used

5-130 in the accumulator is 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

SHFT

L ANDST

D

SHFT

B

I

GX OUT

SHFT

1

D

1 3 8

ENT D

C

3

N TMR

3

DL205 User Manual, 4th Edition, Rev. D

2

A

0

A

0

A

0

ENT C

2

A

0

B

1

A

0

ENT

ENT

Page 355

Chapter 5: Standard RLL Instructions

Binary Coded Decimal (BCD)

Binary Coded Decimal instruction converts a binary value BCD 1 230 The in the accumulator to the equivalent BCD value. The result 240 resides in the accumulator. 250-1 In the following example, when X1 is on, the binary (HEX) 2 260 value in V2000 and V2001 is loaded into the accumulator using the Load Double instruction. The binary value in the accumulator is converted to the BCD equivalent value using the BCD instruction. The BCD value in the accumulator is copied to V2010 and V2011 using the Out Used Double instruction.

DS HPP Used

DirectSOFT X1

V2001 0

LDD

0

0

V2000 0

6

F

7

1

Binary Value

V2000 Load the value in V2000 and V2001 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 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

5 3 6 8 7 0 9 1 2

2 6 8 4 3 5 4 5 6

6 7 1 0 8 8 6 4

3 3 5 5 4 4 3 2

1 6 7 7 7 2 1 6

8 3 8 8 6 0 8

2 0 9 7 1 5 2

1 0 4 8 5 7 6

5 2 4 2 8 8

2 6 2 1 4 4

6 5 5 3 6

3 2 7 6 8

1 6 3 8 4

8 1 9 2

4 0 9 6

1 0 2 4

5 1 2

2 5 6

1 6 2 4 8

3 2

1 6

8

4

2 1

1 3 4 2 1 7 7 2 8

BCD

4 1 9 4 3 0 4

1 3 1 0 7 2

2 0 4 8

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

Convert the binary value in the accumulator to the BCD equivalent value 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 1

0

1

0

0

0 0

1

0

0 0

1

0

0 0

1

0

2

8

5

2

9

The BCD value copied to V2010 and V2011

0

0

0

1

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

0

0

V2011

V2010

Handheld Programmer Keystrokes $

B

STR

SHFT SHFT GX OUT

L ANDST

D

B

C

1

SHFT

D

1 3 2 3

ENT D D

C

3 3

2

A

0

A

0

A

0

ENT

ENT C

2

A

0

B

1

A

0

ENT

DL205 User Manual, 4th Edition, Rev. D

1

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

5-131

Page 356

Chapter 5: Standard RLL Instructions

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

Invert (INV) Invert instruction inverts or takes the one’s complement 230 The INV of the 32-bit value in the accumulator. The result resides in 240 the accumulator. 250-1 260 In the following example, when X1 is on, the value in V2000 and V2001 will be loaded into DS Used HPP Used the accumulator using the Load Double instruction. The value in the accumulator is inverted using the Invert instruction. The value in the accumulator is copied to V2010 and V2011 using the Out Double instruction.

DirectSOFT X1

5-132

V2001 0

LDD

4

0

V2000 5

00 22 55 00

V2000 Load the value in V2000 and V2001 into the accumulator Acc.

INV Acc.

Invert the binary bit pattern in 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

1

0

0

1

1

0

0

0

0

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 1

1 1

0

0

1

1

1

0

0

0

1 1

0

1

1

0

0

0

1

0

1

1

0

0

1

1

0

1

0

1

F

OUTD V2010

1

0

1

0

0

0

1

0

1 1

1 1 1

B

F

A

F

A

D

V2010

Copy the value in the accumulator to V2010 and V2011

Handheld Programmer Keystrokes B

STR

1

SHFT

L ANDST

D

SHFT

I

N TMR

GX OUT

SHFT

8

D

3

3

ENT D

C

3

V AND

2

A

0

A

0

A

0

ENT C

2

A

DL205 User Manual, 4th Edition, Rev. D

0

B

1

A

0

0

V2011

$

0

0

ENT

ENT

F

0

1

0

0

1

1

Page 357

Chapter 5: Standard RLL Instructions

Ten’s Complement (BCDCPL)

11 22, accumulator value 33 10’s complement value 4 In the following example when X1 is on, the value in V2000 and V2001 is loaded into the 4 accumulator. The 10’s complement is taken for the 8-digit accumulator using the Ten’s Complement instruction. The value in the accumulator is copied to V2010 and V2011 using 5 5 the Out Double instruction. 66 77 88 99 10 10 11 11 12 12 13 13 14 14 AA BB CC DD

Ten’s Complement instruction takes the 10’s complement 230 The (BCD) of the 8-digit accumulator. The result resides in the 240 accumulator. The calculation for this instruction is : 250-1 100000000 260 DS Used HPP Used

DirectSOFT

BCDCPL

V2000

V2001

X1

0

0

0

0

0

0

8

7

Acc. 0

0

0

0

0

0

8

7

Acc. 9

9

9

9

9

9

1

3

9

9

9

9

9

9

1

3

LDD

V2000

Load the value in V2000 and V2001 into the accumulator

BCDCPL

Takes a 10’s complement of the value in the accumulator OUTD

V2010

V2011

Copy the value in the accumulator to V2010 and V2011

V2010

Handheld Programmer Keystrokes $

B

STR

SHFT

L ANDST

D

SHFT

B

C

GX OUT

SHFT

1

D

1

3

2

3

ENT

D

D

C

3

3

C

C

2

2

P

A

2

CV 0

A

0

A

0

L ANDST

ENT

B

A

1

0

A

0

ENT

ENT

DL205 User Manual, 4th Edition, Rev. D

5-133

Page 358

Chapter 5: Standard RLL Instructions

Binary to Real Conversion (BTOR)

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

Binary-to-Real instruction converts a binary value in the 230 The accumulator to its equivalent real number (floating point) 240 format. The result resides in the accumulator. Both the binary 250-1 and the real number may use all 32 bits of the accumulator. 260

BTOR

NOTE: This instruction only works with unsigned binary, or decimal values. It will not work with signed decimal values.

Discrete Bit Flags SP63 SP70

DS Used HPP Used

5-134

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

In the following example, when X1 is on, the value in V1400 and V1401 is loaded into the accumulator using the Load Double instruction. The BTOR instruction converts the binary value in the accumulator the equivalent real number format. The binary weight of the MSB is converted to the real number exponent by adding it to 127 (decimal). Then the remaining bits are copied to the mantissa as shown. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. The Handheld Programmer would display the binary value in V1500 and V1501 as a HEX value. DirectSOFT X1

V1401 LDD

V1400

0

0

0

5

7

2

4

1

V1400 Load the value in V1400 and V1401 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

1

0

1

0 1

1

1

0

0 1

0

0

0

1 0

0

0

0

1

1

0

1

0 0

0

0

0

1 0

0

0

0

0

Binary Value

2 (exp 18) 127 + 18 = 145 145 = 128 + 16 + 1 BTOR

Convert the binary value in the accumulator to the real number equivalent format

Acc.

0 1

Sign Bit

0

0

1

0 0

0

1

0

1 0

1

1

1

0

0 0

Exponent (8 bits)

Mantissa (23 bits) Real Number Format

OUTD V1500

4

Copy the real value in the accumulator to V1500 and V1501

8

A

E

4

8

V1501

2

0

V1500

The real number (HEX) value copied to V1500

Handheld Programmer Keystrokes $

B

STR

1

SHFT

L ANDST

D

SHFT

B

T MLR

GX OUT

SHFT

1

D

3

3

ENT D

B

3

O INST#

1

R ORN

ENT

B

F

DL205 User Manual, 4th Edition, Rev. D

1

5

E

A

4

0

A

A

0

0

A

0

ENT

ENT

Page 359

Chapter 5: Standard RLL Instructions

Real to Binary Conversion (RTOB)

1 2 3 NOTE : The decimal portion of the result will be rounded down (14.1 to 14 or - 14.1 to -15). NOTE : If the real number is negative, it becomes a signed decimal value. 4 Discrete Bit Flags Description 5 6 7 In the following example, when X1 is on, the value in V1400 and V1401 is loaded into the accumulator using the Load Double instruction. The RTOB instruction converts the real value in the accumulator the equivalent binary number format. The value in the accumulator 8 is copied to V1500 and V1501 using the Out Double instruction. The Handheld Programmer would display the binary value in V1500 and V1501 as a HEX value. 9 10 11 12 13 14 A B C D

Real-to-Binary instruction converts the real number in 230 The the accumulator to a binary value. The result resides in the 240 accumulator. Both the binary and the real number may use all 250-1 32 bits of the accumulator. 260

RTOB

1 2

SP63 SP70 SP72 SP73 SP75

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 an incorrect sign bit. On when a number cannot be converted to binary

DS Used HPP Used

DirectSOFT X1

4 8 A

LDD

4 8 2 0

V1401

V1400

Load the value in V1400 and V1401 into the accumulator

Si n Bit

Acc. 0 ponent

1

0

0

1

0

8 bit

0

0

1

Real anti

0

1

0

1

1 umber Format

V1400

1

0

0

0 a

2 bit

1

0

1

0

0

0

0

0

1

0

0

0

0

0

RTOB

Convert the real number in the accumulator to binary format.

128 12

1 18

1 14 5 14 5

2 e p 18

Binary Value

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

Acc. 0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

1

0

1

1

1

0

0

1

0

0

0

1

0

0

0

0

1

OUTD

V1500

Copy the real value in the accumulator to V1500 and V1501

V1501

V1500

0 0 0 5 andheld ro rammer B

STR

2 4 1

The binary number copied to V1400

A

T ey tro e

T

1

S FT

L D A DST

D

S FT

R OR

T

O

X OUT

S FT

D

LR

B

ST

B

B

1

A

0

0

T

1 1

4

F

5

A

0

A

0

T

DL205 User Manual, 4th Edition, Rev. D

5-135

Page 360

Chapter 5: Standard RLL Instructions

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

Radian Real Conversion (RADR)

230 The Radian Real Conversion instruction converts the real value stored in the accumulator to the equivalent real 240 degree number in radians. The result resides in the accumulator. 250-1 260

RADR

Degree Real Conversion (DEGR)

230 The Degree Real instruction converts the degree real radian stored in the accumulator to the equivalent real number 240 value in degrees. The result resides in the accumulator. 250-1 two instructions described above convert real numbers in 260 The the accumulator from degree format to radian format, and visaDS Used HPP N/A versa. In degree format, a circle contains 360 degrees. In radian format, a circle contains 2 P. These convert between both positive and negative real numbers, and for angles greater than a full circle. These functions are very useful when combined with the transcendental trigonometric functions (see the section on math instructions).

Discrete Bit Flags SP63 SP70 SP71 SP72 SP74 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 V-memory specified by a pointer (P) is not valid On anytime the value in the accumulator is a valid floating point number On anytime a floating point math operation results in an underflow error On when a BCD instruction is executed and a NON-BCD number was encountered

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.

The following example takes the sine of 45 degrees. Since 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 R45

Load the real number 45 into the accumulator.

45.000000

RADR

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

0.7853982

SINR

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

0.7071067

Copy the value in the accumulator to V2000 and V2001.

0.7071067

OUTD V2000

5-136

DEGR

DL205 User Manual, 4th Edition, Rev. D