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 53

DL06 Micro PLC User Manual, Volume 1 of 2, pages 280 to 289

Pages 280 to 289 of 524

The original document is the PDF (6.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 AutomationDirect Direct Logic DL06 and Koyo DL06 D0-06DD1

Page 280

Chapter 5: Standard RLL Instructions - Bit Operation

Decode (DECO)

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

DS5

Used

HPP

Used

5–126

The Decode instruction decodes a 5 bit binary value of 0–31 (0–1Fh) in the accumulator by setting the appropriate bit DECO position to a 1. If the accumulator contains the value Fh (HEX), bit 15 will be set in the accumulator. If the value to be decoded is greater than 31, the number is divided by 32 until the value is less than 32 and then the value is decoded. 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 pattern in the accumulator is decoded by setting the corresponding bit position to a “1” using the Decode instruction.

DirectSOFT 5 Direct SOFT32

X14

X1

LDF

X13 X12 X11 X10

OFF ON OFF ON ON

X10 K5

Load the value in represented by discrete locations X10–X14 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

1

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

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”

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

0

0

0

Handheld Programmer Keystrokes $

B STR

1

SHFT

L ANDST

D

SHFT

D

E 3

ENT F

3

A

B 5

C 4

1

2

1 O INST#

F 0

5

ENT

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

0

0

0

0

0

0

0

1

0

0

0

0

Page 281

Chapter 5: Standard RLL Instructions - Number Conversion

Number Conversion Instructions (Accumulator) Binary (BIN) DS5

Used

HPP

Used

BIN

The Binary instruction converts a BCD value in the accumulator to the equivalent binary, or decimal, value. The result resides in the accumulator. Discrete Bit Flags

Description

SP63 SP70 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 when a BCD instruction is executed and a NON–BCD number was encountered.

In the following example, when X1 is on, the value in V2000 and V2001 is loaded into the accumulator using the Load Double instruction. The BCD value 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.) DirectS OF T 32 DirectSOFT 5 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

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

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

5 3 6 8 7 0 9 1 2

1 6 7 7 7 2 1 6

5 2 4 2 8 8

OU T D V2010 0

Copy the binary data in the accumulator to V2010 and V2011

0

V2011

V2010

The Binary (HEX) value copied to V2010

S tandard R LL Ins tructions

Handheld Programmer Keys trokes $ STR

B 1

S HF T

L ANDS T

D

S HF T

B

I

GX OU T

1 S HF T

E NT D

C

3

3

8

N T MR

D

A 0

A 0

0

E NT

E NT C

3

A 2

A 2

B 0

A 1

0

E NT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

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

5–127

Page 282

Chapter 5: Standard RLL Instructions - Number Conversion

Binary Coded Decimal (BCD)

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

DS5

Used

HPP

Used

The Binary Coded Decimal instruction converts a binary, or decimal, value in the accumulator to the equivalent BCD value. The result resides in the accumulator.

BCD

Discrete Bit Flags

Description

SP63 SP70

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 binary, or decimal, value in V2000 and V2001 is loaded into the accumulator using the Load Double instruction. The 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 Double instruction. DirectSOFT 5 DirectSOFT 5

V2001

X1

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

Convert the binary, or decimal, value in the accumulator to the BCD equivalent value

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

0 1

0

1

0

0

0 0

1

0

0 0

1

0

0 0

1

0

0

2

8

5

2

9

The BCD value copied to V2010 and V2011

0

0

1

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

0

V2011

Handheld Programmer Keystrokes $

B STR

SHFT SHFT GX OUT

5–128

1 L ANDST

D

B

C

D 3

1 SHFT

ENT C 3 D

2

3

3

A 0

A 0

0

ENT

ENT C

D

A 2

A 2

B 0

A 1

0

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

V2010

1

Page 283

Chapter 5: Standard RLL Instructions - Number Conversion

Invert (INV) DS5

Used

HPP

Used

The Invert instruction inverts or takes the one’s INV complement of the 32 bit value in the accumulator. The result resides in the accumulator. 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 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 5 Direct SOFT32 X1

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.

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

0

0

1

1

1

0

1

0

0

1

1

0

1

1

0

0

1

0

1

0

1

0

1

0

1

0

0

1

1

1

0

1

0

1

0

B

F

A

0

1

0

0

0

1

1

1

D

A

F

0

1

0

1

0

0

1

Invert the binary bit pattern in the accumulator

F

OUTD V2010

V2011

F

V2010

Copy the value in the accumulator to V2010 and V2011

Handheld Programmer Keystrokes $

B STR

1

ENT

SHFT

L ANDST

D 3

3

SHFT

I

N TMR

V AND

GX OUT

8 SHFT

D

D

C

A 0

A 0

0

ENT

ENT C

3

A 2

A 2

B 0

A 1

0

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1

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

5–129

Page 284

Chapter 5: Standard RLL Instructions - Number Conversion

Ten’s Complement (BCDCPL)

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

DS5

Used

HPP

Used

5–130

BC DC P L

The Ten’s Complement instruction takes the 10’s complement (BCD) of the 8 digit accumulator. The result resides in the accumulator. The calculation for this instruction is : 100000000 Ҁaccumulator 10’s complement value

In the following example when X1 is on, the value in V2000 and V2001 is loaded into the 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 the Out Double instruction. DirectSOFT DirectS OF T 32 5

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

1

3

LDD V2000 Load the value in V2000 and V2001 into the accumulator

BC DC PL

Takes a 10’s complement of the value in the accumulator OU T D

9 V2010

V2011

V2010

C opy the value in the accumulator to V2010 and V2011 H andheld Programmer Keys trokes $ STR S HF T S HF T GX OU T

B 1 L ANDS T

D

B

C

D 3

1 S HF T

E NT C 3 D

2

C 3

3

A 0

CV

L ANDS T

E NT

B

A

A 2

A 0

P 2

C

D

A 2

0

1

DL06 Micro PLC User Manual, 3rd Edition Rev. A

0

0

E NT

E NT

Page 285

Chapter 5: Standard RLL Instructions - Number Conversion

Binary to Real Conversion (BTOR) DS5

Used

HPP

Used

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

1 2 3 NOTE: This instruction only works with unsigned binary, or decimal, values. It will not work with signed decimal values. 4 Description 5 In the following example, when X1 is on, the value in V1400 and V1401 is loaded into the 6 accumulator using the Load Double instruction. The BTOR instruction converts the binary, or decimal, value in the accumulator the equivalent real number format. The binary weight of 7 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 8 display the binary value in V1500 and V1501 as a HEX value. 9 10 11 12 13 14 A B C D Discrete Bit Flags SP63 SP70

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.

DirectSOFT 5

V1401

X1

BT O R

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, or decimal, 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

V1501

E

4

8

2

0

The real number (HEX) value copied to V1500

V1500

Handheld Programmer Keystrokes $

B

STR

1

ENT

SHFT

L ANDST

D

3

3

SHFT

B

T MLR

O INST#

GX OUT

1

SHFT

D

D 3

B

E

R ORN

ENT

B

F 1

A

4

1

A 5

A

0

A 0

0

0

ENT

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–131

Page 286

Chapter 5: Standard RLL Instructions - Number Conversion

Real to Binary Conversion (RTOB)

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

DS5

Used

HPP

Used

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

NOTE1: The decimal portion of the result will be rounded down (14.1 14 앥 14.1 -15). NOTE2: if the real number is negative, it becomes a signed decimal value.

Discrete Bit Flags

Description

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 an invalid 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.

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 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 5 DirectSOFT32 X1

4

LDD

8

A

E

4

V1401

V1400 Load the value in V1400 and V1401 into the accumulator

Sign Bit

Acc.

Exponent (8 bits)

0 1

0

0

1

0 0

0

8

2

0

Real Number Format

V1400

Mantissa (23 bits)

1

0

1 0

1

1

1

0

0 0

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 + 16 + 1 = 145 127 + 18 = 145 Binary Value

2 (exp 18)

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

5

7

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

V1501 0

0

0

V1500 2

4

1

The binary number copied to V1500.

Handheld Programmer Keystrokes B

$ STR

1

ENT

SHFT

L ANDST

D 3

3

SHFT

R ORN

T MLR

O INST#

SHFT

D

GX OUT

5–132

R TOB

D

B B 1 B

3

E 1

A 0

0

ENT F

1

A 4

A 5

DL06 Micro PLC User Manual, 3rd Edition Rev. A

A 0

0

ENT

ENT

Page 287

Chapter 5: Standard RLL Instructions - Number Conversion

Radian Real Conversion (RADR) DS5 HPP

DS32 HPP

The Radian Real Conversion instruction converts the real degree value stored in the accumulator to the equivalent real number in radians. The result resides in the accumulator.

R ADR

1 2 Degree Real Conversion (DEGR) DE G R 3 The Degree Real instruction converts the degree real radian value stored in the accumulator to the equivalent real number in degrees. The result resides in the 4 accumulator. Discrete Bit Flags Description 5 6 7 The two instructions described above convert real numbers into the accumulator from degree 8 format to radian format, and visa-versa. In degree format, a circle contains 360 degrees. In radian format, a circle contains 2앟 (about 6.28) radians. These convert between both positive and negative real numbers, and for angles greater than a full circle. These functions are very 9 useful when combined with the transcendental trigonometric functions (see the section on math instructions). 10 NOTE: The current HPP does not support real number entry with automatic conversion to the 32-bit IEEE format. You must use DirectSOFT 5 for entering real numbers, using the LDR (Load Real) instruction. 11 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, 12 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 13 from the accumulator to V-memory. The result is 32-bits wide, requiring the Out Double to move it. 14 A 45.000000 B 0.7853982 C 0.7071067 D Used

N/A

Used

N/A

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 an invalid 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.

Accumulator contents (viewed as real number)

DirectSOFT 5 DirectSOFT32 X1

LDR

R45

Load the real number 45 into the accumulator.

RADR

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

SINR

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

OUTD V2000

Copy the value in the accumulator to V2000 and V2001.

0.7071067

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–133

Page 288

Chapter 5: Standard RLL Instructions - Number Conversion

ASCII to HEX (ATH)

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

DS5

Used

HPP

N/A

5–134

The ASCII TO HEX instruction converts a table of ASCII values to ATH a specified table of HEX values. ASCII values are two digits and V aaa their HEX equivalents are one digit. This means an ASCII table of four V-memory locations would only require two V-memory locations for the equivalent HEX table. The function parameters are loaded into the accumulator stack and the accumulator by two additional instructions. Listed below are the steps necessary to program an ASCII to HEX table function. The example on the following page shows a program for the ASCII to HEX table function. Step 1:, Load the number of V-memory locations for the ASCII table into the first level of the accumulator stack. Step 2:, Load the starting V-memory location for the ASCII table into the accumulator. This parameter must be a HEX value. Step 3:, Specify the starting V-memory location (Vaaa) for the HEX table in the ATH instruction. Helpful Hint:, For parameters that require HEX values when referencing memory locations, the LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. Operand Data Type

DL06 Range aaa

V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V

Discrete Bit Flags SP53

See memory map

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

In the example on the following page, when X1 is ON the constant (K4) is loaded into the accumulator using the Load instruction and will be placed in the first level of the accumulator stack when the next Load instruction is executed. The starting location for the ASCII table (V1400) is loaded into the accumulator using the Load Address instruction. The starting location for the HEX table (V1600) is specified in the ASCII to HEX instruction. The table below lists valid ASCII values for ATH conversion. ASCII Values Valid for ATH Conversion ASCII Value

Hex Value

ASCII Value

Hex Value

30 31 32 33 34 35 36 37

0 1 2 3 4 5 6 7

38 39 41 42 43 44 45 46

8 9 A B C D E F

DL06 Micro PLC User Manual, 3rd Edition Rev. A

Page 289

Chapter 5: Standard RLL Instructions - Number Conversion

1 2 3 4 5 6 7 8 9 HEX to ASCII (HTA) The HEX to ASCII instruction converts a table of HEX values to a specified table of ASCII values. 10 HEX values are one digit and their ASCII equivalents are two digits. 11 This means a HEX table of two V-memory locations would require four V-memory locations for the equivalent ASCII table. The function parameters are loaded into the accumulator stack and the accumulator by two additional instructions. Listed below are the steps necessary 12 to program a HEX to ASCII table function. The example on the following page shows a program for the HEX to ASCII table function. 13 Step 1: Load the number of V-memory locations in the HEX table into the first level of the accumulator stack. 14 Step 2: Load the starting V-memory location for the HEX table into the accumulator. This parameter must be a HEX value. A Step 3:Specify the starting V-memory location (Vaaa) for the ASCII table in the HTA instruction. B Helpful Hint:, For parameters that require HEX values when referencing memory locations, the LDA instruction can be used to convert an octal address to the HEX equivalent C and load the value into the accumulator. D DirectSOFT 5 Direct SOFT32 X1

K4

Hexadecimal Equivalents

ASCII T ABLE

Load the constant value into the lower 16 bits of the accumulator. This value defines the number of V memory location in the ASCII table

LD

V1400

33 34

Convert octal 1400 to HEX 300 and load the value into the accumulator

LDA

O 1400

V1401

31 32

V1402

37 38

1234

V1600

5678

V1601

V1600 is the starting location for the HEX table

ATH

V1600

Handheld Programmer Keystrokes B

$

STR

DS5 HPP

Used

N/A

1

SHFT

L ANDST

D

SHFT

L ANDST

D

SHFT

A

T MLR

0

ENT

PREV

3

4

B

A

3

E

E

1

0

B

H

7

ENT

A

4

G

1

A

0

A

6

0

A

0

0

ENT

V1403

35 36

ENT

HTA

V aaa

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–135