Best way of creating interlock between bits

quadPLC

Member
Join Date
Feb 2010
Location
Milwuakee
Posts
51
Hey guys!

Quick question to see if I am doing something the sloppy, hard way or if this is pretty much the only way to do something...

Lets say I have 10 bits (0->9, none in the same word of data) and they are mutually exclusive with one another.

Certainly I could say that


Bit 0
---||-------(R)--- Bit 2
--(R)--- Bit 3
--(R)--- Bit 4
--...--
--(R)--- Bit 9



where each time one of the bits is true, it sets the others false. and do that 10 times, but that's a lot of rungs.

Is there a better way to do this? I know it probably depends on what environment I am in, but generally speaking is there some other process I am overlooking. For anyone that knows what this hardware is, I am using a Horner OCS product and developing some code in CScape...
 
If they are not in the same word, then there probably is no better way. There might be some tricks you could use with indirect addressing, but it is probably not worth the effort to be honest.

Depending on your control strategy, I suppose you could actually clear all, and then re-set the desired one, but that would take much more effort, might be detrimental to your control, and isn't clear.
 
If they are not in the same word, then there probably is no better way. There might be some tricks you could use with indirect addressing, but it is probably not worth the effort to be honest.

Depending on your control strategy, I suppose you could actually clear all, and then re-set the desired one, but that would take much more effort, might be detrimental to your control, and isn't clear.


Yeah, I was afraid of that. Some HMI packages allow you to set 'interlock groups' of buttons (what the bits are tied to) so that when one is pressed, the others are unlatched. However, this particular package doesn't have anything like that, which is irritating.
 
ya its possible but before doing you need to map all these bits into the single word and after you can MOV the respective values which should mov zero to desired bits...
But it is also seeming big logic..
Thanks,
Naag.
 
I know ZERO about Horner or CScape – but in an Allen-Bradley system you might be setting up a nasty "race" condition ...

disclaimer: this is all based on what I THINK you meant by your question ... some more details might certainly change my answer ...

let's look at TWO rungs – based on what you've already posted ...

Bit 0
---||-------(R)--- Bit 2
--(R)--- Bit 3
--(R)--- Bit 4
--...--
--(R)--- Bit 9

Bit 2
---||-------(R)--- Bit 0
--(R)--- Bit 3
--(R)--- Bit 4
--...--
--(R)--- Bit 9



suppose that Bit 0 has a status of ONE ... on the first rung, Bit 2 is being written to a status of ZERO ... all is well ...

now suppose that after a particular scan, Bit 2 somehow also gets written to a status of ONE ... (note that Bit 0 STILL has a status of ONE at this point) ... as the first rung is executed, Bit 2 gets written right back to a status of ZERO again ... I'm just guessing, but I doubt that this is the effect you really want ...

so the question becomes: which bit do you want to give "priority" to? ... the bit which has MOST RECENTLY had its status changed to ONE? ... or the bit being examined on the TOP RUNG in your sequence? ... or something else? ... once we know the answer to your "priority" question (specifically, which bit should "win" – and stay a ONE in a "tie" situation) then we can give you some more detailed answers as to how to accomplish the task ...

survival tip: check this out on a "bench test" system before you go too far with it ...

disclaimer: again, I'm answering as best I can based on what I believe to be your intended question - and on what I assume (gosh, I hate that word) to be the operation of the system you're programming ...
 
Last edited:
It depends on what you are actually trying to accomplish. I don't think the code snippet you posted will actually work. If I understand the intent:

Your first rung uses bit0 to reset bits1-9.
That is followed by 9 similar rungs for bits1-9, reseting the other 9 bits in each case.
Set bit0.
How do you ever get any other bit set? The first rung resets them all.
This could work to keep the bits mutually exclusive, but the bits effectively have a priority with bit0 being highest priority. To turn on a lower priority bit, you have to turn off the bit that is on first. I don't think that was what you wanted...

It sounds to me like you want 10 states.

You can do this easily, and it looks very similar to what you have. But it takes two sets of 10 bits. One set to request a change to a particular state, and one set to indicate the current state. Ten rungs, one for each request bit. Each rung sets one state bit, and resets the other 9. Add one rung at the end to reset all the request bits.

Edit: Ron sure types fast.
 
Another possible solution is to use an integer to hold the system state. Then it's a simple matter of:

--SystemState = 0--------(Bit0)
--SystemState = 1--------(Bit1)
etc.



The integer will automatically keep the system mutually exclusive with no race conditions. Depending on how your HMI screen is setup, you could have the user enter the integer value directly. I'm guessing you have more of a radio button arrangement right now, which can be maintained. Just change the buttons from setting bits to downloading a specific value to the integer register. I.E. If pushbutton X action used to be [Set Bit 0], just change it to [Set SystemState = 0]. This even avoids the possibility of an operator setting the integer to something out of range. I have used this setup many times to provide Hand/Off/Auto control of motors.

Brian
 
but that's a lot of rungs.

Pet peeve alert!

For my money, the number of rungs involved in a solution is completely irrelevant. There are things that are important: reliability of operation, ease of understanding, ability to troubleshoot online. Sometimes execution speed is important. Sometimes memory usage is important (number of rungs has some impact here).
 
I think I see what Brian is suggesting--it's a good idea.

What Horner product are you using? In the XL6, there are radio buttons that can set a value in a %R register depending what button is pressed, but the limit is 4 buttons. You probably can't get your 10 states with that solution.

I don't know a direct way to do that in CScape--they don't have a push button object that will directly write a fixed integer value.

Your best bet is to use 10 momentary pushbuttons to trigger unique bits (%T), and in the ladder have the %T do a move of the binary integer data value (1, 2, 4, 8...) to your %R register. You will then have the individual bits of the register (%R100.1, %R100.2, %R100.3, etc.) set according to which button was pushed.
 
... and do that 10 times...
No need to do exactly that 10 times. Already processed couples should be excluded from the following rungs. In Ron's example, the top branch of the second rung is redundant, as such combination is impossible after the first rung execution. Hence, every following rung will be one branch shorter, and it will be only 9 rungs for 10 bits.

... but that's a lot of rungs...
10 rungs is not a lot, if this makes the program more obvious and straightforward.
 
Last edited:

Similar Topics

I want to create a time stamp within my PLC when an event occurs and then read and display it as a string tag in my HMIs. I figured that someone...
Replies
3
Views
1,653
Compactlogix controller, program has 28 conveyors that use TON's to start the conveyors. The TT sounds a warning horn during start and the DN...
Replies
10
Views
485
I have S7 1512C controler for controlling 48 PID temperature loop, the output is PWM. Please I need the best, most efficient way to write the...
Replies
13
Views
600
I am going to need to use HART multi-drop in order to handle a series of Vega Radar units. There are a lot of options and I'm wondering what...
Replies
3
Views
253
Out of interest, I'd like some thoughts on what would be considered best practice with regards to a 2-position turntable control scheme (see...
Replies
17
Views
1,135
Back
Top Bottom