RSLogix 5000 JSRs & Program Flow

elfmanp

Member
Join Date
Feb 2011
Location
Salt Lake City, Utah
Posts
18
I am trying to figure out how ladder programs in the compactlogix/controllogix platforms handle JSRs and general flow, etc. o_O

If I have 1 rung that calls 6 routines as seen in Image1, does each routine run successive, or do they run in parallel? Versus 6 rungs that run 6 routines as seen in Image2.

What are some common practices to make sure routine 1 runs and finishes before routine 2, etc through the 6 routines? Say I have a routine "Initialize" that must run and complete before routines 1-6, what is the best way to achieve?

Trying to learn to fish here, rather than asking for a fish. Thanks in advance! (y)

Image1.png Image2.png
 
It doesn't matter if they are branched as in photo 1 or separate rungs as in photo 2, although on an old PLC with limited memory the 2 ways would use different amounts of available memory. Processing order and scan speed would not be affected.

The first JSR will finish before the calling rung is gone back to, then the next JSR will be called.

If the second JSR looks at a tag set by the first JSR if they were running concurrently that tag may not have been set yet.

The same goes for AOI's in series or on branches.
 
Either way will work much the same. All rungs are scanned top to bottom, left to right. So in the first image the PLC will run Routine 1 then 2 and so on. In the second image the PLC will run Routine 1 go to the next line and run Routine 2 and so on.

The difference is that image 1 will run slightly faster and take up slightly less memory. I mean SLIGHTLY in that you may not be able to even notice the difference.

I do my JSR's like image 2. To me it is easier to read and easier to add something in-between lines if you need to.

Hope this answers your question. Let us know if you have more.
 
Okay. I understand. Not sure how to phrase the follow-up question. We're just talking about how the PLC scans through rungs, correct? It will go sequentially, but it doesn't necessarily stop in Routine 1 until Routine 1 is satisfied, does it?
(One of those things I have struggled with over the years... More banging of head!)
 
... but it doesn't necessarily stop in Routine 1 until Routine 1 is satisfied, does it? ...


Not sure I understand what "stop" and "satisfied" mean here.


Short of a fault, mode change, or power loss, scanning never stops anywhere.



It will jump to Routine 1 when the rung feeding the [JSR] instruction to jump to Routine 1 is executed and true, and it will not return to (the rung after) that rung until Routine 1 executes either a [RET] instruction or Routine 1's last rung.
 
Instead of "stop in Routine 1 until Routine 1 is satisfied," do you mean "stay in Routine 1 until Routine 1 executes a return?"


Because yes, it will stay in Routine 1 until Routine 1 executes a return*, and will neither jump to, nor start, Routine 2 until that Routine 1 return* is executed.


* Any Routine 1 return includes the implicit return at the end of Routine 1.
 
Last edited:
You said RS 5000, in the new Control Logix platform, it may stop processing a routine in the middle, do something else (higher priority) and then resume where it left off. Also since IO updates are done asynchronous, you can have a physical I/O point change states in the middle of a routine.
 
but it doesn't necessarily stop in Routine 1 until Routine 1 is satisfied, does it?

I guess, what the op meant is does it pause, waiting for an event similar to PC programs.
No, PLC scans doesn't stops for such
 
I think the relevant phrase is single-threaded: scanning instructions on rungs is done in a single thread, even if other things (I/O; comms) are going on at the same time; even if a higher-priority routine interrupts in the middle of scanning a lower-priority routine, the single scanning thread will stop processing the lower-priority thread, process the higher-priority thread, and return to processing the lower-priority thread (assuming no other interrupts).


In no scenario is [Routine 1] executed in parallel (multi-threaded) with any other [Routine N] at the same priority.
 
Thanks all for your replies! :geek: Great information. Left to Right, Top to Bottom. Period. Also, helps me understand the critical nature of mapping inputs/outputs at one point in the code to help reduce weird things happening due to things turning on/off midstream during PLC scans. It is all starting to come together - sort of - maybe.
 
Give it about 40 years and you should know everything.
In 40 years you'll know everything about the state of the art today. But you'll still be playing catch-up on 40 years worth of advances.
I, for instance, can tell you just about anything you need to know about the GE Series Six which went out of production in the early 1990s.
 

Similar Topics

Hi folks, in the alarm manager of Rslogix 5000, the tag-based alarm has been created. But when I tried to change the condition, it was found the...
Replies
2
Views
156
I am completely stuck on building a ladder program that requires a start button to be pressed 3 times to turn on motor 1. Then motor 2 starts...
Replies
20
Views
578
First off, I'm a hobbyist-level programmer, and this program isn't controlling anything anything that could even remotely be considered "life...
Replies
18
Views
518
Hello all, I have a question in regards to RSlogix 5000. I am having issues with the program force closing when I try to make online edits. We...
Replies
0
Views
120
Back
Top Bottom