LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

binary operations

Hi all,
 
Okay im not very familiar with much binary operations, so I need a little help.  The problem that im having is the DAQ board im using has uses a 32 bit interface for digital I/O, and I need to be able to change  lines 8-22, depending on the decimal number and base the user enters and have that binary be in inverted logic.  For example if the user entered 486.6 with a step size of 0.05 the binary in regular logic would be 000000000 010011000000100 00000000 and in inverted logic 000000000 101100111111011 00000000 and I dont want the change of decimal affect any others lines of the code.  I think maybe for that I could just set a max limit for the decimal number to being 2^15-1, but not sure I can create this limit and shift in the binary in labview.  Any help would great, thanks.
0 Kudos
Message 1 of 3
(2,845 Views)
dbartz,

Al of the logic primitives are polymorphic, meaning that you anc use them with numerical values. Set up your data as an unsigned 32 bit integer (U32). Use AND and OR functions to mask off the parts you want to change and the parts you want to protect. If you had 8-bit words (for a simplified example) and wanted to change bits 2, 3, and 4, you could do this:

let K = old data (example K = 10101010)
let P = new data (example P = 00111110) {Notice that P has non-zero values in bits other than 2, 3, 4}
let Mk = mask for old data (example Mk = 11100011), and
let Mp = mask for new data (example Mp = 00011100 = NOT Mk).

Then (K AND Mk) OR (P AND Mp) = data to write.

Using the example values above (K AND Mk) = 10100010, (P AND Mp) = 00011100, and data to write = 10111110.

Lynn
0 Kudos
Message 2 of 3
(2,836 Views)
In addition to Lynn's excellent comments, remember that you can set the format of numeric constants to display the numbers in Hex or Binary. This can make it easier for you to follow what you are doing, and can make the code a lot easier to read.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 3
(2,817 Views)