0% found this document useful (0 votes)
116 views

Subroutine PLC

This document discusses two options for converting temperature inputs from Celsius to Fahrenheit in a PLC program. Option 1 is to add a rung of ladder logic for each conversion, making the program longer and slower. Option 2 uses a subroutine to perform the conversion, which reduces the number of rungs and allows the temperatures to be passed as input parameters. The subroutine example shows temperature data from three drives being passed to the subroutine using JSR instructions, the conversion calculation, and the result being returned to the calling program.

Uploaded by

Adnan Hashmi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views

Subroutine PLC

This document discusses two options for converting temperature inputs from Celsius to Fahrenheit in a PLC program. Option 1 is to add a rung of ladder logic for each conversion, making the program longer and slower. Option 2 uses a subroutine to perform the conversion, which reduces the number of rungs and allows the temperatures to be passed as input parameters. The subroutine example shows temperature data from three drives being passed to the subroutine using JSR instructions, the conversion calculation, and the result being returned to the calling program.

Uploaded by

Adnan Hashmi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 13

PLC 5 and ControlLogix Subroutine Parameters

Input Parameters Simple Example


Three variable frequency drives heat sink temperatures input to PLC Temperatures input in degrees Celsius Convert to degrees Fahrenheit and display on operator interface

Option #1 Ladder Conversion


Each time temperature input could add a rung to do calculations. This would make ladder file longer.
More rungs Slower scan

Option #2 Subroutine Conversion


Put conversion instructions in a subroutine Access subroutine each time conversion necessary Less rungs in ladder JSR input parameters used to move temperature data to subroutine

JSR Instructions with Parameters

Heat Sink Temperature from Three Different Sources


Drive node 21 temperature to F8:0 Drive node 22 temperature to F8:1 Drive node 23 temperature to F8:2

JSR Sends Information to SBR


JSR sends temperature information to SBR instruction input parameter address F8:10. Node 21, F8:0 temperature Node 22, F8:1 temperature Node 23, F8:2 temperature

Subroutine Shares Data


- F8:10 is where temperature is stored.
- F8:10 data used in calculation

CPT Destination Stores Result

Result, F8:11 to RET Output Parameter

Data Returned to JSR

Data from RET instruction return parameter to JSR return parameter F8:12

Data Flow
Ladder 2

A D E C

Ladder 3

No Return Parameter Faults Processor

You might also like