beautypg.com

Application of subroutine – KEYENCE Visual KV Series User Manual

Page 147

background image

2.4 Instruction Details

1

2

3-123

Chapter 2 Instructions

Application of subroutine

When CALL00 is encountered during normal scan execution, the subroutine is
executed. At the completion of this subroutine, program execution returns to pro-
gram at

B

) immediately following CALL00. Then, the normal scan is continued until

an END instruction is encountered.

With no CALL instruction

With CALL instruction

Nesting structure of a subroutine

Subroutine instructions can be nested up to 4 levels deep.

A subroutine which is called from another subroutine should be defined before
the call.

00

CALL

0000

A)

B)

00

CALL

SBN

00

2008

ENDH

RET

END

B)

A)

Subroutine program

Normal scan

Subroutine

Program

Program

Program

Program

00

CALL

0000

B)

A)

Program

Program

Subroutine program

00

CALL

SBN

01

0001

01

CALL

0000

SBN

00

ENDH

RET

RET

END

Call

Program

Subroutine program

CALL / SBN / RET

KVNKA Chap 02_4bP.p65

08.3.11, 0:00 PM

123