Home ยป Allen Bradley PLC Subroutines
PLC Tutorials

Allen Bradley PLC Subroutines

JSR, SBR, and RET instructions are used to direct the controller to execute a separate subroutine file within the ladder program and return to the instruction following the JSR instruction.

Allen Bradley PLC Subroutines

The SBR instruction must be the first instruction on the first rung in the program file that contains the subroutine.

  • Use a subroutine to store recurring sections of program logic that must be executed from several points within your application program
  • A subroutine saves memory because you program it only once.
  • Update critical I/O within subroutines using immediate input and/or output instructions (IIM, IOM), especially if your application calls for nested or relatively long subroutines
  • Otherwise, the controller does not update I/O until it reaches the end of the main program (after executing all subroutines)
  • Outputs controlled within a subroutine remain in their last state until the subroutine is executed again.

When the JSR instruction is executed, the controller jumps to the subroutine instruction (SBR) at the beginning of the target subroutine file and resumes execution at that point. You cannot jump into any part of a subroutine except the first instruction in that file.

The target subroutine is identified by the file number that you entered in the JSR instruction. The SBR instruction serves as a label or identifier for a program file as a regular subroutine file. The instruction must be programmed as the first instruction of the first rung of a subroutine.

The RET instruction marks the end of subroutine execution or the end of the subroutine file. The rung containing the RET instruction may be conditional if this rung precedes the end of the subroutine.

In this way, the controller omits the balance of a subroutine only if its rung condition is true.

If you liked this article, then please subscribe to our YouTube Channel for PLC and SCADA video tutorials.

You can also follow us on Facebook and Twitter to receive daily updates.

Read Next:

Essential Documents in a PLC System

Process Control System Questions

Conveyor Ladder Logic Program

PLC Energize or De-energize

PLC Selective Execution

Share With Your Friends

Related Articles

SCADA Multiple Choice Questions

S Bharadwaj Reddy

Motor Speed Control using VFD and PLC Programming

S Bharadwaj Reddy

How to Retrieve PLC Project From Memory Card?

S Bharadwaj Reddy

Types of Interrupt OB in Siemens Tia Portal

S Bharadwaj Reddy

Communication between Factory IO and Siemens Tia Portal

S Bharadwaj Reddy

What are Trends in SCADA?

S Bharadwaj Reddy

1 comment

Shahid ali September 13, 2018 at 9:13 am

I know about dcs and scada function of instruments.what is the function of dcs


Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Allen Bradley PLC Subroutines

WordPress Image Lightbox
Send this to a friend