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

The text of a manual · part 34 of 53

DL06 Micro PLC User Manual, Volume 1 of 2, pages 330 to 339

Pages 330 to 339 of 524

The original document is the PDF (6.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 AutomationDirect Direct Logic DL06 and Koyo DL06 D0-06DD1

Page 330

Chapter 5: Standard RLL Instructions - Program Control Instructions

For / Next (FOR) (NEXT)

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

DS5

Used

HPP

Used

5–176

The For and Next instructions are used to execute a section of ladder logic between the For and Next instruction a specified numbers of times. When the For instruction is enabled, the program will loop the specified number of times. If the For instruction is not energized the section of ladder logic between the A aaa For and Next instructions is not executed. FOR For / Next instructions cannot be nested. The normal I/O update and CPU housekeeping is suspended while executing the For / Next loop. The program scan can increase significantly, depending on the amount 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 NEXT required to complete the program execution, it may be necessary to reset the watch dog timer inside of the For / Next loop using the RSTWT instruction. Operand Data Type

DL06 Range aaa

V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K

DL06 Micro PLC User Manual, 3rd Edition Rev. A

See memory map 1-9999

Page 331

Chapter 5: Standard RLL Instructions - Program Control 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 Watch Dog Timer setting. For more information on the Watch Dog Timer, refer to the RSTWT instruction. DirectSOFT Direct SOFT325 X1

1

K3

2

3

FOR

RSTWT

X20

Y5 OUT

NEXT

Handheld Programmer Keystrokes $

B STR

1 O INST#

R ORN

R ORN

S

T MLR

SHFT

I

SHFT

F

SHFT $ STR

5

GX OUT SHFT

ENT

RST 8 F 5

N TMR

E

3

ENT

W ANDN

T MLR

ENT

C

A

ENT

2

0

T MLR

ENT

ENT X

4

D

SET

DL06 Micro PLC User Manual, 3rd Edition

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

5–177

Page 332

Chapter 5: Standard RLL Instructions - Program Control Instructions

Goto Subroutine (GTS) (SBR)

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

DS5

Used

HPP

Used

The Goto Subroutine instruction allows a section of ladder K aaa logic to be placed outside the main body of the program GTS execute only when needed. There can be a maximum of 256 GTS instructions and 256 SBR instructions used in a program. The GTS instructions 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 K aaa SBR 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.

Subroutine Return (RT) Operand Data Type

DL06 Range aaa

Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K DS5

Used

HPP

Used

When a Subroutine Return is executed in the subroutine the CPU will return to the point in the main body of the program from which it was called. The Subroutine Return is used as termination of the subroutine which must be the last instruction in the subroutine and is a stand alone instruction (no input contact on the rung).

Subroutine Return Conditional (RTC) DS5

Used

HPP

Used

5–178

The Subroutine Return Conditional instruction is a optional instruction used with a input contact to implement a conditional return from the subroutine. The Subroutine Return (RT) is still required for termination of the Subroutine.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1-FFFF

RT

RTC

Page 333

Chapter 5: Standard RLL Instructions - Program Control 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. X1

Direct SOFT32 Display DirectSOFT 5

K3 GTS

C0 LD K10

END SBR

K3

X20

Y5 OUTI

X21

Y10 OUTI

X35 RT C X35

Y0

Y17 RSTI

RT

Handheld Programmer Keystrokes $

B 1

STR SHFT

G

SHFT

E

SHFT

S

$

SHFT

I

GX OUT

SHFT

I

$

SHFT

I

GX OUT

SHFT

I

$

SHFT

I

SHFT

R ORN

T MLR

SP STRN

SHFT

I

S

SHFT

I

R ORN

T MLR

STR

STR

STR

RST SHFT

ENT

T MLR

S

6

N TMR

D

4

SHFT

B

RST

D RST

3 1

3

ENT R ORN C

8

D 3 A

2 F

8

5 C

8

0

B

B 8

1 A

1 D

8

0 F

3 2

ENT

5

ENT ENT ENT

ENT D

8

F 3

A 8

ENT

ENT

2

C

ENT

5

ENT B

0

H 1

7

ENT

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

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–179

Page 334

Chapter 5: Standard RLL Instructions - Program Control Instructions

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 SOFT32 DirectSOFT 5 X1

END

SBR

K3

X20

Y5 OUT

X21

Y10 OUT

RT

Handheld Programmer Keystrokes B

$ STR

1

SHFT

G

SHFT

E

SHFT $ STR

$ STR

ENT

6

T MLR

S RST

N TMR

D

4 S RST

SHFT

B

SHFT

I

GX OUT

ENT

ENT D

R ORN

3 A

2

0

ENT

ENT

I

C 8

B R ORN

1

3

C

5 SHFT

3

D

8 F

GX OUT

SHFT

5–180

K3 GTS

B 2

A 1

0

T MLR

ENT

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1

ENT

ENT

Page 335

Chapter 5: Standard RLL Instructions - Program Control Instructions

Master Line Set (MLS) DS5

Used

HPP

Used

The Master Line Set instruction allows the program to control K aaa sections of ladder logic by forming a new power rail controlled MLS by the main left power rail. The main left rail is always master line 0. When a MLS K1 instruction is used, a new power rail is created at level 1. Master Line Sets and Master Line Resets can be used to nest power rails up to seven levels deep. Operand Data Type

DL06 Range aaa

Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K

1-FFFF

Master Line Reset (MLR) DS5

Used

HPP

Used

K aaa MLR

The Master Line Reset instruction marks the end of control for the corresponding MLS instruction. The MLR reference is one less than the corresponding MLS. Operand Data Type

DL06 Range aaa

Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K

1-FFFF

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. DirectSOFT 5

Direct SOFT32 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

DL06 Micro PLC User Manual, 3rd Edition Rev. A

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

5–181

Page 336

Chapter 5: Standard RLL Instructions - Program Control Instructions

MLS/MLR Example

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

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 5 DirectSOFT32

Handheld Programmer Keystrokes

X0

K1

X1

X2

A

Y MLS

B

C0 OUT

$

B STR

1

C1

GX OUT

SHFT

C

$

C

ENT

Y0 OUT

X10

K2

C

Y1

Y2

D

X5

SHFT

C

$

D

ENT

OUT X6

Y3

GX OUT

A

$

B

MLR X7

Y4 OUT

0

C

$

F 5

GX OUT

B

$

E

1

B

4

GX OUT

C

T MLR

B

$

F

B

2 1

0

ENT ENT ENT ENT ENT

GX OUT

SHFT

C

$

G

ENT

GX OUT

D

T MLR

A

$

H

3 0

STR GX OUT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

7 E

C 2

2

ENT ENT ENT C

4

ENT

ENT

5

6

ENT

ENT

STR

STR

1

ENT

ENT A

2

0

2

1

Y MLS

OUT K0

3

STR

C2

A 2

GX OUT

STR

MLR

ENT

2

OUT K1

ENT

STR

STR

OUT X4

1

STR

MLS X5

0

ENT

STR

OUT X3

A

$

MLS

2

ENT

ENT

Page 337

Chapter 5: Standard RLL Instructions - Interrupt Instructions

Interrupt Instructions

1 The Interrupt instruction allows a section of ladder logic 2 to be placed below the main body of the program and executed only when needed. High-Speed I/O Modes 10, 3 20, and 40 can generate an interrupt. With Mode 40, you may select an external interrupt (input X0), or a time-based interrupt (3–999 ms). 4 Typically, interrupts are used in an application when a fast response to an input is needed or a program section must execute faster than the normal CPU scan. The interrupt label and all 5 associated logic must be placed after the End statement in the program. When an interrupt occurs, the CPU will complete execution of the current instruction it is processing in ladder 6 logic, then execute the interrupt routine. After interrupt routine execution, the ladder program resumes from the point at which it was interrupted. See Chapter 3, the section on Mode 40 (Interrupt) Operation for more details on interrupt 7 configuration. In the DL06, only one software interrupt is available. The software interrupt uses interrupt #00 (INT 0), which means the hardware interrupt #0 and the software 8 interrupt cannot be used together. Hardware interrupts are labeled in octal to correspond with the hardware input signal (e.g. X1 will initiate INT 1). 9 Operand Data Type DL06 Range aaa 10 Interrupt Return (IRT) 11 An Interrupt Return is normally executed as the last instruction in the interrupt routine. It returns the CPU to the point in the main program from which 12 it was called. The Interrupt Return is a stand-alone instruction (no input contact on the rung). 13 Interrupt Return Conditional (IRTC) The Interrupt Return Conditional instruction is a optional instruction used with an input contact to implement a 14 conditional return from the interrupt routine. The Interrupt Return is required to terminate the interrupt routine. A Enable Interrupts (ENI) The Enable Interrupt instruction is placed in the main ladder B program (before the End instruction), enabling the interrupt. The interrupt remains enabled until the program executes a C Disable Interrupt instruction. D Interrupt (INT)

INT

DS5 HPP

O aaa

Used Used

Constant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . O

DS5

Used

HPP

Used

1-FFFF

IRT

DS5

Used

HPP

Used

DS5

Used

HPP

Used

IRTC

ENI

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–183

Page 338

Chapter 5: Standard RLL Instructions - Interrupt Instructions

Disable Interrupts (DISI)

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

DS5

Used

HPP

Used

A Disable Interrupt instruction in the main body of the application program (before the End instruction) will disable the interrupt (either external or timed). The interrupt remains disabled until the program executes an Enable Interrupt instruction.

DISI

External Interrupt Program Example

5–184

In the following example, we do some initialization on the first scan, using the first-scan contact SP0. The interrupt feature is the HSIO Mode 40. Then we configure X0 as the external interrupt by writing to its configuration register, V7634. See Chapter 3, Mode 40 Operation for more details. During program execution, when X2 is on the interrupt is enabled. When X2 is off the interrupt will be disabled. When an interrupt signal (X0) occurs the CPU will jump to the interrupt label INT O 0. 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 5 SP0

Handheld Programmer Keystrokes

Direct SOFT32 LD K40

Load the constant value (K40) into the lower 16 bits of the accumulator

V7633

Copy the value in the lower 16 bits of the accumulator to V7633

K4

Load the constant value (K4) into the lower 16 bits of the accumulator

OUT

LD

Copy the value in the lower 16 bits of the accumulator to V7634

OUT V7634

$

SHFT

STR SHFT

L ANDST

GX OUT SHFT

SHFT

$

C

ENT

2

SHFT

DISI

SP STRN

E 4

2

SHFT

D

SHFT

E

SHFT

I

$

SHFT

I

SHFT

I

SHFT

I

SHFT

I

I

R ORN

O0 STR

Y7 SETI

X SET $ STR X SET

IRT

N TMR C

END

X3

3 V AND

ENI

Y5 SETI

V AND

D

STR

X2

X1

3

GX OUT

X2

INT

D

SHFT L ANDST

SP STRN

SHFT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

I

0

ENT

SHFT

K JMP

E

H

G

D 6

SHFT

K JMP

E

H

G

D

7

6

A 4

7

I

3 4

S

I RST

N TMR

D

4 8

N TMR

T MLR

3

8

3

ENT

0 B

8

1 F

8

5 D

8

3 H

8

7 T MLR

ENT

A

ENT

ENT ENT ENT ENT

3

ENT

ENT ENT

ENT E

ENT

8

0 D

ENT

8

3

8

A

4

ENT

Page 339

Chapter 5: Standard RLL Instructions - Interrupt Instructions

Timed Interrupt Program Example In the following example, we do some initialization on the first scan, using the first-scan contact SP0. The interrupt feature is the HSIO Mode 40. Then we configure the HSIO timer as a 10 mS interrupt by writing K104 to the configuration register for X0 (V7634). See Chapter 3, Mode 40 Operation for more details. When X4 turns on, the interrupt will be enabled. When X4 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 X3 is not on Y0–Y7 will be reset to off and then the CPU will return to the main body of the program. DirectSOFT 5

Direct SOFT32

SP0

Handheld Programmer Keystrokes Load the constant value (K40) into the lower 16 bits of the accumulator

LD K40

$

B STR

SHFT OUT V7633

K104

D 3

Copy the value in the lower 16 bits of the accumulator to V7633

GX OUT

Load the constant value (K10) into the lower 16 bits of the accumulator

GX OUT

SHFT

V AND

$

E

ENT

SHFT LD

SHFT L ANDST

V7634 X4 ENI

SHFT

V AND

D 3

STR Copy the value in the lower 16 bits of the accumulator to V7634

OUT

ENT

1 L ANDST

4 E 4

SP STRN

N TMR E 4

SHFT

D

I

SHFT

E

SHFT

I

$

SHFT

I

SHFT

I

SHFT

I

SHFT

I

I

R ORN

SHFT

K JMP

E

H

G

D

7

6

SHFT

K JMP

B

H

G

D

7

I

A 4

0 D

3

3 A

1

6

0 4

ENT

8 ENT S

I

3

8

RST

N TMR

D

4 8

N TMR

T MLR

8

ENT

X4 DISI

END INT

STR

O0

X SET X2

Y5

SP STRN

SETI

X SET

X3

Y7

Y0

SHFT

8

3

ENT A 0 C

8

2 F

8

5 D

8

3 A

8 T MLR

ENT

ENT ENT ENT H

0

7

ENT E

E 3

ENT

ENT

ENT

RSTI

IRT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

ENT

4 ENT

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

5–185