maybe a picture will help ...
Justin,
it looks like you’ve already been given all of the information you need ... but since I already had most of this typed up anyway, I’ll post it for what it’s worth ...
first of all, the scan is NOT going to STAY in the subroutine until the timer is done and THEN go back to the main program ... basically it’s going to have to go back to the main program on each and every scan ... if it doesn’t, then the processor will fault ...
anyway ...
here’s the best way to learn about subroutines ... start out by programming this in your main program (ladder file number 2) ... when the software asks you for “input parameter” and “return parameter” just press the Enter key ... you don’t need these entries to start learning ... in fact, most programmers NEVER use them ...
[attachment]
next set up three new subroutines by creating three new ladder files ... for example: ladder 3, ladder 4, and ladder 5 ... (hint if you need it: right click on the Program Files icon and then select New) ... in each one of the new subroutines put another rung just like the first rung shown in the picture ... EXCEPT make sure that you use a DIFFERENT address for each timer ... for example: use T4:3 and T4:3/DN in file number 3 ... use T4:4 and T4:4/DN in file number 4 ... use T4:5 and T4:5/DN in file number 5 ... NOTE: in real life your timer number does NOT have to correspond with your subroutine number ... but in this experiment, it just helps to keep things straight ...
these little timers will act like “scan testers” ... the numbers in their accumulators will constantly be changing while their files (subroutines) are active (being scanned) ... the numbers in their accumulators will freeze when their subroutines are inactive (NOT being scanned) ...
now put the processor in run mode ... next toggle the test bits on and off ... this will selectively activate and deactivate your subroutine files ... watch which timers run ... and which timers freeze ...
this little experiment should give you a good idea of just how the subroutines behave ... trust me, you’ll learn more from this than from reading and rereading the book ... been there ... done that ...
something specific to watch for: the “power rails” at the left and right side of the subroutine ladder files will turn GREEN while the processor is in run mode ... even when the subroutine is NOT being scanned ... some beginners think that the green means that the subroutine is currently “active” ... it doesn’t ...
want to learn more along the same lines? ... research and experiment with these topics ... MCP (Main Control Program) and STI (Selectable Timed Interrupt) ...
finally, did you do a search on this forum for “subroutine” and “JSR” threads? ... this subject comes up quite often ...
good luck ...
PS ... here I'm assuming (gosh I hate that word) that you're using RSLogix5 ... from now on, how about telling us what system you're working with ... that will help us all out ...