AngryRobot

Set multiple non-sequential bits in an array?

3 posts in this topic

What would be the best instruction for setting multiple non-sequential bits in an array?  I have an array of user defined data that is storing part information for a palletized line.  Normally I set these bits individually based on what pallet is as a given work station.    IE: [SET Part_Info[Station_1_Pallet_Number].Part_Failed]

But an occasion has arisen where I want to set a bit in every one of the UDTs within the array at the same time.  So when it is time to change part types I want to set the "Change" bit within every UDT at once.  And since this is the same bit within the UDTs it will be the same bit of every word in the array but they won't be sequential.  So "Part_Failed" might be at D3000.03 for pallet 1, and D3003.03 for pallet 2, D3006.03 for pallet 3, etc.

Is there an instruction that would let me set the third bit of every word for X amount of words?

Share this post


Link to post
Share on other sites

Have a look at BSET - should do it for you. @BSET for a one shot.

Share this post


Link to post
Share on other sites

I would use a variable as the index and run a for next loop using the set instruction.  

ForNextBitSet.thumb.jpg.0f43d42b15c140d1

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