PLC Tutorials

How to use Sub Routines with Allen Bradley PLC

Sub routines are sub programs in a PLC project. We can split the whole program by its function or sequence. We can call the sub programs from main page using instructions.

Sub Routines with Allen Bradley PLC

In the above picture, there are totally 8 files listed. In that SYS 0 and SYS 1 are default files.

  • LAD 2-Main is the main page of the program, that means PLC starts executing IO’s from this page only.
  • LAD-3-IO MAPPING, LAD 4-SCALING, LAD 5-PID, LAD 6-PLANT 1 and LAD 7 PLANT 2 are sub programs categorized by project function and sequence.

PLC Instruction Description

  1. JSR-Jump to Sub routine

We can use this instruction using condition by adding some input before the instruction like,

In the SBR File number, we should give the ladder number i.e. which sub routine we should call at this place as shown in below figure.

  1. RET: Return to Main Page

Return instruction should add at the end of the sub routine program.

PLC Program

In this program, Sub routine instructions are explained using simple example.

LAD 2-MAIN PAGE:

LAD 3–IO MAPPING

Note: Since its for example, LAD 4, LAD 5,LAD 6,LAD 7 pages are not included in this program

Program Description:

Case 1 :

If Sw2 is not turned on, In LAD 3-IO Mapping, no operations will be happen.

LAD 2-MAIN PAGE:

LAD 3–IO MAPPING:

Even though, sw6 is turned ON, Move block is not doing any operation because in main page, JSR instruction is not activated

Case 2 :

If Sw2 is turned on, In LAD 3-IO Mapping, operations will be happen.

LAD 2-MAIN PAGE:

LAD 3–IO MAPPING:

sw6 is turned ON, Move block is doing it s operation because in main page, JSR instruction is activated

Conclusion:

The above explained concept for subroutine is for example only. We can use this example program to understand the working of JSR and RET function in AB PLC ladder logic programming.

Author : Hema Sundaresan

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.

Allen Bradley PLC Subroutines

PLC Training Software Download

Allen Bradley Interview Questions

RSLogix 5000 PLC Programming

PLC Car Parking Ladder Logic

You've successfully subscribed !
Share

Recent Articles

  • PLC Tutorials

Conveyor Sorting Machine PLC Program with Calculation Function

The conveyor sorting machine is widely used in the packing industries using the PLC program…

5 days ago
  • PLC Tutorials

Example of Flip-Flop PLC Program for Lamps Application

Learn the example of flip-flop PLC program for lamps application using the ladder logic to…

5 days ago
  • PLC Tutorials

STAR DELTA Programming using PLC Controller

In this article, you will learn the STAR DELTA programming using PLC controller to start…

5 days ago
  • Instrumentation Design

Single and Three Phase Immersion Electrical Heaters Wiring Circuits

Lube oil consoles of rotary equipment packages in industrial process plants are usually equipped with…

3 days ago
  • Instrumentation Design

Immersion Heaters in Lube Oil Consoles

Rotating equipment packages such as pumps, compressors, turbines need the lube oil consoles for their…

5 days ago
  • PLC Tutorials

How to Blink Lights in Ladder Logic?

This article explains how to blink lights in ladder logic with a detailed explanation video…

4 weeks ago