one other thing that might bear mentioning ... if you “nest” or “chain” your subroutines too many times (more than eight) you will fault the processor ... specific example:
suppose that a JSR in Ladder File #2 calls a subroutine in Ladder File #7 ...
and then a JSR in Ladder File #7 calls a subroutine in Ladder File #8 ...
and then a JSR in Ladder File #8 calls a subroutine in Ladder File #3 ...
and then a JSR in Ladder File #3 calls a subroutine in Ladder File #5 ...
well that’s FOUR jumps so far ... you’re only allowed eight before you start returning back up the chain ... if you keep on with the same “nesting” or “chaining” pattern shown above for more than eight jumps, then the processor will fault ...
on the other hand ... there is no limit to how many “jump-and-returns” you can do ... specific example:
suppose that a JSR in Ladder File #2 calls a subroutine in Ladder File #7 ... at the end of Ladder File #7, the scan returns to Ladder File #2 ...
and then a JSR in Ladder File #2 calls a subroutine in Ladder File #8 ... at the end of Ladder File #8, the scan returns to Ladder File #2 ...
and then a JSR in Ladder File #2 calls a subroutine in Ladder File #3 ... at the end of Ladder File #3, the scan returns to Ladder File #2 ...
and then a JSR in Ladder File #2 calls a subroutine in Ladder File #5 ... at the end of Ladder File #5, the scan returns to Ladder File #2 ...
in this case the subroutines are NOT “nested” or “chained” ... specifically, the scan returns to Ladder File #2 each time a “call” is completed ... as I’ve said, there is no limit to how many jumps of this type you can make ...
finally,
this post gives some more information on how to learn more about this subject by inserting a “scan tester” in some experimental subroutines ... just remember that it was originally written for the larger PLC-5 processor family so some of the features mentioned might not apply to your system if you're using RSLogix500 ...