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'm fairly new to Rockwell software, I've had some basic training in the past but nothing too advanced. My company and I use Reliable products for...
Replies
0
Views
37
Hi all I need help on this As in my project used Schneider TM241 controller. Now I want to communicate Elite energy meter with controller by...
Replies
3
Views
103
Hi all, I am having issues accessing my Cimplicity software - the site code changed after re-install and I am no longer able to attain a new key...
Replies
10
Views
128
Good day all! Can someone help me with the procedure to update Beijers E700 firmware? The Panel I am working on is firmware 2.04v and I would...
Replies
1
Views
53
Hi, We have an application that has a device that goes through a reboot (appears un-graceful) What then happens is the MVI module appears to hang...
Replies
0
Views
59
Back
Top Bottom