just some basic ideas ...
Greetings, Mike,
this particular question comes up rather often ... usually it means that someone with a background in “structured” programming languages is trying to transfer their familiar “GOTO subroutine” ideas into the PLC’s ladder logic ... this CAN be done but it’s seldom worth the effort ...
many (most?) professional PLC programmer’s use the “subroutine” files simply for ORGANIZATIONAL purposes ... for example, the CONVEYOR logic might be stored in Ladder File (subroutine file) #3 ... the GRINDER logic might be stored in Ladder File (subroutine file) #4 ... the PRESS logic might be stored in Ladder File (subroutine file) #5 ... etc. ...
once the logic has been organized this way, we USUALLY program JSR (Jump to Subroutine) instructions to unconditionally scan the ladder files ...
here’s an example of how the “subroutine” files are NOT often used ...
when the garage door is moving UP, then we’ll jump to subroutine file #3 (named something like “OPENING”) ... when the garage door is moving DOWN, then we’ll jump to subroutine file #4 (named something like “CLOSING”) ...
this type of programming CAN be done, but as you’ve already found out, handling all of the “bits keep the last state” problems can be a lot more trouble than it’s worth ...
when used in the most common manner, the basic idea behind SLC and MicroLogix “subroutines” is a lot like using “chapters” in a book ... again, this is usually done simply for organizational purposes ... it is NOT usually done to “sequence” the step-by-step operation of a machine ... it CAN be ... but it’s not at all common ...
hope this helps ...