![background image](http://html1.mh-extra.com/html/allen-bradley/plc-2-30/plc-2-30_programming-and-operations-manual_2900216214.webp)
Jump Instructions and
Subroutine Programming
Chapter 11
1112
A subroutine can loop or call itself (Figure 11.10b). If this procedure
is used, it is recommended that a scan counter be used to ensure that a
maximum of 9 JSR’s (including the original one in the main program) is
not exceeded. If 9 JSR’s are exceeded, it would cause a processor fault.
For example, if the looping occurs in Level-1 subroutine, the counter
preset value should be a maximum of 009. If looping is in Level 3
subroutine, the counter preset value should be a maximum of 006.
Instruction overview:
Subroutine nesting is permitted to 8 Levels (Section 11.3.2)
Recursive subroutine calls (looping) is permitted to 8 levels
(Section 11.3.2)
More than 9 Levels of subroutine calls or a JSR to Label in the main
program are causes of run time error.
If an output instruction in the subroutine area is left on after the processor
has completed the program scan, the output will remain on regardless of
its rung condition. No action will be taken to control that output until the
processor is directed back to the subroutine area or a rung in the main
program is executed which also controls that same output. Instructions in
a subroutine area are acted on only during an actual scan of a subroutine.
This includes status bits of subroutine timers, counters and block
instructions.
For example, in the program below, Rungs 3 and 4 have been added to
the main program to turn off the outputs of rungs 5 and 6, respectively, if
these outputs were left on after the processor completed the subroutine
scan.
11.3.3
Recursive Subroutine
(Looping) Calls
11.3.4
Subroutine Programming
Considerations
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com