Documente Academic
Documente Profesional
Documente Cultură
1 of 1
http://plcguide.mrplc.com/menu.shtml
Menu
Command Index
Basic Instructions
Timer & Counter
Compare
Data
Math
Register and Sequencer
Program Control
Communication
Programming References
Example Programs
PLC GuestBook
Links
Down Loads
Send Comments
2001-2006
All Rights Reserved
Your IP Address is: 117.222.1.67
02-07-2013 16:09
1 of 3
http://plcguide.mrplc.com/prgcon/ret.html
The RET command is used in conjunction with the jump to subroutine (JSR), and subroutine (SBR)
commands. The instructions are used to direct the controller to execute a separate subroutine file within
the ladder logic program and return to the previous program at the rung following the JSR instruction.
The return from subroutine (RET) instructions marks the end of the subroutine
execution or the end of the subroutine file. It causes the controller to return to
the program where the JSR command instruction was placed and resume
execution of that program, following the JSR instruction.
The symbol for the Return to Subroutine command is illustrated above. The RET command
or
commands can be placed within or at the end of the subroutine file. The RET instruction may be
conditional if the rung conditional logic is true. This way the controller omits the balance of a subroutine
only if the rung conditional logic is true.
Use the tab on the bottom of the ladder logic program to flip between the main logic program to any
subroutine programs.
In the following figure 1-1, is a basic subroutine ladder logic program.
In the following figure 1-2, is a basic subroutine ladder logic program with multiply returns. This allows
the program to return from a subroutine quicker, if certain conditions are met skipping the remainder of
the subroutine.
02-07-2013 16:09
2 of 3
http://plcguide.mrplc.com/prgcon/ret.html
Example Problem
Use a subroutine command to count the number of parts passing through a system. When the counter
reaches ten, have the controller turn off an output.
02-07-2013 16:09
3 of 3
http://plcguide.mrplc.com/prgcon/ret.html
In this example the subroutine contains a counter. Each time the JSR inputs are activated in the main
program by either the I:1/0 or I:1/5 the counter counts up by one in the subroutine program. This example
allows parts to be countered at two different places. When the counter reaches ten O:2/9 is disabled.
[Back] [Next Command]
02-07-2013 16:09