Help on the correct use of JSR as a Fuction. RS5000

edwinmart

Member
Join Date
Jun 2006
Location
Santo Domingo
Posts
31
I am trying to use the JSR instruction instead of repeat dozens of times the same rung structure. By using JSR to jump to a separate routine, pass data to the routine, execute the routine, and return results.


I know that I have to specify the Input and Output Parameters but inside the subroutines what tags I use?​

But maybe Im no far from reality...​
What I think is using JSR with values of input pars I0.0 and I0.1 and output par O0.0​

-----------JSR-----------​
| Routine Name: Routine A​
| Input par: I0.0​
| Input par: I0.1​
| Return par: O0.0​
-------------------------​

Then inside the rungs in subroutine "Routine A"​

I use the SBR instruction​
--------SBR------​
| Input par: Ix​
| Input par: Iy​
-----------------​

--[ ADD Ix, Iy, Oz ] -------​

then the return instruction inside "Routine A"​

------RET-------​
| Return par: Oz​
----------------​

So the value of Oz goes to O0.0​

If I am wrong please tell me.​

RSlogix 5000 v13​
 
Last edited:
If you have access to RSLogix5K V16, get it. The new feature AOI (Add On Instruction), is a vast improvement over JSRs with parameters.
 
Think of the subroutine as a separate isolated program in the PLC. You can specify whatever tags you want within the subroutine.


I try and think of passing parameters like MOV instructions. The Input Parameter on the JSR is the source and the Input Parameter on the SBR is the destination.

The idea being you (as the main program) can pass me (the subroutine) whatever tag you want and I can store that tag anywhere I wish to use within the suboutine. I can then manipulate my tag however I need to and then return my result back to you. When I return it to you using the RET, I specify what tag "I" am returning to you. You then using the JSR can specify where you want to place that result. You can then use or manipulate that data as you see fit.

So I don't know what tag you are sending me, I merely receive the data and put it wherever I choose. You likewise do not see my tag, you just receive the data I return to you.

Hope that helps!

OG

** edit ** V16 adds some new features that can make what you are trying to do easier and much faster. However, you can certainly accomplish your goal with your current version
 
thanks for the answers.

What I am trying to do its an alarm system with 96 inputs but I am trying to use the JSR in case of future modifications will be more easy to edit just the subroutine and not 4 rungs x 96 times.


Edwin
 
sorry to resurrect this thread but what is the difference between return par in JSR as compare to Return par in SBR block?:oops:. Is jsr only used for organization purpose or does it serve any purpose ?If some one could please explain this.
 
Going back to my explanation from 2007 (has it really been that long ago?), think of these like MOV instructions.

The return parameter of the RET instruction would be the "source" and the return parameter of the JSR would be the destination.

The value/tag is being passed (returned) from the subroutine back to the calling routine.

OG
 

Similar Topics

I have an old Sentry Palletizer (S/O Number 3007 / Serial Number 1172) that has lost its program as the backup battery died years ago. I can...
Replies
0
Views
86
Hello, I need to write the following program in Ladder language, but I could not integrate the Fibonacci sequence into the ladder. Can you help...
Replies
22
Views
458
this a program to send data to barcode printer I want to integrate a new printer in a new machine and i wanted to adapt the old prgram on it but I...
Replies
4
Views
172
So i've been at this for a long while, i have Citect Scada 2018, i have full access to everything but i can't seem to find any option or...
Replies
0
Views
64
Hi all, hope you are having a great day, I am in need of your help to create a AOI or program that does this kind of job: I have a IO Link...
Replies
26
Views
554
Back
Top Bottom