The text of a manual · part 41 of 60
DL205 PLC User Manual, Volume 1 of 2, pages 401 to 410
Pages 401 to 410 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 401
Chapter 5: Standard RLL Instructions
CPU Control Instructions
1 The No Operation is an empty (not programmed) memory location. 2 NOP
3
4 5 6 End (END) The End instruction marks the termination point of the normal program 7
END scan. An End instruction is required at the end of the main program body. If the End instruction is omitted, an error will occur and the CPU will not enter the Run Mode. Data labels, subroutines and interrupt
8 routines are placed after the End instruction. The End instruction is not conditional; therefore, no input contact is allowed. 9 10 11 12 Stop (STOP) The Stop instruction changes the operational mode of the CPU from STOP
13 Run to Program (Stop) mode. This instruction is typically used to stop
PLC operation in a shutdown condition such as an I/O module failure.
14
In the following example, when SP45 comes on indicating an I/O module failure, the CPU will stop operation and switch to the program mode. A B C D No Operation (NOP)
230 240
250-1 260
Handheld Programmer Keystrokes
DirectSOFT
SHFT
NOP
DS Used HPP Used
N TMR
O INST#
P
ENT
CV
230 240
250-1 260
DS Used HPP Used
DirectSOFT
Handheld Programmer Keystrokes SHFT
END
E
4
N TMR
D
ENT
3
230 240
250-1 260
DS Used HPP Used
DirectSOFT
Handheld Programmer Keystrokes $
SP45
STOP
SP45 will turn on if there is an I/O module failure.
STR
SHFT
S RST
SHFT
SP STRN
E
SHFT
T MLR
O INST#
4
F
P
5
CV
ENT
ENT
DL205 User Manual, 4th Edition, Rev. D
5-177
Page 402
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Reset Watch Dog Timer (RSTWT) The Reset Watch Dog Timer instruction resets the CPU scan
230 timer. The default setting for the watch dog timer is 200ms. 240 Scan times very seldom exceed 200ms, but it is possible. For/next 250-1 loops, subroutines, interrupt routines, and table instructions can programmed such that the scan becomes longer than 200ms. 260 be When instructions are used in a manner that could exceed the DS Used HPP Used
5-178
RSTWT watch dog timer setting, this instruction can be used to reset the timer. A software timeout error (E003) will occur and the CPU will enter the program mode if the scan time exceeds the watch dog timer setting. Placement of the RSTWT instruction in the program is very important. The instruction has to be executed before the scan time exceeds the watch dog timer’s setting. If the scan time is consistently longer than the watch dog timer’s setting, the timeout value may be permanently increased from the default value of 200ms by AUX 55 on the HPP or the appropriate auxiliary function in your programming package. This eliminates the need for the RSTWT instruction. In the following example, the CPU scan timer will be reset to 0 when the RSTWT instruction is executed. See the For/Next instruction for a detailed example. DirectSOFT
Handheld Programmer Keystrokes SHFT RSTWT
DL205 User Manual, 4th Edition, Rev. D
R ORN
S RST
T MLR
W ANDN
T MLR
ENT
Page 403
Chapter 5: Standard RLL Instructions
Program Control Instructions
1 The Goto / Label skips all instructions between the Goto 2 and the corresponding LBL instruction. The operand value for the Goto and the corresponding LBL instruction is the same. The logic between Goto and LBL instruction 3 is not executed when the Goto instruction is enabled. Up LBL K aaa to 128 Goto instructions and 64 LBL instructions can be 4 used in the program. 5 Operand Data Type DL240 Range DL250-1 Range DL260 Range aaa aaa aaa 6 7 In the following example, when C7 is on, all the program logic between the GOTO and the corresponding LBL instruction (designated with the same constant Kaaa value) will be skipped. 8 The instructions being skipped will not be executed by the CPU. 9 10 11 12 13 14 A B C D
Goto Label (GOTO) (LBL)
230 240 250-1 260 DS Used HPP Used
K aaa
GOTO
Constant
K
1-FFFF
DirectSOFT C7
1-FFFF
Handheld Programmer Keystrokes
K5
GOTO
$
C2
OUT
STR
SHFT
$
X1
STR
GX OUT
SHFT
LBL
$
K5
STR
GX OUT
X5
1-FFFF
G
6
SHFT
C
O INST#
T
B
ENT
1
SHFT
L B ANDST 1 F
C
5 2
2
MLR
C
2
L ANDST
H
7
ENT
O INST#
C
2
F
5
ENT
ENT
F
5
ENT
ENT ENT
Y2
OUT
DL205 User Manual, 4th Edition, Rev. D
5-179
Page 404
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
For/Next (FOR) (NEXT) For and Next instructions are used to execute a section of 230 The ladder logic between the For and Next instruction a specified 240 numbers of times. When the For instruction is enabled, the 250-1 program will loop the specified number of times. If the For 260 instruction is not energized, the section of ladder logic between the DS Used HPP Used
5-180
A aaa FOR
For and Next instructions is not executed. For/Next instructions cannot be nested. Up to 64 For/Next loops may be used in a program. If the maximum number of For/Next NEXT loops is exceeded, error E413 will occur. The normal I/O update and CPU housekeeping is suspended while executing the For/Next loop. The program scan time can increase significantly, depending on the number of times the logic between the For and Next instruction is executed. With the exception of immediate I/O instructions, I/O will not be updated until the program execution is completed for that scan. Depending on the length of time required to complete the program execution, it may be necessary to reset the watchdog timer inside of the For/Next loop using the RSTWT instruction. Operand Data Type V-memory Constant
DL240 Range
DL250-1 Range
DL260 Range
A aaa aaa aaa
V K
All (See page 3 - 54) 1-9999
All (See page 3 - 55) 1-9999
All (See page 3 - 56) 1-9999
DL205 User Manual, 4th Edition, Rev. D
Page 405
Chapter 5: Standard RLL Instructions In the following example, when X1 is on, the application program inside the For/Next loop will be executed three times. If X1 is off, the program inside the loop will not be executed. The immediate instructions may or may not be necessary depending on your application. Also, The RSTWT instruction is not necessary if the For/Next loop does not extend the scan time larger the Watchdog Timer setting. For more information on the Watchdog Timer, refer to the RSTWT instruction. DirectSOFT X1
1
K3
2
3
FOR
RSTWT
X20
Y5 OUT
NEXT
Handheld Programmer Keystrokes $
B
STR
1
ENT
SHFT
F
5
O INST#
R ORN
SHFT
R ORN
S RST
T MLR
SHFT
I
$
STR
GX OUT SHFT
F N TMR
E
8 5 4
D
3
ENT
W ANDN
T MLR
ENT
C
A
ENT
2
0
ENT X SET
T MLR
ENT
DL205 User Manual, 4th Edition, Rev. D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5-181
Page 406
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Goto Subroutine (GTS) (SBR) Goto Subroutine instruction allows a section of ladder 230 The logic to be placed outside the main body of the program 240 and execute only when needed. There can be a maximum 250-1 of 128 GTS instructions and 64 SBR instructions used in 260 a program. The GTS instructions can be nested up to 8 DS Used HPP Used levels. An error E412 will occur if the maximum limits are exceeded. Typically this will be used in an application where a block of program logic may be slow to execute and is not required to execute every scan. The subroutine label and all associated logic is placed after the End statement in the program. When the subroutine is called from the main program, the CPU will execute the subroutine (SBR) with the same constant number (K) as the GTS instruction that called the subroutine. By placing code in a subroutine, it is only scanned and executed when needed since it resides after the End instruction. Code which is not scanned does not impact the overall scan time of the program. Operand Data Type Constant
K aaa GTS
K aaa
SBR
DL240 Range
DL250-1 Range aaa aaa aaa
1-FFFF
1-FFFF
1-FFFF
K
DL260 Range
Subroutine Return (RT)
230 When a Subroutine Return is executed in the subroutine, 240 the CPU will return to the point in the main body of the 250-1 program from which it was called. The Subroutine Return 260 is used as termination of the subroutine, which must be
RT
Return Conditional (RTC) 230 Subroutine The Subroutine Return Conditional instruction is 240 an optional instruction used with an input contact to 250-1 implement a conditional return from the subroutine. The 260 Subroutine Return (RT) is still required for termination
RTC the last instruction in the subroutine and is a stand-alone instruction (no input contact on the rung).
of the Subroutine.
DS Used HPP Used
5-182
DL205 User Manual, 4th Edition, Rev. D
Page 407
Chapter 5: Standard RLL Instructions In the following example, when X1 is on, Subroutine K3 will be called. The CPU will jump to the Subroutine Label K3, and the ladder logic in the subroutine will be executed. If X35 is on, the CPU will return to the main program at the RTC instruction. If X35 is not on, Y0–Y17 will be reset to off and then the CPU will return to the main body of the program.
DirectSOFT
X1
K3 GTS
C0 LD K10
END
SBR
K3
X20
Y5 OUTI
X21
Y10 OUTI
X35 RTC
X35
Y0
Y17 RSTI
RT
Handheld Programmer Keystrokes STR SHFT
G
1
ENT
T
S
K
3
ENT
SHFT
E
N
D
ENT
SHFT
S
SHFT
B
R
K 1
3
STR
SHFT
I
X
2
0
ENT
ENT
SHFT
I
Y
5
STR
SHFT
I
X
2
1
ENT
OUT
SHFT
I
Y
1
0
ENT
STR
SHFT
I
X
3
5
ENT
SHFT
R
T
STRN
SHFT
I
X
3
5
ENT
RST
SHFT
I
Y
0
Y
1
SHFT
R
T
C
Standard RLL Instructions
OUT
ENT
ENT
7
ENT
ENT
DL205 User Manual, 4th Edition, Rev. D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5-183
Page 408
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-184
In the following example, when X1 is on, Subroutine K3 will be called. The CPU will jump to the Subroutine Label K3 and the ladder logic in the subroutine will be executed. The CPU will return to the main body of the program after the RT instruction is executed. Direct SOFT X1
K3 GTS
END
SBR
K3
X20
Y5 OUT
X21
Y10 OUT
RT
Handheld Programmer Keystrokes $
B
STR
SHFT
G
1
ENT
6
T MLR
S RST
4
N TMR
D B
D
3
ENT
SHFT
E
SHFT
S RST
SHFT
SHFT
I
$
STR
GX OUT $
STR
F SHFT
GX OUT SHFT
I B
R ORN
3 1
C
8 5
T MLR
2
D A
0
3
ENT
ENT C
8 1
ENT R ORN
A
0
2
ENT
ENT
DL205 User Manual, 4th Edition, Rev. D
B
1
ENT
ENT
Page 409
Chapter 5: Standard RLL Instructions
Master Line Set (MLS)
1 2 seven levels deep. Note that unlike stages in RLL , the logic within 3 the master control relays is still scanned and updated even though it will not function if the MLS is off. 4 Operand Data Type DL230 Range DL240 Range DL250-1 Range DL260 Range aaa aaa aaa aaa 5 Master Line Reset (MLR) 6 K aaa
The Master Line Reset instruction marks the end of control for the MLR corresponding MLS instruction. The MLR reference is one less than 7 the corresponding MLS.
8 Operand Data Type DL230 Range DL240 Range DL250-1 Range DL260 Range aaa aaa aaa aaa 9 10 Understanding Master Control Relays The Master Line Set (MLS) and Master Line Reset (MLR) instructions allow you to quickly enable (or disable) sections of the RLL program. This provides program control flexibility. 11 The following example shows how the MLS and MLR instructions operate by creating a sub power rail for control logic. 12 13 14 A B C D The Master Line Set instruction allows the program to control sections
230 of ladder logic by forming a new power rail controlled by the main left 240 power rail. The main left rail is always master line 0. When an MLS 250-1 K1 instruction is used, a new power rail is created at level 1. Master power rails up to 260 Line Sets and Master Line Resets can be used to nest PLUS
Constant
K aaa MLS
K
1-7
1-7
1-7
1-7
Constant
K
0-6
0-6
0-6
0-6
DS Used HPP Used
DirectSOFT
230 240
250-1 260
X0
K1
MLS
X1
When contact X0 is ON, logic under the first MLS will be executed.
Y7
OUT K2
X2
MLS
X3
When contact X0 and X2 are ON, logic under the second MLS will be executed.
Y10
OUT K1
MLR K0
The MLR instructions note the end of the Master Control area.
MLR
X10
Y11
OUT
DL205 User Manual, 4th Edition, Rev. D
5-185
Page 410
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-186
MLS/MLR Example In the following MLS/MLR example, logic between the first MLS K1 (A) and MLR K0 (B) will function only if input X0 is on. The logic between the MLS K2 (C) and MLR K1 (D) will function only if input X10 and X0 is on. The last rung is not controlled by either of the MLS coils. DirectSOFT
Handheld Programmer Keystrokes
X0
K1 MLS X1
X2
A
$
B
C1
GX OUT
SHFT
C
$
C
ENT
MLS
C
Y1 OUT Y2
K1 MLR
D
C2 OUT
X6
Y3 OUT K0 MLR
X7
Y4 OUT
B
STR
STR
1
2
ENT ENT 2
SHFT
C
$
D
ENT
STR
GX OUT
A
$
B
STR
Y MLS
C
$
F
STR
GX OUT
B
$
E
STR
GX OUT
C
T MLR
B
$
F
STR
3 0 1 2 5 1 4 2 1 5
2
A
0
ENT ENT ENT
ENT
T MLR
A
$
H
STR
E
3 0 7 4
ENT
ENT
G D
ENT
ENT
$
GX OUT
1
ENT
ENT
C
6
B
0
ENT
SHFT
STR
A
ENT
GX OUT
GX OUT
DL205 User Manual, 4th Edition, Rev. D
1
GX OUT
OUT
X5
ENT
OUT
K2
X4
0
B
Y0
X5
A
Y MLS
OUT X10
STR
C0
OUT X3
$
2
ENT ENT ENT ENT
C
2
ENT