Sign in to follow this  
Followers 0
echomayor

Find set bits and there location in a 16 bit word

3 posts in this topic

I need to search B3:0 and find which bits are set and there location in RSLogix 500 using Micrologix1400.  Using it for part tracking

Thanks for any suggestions.

Share this post


Link to post
Share on other sites

Scroll down the left side to fing B3 file and double-click it.  Then click usage.

For references to individual bit, then the bit and right click and select Find.

Share this post


Link to post
Share on other sites

you can test individual bits using XIC and bit address, such as B3:0/3

if word contains several bits that can be set and you need to identify ONE bit that is set, just calculate

A AND (-A)

where "A" is an integer memory location such as N7:0 or B3:0

this is much faster than iterating through all bit positions one by one.

also this is much simpler to program - only two fundamental instructions that are available on any type of controller.

 

1 person likes 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