The text of a manual · part 28 of 60
DL205 PLC User Manual, Volume 1 of 2, pages 271 to 280
Pages 271 to 280 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 271
Chapter 5: Standard RLL Instructions
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.
1 2 3 4 5 6 7 8 Counter Example Using Comparative Contacts 9 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 10 0, and the comparative contacts will turn off. 11 12 13 14 A B C D Counting diagram
DirectSOFT
X1
CNT
CT2
X1
K3
C10
C10
CT2
Y7
CT2 or Y7
OUT
Current Value
1
$
B
STR
C
SHFT
STR
GY CNT
C
$
ENT
1
3
4
0
Handheld Programmer Keystrokes (cont)
Handheld Programmer Keystrokes $
2
B
2
D
2
A
1
ENT
0
STR
GX OUT
SHFT
C
H
ENT
7
2
T MLR
SHFT
C
2
ENT
ENT
3
Counting diagram
DirectSOFT
X1
CNT
CT2
X1
K3
C10
CTA2
C10
Y3
K1
Y3
OUT
Y4
CTA2
Y4
K2
OUT
CTA2
Y5
K3
Y5
1
Current Value
2
3
4
0
OUT
Handheld Programmer Keystrokes $ $
B
STR
1
SHFT
STR
GY CNT
C
$
SHFT
STR
B
GX OUT
1
Handheld Programmer Keystrokes (cont) $
ENT
C
2
B
D
2
C
2
1
3
SHFT
A
0
T MLR
C
ENT
ENT
C
2
3
$
SHFT
STR
GX OUT
3
C
2
SHFT
T MLR
C
SHFT
T MLR
C
2
ENT
E
D
ENT
2
GX OUT
ENT
D
SHFT
STR
4
ENT
C
2
2
ENT
F
5
ENT
DL205 User Manual, 4th Edition, Rev. D
5-47
Page 272
Chapter 5: Standard RLL Instructions
Stage Counter (SGCNT)
The Stage Counter is a single-input counter that 1 increments when the input logic transitions from off to on. This counter differs from other counters since it will hold its current value until reset using the RST 2 instruction. The Stage Counter is designed for use in
RLL programs but can be used in relay ladder logic 3 programs. When the current value equals the preset value, the counter status bit turns on and the counter continues 4 to count up to a maximum count of 9999. The maximum value will be held until the counter is reset. Instruction Specifications 5 Counter Reference (CTaaa): Specifies the counter number. 6 Preset Value (Bbbb): Constant value (K) or a V-memory location.(Pointer (P) for DL240, DL250-1 and DL260.) Current Values: Counter current values are accessed by referencing the associated V or CT 7 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. 8 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 9 discrete status bit for Counter 2 would be CT2. NOTE: When using a counter inside a stage, the stage must be active for one scan before the input to the 10 counter makes a 0-1 transition. Otherwise, there is no real transition and the counter will not count. 11 NOTE: A V-memory preset is required only if the ladder program or an OIT must used to change the preset. 12 Operand Data DL230 Range DL240 Range DL250-1 Range DL260 Range Type B aaa bbb aaa bbb aaa bbb aaa bbb 13 14 A B C NOTE: * Both the Counter discrete status bits and the current value are accessed with the same data reference D with the HPP. DirectSOFT uses separate references, such as “CT2” for discrete status bit for Counter CT2, Counter#
230
CT aaa SGCNT B bbb
240
250-1 260
Preset
PLUS
The counter discrete status bit and the current value are not specified in the counter instruction.
DS Used HPP Used
Counters CT V-memory for preset values V Pointers (presets only) P Constants (presets only) K Counter discrete status bits CT/V Counter current values V/CT
0-77 –
0-177
2000-2377
–
0-177
2000-3777 2000-3777
–
0-9999
–
0-9999
–
1400-7377 10000-17777 1400-7377 10000-17777 0-9999
0-377 –
–
1400-7377 10000-37777 1400-7377 10000-37777 0-9999
0-77 or V41140-41143
0-177 or V41140-41147
0-177 or V41140-41147
0-377 or V41140-41157
1000-1077
1000-1177
1000-1177
1000-1377 and “CTA2” for the current value of Counter CT2.
5-48
–
DL205 User Manual, 4th Edition, Rev. D
Page 273
Chapter 5: Standard RLL Instructions
Stage Counter Example Using Discrete Status Bits
1 2 3 4 5 6 7 8 Stage Counter Example Using Comparative Contacts 9 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 10 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. 11 12 13 14 A B C D 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. Counting diagram
DirectSOFT
X1
SGCNT K3
CT7
C5
CT7
X1
Y7
Y7
OUT
Current Value
CT7
RST CT7
RST
B
STR
S RST
SHFT
H $
7
1
G
D
ENT
3
SHFT
STR
ENT
SHFT
C
6
2
2
SHFT
GY CNT
GX OUT
H
$
SHFT
C
SHFT
C
STR
S RST
SHFT
CTA2
T MLR
H
7
Y3
K1
CTA2
Y4
K2
OUT
CTA2
Y5
K3
OUT
B
STR
S RST
1
6
1
SHFT
STR
GX OUT
G B
2
B
4
0
ENT
5
T MLR
SHFT
2
H
7
ENT
1
SHFT
GY CNT
A
ENT
0
2
Y4
Y5
Current Value
1
2
SHFT
3
SHFT
STR
C
T MLR
C
2
E
SHFT
STR
GX OUT
3
C
2
SHFT
T MLR
C
SHFT
T MLR
C
2
ENT
$
D
ENT
2
GX OUT
ENT
D
3
RST CT2
$
ENT
C
X1
Y3
Handheld Programmer Keystrokes (cont)
Handheld Programmer Keystrokes
$
F
2
ENT
SGCNT CT2 K10
OUT
C
0
Counting diagram
X1
SHFT
4
ENT
7
DirectSOFT
$
3
Handheld Programmer Keystrokes (cont)
Handheld Programmer Keystrokes $
1
4
ENT
C
2
2
ENT
F
5
ENT
DL205 User Manual, 4th Edition, Rev. D
5-49
Page 274
Chapter 5: Standard RLL Instructions
Up Down Counter (UDC)
Up
UDC
CT aaa B bbb
This Up/Down Counter counts up on each off-to-on 1 transition of the Up input and counts down on each off to on transition of the Down input. The counter is reset to 0 when the Reset input is on. The count 2 range is 0 to 99999999. The count input not being used must be off in order for the active count input to 3 function. Instruction Specification Caution: The UDC uses two 4 Counter Reference (CTaaa): Specifies the counter V-memory locations for the 8-digit current value. This means that the number. UDC uses two consecutive 5 Preset Value (Bbbb): Constant value (K) or two counter locations. If UDC CT1 is consecutive V-memory locations. (Pointer (P) for used in the program, the next available counter is CT3. 6 DL240, DL250-1 and DL260). Current Values: Current count is a double word value accessed by referencing the associated V or CT memory locations. The V-memory location 7 is the counter location + 1000. For example, the counter current value for CT5 resides in V-memory location V1005 and V1006. 8 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 9 discrete status bit for Counter 2 would be CT2. NOTE: The UDC uses two consecutive V-memory locations for the 8-digit value, therefore two consecutive 10 counter locations. For example, if UDC CT1 is used, the next available counter number is CT3. 11 NOTE: A V-memory preset is required only if the ladder program or an OIT must be used to change the preset. 12 Operand Data DL230 Range DL240 Range DL250-1 Range DL260 Range 13 Type B aaa bbb aaa bbb aaa bbb aaa bbb 14 A B C NOTE: * Both the Counter discrete status bits and the current value are accessed with the same data D reference with the HPP. DirectSOFT uses separate references, such as “CT2” for discrete status bit for 230
Down
240
Counter #
250-1
Reset
260
Preset
DS Used HPP Used
Counters CT V-memory for preset values V Pointers (presets only) P Constants (presets only) K Counter discrete status bits CT/V* Counter current values V/CT*
0-76 –
0-176
2000-2377
–
0-176
2000-3777
–
2000-3777
–
0-99999999
–
0-99999999
–
0-99999999
0-376 –
–
1400-7377 10000-37777 1400-7377 10000-37777 0-99999999
0-76 or V41140-41143
0-176 or V41140-41147
0-176 or V41140-41147
0-376 or V41100-41157
1000-1076
1000-1176
1000-1176
1000-1376
Counter CT2, and “CTA2” for the current value of Counter CT2.
5-50
1400-7377 10000-17777 1400-7377 10000-17777
DL205 User Manual, 4th Edition, Rev. D
Page 275
Chapter 5: Standard RLL Instructions
Up/Down Counter Example Using Discrete Status Bits
1 2 3 4 5 6 7 8 9 Up/Down Counter Example Using Comparative Contacts In the following example, when X1 makes an off to on transition, counter CT2 will increment 10 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 11 comparative contacts will turn off. 12 13 14 A B C D 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. Counting Diagram
DirectSOFT X1
UDC
CT2
K3
X2
X1
X2
X3
X3
Y10
CT2
OUT
CT2
$ $
B
STR
1
C
STR
D
STR
U ISG
SHFT
D
2
3
3
D
ENT ENT
$
ENT
GX OUT
C
2
2
1
3
0
Handheld Programmer Keystrokes (cont)
Handheld Programmer Keystrokes $
1
Current Value
C
2
ENT
3
SHFT C
STR
B
A
1
SHFT T MLR
2
C
ENT
2
ENT
0
2
Counting Diagram
DirectSOFT X1
UDC
X2
V2000
CT2
X1
X2
X3
X3
CTA2
Y3
K1
Y3
OUT
Y4
CTA2
Y4
K2
OUT
Handheld Programmer Keystrokes $ $ $
B
STR
C
STR
D
STR
SHFT
U
SHFT
V AND
$
STR
ISG
D C
1 2 3
3
2
SHFT
Current Value
1
2
B
1
D
ENT
$
SHFT
C
C
2 0
2
0
ENT
ENT
GX OUT
A
4
Handheld Programmer Keystrokes (cont)
ENT
C
3
A
0
SHFT
A
STR
C
2
0
T MLR
ENT
C
GX OUT
2
3
ENT
C
2
SHFT
T MLR
C
2
ENT
E
4
ENT
2
DL205 User Manual, 4th Edition, Rev. D
5-51
Page 276
Chapter 5: Standard RLL Instructions
Shift Register (SR)
The Shift Register instruction shifts data through a 1 predefined number of control relays. The control ranges in the shift register block must start at the beginning of an 8-bit boundary and use 8-bit blocks. 2
The Shift Register has three contacts. 3 •, the value (1 or 0) that will enter the register •, the bits one position on each low to high 4 transition • Reset, resets the Shift Register to all zeros. 5 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 16 bits to be shifted from left to right. From C17 to C0 would define a block of 16 bits, to be shifted from right to left. The 7 maximum size of the shift register block depends on the number of available control relays. 8 Operand DataThe minimum block size is 8 control relays. DL230 Range DL240 Range DL250-1 Range DL260 Range Type 9 A/B aaa bbb aaa bbb aaa bbb aaa bbb 10 11 12 13 14 Inputs on Successive Scans Shift Register Bits C0 C17 A 1 1 0 0 1 0 B 0 1 0 1 1 0 C 0 1 0 0 0 1 D 230
DATA
240
SR
From A aaa
250-1
CLOCK
260
To
DS Used HPP Used
Control Relay
C
0-377
0-377
0-377
0-377
X1
$
Data Input
SR
$
X2
X3
Data
0-1777
0-1777
0-3777
0-3777
Handheld Programmer Keystrokes
DirectSOFT
From
C0
$
Clock Input
To
Clock
D
STR
Reset
Indicates OFF
DL205 User Manual, 4th Edition, Rev. D
C
STR
SHFT
C17
B
STR
Reset Input
Indicates ON
5-52
B bbb
RESET
1 2 3
ENT ENT ENT
S RST
SHFT
R ORN
B
H
ENT
1
7
SHFT
A
0
Page 277
Chapter 5: Standard RLL Instructions
Accumulator/Stack Load and Output Data Instructions
1 The accumulator in the DL205 series CPUs is a 32-bit register that is used as a temporary storage location for data that is being copied or manipulated in some manner. For example, you 2 have to use the accumulator to perform math operations, such as, add, subtract, multiply, etc. Since there are 32 bits, you can use up to an 8-digit BCD number or a 32-bit 2’s compliment 3 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 location to the accumulator, or to copy data from the accumulator to V-memory. The 5 following example copies data from V-memory location V1400 to V-memory location V1410. 6 7 8 9 10 Since the accumulator is 32 bits and V-memory locations are 16 bits, the Load Double and 11 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 V-memory address to the accumulator. For example, if you wanted to copy data from V1400 and V1401 12 to V1410 and V1411, the most efficient way to perform this function would be as follows: 13 14 A B C D Using the Accumulator
X1
V1400
LD
8
V1400
Copy data from V1400 to the lower 16 bits of the accumulator
9
3
5
8
9
3
5
8
9
3
5
Unused accumulator bits are set to zero
Acc. 0
0
0
0
OUT
V1410
V1410
Copy data from the lower 16 bits of the accumulator to V1410
X1
V1400
V1401
LDD
V1400
6
7
3
9
5
0
2
6
Acc. 6
7
3
9
5
0
2
6
6
7
3
9
5
0
2
6
Copy data from V1400 and V1401 to the accumulator
OUTD
V1410
Copy data from the accumulator to V1410 and V1411
V1411
V1410
DL205 User Manual, 4th Edition, Rev. D
5-53
Page 278
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-54
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
Acc. 0
0
0
0
Acc. 0
3
2
4
X
X
0
0
Accumulator Stack
5
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X
X
Level 2
X X X X
X
X X
5
X
1
X
5
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
55
1
5
X
Level 1
0
0
0
0
3
2
4
5
0
0
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
0
33 22 44 55
6
3
6
3
Current Acc. value 0
0
0
66 33 66 33
Bucket Accumulator Stack
Previous Acc. value Acc. 0
0
0
Bucket
Accumulator Stack
Constant
Acc. 0
X
1
Previous Acc. value
LD
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
5
Current Acc. value
Acc. 0
K6363
4
Level 1
Constant
LD
Load the value 5151 into the accumulator, pushing the value 3245 onto the stack
2
Previous Acc. value Acc. X
K5151
3
Current Acc. value
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 that 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.
DL205 User Manual, 4th Edition, Rev. D
Page 279
Chapter 5: Standard RLL Instructions
X1
Previous Acc. value
POP
Acc. X POP the 1st value on the stack into the accumulator and move stack values up one location
X
X
X
X X
X X
X
X
0
44 55
4
5
Accumulator Stack
Current Acc. value Acc. 0
0
OUT
0
V2000
V2000
4
5
4
5
Cop data rom the accum ulator to V2000
Level 1
0
0
0
0
3
7
9
2
Level 2
0
0
0
0
7
9
3
0
Level 3
X
X
X
X
X
X
X
Level 4
X ? 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
Level 1
0
0
0
0
7
9
3
0
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
Level 1
X
X
X
X
X
X
X
X
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
Previous Acc. value
POP
Acc. 0 POP the 1st value on the stack into the accumulator and move stack values up one location
0
0
0
44 55 44 55
0
33 77 99 22
Accumulator Stack
Current Acc. value Acc. 0
0
OUT
0
V2001
V2001
3
7
9
2
Cop data rom the accum ulator to V2001. Previous Acc. value POP
Acc. 0
0
0
0
33 47 69 02
X
7
Accumulator Stack
Current Acc. value POP the 1st value on the stack into the accumulator and move stack values up one location
OUT V2002 Cop data rom the accum ulator to V2002
Acc. X
X
X
V2002
7
9
9
3
3
0
0
DL205 User Manual, 4th Edition, Rev. D
11 22 33 44 55 66 77 88 99 10 10 11 11 12 12 13 13 14 14 AA BB CC DD 5-55
Page 280
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-56
Changing the Accumulator Data 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 V1410. 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 V1410 Output the lower 16 bits of the accumulator to V1410
V1410
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. The following example rotates the value 67053101 two bits to the right and outputs the value to V1410 and V1411. X1
Constant 6
LDD
7
0
5
3
1
0
1
K67053101 Load the value 67053101 into the accumulator
Acc.
ROTR K2 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
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
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 0
1 0
0 1
0
1 0
1 0
1 0
9
C
1
0
0
0
0
0
1 0
0
1
0
0
1
1
0
Rotate the data in the accumulator 2 bits to the right
OUTD V1410 Output the value in the accumulator to V1410 and V1411
0
5
V1411
DL205 User Manual, 4th Edition, Rev. D
8
V1410
0
0