How to program this logic in Logix5000?

wendaiyu

Member
Join Date
Jun 2014
Location
toronto
Posts
87
Hi, folks, how’s going?

Could you give a hand to program this logic: in Logix5000, there are 6 bits “testbit.0”, “testbit.1” ……”testbit.5”.

If any two of them are ON at the same time, the bit “testbit.10” will be ON.

How can we program it? I edited 7 rungs to make it, but it does not look like the best way.

Thanks a lot.
 
If properly documented then the code would be easily understandable by someone in the future who has to maintain it. Elegant bit hacks may not be so understandable or maintainable in the future. The seven rungs sound correct.
 
Couldn't this be done in one rung? Can MORE than two bits be high at any time? My first thought was one long OR statement. i.e 0&1 or 0&2 or 0&3 etc, etc.
 
Thanks, guys.

I program the logic like that (check attachment) and I have do it bit by it.

Is it the best way? Thanks.

testbit.JPG
 
Extra bits

Now you have introduced a bit that is not in the description. I do not know if this would be considered "correct" if following the given instructions is required. That is, using extra bits as outputs and then using them at the end as input conditions for testbit.10 would be out of the problem's requirements. Are you required to only use the bits in your description, and can ONLY two bits be high at any given time to meet the requirements of the problem?
 
Yes, would be nice to know more but you can go from the following:
If any ONE bit out of 5 is on than testbit word will be either 2,4,8 or 16. Of none are on than word = 0. So you can use compare or NEQ and fit all in one rung.

Question is - are you using any other bits in this word for something? It will not work if you do.
Another solution is to use a cycle (I like ST) and counter for bits to be ON. If counter equals 2 then make your target bit 1.
 
it depends on your skill level, no offence.

you have programmed all situations for test bit 0, thanks for showing your work.
repeat this process for bits 1 to 6, note that previous programmed rungs will cancel out some of your work so you wont have to repeat it.

then those output bits will turn on bit 10.

this is perhaps the easiest way for maintenance to understand.
james
 
Think in mathematical way,

Create an event, maybe a time slice, during the time slice within a single scan add one into a a register if a testbit is ON, so 7 similar rungs for each testbits

At the end, if the register count is equal to 2 your conditions are met.

Add another rung to reset your register, if you want to repeat the test.

Hope you understand it
 
Thanks, guys.

I program the logic like that (check attachment) and I have do it bit by it.

Is it the best way? Thanks.


On the rung shown add four branches to complete using James Mcquade's advice. That is the simplest solution.

6,5,4,3,2.
 
I did this in RSLogix 500 but the concept is the same. I think this will work for what you are looking to do but I'm not sure.
Basically N9:0 is equivalent to your "testbit" tag and N10:0.0 is the output bit. On Rung 0 if N9:0 (testbit) equals 0, 1, 2, 4, 8, 16 or 32 I.E. any bit 0 thru 5 is enabled by itself then bit B3:0/0 is enabled. On Rung 1 when bit B3:0/0 is off and bits N9:0/6 thru 15 are off then the output is on. If two or more bits are on then N9:0 doesn't equal 0, 1, 2, 4, 8, 16 or 32 and bit B3:0/0 is off turning the output on. I put the XIO's with bits 6 thru 15 on rung 1 on the assumption that they aren't part of the equation so if any of them are on the output stays off.
Without know some of the details of what you are trying to do I had to guess on a few things but you should be able to get the concept and adapt it to work with your application.

enhance
 
Thanks, guys.

I program the logic like that (check attachment) and I have do it bit by it.

Is it the best way? Thanks.


Output will be on, if 2 or more bits are on.

Is that correct or is output wanted to be on when only two bits are on simultaneusly?
 
I did this in RSLogix 500 but the concept is the same. I think this will work for what you are looking to do but I'm not sure.
Basically N9:0 is equivalent to your "testbit" tag and N10:0.0 is the output bit. On Rung 0 if N9:0 (testbit) equals 0, 1, 2, 4, 8, 16 or 32 I.E. any bit 0 thru 5 is enabled by itself then bit B3:0/0 is enabled. On Rung 1 when bit B3:0/0 is off and bits N9:0/6 thru 15 are off then the output is on. If two or more bits are on then N9:0 doesn't equal 0, 1, 2, 4, 8, 16 or 32 and bit B3:0/0 is off turning the output on. I put the XIO's with bits 6 thru 15 on rung 1 on the assumption that they aren't part of the equation so if any of them are on the output stays off.
Without know some of the details of what you are trying to do I had to guess on a few things but you should be able to get the concept and adapt it to work with your application.

enhance

Why so many compare instructions when you can check the bit individually?

Think in mathematical way,

Create an event, maybe a time slice, during the time slice within a single scan add one into a a register if a testbit is ON, so 7 similar rungs for each testbits

At the end, if the register count is equal to 2 your conditions are met.

Add another rung to reset your register, if you want to repeat the test.

This is what I was thinking as the best way to solve it.

Another way, since we're being creative, is to check if testbit register equals any number in this group (3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48).

Yet another would be to break down the testbit number into binary format by dividing it by 2 and through the MOD instruction, but it would be way too elaborate for what you want.
 
Why so many compare instructions when you can check the bit individually?

Assuming that the intent is to look at only the first 6 bits of a 16 bit word, then there are only 6 values that the word can be at with only 1 (or less) of the bits set, 0, 1, 2, 4, 8, 16 and 32. If you use the individual bits, I don't see how it can be done on 1 rung. The using a counter is a good idea but it does require at least 7 rungs of logic.
Just one way to do it.
 

Similar Topics

Hi, guys, could you tell us how to program a Less Time On logic on Logix5000? E.g. if the duration of input “tagI” on is Less than 3s, the output...
Replies
2
Views
2,168
Hi, I am new to this forum. I am trying to get into the program offline of one PLC Fanuc GE 90-30. To see the program I downloaded the software...
Replies
7
Views
503
https://www.youtube.com/watch?v=zTOOYWMJg9M . Specifically see 1:46 to 2:11. 3. The Cell PLC is in constant communication with two other field...
Replies
14
Views
3,079
Dear all I have it working (please do not comment about the “box” Looking for your thoughts and comments and areas of “knowledge...
Replies
18
Views
5,534
Is it correct to say that the dl05 program when uploaded does not store the current value in a v memory location? I have a customer that has one...
Replies
8
Views
3,069
Back
Top Bottom