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 41

DL305 User Manual: Chapter 11: Instruction Set, pages 270 to 279

Pages 270 to 279 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 270

11--31

Instruction Set Accumulator Logic Instructions

The Data Or (F76) is a 16--bit instruction that logically ors the value in a 16--bit reference, two consecutive 8--bit registers, (specify starting location) or a 4--digit BCD constant with the value in the accumulator. The result resides in the accumulator. Data Type

DOR (F76) A aaaa

D3--330 Range

D3--340 Range

A aaaa aaaa aaaa

Inputs / Outputs

R

000--014 070--075

000--014 070--075

000--014 070--075

Control Relays

R

016--036

016--036 100--105

016, 020--027

Shift Registers

R

040--056

040--056

----

Stages

R

----

----

100--116

Timer /Counters (16 bit)

R

600--677

600--677

600--677

Data Registers

R

400--577

400--577 700--777

400--577

Constant (4--digit BCD)

K

0000--9999

0000--9999

0000--9999

Instruction Set

Data Or DOR (F76)

D3--330P Range

In the following example, when input 000 is on the value (6481) in R402 and R403 is loaded into the accumulator using the Data Store (F50) instruction. The data in the accumulator is logically ored with the constant K4102 with the result residing in the accumulator. The value in the accumulator is output to data registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 402 Load the value in register R402 and 403 into the accumulator

7 Acc.

DOR (F76) K4102 AND the value in the accumulator with the constant value 4102

DOUT (F60) R 404

OR

6

5

1

STR F

SHF 5

0 0

ENT ENT

3

R F K

4 7 4

0 6 1

2 ENT 0

6 4

0 0

ENT 4

R403

R402

6

8

4

4

3

2

1

0

7

6

5

4

2

1

0

0

1

1

0

0

1

0

0

1

0

0

0

0

0

0

1

F R

0

1

1

0

0

1

0

0

1

0

0

0

0

0

0

1

Accumulator

0

1

0

0

0

0

0

1

0

0

0

0

0

0

1

0

Constant (4102)

0

1

1

0

0

1

0

1

1

0

0

0

0

0

1

1

Accumulator

6

5

8

3

R405

R404

Output the value in the accumulator to registers R404 and R405

DL305 User Manual, Rev. D

ENT 2 ENT

ENT

Page 271

Instruction Set

11--32

Instruction Set Accumulator Logic Instructions

Compare CMP (F70)

The Compare (F70) is a 16--bit instruction that compares the value in a 16--bit reference, two consecutive 8--bit registers (specify starting location), or a 4--digit BCD against the value in the accumulator. Discrete bit flags are used to indicate if the result of the comparison was greater than, equal to, or less than the value in the accumulator. Data Type

CMP (F70) A aaaa

D3--330 Range

D3--340 Range

A aaaa aaaa aaaa

Inputs / Outputs

R

000--014 070--075

000--014 070--075

000--014 070--075

Control Relays

R

016--036

016--036 100--105

016, 020--27

Shift Registers

R

040--056

040--56

----

Stages

R

----

----

100--116

Timer /Counters (16 bit)

R

600--677

600--677

600--677

Data Registers

R

400--577

400--577 700--777

400--577

Constant (4--digit BCD)

K

0000--9999

0000--9999

0000--9999

Discrete Bit Flags

Description

772

Will be on if the accumulator value is greater than the compare value

773

Will be on if the accumulator value is equal to the compare value

774

Will be on if the accumulator value is less than the compare value

DL305 User Manual, Rev. D

D3--330P Range

Page 272

11--33

Instruction Set Accumulator Logic Instructions

DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 402 Load the value in registers 402 and 403 into the accumulator

R 403

R 402

2

1

3

Acc.

2

1

3

2

2

Compared with CMP (F70) R 404 Compare the value in the accumulator with the value in registers 404 and 405 000

774

160

7

5

R405

0

2

STR F

SHF 5

0 0

ENT ENT

R F R STR AND

4 7 4 SHF SHF

0 0 0 0 7

2 ENT 4 ENT 7

ENT

4

ENT

OUT

SHF

1

6

0

ENT

ENT

R404

772 Accumulator value is greater than compare value

OUT 773 Flag status after Compare execution 772 off 773 off 774 on

Accumulator value is equal to compare value 774 Accumulator value is less than compare value

NOTE: Input 000 has been used to interlock output 160. This is done since an earlier comparison could result in status flag 774 coming on when this particular comparison is not being executed thereby providing the opportunity for an unexpected output signal on output 160. It is a common mistake to just use the status flags without interlocking to control outputs in a program but, status flags 772 -- 774 can change several times during the same scan. Just as you should not use the status flags by themselves to control outputs, you also should not monitor status flags within the program. Instead you should monitor the interlocked outputs controlled by the status flags.

DL305 User Manual, Rev. D

Instruction Set

In the following example, when input 000 is on the value (2132) in R402 and R403 is loaded into the accumulator using the Data Store (F50) instruction. The data in the accumulator is compared to value in data registers R404 and R405 using the Compare (F70) instruction. Discrete status flag 774 is used to indicate if the accumulator is less than the compare value in this example.

Page 273

11--34

Instruction Set Math Instructions

Instruction Set

Math Instructions Add ADD (F71)

The Add (F71) is a 16--bit instruction that adds the value of a 16 bit reference, two consecutive 8--bit registers (specify starting location), or a 4--digit BCD value with the value in the accumulator. The result resides in the accumulator. Discrete bit flags are used to indicate if the result had a carry digit or if the result was was zero. Data Type

ADD (F71) A aaaa

D3--330 Range

D3--340 Range

A aaaa aaaa

D3--330P Range aaaa

Inputs / Outputs

R

000--014 070--075

000--014 070--075

000--014 070--075

Control Relays

R

016--036

016--036 100--105

016, 020--027

Shift Registers

R

040--056

040--056

----

Stages

R

----

----

100--116

Timer /Counters (16 bit)

R

600--677

600--677

600--677

Data Registers

R

400--577

400--577 700--777

400--577

Constant (4--digit BCD)

K

0000--9999

0000--9999

0000--9999

Discrete Bit Flags

Description

775

Will be on if the operation results in a carry

776

Will be on if the result is 0

In the following example, when input 000 is on the value (3619) in R402 and R403 is loaded into the accumulator using the Data Store (F50) instruction. The Add instruction (F71) adds the value (2602) in R410 and R411 to the value in the accumulator. The result in the accumulator is then copied to data registers R404 and R405 with the Data Out (F60) instruction. DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 402

R 403

R 402

3

6

1

9

3

6

1

9

Accumulator

2

6

0

2

(R410 and R411)

6

2

2

1

Accumulator

6

2

2

1

Load the value in registers R402 and R403 into the accumulator ADD (F71) R410

+

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

R 405

R 404

777 Carry bit 776 Result equal 0

DL305 User Manual, Rev. D

STR F

SHF 5

0 0

ENT ENT

R F R

4 7 4

0 1 1

2 ENT 0

F R

6 4

0 0

ENT 4

ENT ENT ENT

Page 274

Instruction Set Math Instructions Add Example

11--35

Registers for DSTR Instruction

Registers for ADD Instruction

Registers for DOUT Instruction

Discrete Status Flag

Discrete Status Flag

R401/R400

R403/R402

R405/R404

775

776

Example 1

500

400

0900 off off

Example 2

5000

5000

0000 on on

Example 3

5050

5000

0050 on off

DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 400 Load the value in registers R400 and R401 into the accumulator ADD (F71) R402 Add the value in the accumulator with the value in registers R402 and R403 DOUT (F60) R 404

STR F

SHF 5

0 0

ENT ENT

R F R

4 7 4

0 1 0

0 ENT 2

F R

6 4

0 0

ENT 4

ENT

STR OUT

SHF SHF

7 0

7 1

5 0

ENT ENT

STR OUT

SHF SHF

7 0

7 1

6 1

ENT ENT

ENT ENT

Output the value in the accumulator to registers R404 and R405 000

775

010 OUT Output 010 will be on if the operation results in a carry

000

776

011 OUT Output 011 will be on if the result of the addition is zero

NOTE: An input has been used to interlock the outputs on the last two rungs. This is done since an earlier math instruction could result in the status flag coming on when this particular math instruction is not being executed thereby providing the opportunity for an unexpected output signal. It is a common mistake to just use the status flags without interlocking to control outputs in a program but, the status flags can change several times during the same scan. Just as you should not use the status flags by themselves to control outputs, you also should not monitor status flags within the program. Instead you should monitor the interlocked outputs controlled by the status flags.

DL305 User Manual, Rev. D

Instruction Set

The following examples demonstrate how the discrete status flags are used to indicate if the result of the add has produced a number which exceeds the capacity of the accumulator. Remember, the accumulator has a 4 digit maximum. When a calculation produces a number larger than 4 digits, part of this number is lost. The following table shows different values being used in the logic example below. Notice how the discrete status flags change.

Page 275

Instruction Set

11--36

Instruction Set Math Instructions

Subtract SUB (F72)

The Subtract (F72) is a 16--bit instruction that subtracts the value in a 16--bit register, two consecutive 8--bit registers (specify starting location), or a 4--digit BCD value from the value in the accumulator. The result resides in the accumulator. Discrete bit flags are used to indicate if the result had a borrow digit or the result was zero. Data Type

SUB (F72) A aaaa

D3--330 Range

D3--340 Range

A aaaa aaaa

D3--330P Range aaaa

Inputs / Outputs

R

000--014 070--075

000--014 070--075

000--014 070--075

Control Relays

R

016--036

016--036 100--105

016, 020--027

Shift Registers

R

040--056

040--056

----

Stages

R

----

----

100--116

Timer /Counters (16 bit)

R

600--677

600--677

600--677

Data Registers

R

400--577

400--577 700--777

400--577

Constant (4--digit BCD)

K

0000--9999

0000--9999

0000--9999

Discrete Bit Flags

Description

775

Will be on if the result if a borrow digit occurred

776

Will be on if the result is 0

In the following example, when input 000 is on the value (3619) in R402 and R403 is loaded into the accumulator using the Data Store (F50) instruction. The constant value K1406 is subtracted from the value in the accumulator using the Subtract (F72) instruction. The result in the accumulator is then copied to data registers R404 and R405 using the Data Out (F60) instruction. Handheld Programmer Keystrokes

DirectSOFT Display 000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator SUB (F72) K1406

--

Subtract the value in the accumulator with the value in registers R402 and R403

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

R 403

R 402

3

6

1

9

3

6

1

9

Accumulator

1

4

0

6

Constant (K1406)

2

2

1

3

Accumulator

2

2

1

3

R 405

R 404

775 Borrow digit 776 Result equal 0

DL305 User Manual, Rev. D

STR F

SHF 5

0 0

ENT ENT

R F SHF

4 7 1

0 2 4

2 ENT 0

F R

6 4

0 0

ENT 4

ENT 6 ENT

ENT

Page 276

Instruction Set Math Instructions Subtract Example

11--37

Registers for DSTR Instruction

Registers for SUB Instruction

Registers for DOUT Instruction

Discrete Status Flag

Discrete Status Flag

R401/R400

R403/R402

R405/R404

775

776

Example 1

6050

5000

1050 off off

Example 2

7050

7050

0000 off on

Example 3

5000

6000

9000* on off

* The DL305 cannot process negative numbers. When the number being subtracted from the accumulator is larger than the number in the accumulator, a borrow digit occurs and the subtraction is completed. The value in the accumulator does not represent the difference between the two numbers. To get the difference between the two numbers in Example 3 the result (9000) in the accumulator is subtracted from 0. The final result is 1000, the difference between 6000 and 5000. DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 400 Load the value in registers R400 and R401 into the accumulator SUB (F72) R402 Subtract the value in the accumulator with the value in registers R402 and R403 DOUT (F60) R 404

000

775

Output the value in the accumulator to registers R404 and R405 DSTR (F50) K0

STR F

SHF 5

0 0

ENT ENT

R F R

4 7 4

0 2 0

0 ENT 2

F R STR

6 4 SHF

0 0 0

ENT 4 ENT

AND F

SHF 5

7 0

7 ENT

R F K

4 7 0

0 2 ENT

4 ENT

F R

6 4

0 0

ENT 4

ENT ENT ENT 5

ENT

ENT

Load the constant zero (0) into the accumulator

SUB (F72) R404 Subtract the value in the accumulator with the value in registers R404 and R405

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

NOTE: It is a common mistake to just use the status flags without interlocking to control outputs in a program, but the status flags can change several times during the same scan. Just as you should not use the status flags by themselves to control outputs, you also should not monitor status flags within the program. Instead you should monitor the interlocked outputs controlled by the status flags.

DL305 User Manual, Rev. D

Instruction Set

The following examples demonstrate how the discrete status flags are used to indicate if the result of the Subtraction is a 0 or required a borrow digit. The following table shows different values being used in the logic example below. Notice how the discrete status flags change for each example.

Page 277

Instruction Set

11--38

Instruction Set Math Instructions

Multiply MUL (F73)

The Multiply (F73) is a 16--bit instruction that multiplies the value in a 16--bit register, two consecutive 8--bit registers, or a 4--digit BCD value by the value in the accumulator. The least significant four digits of the result are stored in the accumulator and the most significant four digits are stored in the auxiliary accumulator (R575 and R577). A discrete bit flag is used to indicate if the result was zero. Data Type

MUL (F73) A aaaa

D3--330 Range

D3--340 Range

A aaaa aaaa

D3--330P Range aaaa

Inputs / Outputs

R

000--014 070--075

000--014 070--075

000--014 070--075

Control Relays

R

016--036

016--036 100--105

016, 020--027

Shift Registers

R

040--056

040--056

----

Stages

R

----

----

100--116

Timer /Counters (16 bit)

R

600--677

600--677

600--677

Data Registers

R

400--577

400--577 700--777

400--577

Constant (4--digit BCD)

K

0000--9999

0000--9999

0000--9999

Discrete Bit Flags

Description

776

Will be on if the result is 0

In the following example, when input 000 is on the value (3619) in R402 and R403 is loaded into the accumulator using the Data Store (F50) instruction. The data in the accumulator is multiplied with the constant K2 with the result residing in the accumulator and auxiliary accumulator (R576 and R577) using the Multiply (F73) instruction. The value in the accumulator is output to data registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator MUL (F73) K2 Multiply the value in the accumulator with the constant 2

R 403

R 402

3

6

1

9

3

6

1

9

Accumulator

2

Constant (K2)

X 0

0

0

0

Auxilliary Acc. R 577 R 576

2

3

8

Accumulator

7

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

7

2

R 405

3

8

R 404

776 Result equal 0

DL305 User Manual, Rev. D

STR F

SHF 5

0 0

ENT ENT

R F SHF

4 7 2

0 3 ENT

2 ENT

F R

6 4

0 0

ENT 4

ENT

ENT

Page 278

11--39

Instruction Set Math Instructions Multiply Example

Whenever possible multiplications resulting in more than 4 digits should be avoided since the DL305 instruction set can only manipulate a maximum of two consecutive 8--bit registers (4 digits) at one time. If the result of a multiplication is greater than 4 digits, the application program must be written to compensate for the instruction set 4 digit maximum for data manipulation. The example below shows how the auxiliary accumulator is used to store a result with more than 4 digits and how to access the upper 4 digits. The example below shows how the auxiliary accumulator is used to process numbers larger than 4 digits when the multiplication instruction is used. DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator MUL (F73) K50 Multiply the value in the accumulator with the constant 50

DOUT (F60) R412

R 403

R 402

3

6

1

9

3

6

1

9

Accumulator

5

0

Constant (K50)

5

0

X 0

0

1

8

Auxilliary Acc. R 577 R 576

0

9

Accumulator

0

9

5

STR F

SHF 5

0 0

ENT ENT

R F SHF

4 7 5

0 3 0

2 ENT ENT

F R F

6 4 5

0 1 0

ENT 2 ENT

R F R

5 6 4

7 0 1

6 ENT 4

0

R 413

R 412

0

1

Output 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 Output the value in the accumulator to registers R414 and R415

0

8

Accumulator

0

0

R 415

1

8

R 414

DL305 User Manual, Rev. D

ENT

ENT ENT ENT

Instruction Set

The multiply instruction allows you to multiply two 4--digit numbers together. The result is located in the accumulator and the auxiliary accumulator (R576 and R577) when necessary. The accumulator holds the lower 4 digits of the result and the auxiliary accumulator holds the upper 4 digits.

Page 279

Instruction Set

11--40

Instruction Set Math Instructions

Divide DIV (F74)

The Divide (F74) is a 16--bit instruction that divides the value in the accumulator by the value in a 16--bit register, two consecutive 8--bit registers, or a 4--digit BCD value. The integer portion of the result is stored in the accumulator and the decimal fraction is stored in the auxiliary accumulator, R576 and R577. Discrete flags are used to indicate if the dividend or divisor is zero or if only the divisor is zero. Data Type

D3--330 Range

D3--340 Range

DIV (F74) A aaaa

D3--330P Range

A aaaa aaaa aaaa

Inputs / Outputs

R

000--014 070--075

000--014 070--075

000--014 070--075

Control Relays

R

016--036

016--036 100--105

016, 020--027

Shift Registers

R

040--056

040--056

----

Stages

R

----

----

100--116

Timer /Counters (16 bit)

R

600--677

600--677

600--677

Data Registers

R

400--577

400--577 700--777

400--577

Constant (4--digit BCD)

K

0000--9999

0000--9999

0000--9999

Discrete Bit Flags

Description

776

Will be on if the dividend or divisor is zero

777

Will be on if the divisor is zero

In the following example, when input 000 is on the value (530) in R402 and R403 is loaded into the accumulator using the Data Store (F50) instruction. The data in the accumulator is divided by the constant 10 (K10). The result in the accumulator and is copied to data registers R404 and R405 using the Data Out (F60) instruction. The remainder is in the auxiliary accumulator (R576 and R577). DirectSOFT Display

Handheld Programmer Keystrokes

000 DSTR (F50) R 402 Load the value in registers R402 and R403 into the accumulator DIV (F74) K10 Divide the value in the accumulator by the constant value 10

R 403

R 402

0

3

0

Copy the value in the accumulator to registers R404 and R405

5

­ 0

0

0

STR F

SHF 5

0 0

ENT ENT

3

0

Accumulator

R F SHF

4 7 1

0 4 0

2 ENT ENT

1

0

Constant (K10)

5

3

F R

6 4

0 0

ENT 4

Accumulator

0 DOUT (F60) R404

5

0

R 405

5

0

0

0

Auxilliary Acc. R 577 R 576

3

R 404

776 Dividend or divisor is zero 777 Divisor is zero

DL305 User Manual, Rev. D

0

ENT

ENT