25.07.2014 Views

1756-PM003H-EN-E, SFC and ST Programming Languages ...

1756-PM003H-EN-E, SFC and ST Programming Languages ...

1756-PM003H-EN-E, SFC and ST Programming Languages ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

10-6 Program Control Instructions (JSR, RET, SBR)<br />

The following diagram illustrates how the instructions operate.<br />

Calling Routine<br />

Subroutine<br />

SBR<br />

1. If the JSR instruction has an input<br />

parameter, enter an SBR instruction.<br />

JSR<br />

1. If you want to copy data to a tag in<br />

the subroutine, enter an input<br />

parameter.<br />

2. If you want to copy a result of the<br />

subroutine to a tag in this routine,<br />

enter a return parameter.<br />

3. Enter as many input <strong>and</strong> return<br />

parameters as you need.<br />

JSR<br />

SBR<br />

RET<br />

RET<br />

42974<br />

2. Place the SBR instruction as the first<br />

instruction in the routine.<br />

3. For each input parameter in the JSR<br />

instruction, enter the tag into which<br />

you want to copy the data.<br />

RET<br />

1. If the JSR instruction has a return parameter, enter an RET<br />

instruction.<br />

2. Place the RET instruction as the last instruction in the routine.<br />

3. For each return parameter in the JSR instruction, enter a return<br />

parameter to send to the JSR instruction.<br />

4. In a ladder routine, place additional RET instructions to exit the<br />

subroutine based on different input conditions, if required.<br />

(Function block routines only permit one RET instruction.)<br />

There are no restrictions, other than controller memory, on the<br />

number of nested routines you can have or the number of parameters<br />

you pass or return.<br />

level 1<br />

subroutine action_1<br />

level 2<br />

subroutine action_2<br />

level 3<br />

subroutine action_3<br />

main routine<br />

action_1<br />

SBR<br />

SBR<br />

SBR<br />

JSR<br />

action_2<br />

action_3<br />

JSR<br />

JSR<br />

RET<br />

RET<br />

RET<br />

Publication <strong>1756</strong>-<strong>PM003H</strong>-<strong>EN</strong>-E (excerpt from <strong>1756</strong>-RM003H-<strong>EN</strong>-P) - August 2005

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!