Single Main Routine or Multiple Main Routine

learner

Lifetime Supporting Member
Join Date
Apr 2007
Location
British Columbia
Posts
81
Hi Guys,

I would like to know if there is any advantages for having a single main routine in CONTROLLOGIX 5000. To be more precise, if you have a choice of having different main programs compare to a single main program with lots of "JSR", which one would you choose?

I already know that the answer to this question might depend on a lot of other items that I haven't clarified, however let's think about an equal condition. I'm asking this because I would like to develop a "Good programming habit".

Thanks:nodi:
 
As you have already stated, there really isn't one correct answer to that question, but I'll offer an example.

Let's say you have five pieces of equipment each controlled by a single CLX controller but each operates independently of the others. With multiple "programs", troubleshooting would likely be easier. If Machine #3 is having a problem, you are able to look just at the Machine #3 code without all of the other code cluttering things up.

Likewise if Machine #4 isn't being used today, you can turn that program off. Or if you need a Machine #6 one day, you can copy the entire program easily. You also can very easily change the order of how things are scanned.

Then you have program tags which can also make copying and pasting entire programs very useful.

So, could all of these things be done with one "mainroutine" and a bunch of subroutines and JSRs? Sure, but I think programs make that easier.

Do programs make sense for every job? No, but in most instances I think a fair case can be made.

OG
 
Thanks for the tip.



Operaghost said:
As you have already stated, there really isn't one correct answer to that question, but I'll offer an example.

Let's say you have five pieces of equipment each controlled by a single CLX controller but each operates independently of the others. With multiple "programs", troubleshooting would likely be easier. If Machine #3 is having a problem, you are able to look just at the Machine #3 code without all of the other code cluttering things up.

Likewise if Machine #4 isn't being used today, you can turn that program off. Or if you need a Machine #6 one day, you can copy the entire program easily. You also can very easily change the order of how things are scanned.

Then you have program tags which can also make copying and pasting entire programs very useful.

So, could all of these things be done with one "mainroutine" and a bunch of subroutines and JSRs? Sure, but I think programs make that easier.

Do programs make sense for every job? No, but in most instances I think a fair case can be made.

OG
 
I tend to go for the subroutines. It allows me to divide the program up into smaller pieces which is much easier to work with, Creating all the JSR's is not really that much work when you consider how cumbersome it would be to have to scroll through a large program file. As Operaghost mentioned, then if you need to you can easily turn off a section. This is very useful if you are writing a program that will be used for a standard machine and want to be able to easly turn on and off options for that machine.
 
I often have around 25 programs and 10 routines in each program, in the main continous task. I usually have a MainRoutine in each program containing the JSR's to the other routines. So yes, divide the project up as best suited and no need to be frugal with number of programs and routines. The is some memory and scan time implications to adding programs and routines but in most applications not a concern and you can use period tasks for time crtical stuff.
 
Originally posted by Oreraghost:

Then you have program tags which can also make copying and pasting entire programs very useful.

While I fully agree with Operaghost about copying programs for identical machine sections (I've done it quite often myself), the program tags thing is a two-edged sword for people not familiar with Logix. Basically you will have two tags that look identical in indentical looking sections of code. The user REALLY needs to be careful about what they are looking at. The program containing the routine is clearly displayed in the window banner so it's not like it is cryptic. But you need to look at the banner every time to make sure you know where you are.

Keith
 
I agree. in fact I still tend to use controller scoped tags ONLY. By using UDT's you can still have an easily managed tag list even on a large project. While program tags have their place you can get caught monitoring the wrong file and they are a bit tough on maintenance guys.
 

Similar Topics

hi, i have some question about the single phase line-to-line for the kinetix 2000. the manual only show that contractor using for the three phase...
Replies
0
Views
1,253
Hey guys, I was wondering if anybody here has had any experience with single sign on software that is used to authenticate users over multiple...
Replies
3
Views
2,538
Why does the controllogix redundancy modules use a single mode fiber vs multimode fiber?
Replies
1
Views
78
I am converting a SLC 500 to a Compact Logix. I plan on using a Compact Logix 5380 with conversion Kit. The problem is that the analog input cards...
Replies
1
Views
146
Hello, friends, I am trying to upgrade a system that uses an Onrom incremental encoder (E6B2-CWZ6C) connected to a Danfoss VFD (FC360), but now...
Replies
4
Views
271
Back
Top Bottom