How to program this logic in Logix5000?

If I interpret this correct, you want to know if more than 1 bit of the bits 0-6 are on, then set bit 10.

I will show you what I consider clever code. I do not recommend this in a production environment because it is not intuitive, but for an academic exercise it is good to see how it works. Also I did not test this on a PLC, so I will not guarantee my code is completely correct.

CheckMoreThan1Bit.png
 
I usually go for a loop in structured text for these kind of problems:
BF1Cizq.png
 
"If any two of them are ON at the same time, the bit “testbit.10” will be ON."

l still think he hasn't clarified the question, like Lare asked, if 2 bits are ON or if 2 or more bits are ON?
 
Last edited:
Can easily do this with a FOR instruction calling a counting routine, here's my take on it ....

2019-08-21_110334.jpg 2019-08-21_110357.jpg
 
It seems we have been steered off course.:site:


From OP post #4

Thanks, guys.

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

Is it the best way? Thanks.

From James post #7

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


From Myself Post #9

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 didn't show this in the original post but this is what I thought the OP was looking to accomplish. One Rung of bit logic.

But I like to look and learn the clever logic that people show.:geek:

Test 2 bits.PNG
 
It seems we have been steered off course.:site:


From OP post #4



From James post #7




From Myself Post #9




I didn't show this in the original post but this is what I thought the OP was looking to accomplish. One Rung of bit logic.

But I like to look and learn the clever logic that people show.:geek:


But this

BF1Cizq.png



and this won't give same result
attachment.php





Either compare should have >= or bit comparing inverted contacts

test_bits.png
 
Last edited:
you are correct. If the test was for ONLY 2. But that was never clarified by the OP.

My Logic was for at least 2. The way the OP post #4 was shown.
 
It is surprisingly difficult to hit on a clean solution in the 5000 platform. SSUM would be a possibility in FBD. Rockwell doesn't like BOOLs as values.

Check for Exactly 2 Bits On.PNG
 
You can do it on one rung. You use a CMP statement with the following logic:

((test AND 1) / (test AND 1)) +
((test AND 2) / (test AND 2)) +
((test AND 4) / (test AND 4)) +
((test AND 8) / (test AND 8)) +
((test AND 16) / (test AND 16)) +
((test AND 32) / (test AND 32)) >= 2

If the comparison evaluates true, it sets bit 10.

Each AND compares if the corresponding bit is true. The division of the same expression casts the result as 0 or 1 so they can be summed. Comparing if the sum is >= 2 checks that two or more of the bits are true. Changing this to = 2 would check if exactly two bits are true.

I loaded and tested this and it works. It doesn't fault on division by zero during the intermediate calculation.

test.png
 

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,172
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
524
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,104
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,560
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,091
Back
Top Bottom