Sign in to follow this  
Followers 0
sczot

Number of ON bits in word

3 posts in this topic

Hello guys,

I´m unable to find instruction which would return how many bits are ON in word (like 1 for 2, 4, 8... 2 for 3, 5, 9 etc..)

I was searching through manuals, but without any result... Maybe wrong keywords, maybe to many hours today..

 

Thanks in advance

Share this post


Link to post
Share on other sites

If it is for FX PLCs, the instruction SUM should do it (FNC 43 – SUM / Sum of Active Bits - this instruction counts the number of "1" (ON) bits in the data of a specified device). Or DSUM for 32 bits.

2 people like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0