Dectect morethan 1 bit set in a byte.

Not a purist solution, but for a ladder logic guy like me a brute force method would look like this.

Move 0 to integer address with tag name "Bit_Check".

If bit 1 is on, add 1 to Bit_Check
If bit 2 is on, add 1 to Bit_Check
If bit 3 is on, add 1 to Bit_Check
If bit 4 is on, add 1 to Bit_Check
If bit 5 is on, add 1 to Bit_Check
If bit 6 is on, add 1 to Bit_Check
If bit 7 is on, add 1 to Bit_Check
If bit 8 is on, add 1 to Bit_Check

If Bit_Check is greater than 1, more than one bit is set.

In Siemens you could make an FC that would contain the code so it would appear clean when calling the FC in ladder. Just another take on the solution, there are as many ways to do it as there are programmers.
 
Geez - it is easy in Omron - mask the byte to another word, use the BCNT (bit count) function and do a compare.
 
OOHHH! That is new. Last time I used S7 I think it was Jesper posted some code to manufacture a bit count instruction for me.
 

Similar Topics

See the screenshot of EIP tag list. We are trying to read in a digital input that is hard-wired. It is shown here as I31.1. I believe we cannot...
Replies
7
Views
310
A couple days ago I accidentally toggled an alwasyoff bit. The issue is it was set up as a single OTU on a rung, nothing else, and used as XICs...
Replies
3
Views
238
Hi I have an old panel builder 32 that I’m replacing for a factory talk me hmi . In the plc for the old panel builder there is a coms bit for the...
Replies
0
Views
85
Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
177
I tried researching but I still don't quite get it. As far as I understood, it's used after a function is called in STL and then if the function...
Replies
1
Views
154
Back
Top Bottom