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

The text of a manual · part 19 of 40

DL05 Micro PLC User Manual, Volume 1 of 2: Chapter 5: Standard RLL and Intelligent Box Instructions, pages 164 to 173

Pages 164 to 173 of 379, from DL05 Micro PLC User Manual, Volume 1 of 2

The original document is the PDF (5.8 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 D0-05AA

Page 164

Chapter 5: Standard RLL - Timer, Counter and Shift Register Instructions

Counter (CNT) DS5

Used

HPP

Used

1 2 3 4 5 6 7 8 9 NOTE: Counter preset constants (K) may be changed by using a programming device, even when the CPU is 10 in Run Mode. Therefore, a V-memory preset is required only if the ladder program must change the preset. 11 Operand Data Type DL05 Range aaa bbb 12 13 14 A NOTE: * May be non-volatile if MOV instruction is used. ** With the HPP, both the Counter discrete status bits and current value are accessed with the same data B reference. DirectSOFT 5 uses separate references, such as “CT2” for discrete status bit for Counter CT2, and “CTA2” for the current value of Counter CT2. C D Counter# The Counter is a two input counter that increments when the count input logic transitions from off to on. Count CNT CT aaa When the counter reset input is on the counter resets B bbb to 0. When the current value equals the preset value, the counter status bit comes on and the counter Reset continues to count up to a maximum count of 9999. The maximum value will be held until the counter is reset. Preset Instruction Specifications The counter discrete status bit and the current value are not specified in the Counter Reference (CTaaa): Specifies the counter counter instruction. number. Preset Value (Bbbb): Constant value (K) or a V-memory location as a BCD value. Current Values: Counter current values are accessed by referencing the associated V or CT memory locations*. The V-memory location is the counter location + 1000. For example, the counter current value for CT3 resides in V-memory location V1003 as a BCD value. Discrete Status Bit: The discrete status bit is accessed by referencing the associated CT memory location. It will be on if the value is equal to or greater than the preset value. For example the discrete status bit for counter 2 would be CT2.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A/B Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CT

0–177

V-memory (preset only) . . . . . . . . . . . . . . . . . . V

––

Pointers (preset only) . . . . . . . . . . . . . . . . . . . . P

Constants (preset only) . . . . . . . . . . . . . . . . . . K Counter discrete status bits . . . . . . . . . . . . CT/V Counter current values . . . . . . . . . . . . . . V /CT**

–– 1200–7377 7400–7577* 1200–7377 –– 7400–7577 –– 0–9999 0–177 or V41140–41147 0–177

DL05 Micro PLC User Manual, 6th Edition, Rev. A

5–41

Page 165

Chapter 5: Standard RLL - Timer, Counter and Shift Register Instructions

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

Counter Example Using Discrete Status Bits In the following example, when X1 makes an off to on transition, counter CT2 will increment by one. When the current value reaches the preset value of 3, the counter status bit CT2 will turn on and energize Y7. When the reset C10 turns on, the counter status bit will turn off and the current value will be 0. The current value for counter CT2 will be held in V-memory location V1002. DirectSOFT 5 X1 CNT

CT2 X1 K3

C10 C10

CT2

Y7

CT2 or Y7

OUT

Current Value

1

2

3

Handheld Programmer Keystrokes

Handheld Programmer Keystrokes (cont)

$

$

B STR

ENT

1

$ STR

B 2

A 1

C

GY CNT

SHFT

C

B

A

STR

C

SHFT

GX OUT

ENT

0

D 2

SHFT

2

1

4

T MLR

C 2

ENT

ENT

0

ENT

3

Counter Example Using Comparative Contacts In the following example, when X1 makes an off to on transition, counter CT2 will increment by one. Comparative contacts are used to energize Y3, Y4, and Y5 at different counts. When the reset C10 turns on, the counter status bit will turn off and the counter current value will be 0, and the comparative contacts will turn off. DirectSOFT 5

Counting diagram

DirectSOFT32 X1 CNT

CT2 X1 K3

C10 C10

CTA2

Y3

K1

Y3

OUT Y4 Y4

K2

CTA2

OUT

CTA2

Y5

K3

Y5 1

Current Value

2

3

4

OUT

Handheld Programmer Keystrokes (cont)

Handheld Programmer Keystrokes $

B STR

1

$

SHFT

STR GY CNT

C

$

SHFT

STR B GX OUT

$

ENT C 2

A 1

D 3 C 2

SHFT

0 ENT T MLR

C

ENT

C 2

2

E

$

SHFT

3

4

STR D 3

ENT

GX OUT

C 2

SHFT

T MLR

C

SHFT

T MLR

C

2

ENT

GX OUT

ENT D

SHFT

STR B

2

1

5–42

Counting diagram

DirectSOFT32

ENT C 2

ENT F 5

ENT

DL05 Micro PLC User Manual, 6th Edition, Rev. A

2

0

0

Page 166

Chapter 5: Standard RLL - Timer, Counter and Shift Register Instructions

Stage Counter (SGCNT) DS5

Used

HPP

Used

1 2 3 4 5 6 7 8 9 10 Operand Data Type DL05 Range aaa bbb 11 12 13 14 NOTE: * May be non-volatile if MOV instruction is used. ** With the HPP, both the Counter discrete status bits and current value are accessed with the same data reference. DirectSOFT 5 uses separate references, such as “CT2” for discrete status bit for Counter CT2, and A “CTA2” for the current value of Counter CT2. B C D The Stage Counter is a single input counter that increments when the input logic transitions from off to Counter# on. This counter differs from other counters since it will hold its current value until reset using the RST CT aaa SGCNT instruction. The Stage Counter is designed for use in B bbb RLLPLUS programs but can be used in relay ladder logic programs. When the current value equals the preset Preset value, the counter status bit turns on and the counter The counter discrete status bit and the continues to count up to a maximum count of 9999. current value are not specified in the The maximum value will be held until the counter is counter instruction. reset. Instruction Specifications Counter Reference (CTaaa): Specifies the counter number. Preset Value (Bbbb): Constant value (K) or a V-memory location. Current Values: Counter current values are accessed by referencing the associated V or CT memory locations*. The V-memory location is the counter location + 1000. For example, the counter current value for CT3 resides in V-memory location V1003. Discrete Status Bit: The discrete status bit is accessed by referencing the associated CT memory location. It will be on if the value is equal to or greater than the preset value. For example the discrete status bit for counter 2 would be CT2.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A/B Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CT

0–177

V-memory (preset only) . . . . . . . . . . . . . . . . . . V

––

Pointers (preset only) . . . . . . . . . . . . . . . . . . . . P Constants (preset only) . . . . . . . . . . . . . . . . . . K Counter discrete status bits . . . . . . . . . . . . CT/V Counter current values . . . . . . . . . . . . . . V /CT**

–– 1200–7377 7400–7577* 1200–7377 –– 7400–7577 –– 0–9999 0–177 or V41140–41147 1000–1177

DL05 Micro PLC User Manual, 6th Edition, Rev. A

5–43

Page 167

Chapter 5: Standard RLL - Timer, Counter and Shift Register Instructions

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

Stage Counter Example Using Discrete Status Bits In the following example, when X1 makes an off to on transition, stage counter CT7 will increment by one. When the current value reaches 3, the counter status bit CT7 will turn on and energize Y7. The counter status bit CT7 will remain on until the counter is reset using the RST instruction. When the counter is reset, the counter status bit will turn off and the counter current value will be 0. The current value for counter CT7 will be held in V-memory location V1007. DirectSOFT 5 Counting diagram

DirectSOFT32 X1

SGCNT K3

CT7

C5

X1

Y7

Y7

OUT

Current Value

CT7

Handheld Programmer Keystrokes $

B STR S RST

SHFT H

SHFT

G

D

ENT

7 $

GY CNT

GX OUT

B

$

SHFT

C

SHFT

C

SHFT

2

T MLR

STR

H

A 1

S RST

C

SHFT

STR

SHFT

6

3

2

3

4

0

Handheld Programmer Keystrokes (cont)

ENT

1

1

RST CT7

RST

ENT

0

F 2

ENT

5 SHFT

2

T MLR

H

ENT

7

ENT

7

Stage Counter Example Using Comparative Contacts In the following example, when X1 makes an off to on transition, counter CT2 will increment by one. Comparative contacts are used to energize Y3, Y4, and Y5 at different counts. Although this is not shown in the example, when the counter is reset using the Reset instruction, the counter status bit will turn off and the current value will be 0. The current value for counter CT2 will be held in V-memory location V1002. DirectSOFT 5

Counting diagram

DirectSOFT32 X1

SGCNT CT2 K10 X1

CT2

Y3

K1

OUT

Y3

Y4 Y4

K2

CT2

OUT

Y5

K3

CT2

Y5 Current Value

1

2

3

4

OUT RST CT2 Handheld Programmer Keystrokes (cont)

Handheld Programmer Keystrokes B

$ STR SHFT

1 S RST

C

G 6 B

2

SHFT

STR 1 GX OUT

$

ENT SHFT A

ENT

0 C 2

SHFT

C 2

T MLR

C 2

E

$

SHFT

3

4

STR D 3

ENT

GX OUT

DL05 Micro PLC User Manual, 6th Edition, Rev. A

C 2

SHFT

T MLR

C

SHFT

T MLR

C

2

ENT

GX OUT

ENT D

SHFT

STR GY CNT

1

$ B

5–44

CT7

ENT C 2

ENT F 5

ENT

2

0

Page 168

Chapter 5: Standard RLL - Timer, Counter and Shift Register Instructions

Up Down Counter (UDC) DS5

Used

HPP

Used

1 2 3 4 5 6 7 8 9 10 11 Operand Data Type DL05 Range 12 aaa bbb 13 14 A NOTE: * May be non-volatile if MOV instruction is used. B ** With the HPP, both the Counter discrete status bits and current value are accessed with the same data reference. DirectSOFT 5 uses separate references, such as “CT2” for discrete status bit for Counter CT2, and C “CTA2” for the current value of Counter CT2. D This Up/Down Counter counts up on each off to on transition of the Up input and counts down on each CT aaa Up UDC off to on transition of the Down input. The counter B bbb is reset to 0 when the Reset input is on. The count Down range is 0–99999999. The count input not being Counter # used must be off in order for the active count input to function. Reset Preset Instruction Specification Counter Reference (CTaaa): Specifies the counter Caution: The UDC uses two number. V-memory locations for the 8 digit current value. This means that the Preset Value (Bbbb): Constant value (K) or two UDC uses two consecutive consecutive V-memory locations as a BCD value. counter locations. If UDC CT1 is used in the program, the next Current Values: Current count is a double word value available counter is CT3. accessed by referencing the associated V or CT memory locations*. The V-memory location is the The counter discrete status bit and counter location + 1000. For example, the counter the current value are not specified current value for CT5 resides in V-memory location in the counter instruction V1005 and V1006 as a BCD value. Discrete Status Bit: The discrete status bit is accessed by referencing the associated CT memory location. Operating as a “counter done bit” it will be on if the value is equal to or greater than the preset value. For example the discrete status bit for counter 2 would be CT2.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A/B Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CT

V-memory (preset only) . . . . . . . . . . . . . . . . . . V Pointers (preset only) . . . . . . . . . . . . . . . . . . . . P

Constants (preset only) . . . . . . . . . . . . . . . . . . K Counter discrete status bits . . . . . . . . . . . . CT/V Counter current values . . . . . . . . . . . . . . V /CT**

0–176

–– 1200–7377 –– 7400–7577* 1200–7377 –– 7400–7577 –– 0–99999999 0–176 or V41140–41147 0–176

DL05 Micro PLC User Manual, 6th Edition, Rev. A

5–45

Page 169

Chapter 5: Standard RLL - Timer, Counter and Shift Register Instructions

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

Up / Down Counter Example Using Discrete Status Bits In the following example if X2 and X3 are off ,when X1 toggles from off to on the counter will increment by one. If X1 and X3 are off the counter will decrement by one when X2 toggles from off to on. When the count value reaches the preset value of 3, the counter status bit will turn on. When the reset X3 turns on, the counter status bit will turn off and the current value will be 0. DirectSOFT 5 DirectSOFT32 UDC

CT2 X1

K3 X2

X2 X3 X3

CT2

CT2

Y7 OUT

$

B STR

1

STR

2

$

D STR

3 U

SHFT

D

3

1

2

3

0

ENT

3

ENT

$

ENT

GX OUT

STR

C

D ISG

2

Handheld Programmer Keystrokes (cont)

ENT

C

$

1

Current Value

Handheld Programmer Keystrokes

SHFT

C

B

A

C

ENT

2

ENT

0

1

T MLR

SHFT

2

C 2

2

Up / Down Counter Example Using Comparative Contacts In the following example, when X1 makes an off to on transition, counter CT2 will increment by one. Comparative contacts are used to energize Y3 and Y4 at different counts. When the reset (X3) turns on, the counter status bit will turn off, the current value will be 0, and the comparative contacts will turn off. DirectSOFT 5 DirectSOFT32 X1

Counting Diagram UDC

CT2 V2000

X1

X2 X2 X3 X3

CTA2

Y3

K1

Y3

OUT Y4 CTA2

Y4

K2

OUT

Handheld Programmer Keystrokes $

B STR

1

$

C STR

2

$

D STR

3

SHFT

U

SHFT

V AND

$ STR

5–46

Counting Diagram

X1

D ISG

2

B 1

D

ENT

$

SHFT

2

C 2

C 2

A 0

3

STR C

A

4

ENT

ENT

3

3

Handheld Programmer Keystrokes (cont)

GX OUT

2 SHFT

1

ENT

C

C

Current Value

A 0

0

SHFT

T MLR

2 ENT

GX OUT

C 2

DL05 Micro PLC User Manual, 6th Edition, Rev. A

ENT C 2

ENT E 4

ENT

SHFT

T MLR

C 2

0

Page 170

Chapter 5: Standard RLL - Timer, Counter and Shift Register Instructions

Shift Register (SR) DS5

Used

HPP

Used

1 2 3 • Data, determines the value (1 or 0) that will enter the register 4 • Clock, shifts the bits one position on each low to high transition 5 • Reset, resets the Shift Register to all zeros. With each off to on transition of the clock input, the bits which make up the shift register block are shifted by one bit position and the status of the data input is placed into the starting 6 bit position in the shift register. The direction of the shift depends on the entry in the From and To fields. From C0 to C17 would define a block of sixteen bits to be shifted from left to 7 right. From C17 to C0 would define a block of sixteen bits, to be shifted from right to left. The maximum size of the shift register block depends on the number of available control 8 relays. The minimum block size is 8 control relays. Operand Data Type DL05 Range 9 aaa bbb 10 11 12 13 14 Inputs on Successive Scans Shift Register Bits C0 C17 A 1 0-1-0 0 0 0-1-0 0 B 0 0-1-0 0 1 0-1-0 0 C 0 0-1-0 0 D 0 0 1 The Shift Register instruction shifts data through a predefined number of control relays. The control ranges in the shift register block must start at the beginning of an 8 bit boundary use 8-bit blocks. The Shift Register has three contacts.

SR

DATA

From A aaa

CLOCK

To

B bbb

RESET

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A/B Control Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . C

DirectSOFT Direct SOFT325 X1

0–777

Handheld Programmer Keystrokes $

Data Input

B

STR

SR

1

$

X2

X3

0–777

From

C

STR

C0

2

D

$

Clock Input

3

STR

To

C17

SHFT

Reset Input

ENT ENT

S RST

SHFT

R ORN

B

H

ENT

1

Indicates ON

ENT

7

SHFT

A

0

Indicates OFF

DL05 Micro PLC User Manual, 6th Edition, Rev. A

5–47

Page 171

Chapter 5: Standard RLL - Accumulator/Stack Load and Output Data Instructions

1 Accumulator/Stack Load and Output Data Instructions Using the Accumulator 2 The accumulator in the DL05 internal CPUs is a 32 bit register which is used as a temporary storage location for data that is being copied or manipulated in some manor. For example, you have to use the accumulator to perform math operations such as add, subtract, multiply, 3 etc. Since there are 32 bits, you can use up to an 8-digit BCD number. The accumulator is reset to 0 at the end of every CPU scan. 4 Copying Data to the Accumulator The Load and Out instructions and their variations are used to copy data from a V-memory 5 location to the accumulator, or, to copy data from the accumulator to V-memory. The following example copies data from V-memory location V2000 to V-memory location 6 V2010. 7 8 9 10 11 Since the accumulator is 32 bits and V-memory locations are 16 bits the Load Double and Out Double (or variations thereof ) use two consecutive V-memory locations or 8 digit BCD constants to copy data either to the accumulator from a V-memory address or from a 12 V-memory address to the accumulator. For example if you wanted to copy data from V2000 and V2001 to V2010 and V2011 the most efficient way to perform this function would be as 13 follows: 14 A B C D X1

V2000

LD

8

9

3

5

V2000

Copy data from V2000 to the lower 16 bits of the accumulator

Unused accumulator bits are set to zero

Acc. 0

0

0

0

88 99 33 55

OUT

8

V2010

X1

9

3

V2010

Copy data from the lower 16 bits of the accumulator to V2010

V2000

V2001

LDD

6

7

3

9

5

Acc. 6

7

3

9

55 00 22 66

6

7

3

9

5

V2000

0

2

6

Copy data from V2000 and V2001 to the accumulator

OUTD

V2010

Copy data from the accumulator to V2010 and V2011

5–48

DL05 Micro PLC User Manual, 6th Edition, Rev. A

V2011

0

2

V2010

6

5

Page 172

Chapter 5: Standard RLL - Accumulator/Stack Load and Output Data Instructions

Changing the Accumulator Data

1 2 3 4 5 6 7 8 9 10 11 Some of the data manipulation instructions use 32 bits. They use two consecutive V-memory locations or an 8 digit BCD constant to manipulate data in the accumulator. 12 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 added 13 with the value in V2006 and V2007 using the Add Double instruction. The value in the accumulator is copied to V2010 and V2011 using the Out Double instruction. 14 A B C D Instructions that manipulate data also use the accumulator. The result of the manipulated data resides in the accumulator. The data that was being manipulated is cleared from the accumulator. The following example loads the constant value 4935 into the accumulator, shifts the data right 4 bits, and outputs the result to V2010.

X1

4

Constant

LD

9

3

5

K4935

Load the value 4935 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

1

0

0

1

1

0

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

1

0

0

1

0

The upper 16 bits of the accumulator will be set to 0

Shifted out of accumulator

SHFR

K4

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

1

0

1

1

0

4

9

3

0

0

0

0

0 1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

Shift the data in the accumulator 4 bits (K4) to the right

OUT

V2010

Output the lower 16 bits of the accumulator to V2010

V2010

V2001

X1

LDD

V2000

6

7

3

9

5

0

2

6

V2000

Load the value in V2000 and V2001 into the accumulator ADDD

V2006

Add the value in the accumulator with the value in V2006 and V2007

6

7

3

9

5

0

2

6

(Accumulator)

+ 2

0

0

0

4

0

4

6

(V2006&V2007)

Acc. 8

7

3

9

9

0

7

2

8

7

3

9

9

0

7

2

OUTD

V2010

Copy the value in the accumulator to V2010 and V2011

V2011

V2010

DL05 Micro PLC User Manual, 6th Edition, Rev. A

5–49

Page 173

Chapter 5: Standard RLL - Accumulator/Stack Load and Output Data Instructions

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

Using the Accumulator Stack The accumulator stack is used for instructions that require more than one parameter to execute a function or for user defined functionality. The accumulator stack is used when more than one Load instruction is executed without the use of an Out instruction. The first load instruction in the scan places a value into the accumulator. Every Load instruction thereafter without the use of an Out instruction places a value into the accumulator and the value that was in the accumulator is placed onto the accumulator stack. The Out instruction nullifies the previous load instruction and does not place the value that was in the accumulator onto the accumulator stack when the next load instruction is executed. Every time a value is placed onto the accumulator stack the other values in the stack are pushed down one location. The accumulator is eight levels deep (eight 32 bit registers). If there is a value in the eighth location when a new value is placed onto the stack, the value in the eighth location is pushed off the stack and cannot be recovered. X1

Constant

LD K3245 Load the value 3245 into the accumulator

3

2

4

5

Current Acc. value Acc. 0

0

0

0

3

2

4

Acc. X

X

X

X

Constant

LD

Load the value 5151 into the accumulator, pushing the value 3245 onto the stack

Acc. 0

5

X

1

X

5

X

X X X X

X X X X

X X X X

X X X X

X X X X

Level 3

X

X

X

X

X

X

X

X

Level 4

X

X

X

X

X

X

X

X

Level 5

X

X

X

X

X

X

X

X

Level 6

X

X

X

X

X

X

X

1

X

Level 7

X

X

X

X

X

X

X

X

Level 8

X

X

X

X

X

X

X

0

0

0

55

1

5

X

0

0

0

33 22 44 55

Level 1

0

0

0

0

3

2

4

5

Level 2

X

X

X

X

X

X

X

X

Level 3

X

X

X

X

X

X

X

X

Level 4

X

X

X

X

X

X

X

X

Level 5

X

X

X

X

X

X

X

X

Level 6

X

X

X

X

X

X

X

X

Level 7

X

X

X

X

X

X

X

X

Level 8

X

X

X

X

X

X

X

X

X

1 Bucket

Accumulator Stack

Previous Acc. value

Constant

LD

6

3

6

3

Current Acc. value Acc. 0

Load the value 6363 into the accumulator, pushing the value 5151 to the 1st stack location and the value 3245 to the 2nd stack location

X X

Current Acc. value

Acc. 0

K6363

X X X X

X

Level 2

X X X X

Level 1 Previous Acc. value

K5151

Accumulator Stack

5

0

0

0

66 33 66 33

Bucket Accumulator Stack

Previous Acc. value Acc. 0

0

0

0

55

1

5

1

Level 1

0

0

0

Level 2 Level 3

0 0 X

0 0 X

0 0 3 2 4 5 0 0 X X X X X X

0

5

1

5

1

Level 4

X

X

X

X

X

X

X

X

Level 5

X

X

X

X

X

X

X

X

Level 6

X

X

X

X

X

X

X

X

Level 7

X

X

X

X

X

X

X

X

Level 8

X

X

X

X

X

X

X

X

Bucket

The POP instruction rotates values upward through the stack into the accumulator. When a POP is executed the value which was in the accumulator is cleared and the value that was on top of the stack is in the accumulator. The values in the stack are shifted up one position in the stack.

DL05 Micro PLC User Manual, 6th Edition, Rev. A