LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bit Manipulation

Hello,

 

I want to do some bit manipulation during a Register Read/Write Process.

Read a register value (16-bit), set a particular bit to "One" or "Zero",

 

Please note the bit position and logic i want to set is need to read from a text file.

Please find the  attachment for the sample VI.

 

Please comment on this.

 

-mfp.

0 Kudos
Message 1 of 6
(3,301 Views)

try casting your string as an array of U16's and index out the element you want, then you can use bit-wise bolean opeartors to set clear etc.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 6
(3,293 Views)

Your attached example has missing subVIs and does not give a clue on what kind of bit manipulation you actually want to do.

 

You should also set the default to U16 at "hexadecimal string to number", currently you get U32

 

To set a bit of an U16 integer, you would do a logical OR with a number that only has the desired bit set (2^bit position). To clear a bit, you would use AND with a number that has all but the desired bit set. Mix & match!

0 Kudos
Message 3 of 6
(3,289 Views)

Hi,

 

Sorry. i couldnot able to do that.

 

Please find the attachment for the Detailed VI.

 

Please comment on this.

 

-mfp.

 

0 Kudos
Message 4 of 6
(3,247 Views)

Hi Favas,

 

it seems you have to learn a lot on boolean operations.

The attachment shows two possible solutions...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(3,239 Views)

Here's what I would do:

 

See if it makes sense (for demonstration, I replaced your derived input number with a control)

 

 

0 Kudos
Message 6 of 6
(3,214 Views)