Subroutine

shahid_6673

Member
Join Date
Dec 2013
Location
Dubai
Posts
5
I am having a program using RSlogix 500 developed by my friend. Now i am working on that during commissioning. It contains 8 subroutine program and a main program. There is no condition with JSR instruction used in main program for all subroutine. Please advise me that how it will work during scanning without condition with JSR. Is it necessary to give condition with every JSR instruction. I am new with allen bradley plc. Please help me.
 
Welcome to the site
Conditional subroutines are optional programming methods.
 
Many use subroutines for more logical partitioning of the program and better understanding. They may be executed without conditions on every scan.
 
Program scans Main Routine. Program encounters Unconditional JSR and Jumps to Subroutine and scans Subroutine after completion returns to Main Routine at the jump position and continues to scan Main. Program encounter next Unconditional JSR and jumps to Subroutine and repeats process until it reaches the bottom of the Main Routine.
 
Hi

If I have read your post correct you said that your friend had no jsr
Instruction in the main program.
Well if this is correct unless there is some other way that I don't know
( maybe sti) there is no way the rest of your logic is been scanned
why not post the code

Donnchadh
 
And I use them occasionally for trial logic where I can conditionally jump to either the old subroutine, or the new one containing my trial logic.

But to answer your question, I don't see how those subroutines will get scanned if you are not calling them. Put JSRs in your main routine to call them.
 
rootboy and Donnchadh,

I think you are reading it wrong...

shahid_6673 said:
...It contains 8 subroutine program and a main program...

...There is no condition with JSR instruction used in main program for all subroutine...

...how it will work during scanning without condition with JSR...

...necessary to give condition with every JSR instruction...

To me, this reads as...

...there are no conditions before the JSR instructions in the MAIN ladder file...

...how does the PLC scan these JSR instructions without any conditions before them...

...is it necessary to place conditions before the JSR instructions, or not...

I think bernie and cwal61 answered your questions. No you do not have to use any conditional logic before the JSR instructions in the MAIN ladder file, unless you require some. Also, the JSR instruction should only be used in the MAIN ladder file, as this file is always scanned.

G.
 
I read this - There is no condition with JSR

I could understand making rungs conditional if you want to reduce overall program scan time
 
Also, the JSR instruction should only be used in the MAIN ladder file, as this file is always scanned.

G.

That is incorrect, the JSR instruction can be used anywhere, in any program file. Subroutine files can call other subroutine files (nesting).

JSR is simply an instruction that says "go and execute the code in this program file".

You are quite correct in that the MAIN ladder file (file 2) is always scanned, and it is the ONLY program file that is scanned automatically.

The programmer decides which of the other program files are scanned using JSR instructions.

A program file can also be scanned on a timebase (STI), or on change-of-state of a digital input (DII), in which case there will be no JSR for those files.
 
And here I read it as there were no JSR's! LOL!

(but English is like a second language to me, I don't have a first).
 
In Australia we gave up on the CREENS ENGRISH loong ago
now we use strictly STRINE (Australian for those who aint herd it)
 
Nesting Subroutines

daba said:
Geospark said:
Also, the JSR instruction should only be used in the MAIN ladder file, as this file is always scanned.

G.

That is incorrect, the JSR instruction can be used anywhere, in any program file. Subroutine files can call other subroutine files (nesting)...

daba,

While I am aware of the different methods. I just didn't make my point clear enough, and having re-read my statement I can see it as misleading alright.

I was only pointing out to shahid_6673 that for his program, as it is using the typical method of all the JSR's in the MAIN file, his JSR's should only be placed in the MAIN routine so all the subroutines will be called. I didn't mean it as a general statement, but it could quite easily be read that way.

Thanks for pointing that out to me.

However,

daba said:
...the JSR instruction can be used anywhere, in any program file...

This is 'slightly' incorrect.

Nesting Subroutines...

For RSLogix 5000 (Studio 5000) based controllers, there is no restriction, other than controller memory, on the number of nested subroutines you can have. So you can place a JSR instruction in any subroutine file.

For RSLogix 500 based controllers...

From the MAIN routine file you can JSR to 8 levels of nested subroutines for all SLC and MicroLogix controllers (only 4 for SLC5/01). One could place a single JSR in the MAIN routine to jump to the first subroutine, then place a JSR at the bottom of that subroutine to jump to the next, and so on, with the 8th level nested subroutine's RET (Return) instruction jumping back to the MAIN routine. The order of subroutines scanned need not be sequential to the subroutine file numbers either.

However, you cannot place a JSR instruction in the 8th level nested subroutine file or the PLC will fault for a Subroutine Stack Overflow error. You must only place a RET in the last nested subroutine file to return to the MAIN routine file.

If using a Selectable Timed Interrupt Subroutine (STI), Discrete Input Interrupt Subroutine (DII), I/O Event-Driven Interrupt Subroutine, User Fault Subroutine, or High Speed Counter Interrupt Subroutine (HSC - ML1000 only), you can only nest up to 3 levels of subroutines. The 3rd subroutine file also being restricted from using a JSR instruction.

I suppose we should all be more careful when making statements without thinking them out fully. :rolleyes:

G.

Nesting_Subroutines.jpg
 
Hi all

As Geospark will confirm we speak English in Ireland and also are taught Irish in school for about 12 Years and very few can speak it.
Even in a small island like Ireland in different parts the same word can mean something different.
So i would accepect that when we get some many different flags of the world that we ( sorry I can only speak for my self) can pick things up different.

The only answer is the poster to come back and let us know what he or she ment.

Just my taughts

Donnchadh
 
donnchadh said:
...So i would accepect that when we get some many different flags of the world...

Did you type this on your mobile phone? Looks like predictive text at its best? :confused:
I'm just glad the l stayed in flags! o_O

-------------------------------------------------------------

Donnchadh,

Tá an dá mo mhac agus iníon ag freastal ar Ghaelscoil bunscoileanna áitiúla agus iad cainteoirí an-líofa Gaeilge.
Le líon na Gaelscoileanna ar an méadú anseo, tá súil againn go mbeidh an Ghaeilge maireachtáil ní amháin, ach tús a rathú arís!

Dea-mhéin,
Seoirse

-------------------------------------------------------------

Donnchadh,
Brown Chief (Donn = Brown; chadh = Chief )

Both my son and daughter attend a local primary Gaelscoil and are very fluent Irish speakers.
With the number of Gaelscoils on the increase here, hopefully the Irish language will not only survive, but start to thrive again!

Best regards,
George
 

Similar Topics

I have a bender table that I am automating. I have added a Kinco HMI and PLC, I am also using an Omron encoder sensing the rotation of the table...
Replies
49
Views
9,361
See image below. Look at line 95. I tested all data type, but none of them works. https://ibb.co/H2Csr15 See this. TEMPDATA2 is used only...
Replies
3
Views
2,718
With RS5000 and a Clogix, I would like to know if i can work with same coils adresse on 2 different subroutine and just call one at the time? I...
Replies
13
Views
3,204
When the subroutine is no longer being called, and then called up again, what happens with one-shots in that subroutine? I have some rungs in...
Replies
12
Views
3,070
Hi Friends How can I create/Call in a subroutine in GXWork3/GXworks2?
Replies
4
Views
1,593
Back
Top Bottom