RS L5K function block vs ladder sbr

Nixalicious

Member
Join Date
Jun 2013
Location
Yucaipa, CA
Posts
4
So I am just starting on this whole PLC programming thing and I am a bit confused on the requirements for a function block subroutine work vs a ladder logic subroutine. I like function block a lot better so I do want to stick with it.

I guess my biggest question is do I have to put in a subroutine in my function or can I just use the tags and use the output bit from the routine in my other routines. Like I said I am just learning so if this doesn't make sense please let me know.

Doug

PS I did attach my routine so hopefully it helps.

HS Crane vs U2 06262013.jpg
 
Welcome to the Forum!
Treat any type of subroutine, either LAD, FB, STL, ST identically.
In order to be functional, any type of subroutine will have to be "called up" within the "Main" routine of the given program using the JSR instruction.
Just as any RSL5K configured tags, any Controller Scoped tags will be available to all the project's programs while Program Scoped tags will be available only to the respective program's routines.
 
I prefer Function Block on something that is a continuous process with few or no conditions ahead of it--things like PID loops, Scaling, Math functions, etc. I prefer ladder if there is a fairly complicated decision tree for the instruction--lots of IF, AND, OR, and so on.
 
Hi

I am with brstilson.


I would also add in motion, machine sequences, alarms, mapping I/O, for ladder and I often do my maths in structured Text.

But that's just me other will disagree and they will not be wrong or correct either
it is really up to the programmer.

Donnchadh
 
Welcome to the Forum!
Treat any type of subroutine, either LAD, FB, STL, ST identically.
In order to be functional, any type of subroutine will have to be "called up" within the "Main" routine of the given program using the JSR instruction.
Just as any RSL5K configured tags, any Controller Scoped tags will be available to all the project's programs while Program Scoped tags will be available only to the respective program's routines.

Now I do not have to jsr in the main routine correct? This routine is only for two subroutines. So I could use it as a sub to a sub correct I mean that is only since I am using it specifically for those routines.
 
No you do not; once designated as "Main" a routine will always be scanned; this will be the equivalent of LAD.2 of the PLC/SLC systems which is automatically added to any new project and the only one which the CPU scans by default.
Any RSL5K "not Main" routines (usually refered to as subroutines) will have to be JSR called-up within the routine designated as "Main".
 
.... Any RSL5K "not Main" routines (usually refered to as subroutines) will have to be JSR called-up within the routine designated as "Main".

Does the JSR have to be directly in the "Main"?

I thought a JSR could be used in any routine.
It's just that the JSR in "Non-main(1)" to "Non-main(2)" will not be called if there in not a JSR path back to "Main".
 
I thought a JSR could be used in any routine.
It's just that the JSR in "Non-main(1)" to "Non-main(2)" will not be called if there in not a JSR path back to "Main".
You are exactly correct. You can call Subroutine 2 from Subroutine 1. Just remember that the PLC scan has to get to Sub 1 somehow (maybe called from Sub 0 or from the Main).
 
Does the JSR have to be directly in the "Main"?

no, it doesn't have to be in the "Main" – but its rung DOES have to be scanned/executed by the processor or the JSR won't "call" the subroutine ...

I thought a JSR could be used in any routine.

it CAN be ...

but ...

there is a limit as to how many "jumps" you can make in a row ... for the older systems (using RSLogix5 and RSLogix500) the limit is eight ... trying to jump too many times in a row will cause a processor fault ...

by "jumps in a row" I mean that A calls B - then B calls C - then C calls D - and so on and on ...

with the RSLogix5000 systems the "jumps in a row" limit is 34 – and then you'll get a "Stack Overflow" fault ...

it's not very likely that someone would ever intentionally program a string with more than 34 "jumps" in a row – but as long as we're discussing the concepts, I suppose that we should go ahead and nail down some more of the basic ideas ...

and along those lines ...

just for completeness, you should also look up the FOR instruction for the RSLogix5000 systems ... that arrangement (actually a For/Next loop) is yet another way in which the processor can "call" a subroutine into action - even though no JSR instruction is involved ...

note that the older RSLogix5 and RSLogix500 systems didn't have this extra FOR "subroutine calling" capability ... but if you're working with those systems you should also research the STI (Selectable Timed Interrupt) function – and the PII or DII functions ...
 
Last edited:

Similar Topics

Hello Could one of our AB users please create a simple L5K file for me? A few basic tags, a few structures and a few tags of the structure type...
Replies
3
Views
176
We updated from Crimson 3.2.0067.0 to Crimson 3.2.0071.0 and now there is no comms between the 12" Graphite HMI and the AB Compact Logix PLC...
Replies
2
Views
511
Curious if anybody has any documentation or input on what this exactly does . Many times when I have a problem it is one of the first things tech...
Replies
3
Views
2,368
I have to change IP subnets throughout the facility. Just about every model from PLC5 through L81, even a couple ENI modules for ML1200's ... I...
Replies
7
Views
1,604
Is there a way to batch convert a bunch of logix files into L5K? I have to gather MSG IPs for a plantwide re-addressing and a search of text files...
Replies
4
Views
1,926
Back
Top Bottom