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

The text of a manual · part 33 of 41

DL305 User Manual: Chapter 11: Instruction Set, pages 280 to 289

Pages 280 to 289 of 357, from DL305 User Manual

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 PLC Direct D3-08TD1, PLC Direct D3-16NA, Koyo D3-08TD1 and Koyo D3-16NA

Page 280

11--41

Instruction Set Math Instructions Divide Example

DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator DIV (F74) K32 Divide the value in the accumulator with the constant value 32

DOUT (F60) R412

R 403

R 402

0

2

0

5

5

­ 0

0

9

STR F

SHF 5

0 0

ENT ENT

2

9

Accumulator

R F SHF

4 7 3

0 4 2

2 ENT ENT

3

2

Constant (K32)

1

6

F R F

6 4 5

0 1 0

ENT 2 ENT

R F

5 6

7 0

6 ENT

ENT

R

4

1

4

ENT

Accumulator

0

0

1

5

3

1

2

Auxilliary Acc. R 577 R 576

6

R 413

R 412

5

1

Copy the value in the accumulator to registers R412 and R413

DSTR (F50) R 576 Load the value in registers R576 and R577 into the accumulator DOUT (F60) R414

3

2

Accumulator

5

3

R 415

1

2

R 414

Copy the value in the accumulator to registers R414 and R415

DL305 User Manual, Rev. D

ENT

ENT

Instruction Set

The divide instruction allows you to divide the value in the accumulator by 4 digits maximum. The divide instruction uses the accumulator for the integer value of the result and the auxiliary accumulator (R576 and R577) for fraction. The instruction set only allows manipulation on two consecutive registers at a time. For example, if the result was a 4 digit number with a remainder it would have to be treated like two 4--digit numbers in the program. Manipulating numbers over 4 digits should be avoided whenever possible. If it cannot be avoided the application program must be written to compensate for the 4--digit maximum for data manipulation. The example below shows how the auxiliary accumulator is used to store the fractional portion of the result and how to access the remainder.

Page 281

11--42

Instruction Set Bit Operation Instructions

Instruction Set

Bit Operation Instructions Shift Left SHFL (F81)

The Shift Left (F81) is a 16--bit instruction that shifts the value in the accumulator a specified number of bits (15 maximum) to the left. Discrete bit flags are used to indicate if a “1” was shifted out of the accumulator or if the accumulator equals “0” after the shift. Data Type

SHFL (F81) K aaaa

D3--330 Range

D3--340 Range

D3--330P Range aaaa aaaa aaaa

1--16

1--16

1--16

Constant (4--digit BCD)

K

Discrete Bit Flags

Description

775

Will be on if a“1” was shifted out of the accumulator.

776

Will be on if the accumulator equals zero after the shift instruction is executed.

In the following example, when input 000 is on the value in R000 and R010 is loaded into the accumulator using the Data Store 5 (F55) instruction. The bit pattern in the accumulator is shifted to the left 4 bit positions using the Shift Left (F81) instruction with the result resides in the accumulator. The value in the accumulator is copied to data registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display 000

R 010

R 000

Handheld Programmer Keystrokes

6

3

STR F

SHF 5

0 5

ENT ENT

R F SHF

0 8 4

ENT 1 ENT

ENT

F R

6 4

0 0

ENT 4

9

5

DSTR 5 (F55) R0 Load the value in registers R0 and R10 into the accumulator 7

6

0

1

I/O Points 100--107 5 4 3 2 1 0 1

0

1

0

Acc.

1

S S

Shifted out of accumulator

SHFL (F81) K4

0

7

6

0

0

I/O Points 000--007 5 4 3 2 1 0 1

1

0

1

0

1

S S

15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

1

1

0

1

1

0

0

0

5

0

0

0

1

0

0

1

0

0

775 will be ON after the shift 776 will be OFF after the shift

Shift the value in the accumulator 4 bits to the left

9

DOUT (F60) R 404 Copy the value in the accumulator to registers R404 and R405

3

R 405

R 404

775 Shifted a “1” out of Accumulator 776 Accumulator equals zero after shift

DL305 User Manual, Rev. D

ENT

Page 282

11--43

Instruction Set Bit Operation Instructions

The Shift Right (F80) is a 16--bit instruction that shifts the value in the accumulator a specified number of bits (15 maximum) to the right. Discrete bit flags are used to indicate if a “1” was shifted out of the accumulator or if the accumulator equals “0” after the shift. Data Type

Instruction Set

Shift Right SHFR (F80)

SHFR (F80) Kaaaa

D3--330 Range

D3--340 Range

D3--330P Range aaaa aaaa aaaa

1--16

1--16

1--16

Constant (4--digit BCD)

K

Discrete Bit Flags

Description

775

Will be on if a“1” was shifted out of the accumulator.

776

Will be on if the accumulator equals zero after the shift instruction is executed.

In the following example, when input 000 is on the value in R000 and R010 is loaded into the accumulator using the Data Store 5 (F55) instruction. The bit pattern in the accumulator is shifted 4 bit positions using the Shift Right (F80) instruction and the result resides in the accumulator. The value in the accumulator is copied to data registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display 000 DSTR 5 (F55) R0 Load the value in registers R0 and R10 into the accumulator

R 10

R0

4

3

9

7

I/O Points 100--107 6 5 4 3 2 1 0

7

I/O Points 000--007 6 5 4 3 2 1 0

0

1

0

0

0

0

1

0

0

1

S S

SHFR (F80) K4

Acc.

Handheld Programmer Keystrokes

5

1

S S

1

0

1

0

1

8

7

6 5

4 3

2

1

0

0

0

1

0

1

0

1

1

9

3

0

0

0

1

0

SHF 5

0 5

ENT ENT

R F SHF

0 8 4

ENT 0 ENT

ENT

F R

6 4

0 0

ENT 4

Shifted out of accumulator

15 14 13 12 11 10 9 0

STR F

0

0

775 will be ON after the shift 776 will be OFF after the shift

Shift the value in the accumulator 4 bits to the right

0

DOUT (F60) R 404 Copy the value in the accumulator to registers R404 and R405

4

R 405

R 404

775 Shifted a “1” out of Accumulator 776 Accumulator equals zero after shift

DL305 User Manual, Rev. D

ENT

Page 283

11--44

Instruction Set Number Conversion Instructions

Instruction Set

Number Conversion Instructions Encode ENCOD (F83)

The Encode instruction encodes the accumulator bit position that contains a 1 by returning the corresponding binary representation. If the most significant bit is set to HEX F (decimal 15), the binary value 15 is returned to the accumulator. If the accumulator value is 0000 or 0001 a zero will be returned to the accumulator. If there is more than one bit position set to a “1” the least significant “1” will be encoded. The discrete bit flag 777 is used to indicate if there were multiple 1s in the accumulator.

ENCOD (F83)

Discrete Bit Flags

Description

777

Will be on if there was more than one bit position set to a ”1” in the accumulator.

DL305 User Manual, Rev. D

Page 284

11--45

Instruction Set Number Conversion Instructions

DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR 5 (F55) R 005

R 015

R 005

0

4

0

0

Load the value in registers R005 and R015 into the accumulator Acc.

15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

0

STR F

SHF 5

0 5

ENT ENT

R F F R

5 8 6 4

ENT 3 3 0

ENT ENT 4

Bit position 6 converted to binary.

ENCOD (F83)

Acc.

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

6

0

0

0

0

0

0

0

Encode the bit position in the accumulator set to “1” by returning the corresponding binary number

DOUT3 (F63) R 404 Copy the lower four bits in the accumulator to the lower four bits of register R404.

R 404

DL305 User Manual, Rev. D

ENT

Instruction Set

In the following example, when input 000 is on the 16--bit binary pattern from registers R005 and R015 is loaded in the accumulator by the Data Store 5 (F55) instruction. In this example the 6th bit (BCD 40) is on. When the Encode (F83) instruction executes the accumulator will contain the BCD value of 6. The lower four bits of the accumulator are copied to the lower four bits of register R404 by the Data Out 3 (F63) instruction.

Page 285

Instruction Set

11--46

Instruction Set Number Conversion Instructions

Decode DECOD (F82)

The Decode instruction decodes a four bit binary number (0--F) in the accumulator and sets the corresponding bit position to a one. If the accumulator contains a HEX F (decimal 15) the most significant bit (bit 15) will be set in the accumulator. If the accumulator contains a zero the least significant bit (bit 0) will be set to a one. All other bits in the accumulator will be set to a zero.

DECOD (F82)

In the following example, when 000 is on the binary value of the lower four bits in R016 (5) will be loaded in the accumulator by the Data Store 3 (F53) instruction. The Decode instruction will then translate the value 5 to a 1 in the fifth bit position of the accumulator. The value 20 in the accumulator is copied to data registers R404 and R405 with the Data Out (F60) instruction. DirectSOFT Display

Handheld Programmer Keystrokes

000

R 016

DSTR3 (F53) R 016

0

5

Load the lower four bits in R016 into the accumulator

Acc.

15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

0

0

1

0

1

0

0

0

0

0

0

0

0

Bit pattern equals 5 BCD

DECOD (F82)

Acc.

15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

0

0

0

0

0

2

0

0

0

0

0

0

0

Decode the binary bit pattern in the accumulator and set the appropriate bit to a ”1”

DOUT (F60) R 404 Copy the value in the accumulator to registers R404 and R405

DL305 User Manual, Rev. D

0

0

R 405

R 404

1

0

STR F

SHF 5

0 3

ENT ENT

R F

1 8

6 2

ENT ENT

F R

6 4

0 0

ENT 4

ENT

Page 286

11--47

Instruction Set Number Conversion Instructions

The Binary (F85) instruction converts a BCD value in the accumulator to the binary/HEX equivalent value. The result of the conversion resides in the accumulator.

BIN (F85)

In the following example, when input 000 is on the value (2571 BCD) in R600 is loaded into the accumulator using the Data Store (F50) instruction. The value in the accumulator is converted to a binary number (HEX 0A0B) using the Binary (F85) instruction with the result residing in the accumulator. The value in the accumulator is copied to I/O registers R000 and R010 (which corresponds to I/O points 0--7 and 100--107) with the Data Out 5 (F65) instruction. DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 600 Load the value in registers 600 and 601 into the accumulator

BIN (F85)

1

STR F

SHF 5

0 0

ENT ENT

R F F

6 8 6

0 5 5

0 ENT ENT

R

0

ENT

R601

R600

2

7

5

Accumulator value before BIN instruction

2

5

7

1

Accumulator value after BIN instruction

0

A

0

B

Hex.

Convert the BCD number in the accumulator to a binary number I/O Points 100--107 DOUT5 (F65) R 000 Output the value in the accumulator to R000 and R010

I/O Points 000--007

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

0

0

0

0

1

0

1

0

0

0

0

0

1

0

1

1

R010

R000

DL305 User Manual, Rev. D

ENT

Instruction Set

Binary BIN (F85)

Page 287

Instruction Set

11--48

Instruction Set Number Conversion Instructions

Binary Coded Decimal BCD (F86)

The Binary Coded Decimal (F86) instruction converts a binary/HEX value in the accumulator to the BCD equivalent. The result of the conversion resides in the accumulator.

BCD (F86)

In the following example, when input 000 is on the value (HEX 0A0A) in R000 and R010 is loaded into the accumulator with the Data Store 5 (F55) instruction. The value in the accumulator is converted to a BCD number (BCD 2570) using the BCD (F86) instruction with the result residing in the accumulator. The value in the accumulator is output to register R600 using the Data Out (F60) instruction.

DirectSOFT Display

R 10

R0

0

0

A

A

Handheld Programmer Keystrokes

000 DSTR5 (F55) R0 Load the value in registers R000 and R010 into the accumulator

Accumulator value before BCD instruction

7

6

0

0

I/O Points 100--107 5 4 3 2 1 0 0

0

1

0

1

0

7

6

0

0

I/O Points 000--007 5 4 3 2 1 0 0

0

1

0

1

0

BCD (F86) Convert the binary number in the accumulator to a BCD number DOUT (F60) R600

15 14 13 12 11 10 9

8

7

6 5

4 3

2

1

0

0

0

0

0

1

0

1

0

0

0

0

0

1

0

1

0

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 1 2

2 5 6

1 6 2 4 8

3 2

1 8 6

4

2

1

2

5

7

0

2

5

7

0

Copy the value in the accumulator to R600 and R601

Accumulator value after BCD instruction

R601

DL305 User Manual, Rev. D

R600

STR F

SHF 5

0 5

ENT ENT

R F F

0 8 6

ENT 6 0

ENT ENT

R

6

0

0

ENT

Page 288

11--49

Instruction Set Number Conversion Instructions

The Invert instruction generates the one’s complement of the number in the accumulator. The result is stored in the accumulator.

INV (F84)

In the following example, when input 000 is on the value (AD63) in R000 and R010 is loaded into the accumulator using the Data Store (F55) instruction. The value in the accumulator is inverted with the result residing in the accumulator. The value (HEX 529C) is copied to registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display 000

R 10

R0

A

6

D

Handheld Programmer Keystrokes

3

DSTR5 (F55) R0 Load the value in register R000 and R010 into the accumulator

INV (F84) Invert the value in the accumulator

DOUT (F60) R 404

STR F

SHF 5

0 5

ENT ENT

0 8 6

ENT 4 0

ENT ENT

4

0

4

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

R F F

1

0

1

0

1

1

0

1

0

1

1

0

0

0

1

1

R

1

0

1

0

1

1

0

1

0

1

1

0

0

0

1

1

Accumulator

0

0

Accumulator

I/O Points 100--107

I/O Points 000--007

Invert the value in the accumulator 0

1

0

1

0

5

2

R405

0

1

0

1

0

0

1

1

9

C

1

R404

Copy the value in the accumulator to registers R404 and R405

DL305 User Manual, Rev. D

ENT

Instruction Set

Invert INV (F84)

Page 289

11--50

Instruction Set Program Control Instructions

Instruction Set

Program Control Instructions Master Control Set (MCS) DL330/DL340 Only Master Control Reset (MCR) DL330/DL340 only Understanding Master Control Relays

The Master Control Set and Master Control Reset instructions are used to provide an additional left power rail which is controllable by a input contact. This is sometimes known as a sub power rail. Any number of rungs of ladder logic can be disabled using these instructions.

MCS

MCR

The Master Control Set (MCS) and Master Control Reset (MCR) instructions allow you to quickly enable (or disable) sections of the RLL program. This provides program control flexibility. The following example shows how the MCS and MCR instructions operate by creating a sub power rail for control logic. 000

When contact 000 is on, logic under the first MCS will be executed.

MCS

050 OUT

001 002

When contact 002 is on, logic under the second MCS will be executed.

MCS

003

MCR

010

DL305 User Manual, Rev. D

MCR

The MCR instructions note the end of the Master Control area. (They will be entered in adjacent addresses.)