Allen Bradley: Same output in different routine

marvis

Member
Join Date
Mar 2016
Location
Italy
Posts
108
Hello everyone,
I wanted to know if it was possible to use the same routine with the same outputs, routine that I will duplicate, which has differences only in logic based on different conditions.
I will then enable the routines with JSR based on another conditions.
It's possible?
Unfortunately the routine is very complex and it would make things a lot easier for me.
I attach some pics, hoping that everything is clear.

Thank you.

img1.png img2.png img3.png
 
Last edited:
As long as you always call one routine or the other you might be able to get away with it. There should never be a case where neither or both are called in the same scan.
However, there are still pitfalls that could trip you up. Personally, I would come out of each subroutine with a separate internal bit and OR them in the main body of the program to turn on the output. Easier to troubleshoot and shows concern for the person who has to live with your code after you're gone.
 
Last edited:
Personally, I would come out of each subroutine with a separate internal bit and OR them in the main body of the program to turn on the output. Easier to troubleshoot and shows concern for the person who has to live with your code after you're gone.

This, the other way would be terrible and anyone that had to look at it would curse you.
 
So yes, it can be done. You may also get WARNING messages about the duplicates. But if it is done right, it can work.

As mentioned, it can be tougher to troubleshoot and in general it isn't the best way to program.

OG
 
Providing only one of the routines are called at any time there should not be any problems. In actual fact it's a bit like having different programs that can be selected. A simple example would be where a pick & place robot on program 1. go to home position (back towards pick up nest). would at home position extend down, grab part, retract up, move forward, extend down, drop part, retract up, move back.
Program 2. go to 2nd home position (extended). go to program 2 position, extend down, grab, retract up, move back, extend down, drop part, retract up, extend out to program. 2 start position.
so in effect you have two programs, program 1 runs P&P in normal mode i.e. picks up part at supply, drops it at receive station, program 2 does the reverse.
Sometimes this method may be easier to debug than trying to incorporate the logic to drive one set of outputs in a single program i.e. split them into two subroutines that are called by selection. Another way is to use different markers in each routine and OR them to drive the outputs in a cyclic routine.
 
you may want to do the following.

you have multiple subroutines that require different outputs, or the same output in each routine.

create your subroutines and turn on an internal bit in each subroutine for each output.

at the end of your program, have those subroutine bits turn on those outputs.

I had several machines in an auto plant that could 32 different test fixtures.
each subroutine used the same output at different times.

I programmed the subroutines and at the end I had the output rungs.

james
 
Personally I would have intermediate bits in the subroutines, and an OUTPUTs program that simply OR's them onto the real output. Doing it that way means there's no chance of a stray output somewhere else, you'd only have the one output bit, and if that needs to be turned off by alarms or interlocks, you only have the one place to do it.

Using intermediate bits means you don't have to have your subroutines conditional, so you don't get the problem of not turning bits off if the sub stops being called.


Always done it with intermediate bits, so much easier to trace and debug.
 
Thanks for the double echo lol. Yes as I said at the end probably best to use bits in routines & use them to drive the outputs.
This happened to me the other day on one post I replied and there must have been 3 other people reply at the same time saying the same thing. So don't think when people repeat the same detail in a post we haven't read the posts first 🍺
 

Similar Topics

Hi guys I have been told that you can't really have siemens and allen bradley software on the same laptop as the have conflict issues? Is this...
Replies
11
Views
4,658
Hi Guys, Do people still recommend keeping A/B and Siemens software on separate laptops? I know we used to do this because software packages...
Replies
8
Views
5,902
Hi, I have a ControlLogix system with 1756-IF16 analogue inputs. I can't scale the inputs at the card as there is a requirement to facilitate...
Replies
14
Views
355
Dear community, I am trying to find a tool for Allen-Bradley PLCs similar to SiVArch for Siemens PLCs to automatically generate faceplates and...
Replies
0
Views
90
Hi everyone, new to forum. Since very long time i having issue with 1734-AENT module, after some period of time its keep stuck in error (simmilar...
Replies
16
Views
582
Back
Top Bottom