Four Mutually exclusive bits.

gbradley

Lifetime Supporting Member
Join Date
Apr 2002
Location
Corona, Ca.
Posts
1,637
How can I turn off the other three bits when I select one of these four bits?
I’ve done this before, and never did like the results.
If Bit_A is on, Bit_A wins.
I can’t turn on any other bit unless I turn off Bit_A first

If Bit_B is on, Bit_B wins, over Bit_C, or Bit_D.
I can’t turn on Bit_C, or Bit_D unless I turn off Bit_B first, but…
If I turn on Bit_A, Bit_B turns Off and Bit_A turns on.


So on and so on until Bit_D, that one is last, so if it is on, turning on any other bit will shut it off.

FourBits.jpg
 
I didn't put a lot of thought into it but I think you need a buffer register or bit. Along the line of..

B3:6 - New
B3:5 - Now

then compare B3:5 and B3:6, if different, wipe out B3:5 and copy B3:6 into it.
 
Here's what I did in a CLogix:

it works for "a" and "b" but I'm still working on "c"....

PM.png
 

Attachments

  • PM.pdf
    25.3 KB · Views: 23
Last edited:
I'm not sure if I completely understand your question. Are you saying that you need a bit priority, or complaining that its unsatisfactory because there is a bit priority and you have to undo a bit to change?

Assuming (you know what that means) it is the latter:
Why not use some one shots. That way there is no priority unless two bits simultaneously go true on the same scan.


A B C D
---] [---[ONS]--------(U)--(U)--(U)--


B A C D
---] [---[ONS]--------(U)--(U)--(U)--

C A B D
---] [---[ONS]--------(U)--(U)--(U)--

D A B C
---] [---[ONS]--------(U)--(U)--(U)--

note: OTUs are Controllogix style for simplicity



Also, don't forget the DCD (decode) instruction as another option.
🍺
 
Last edited:
Ooops, I meant to say "Don't forget the DCD instruction as another option" (I went back and edited). I have used it in the past when I wanted to guarantee exclusive bits for a state engine.
 
I'm not sure if I completely understand your question.
I knew I wasn't explaining it well.

Remember the old time radio with the preset stations.
You could select any station that you wanted.
You click off station1, and then go to station6, then back to station 2. Any order is possible. That's what I'm trying to do.
 
..

That way there is no priority unless two bits simultaneously go true on the same scan.

..
That's the problem as I see it and I don't see any way to do this without using a buffer (unless it's binary, that's any why for OP a/b works but not a/b/c/..)

A buffer is need to tell the PLC what's new vs what was before. It's what I call the "evil twin" problem: one day the evil twin of your friend shows up, both claiming to be your friend. How can you tell which one is telling the truth :ROFLMAO:
 
Well, on 2nd thought, Alaric's solution works if using a oneshot along with move the numeric value into the word.
Code:
--[A]----[ONS]-----[MOV 1]
--[b]----[ONS]-----[MOV 2]
--[C]----[ONS]-----[MOV 4]
--[D]----[ONS]-----[MOV 8]

Peter, from I can see on wikipedia, bit hax use a buffer as well
 
If I understand what you are trying to do correctly. Would something like this work for you?

Stu...
 
In a radio button set you want the last button pressed.

Hacks can isolate a single bit, for example I & !(I - 1) isolates the low order bit. But what if the low order bit was not the last to be set? What if the high order bit was not the last one to be pressed? How to tell which was last?

Detecting the rising edge of the bit state will tell you which one was last pressed.
 
Here's what I do.

Then:

B3:0/0 -> Station 1
B3:0/1 -> Station 2
B3:0/2 -> Station 3
B3:0/3 -> Station 4

Also, you cannot use the rest of the word B3:0 for anything else but usually there is enough room for you to burn the extra bits.

RadioButtons.jpg
 
Last edited:

Similar Topics

Good afternoon All I have four CT transformers and one digital display. CT signal is 4-20, and the display is scaled 0 to 200 amps. What I am...
Replies
15
Views
10,048
hi, everyone I read the micro800 controller instruction manual today, it mentioned that "A maximum of four message requests per channel can be...
Replies
0
Views
1,345
hi, everyone I read the micro800 controller instruction manual today, it mentioned that "A maximum of four message requests per channel can be...
Replies
0
Views
1,372
Hi All can anyone help, I need to control four ac motors with one VSD. the trick is all four motors have different slow and fast speed. I am...
Replies
1
Views
1,896
I need to mount a load cell vertically in between 2 pieces of metal. I am afraid there will be some unwanted rotational force acting on the load...
Replies
7
Views
2,911
Back
Top Bottom