Micrologix 1400 and / or

Jayden

Member
Join Date
Dec 2007
Location
camperdown
Posts
41
Hi all,

I have a series of 7 bits I would like to monitor. If any 'two' of these bits are on I need to activate a flag in my program. I'm trying to avoid having a group of nested instructions to do this. Is there any simple way to achieve this with bits.

Thanks
 
A couple of ways that come to mind:

- If the bits are all sequential then you could use a rung with 7 NEQ instructions in series looking at the word as a whole - e.g. for B3:1/0 through B3:1/6, if it is NEQ to 0, 1, 2, 4, 8, 16, 32 or 64 then turn on an output. You would have to make sure that none of the other bits in the word ever get used - perhaps to guard against this, do a masked move first into an N word, to ensure that you are only examining those 7 bits

- On one rung, set an N word to zero. On the next 7 rungs, XIC each of your bits and if true, add 1 to your N word. If N>1 then you have two bits on. Again, if all the bits were sequential you could do this in two rungs instead of eight by also using a pointer and incrementing through (e.g.) B3:1/[N7:0] where N7:0 is your pointer. You could either increment the pointer every scan and it would take 7 scans to check all the bits, or you could use JMP and LBL to create a loop and do it all in one scan. Just make sure to stop incrementing the pointer on the last bit and give it a way to exit the loop!

Garry's method above is also a good one.
 
Your specification could be interpreted as 'at least two' (2 or greater) or as 'only two' (exactly 2).

The 'count up' method makes it easy to accomodate either interpretatiion because the final test can be 'equal to 2' or 'greater than or equal to 2'. Garry's method and ASF's second method each provide for a count.

I like the first sentence of ASF's second method. This will be understandable by virtually anyone just by looking at it. A nice rung comment of 'Count the ON Bits' on the first of the rungs would prevent any confusion.
 
Last edited:
Your specification could be interpreted as 'at least two' (2 or greater) or as 'only two' (exactly 2).

The 'count up' method makes it easy to accomodate either interpretatiion because the final test can be 'equal to 2' or 'greater than or equal to 2'. Garry's method and ASF's second method each provide for a count.

I liike the first sentence of ASF's second method. Yhis will be understandable by virtually anyone just by looking at it. A nice rung comment of 'Count the ON Bits' on the first of the rungs would prevent any confusion.

It seems to me that if it is "at least 2 are on" that you could create an integer from the bits and if the result is >2 you know that at least 2 are on. I don't work with AB enough to know the method to do it without playing with it a bit but it shouldn't be too hard. However, I suspect that it is "exactly 2 are on"
 
If the bits are contiguous then the bits can be interpreted as a number (0 - 127).

If we are looking for exactly 2 bits on there are 21 numbers that fit this.

If we are looking for 2 or greater bits on then it is actually a little easier as there are only 8 numbers that DON'T fulfill that.
 
Thanks for all the replies, (sorry for my delayed response)

I ended up needing a quick solution this this on the run so I just moved the Bit status to Integers and computed the SUM of the integers to get it working. I was curious to see if someone had a simple solution that I was maybe overlooking.

Although there are some good ideas I decided keep the integer solution because the bits are not sequential and I also the maintenance guys have trouble with anything other than very basic logic.

As for the reason I was trying to avoid nested, the program I'm working on has heaps of large nested rungs which I am slowly trying to re-write. I hate navigating and fault finding in programs with massive nested rungs.
 
Construct the rung with multiple branches, test it works, and forget it... Who cares if it fits on the screen, so long as it works...

There are only 21 possible values the 7-bit register can have if only 2 bits are on - 3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80, and 96

If you want "2 or more bits on", then just test that the number isn't one of the 8 values 0,1,2,4,8,16,32, or 64

21 and 8 - just as Bernie posted earlier !!
 

Similar Topics

I'm using a SLC typed write from the ControlLogix5572 to the MicroLogix 1400, with path: 2, (MicroLogix IP). The ControlLogix equipment has a...
Replies
0
Views
87
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
221
Hi everyone, I hope I don't butcher this up, please feel free to critique me wherever if I do, I have an issue I would equate to "chasing...
Replies
4
Views
300
Hi everyone, I'm working on a project where I need to exchange data between a Siemens S7-1200 PLC and an Allen-Bradley MicroLogix 1400 PLC. The...
Replies
8
Views
637
I'm not super familiar with the Micrologix line of processors, but I am pretty familiar with RSLogix 500. I'm trying to simply copy a string to...
Replies
4
Views
303
Back
Top Bottom