The text of a manual · part 43 of 61
DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 403 to 412
Pages 403 to 412 of 592, from DL205 PLC User Manual, Volume 1 of 2
The original document is the PDF (13 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 D2-08ND3 and Koyo D2-08ND3
Page 403
Chapter 5: Standard RLL Instructions - Program Control 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 Watch Dog Timer setting. For more information on the Watch Dog Timer, refer to the RSTWT instruction. DirectSOFT X1
1
K3
2
3
FOR
RSTWT
X20
Y5 OUT
NEXT
Handheld Programmer Keystrokes $
B 1
STR SHFT
F 5
O INST#
SHFT
R ORN
S RST
SHFT
I
$ STR GX OUT SHFT
T MLR
8 F 5
N TMR
ENT R ORN
E 4
D 3
ENT
W ANDN
T MLR
ENT
C
A
ENT
2
0
T MLR
ENT
ENT X SET
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–181
Page 404
Chapter 5: Standard RLL Instructions - Program Control
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 230 The ladder logic to be placed outside the main body of the 240 program and execute only when needed. There can be a 250-1 maximum of 128 GTS instructions and 64 SBR 260 instructions used in a program. The GTS instructions DS Used HPP Used can be nested up to 8 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 which 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
K aaa GTS
K aaa
SBR
DL240 Range
DL250-1 Range aaa aaa
DL260 Range aaa
1-FFFF
1-FFFF
1-FFFF
Subroutine Return (RT) When a Subroutine Return is executed in the subroutine,
CPU will return to the point in the main body of the 240 the program from which it was called. The Subroutine 250-1 Return is used as termination of the subroutine, which 260 must be the last instruction in the subroutine and is a 230
RT stand alone instruction (no input contact on the rung).
Subroutine Return Conditional (RTC) Subroutine Return Conditional instruction is a 230 The optional instruction used with an input contact to 240 implement a conditional return from the subroutine. The 250-1 Subroutine Return (RT) is still required for termination 260 of the Subroutine. DS Used HPP Used
5–182
DL205 User Manual, 4th Edition, Rev. A
RTC
Page 405
Chapter 5: Standard RLL Instructions - Program Control 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
E
N
D
ENT
SHFT
S
SHFT
B
R
1 K
3
STR
SHFT
I
X
2
0
ENT
OUT
SHFT
I
Y
5
ENT
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
ENT
Standard RLL Instructions
SHFT
ENT
C
7
ENT
ENT
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–183
Page 406
Chapter 5: Standard RLL Instructions - Program Control
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
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
END
SBR
K3
X20
Y5 OUT
X21
Y10 OUT
RT
Handheld Programmer Keystrokes $
B STR
SHFT
1 G
ENT
6
T MLR
S RST
N TMR
D
4
B
D 3
ENT
SHFT
E
SHFT
S RST
SHFT
SHFT
I
$ STR GX OUT $ STR
D 3 A
2
0
ENT
ENT
I
C 8
B R ORN
1
ENT R ORN
8 5
SHFT
3
C
F
GX OUT SHFT
5–184
K3 GTS
B 2
A 1
0
T MLR
ENT
ENT
DL205 User Manual, 4th Edition, Rev. A
1
ENT
ENT
Page 407
Chapter 5: Standard RLL Instructions - Program Control
Master Line Set (MLS) The Master Line Set instruction allows the program to control
230 sections of ladder logic by forming a new power rail controlled by the 240 main left power rail. The main left rail is always master line 0. When 250-1 a MLS K1 instruction is used, a new power rail is created at level 1. power 260 Master Line Sets and Master Line Resets can be used to nestPLUS
K aaa MLS rails up to seven levels deep. Note that unlike stages in RLL , the logic within the master control relays is still scanned and updated even though it will not function if the MLS is off.
Operand Data Type Constant
K
DL230 Range
DL240 Range
DL250-1 Range
DL260 Range aaa aaa aaa aaa
1-7
1-7
1-7
1-7
Master Line Reset (MLR) The Master Line Reset instruction marks the end of control for the
230 corresponding MLS instruction. The MLR reference is one less than 240 the corresponding MLS. 250-1 260 Operand Data Type Constant
K
K aaa MLR
DL230 Range
DL240 Range
DL250-1 Range
DL260 Range aaa aaa aaa aaa
0-6
0-6
0-6
0-6
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. The following example shows how the MLS and MLR instructions operate by creating a sub power rail for control logic. DS Used HPP Used
DirectSOFT X0
K1 MLS
When contact X0 is ON, logic under the first MLS will be executed.
Y7
X1
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
OUT
DL205 User Manual, 4th Edition, Rev. A
5–185
Page 408
Chapter 5: Standard RLL Instructions - Program Control
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
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
X1
X2
A
Y MLS
B
OUT
$
B STR
1
C1
GX OUT
SHFT
C
$
C
ENT
Y0
K2
C
Y1
Y2
D MLR
OUT X6
Y3
SHFT
C
$
D
ENT
MLR X7
Y4 OUT
A
$
B
0
C
$
F 5
GX OUT
B
$
E
1
B
4
GX OUT
C
T MLR
B
$
F
2 1
0
ENT ENT ENT ENT ENT
SHFT
C
$
G
ENT
GX OUT
D
T MLR
A
$
H
3 0 7 E 4
ENT
ENT
GX OUT
6
ENT
ENT
5
STR
1
ENT
ENT
STR
STR
DL205 User Manual, 4th Edition, Rev. A
B
A
2
0
2
1
Y MLS
GX OUT
5–186
3
GX OUT
OUT K0
A 2
GX OUT
STR
C2
ENT
2
STR
K1
ENT
STR
OUT
X5
1
STR
OUT X4
0
STR
MLS X5
ENT
C0
OUT X10
A STR
OUT X3
$
MLS
C 2
ENT ENT ENT ENT
2
ENT
Page 409
Chapter 5: Standard RLL Instructions - Interrupt
Interrupt Instructions
1 Interrupt (INT) The Interrupt instruction allows a section of ladder logic to 2 be placed outside the main body of the program and executed when needed. Interrupts can be called from the 3 program or by external interrupts via the counter interface module (D2–CTRINT), which provides 4 interrupts.
4 The software interrupt uses interrupt #00 which means the hardware interrupt #0 and the 5 software interrupt cannot be used together. Typically, interrupts will be used in an application where a fast response to an input is needed 6 or a program section needs to execute faster than the normal CPU scan. The interrupt label and all associated logic must be placed after the End statement in the program. When the interrupt routine is called from the interrupt module or software interrupt, the CPU will 7 complete execution of the instruction it is currently processing in ladder logic, then execute the designated interrupt routine. Interrupt module interrupts are labeled in octal to 8 correspond with the hardware input signal (X1 will initiate interrupt INT1). There is only one software interrupt and it is labeled INT 0. The program execution will continue from where it was before the interrupt occurred once the interrupt is serviced. 9 The software interrupt is setup by programming the interrupt time in V7634. The valid range is 3 to 999 ms. The value must be a BCD value. The interrupt will not execute if the value is 10 out of range. NOTE: See the example program of a software interrupt. 11 Operand Data Type DL240 Range DL250-1 Range DL260 Range 12 aaa aaa aaa 13 DL240/250-1/260 Software DL240/250-1/260 Hardware 14 Interrupt Input Interrupt Routine Interrupt Input Interrupt Routine A B C D 230
O aaa
INT
240
250-1 260
DS Used HPP Used
Constant
0
0-3
0-3
0-3
V7634 sets interrupt time
INT 0
INT 0
-
-
X0 (cannot be used along with s/w interrupt) X1 X2 X3
INT 1 INT 2 INT 3
DL205 User Manual, 4th Edition, Rev. A
5–187
Page 410
Chapter 5: Standard RLL Instructions - Interrupt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Interrupt Return (IRT) When an Interrupt Return is executed in the interrupt routine, the
230 CPU will return to the point in the main body of the program from 240 which it was called. The Interrupt Return is programmed as the last 250-1 instruction in an interrupt routine and is a stand alone instruction 260 (no input contact on the rung).
IRT
Interrupt Return Conditional (IRTC)
The Interrupt Return Conditional instruction is a optional
230 instruction used with an input contact to implement a condtional 240 return from the interrupt routine. The Interrupt Return is required to 250-1 terminate the interrupt routine. 260 Enable Interrupts (ENI)
IRTC
The Enable Interrupt instruction is programmed in the main body of
230 the application program (before the End instruction) to enable 240 hardware or software interrupts. Once the coil has been energized, 250-1 interrupts will be enabled until they are disabled by the Disable 260 Interrupt instruction.
ENI
Disable Interrupts (DISI) The Disable Interrupt instruction is programmed in the main body of
230 the application program (before the End instruction) to disable both 240 hardware or software interrupts. Once the coil has been energized, 250-1 interrupts will be disabled until they are enabled by the Enable 260 Interrupt instruction.
5–188
DL205 User Manual, 4th Edition, Rev. A
DISI
DS Used HPP Used
Page 411
Chapter 5: Standard RLL Instructions - Interrupt
Interrupt Example for Interrupt Module In the following example, when X40 is on, the interrupts will be enabled. When X40 is off the interrupts will be disabled. When a interrupt signal X1 is received, the CPU will jump to the interrupt label INT O 1. The application ladder logic in the interrupt routine will be performed. The CPU will return to the main body of the program after the IRT instruction is executed. DirectSOFT
Handheld Programmer Keystrokes $
X40
E STR
ENI
SHFT
E 4
SP STRN X40 DISI
. . . END
O1
X20
Y5 SETI
X21
Y10
I
E
A 0
3
8
S RST
N TMR
D
4 8
N TMR
T MLR
SHFT
E
SHFT
I
$
SHFT
I
X SET
SHFT
I
$
SHFT
I
X SET
SHFT
I
SHFT
I
R ORN
STR
I
8
ENT
8
4 D
ENT
0
N TMR
SHFT
STR INT
A 4
3
ENT I 8
ENT
ENT B 1 C
8
A 2
F 8
5 C
8
0
B
B T MLR
1 A
1
ENT
ENT
2
8
ENT
0
ENT
SETI
IRT
DL205 User Manual, 4th Edition, Rev. A
ENT ENT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–189
Page 412
Chapter 5: Standard RLL Instructions - Interrupt
In the following example, when X1 is on, the value 10 is copied to V7634. This value sets the software interrupt to 10 ms. When X20 turns on, the interrupt will be enabled. When X20 turns off, the interrupt will be disabled. Every 10 ms the CPU will jump to the interrupt label INT O 0. The application ladder logic in the interrupt routine will be performed. 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
Handheld Programmer Keystrokes SP0
$
LD
SHFT
STR
K40
SHFT
L ANDST
SP STRN
D 3
A 0
ENT
SHFT
K JMP
B
H
G
D
A 4
0
ENT
OUT V7633
X1
GX OUT
SHFT
$
B
K104*
SHFT
Load the constant value (K10) into the lower 16 bits of the accumulator *
GX OUT $
L ANDST
SHFT
Copy the value in the lower 16 bits of the accumulator to V7634
4
SP STRN
ENI
X20
. . . END
INT
SHFT
K JMP
B
SHFT
G
D
C
A
ENT
O0
I
C
A 0
3
8
S RST D
4
N TMR
8
N TMR
T MLR
SHFT
E
SHFT
I
$
SHFT
I
X SET
SHFT
I
SP STRN
SHFT
I
S RST
SHFT
I
SHFT
I
R ORN
8
3
8
4
ENT
ENT
ENT
A 0
8
A 2
F 8
5 D
8
0
3
ENT ENT
ENT F
A
5
ENT B
0 T MLR
3
4
ENT
H 1
7
ENT
ENT
Y5 SETI
Y0
Y17 RSTI
5–190
6
E 0
E
ENT I
C
8
A 1
* The value entered, 3-999, must be followed by the digit 4 to complete the instruction.
X20
X35
3
ENT
ENT
8
2 I
7
0
N TMR
SHFT
STR DISI
3
H
D
X20
6
V AND
3
2 E
7
D
ENT
D
STR V7634
V
1
STR
LD
OUT ard RLL uctions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Interrupt Example for Software Interrupt
IRT
NOTE: Only one software interrupt is allowed and it must be Int0.
DL205 User Manual, 4th Edition, Rev. A