LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I 24 bit binary data in two's complement to a signed decimal number

This is driving me nuts...  I have a gyro spitting 32 bits of data at me..  The first (MSB's are status bits)  I have stripped these off

and left myself with a 26 bit data string that is in two's complement.  Of course the positive convertion works fine.....

but how do I have Lab View deal with the negative numbers ??

 

 

0 Kudos
Message 1 of 5
(6,785 Views)

I don't quite understand what you are asking.

You have a binary string that is 32 bits coming back from an instrument.

Is this a floating point single precision value (32-bit SGL) ?

 

Why do you only have 26 bits left?

And what is "twos compliment"

Cory K
0 Kudos
Message 2 of 5
(6,774 Views)

Is you data in a I32 format?

Cory, this is the format http://en.wikipedia.org/wiki/Two's_complement common for signed integers

Check and see if this work. It is from the top of my head 😉

snip.png



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 3 of 5
(6,767 Views)

Eh that was wrong try this. And the edit time was up 😞

snip.png



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 4 of 5
(6,756 Views)

After stripping the k MSBs, left shift k times.  Then an I32 correctly interprets the twos complement.  Divide by 2^k.  Result is an I32 containing the value sent by the instrument.

 

Lynn

Message 5 of 5
(6,748 Views)