MicroLogix JSR's outputs staying on

Yes in my application the machine will run in several different modes which occur one after the other in a mostly fixed sequence. There are about 10 different modes. Each mode or "phase of operation" has its own subroutine. When the phase is complete, the subroutine unlatches itself and latches the next mode/subroutine. Each subroutine was called or not called in the main ladder by the latched bit for that particular subroutine. This was my "conditional logic" but I have now changed this so that all subroutines are called and evaluated but had to add these "subroutine ON or OFF" bits into each sub on most of the rungs. Looks messier on the screen but I can't have outputs or other instructions being left on when the program jumps to the next phase and stops calling the sub.


I think the difference between what I said and what you said is that for you, it sounds like each mode might control different outputs. In my example, each mode controls the same outputs.


In auto vs manual, you're controlling the same motor/valve/whatever. In your example, it sounds like you have a sequence where different outputs are used in different places.
 
yes each mode has a unique requirement for which outputs need to be on or off or otherwise controlled. And each mode has its own timers and other instructions such as MOV, CPW, COP, math instructions, Ascii write, etc etc
 
Christoff84 Thank you. Someone else also told me to use bits for my valve outputs such rather than direct outputs. Yes there are several instances in my program where the same output is present on many different rungs in several other subroutines. However, I am absolutely certain that the output would not be energized by a different rung elsewhere in the program at any undesired time. Having said that, I already have set up bits for each output in a special IO Mode test routine where I can manually energize any output for testing purposes as needed. So if I am certain that an output is not going to energized by some other rung I have forgotten about, is there still a benefit to using output bits and another ladder where the bits will energize the output, as opposed to just using direct output addressing in my logic? Thanks so much. I appreciate it a lot.

If you are using the same output in multiple places in your program, and they are not LATCHES (OTL), then it's not the turning on that is the problem, when an output instruction (OTE) is false, it turns the bit off. If you have multiple OTE using the same output address, then the last one scanned will always win, regardless of what the rest of the output instructions tell it to do.

Personally I consider using the same output address in multiple LATCHES and UNLATCHES to be bad programming, and it really is a pain to troubleshoot.
 
If you use MCRs document the start and end of each zone.
I add the same "dummy" bit paralleled around the MCR instruction at the start and end of each MCR zone.
This makes it easy to find the start and end of a specific MCR zone.


MCRs are not my favorite
I had a co-worker use them a lot, he is long retired.
I still get lost in his large MCR zones.
 
OK thanks. I am not using latches for outputs, just OTE's.
So i guess it doesn't matter if the output is activated directly or via a dedicated bit for that output...if the rung goes false, the output will still turn off regardless.


If you are using the same output in multiple places in your program, and they are not LATCHES (OTL), then it's not the turning on that is the problem, when an output instruction (OTE) is false, it turns the bit off. If you have multiple OTE using the same output address, then the last one scanned will always win, regardless of what the rest of the output instructions tell it to do.

Personally I consider using the same output address in multiple LATCHES and UNLATCHES to be bad programming, and it really is a pain to troubleshoot.
 
Personally I think using conditional subroutines are going to cause you a whole lot of whoop-a**, with the speed of PLC's these days scanning un-needed rungs (unless we are talking ten's of hundreds)shouldn't be a problem.


Just my opinion
Steve
 
Here's a thought, if you really don't want to scan subroutines all the time....

Use unique bits of Bit Files as "Intermediate Outputs" in your subroutines.

Use the same bit numbers for the same valves.
Have an integer (eg N7:0) telling you which subroutine is being scanned (set it in the subroutines).


Indirectly address your outputs in a separate subroutine file as ...

XIC B[N7:0]/xx OTE {valve xx}

Generally, and there are always exceptions, don't use OTL on real-world outputs, especially those that open valves and start motors etc., it is not safe.
 
On the whole "should we or should we not use conditional subroutines" topic, I do have somewhat differing views to what I've read in the main here, but I will simply add my usual adage - it should be application dependant and not a user preference...

Skidood said:
...in my application the machine will run in several different modes which occur one after the other in a mostly fixed sequence...

I believe in using programming methods that best suit and keep the application relatively simple, while also being relatively efficient in execution. For ladder logic programming, and regardless of whichever methods we choose to use, adding detailed enough, yet clear and concise, ladder rung comments are a must as a good practice method of assisting the next programmer that may have to delve into your ladder logic code. Explain to them those "things" you feel may prove difficult for them to understand or fault find. But I do understand that for these more basic controllers the user may not always have an offline copy of the program with those precious comments to assist them. So yes, there are pros and cons. Proper training before using any specialised "tool" is also very important, whether that's a soldering iron or a PLC program. But that too is often lacking.

However, for the above application description, I think it actualy is more suited to applying a "State Machine", which could involve implementing exactly what you had begun with here. Based upon your input conditions, the "machine" will typically only ever be in one state at a time. Once the function of that state is complete it will step to the next required state, and so on. This method is common enough used and often does involve conditionally calling subroutines. If you are not familiar with this method of step sequencing, then you can look it up or ask more questions. But your initial method was essentially using this method so you are no novice to it, whether you realise it or not. But to dive right in you can go straight here (if you have a TechConnect Contract?) and access a working example application...

40854 - Using Subroutines to create a State Machine (Example)
Access Level: TechConnect

If you cannot access that for consideration then let us know and we may be able to help you further.

Another simple real World example I could give is selecting a different program mode for a heating system. Whichever mode is selected calls only the subroutine for that mode, where each subroutine may interact with common I/O points and programming flags. It should not be too difficult to inform a program reader that LAD 2 controls which, and which only subroutine is active at any one time.

When structured correctly, and well commented, I usually have no issue with this type of conditional subroutine control. Each to their own, and all that, but I never dismiss valid methods of programming, once they are implemented properly.

Regards,
George
 

Similar Topics

I don't have a PLC right now to try it on so I will ask... Do you need JSRs in a MicroLogix Program for it to run the other subs. I assume so...
Replies
6
Views
2,031
Hi Guys. I have attached my program if this is not an easy answer. I have been working on this for days, so I might have missed something, but I...
Replies
16
Views
6,237
I am currently backing a Micro Logix 1100 and no-one seems to have the file for me to upload from. Is there a way for me to upload the project off...
Replies
15
Views
341
Hi, I am working with a Micrologix 1400 model 1766-L32BXB. With no input wires connected to the “in12” thru “in19”, I am getting 24 volts while...
Replies
4
Views
172
I am trying to set up a read message in a MicroLogix1100 to read the value of a DINT in a ControlLogix5561. I have successfully set up a message...
Replies
2
Views
162
Back
Top Bottom