LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

24 bit MSB-LSB in two's complement to hex number

Solved!
Go to solution

Hi all,

 

i'm reading serially bits out of an ADC through sbRIO 9602 via DIO on P4 connector.

ADC sends 24 bits MSB first in two complement format: how i can convert them to the hex number they represent on FPGA VI?

is there already some VI available for this i haven't still found?

 

Thanks in advance.

0 Kudos
Message 1 of 4
(4,267 Views)
Solution
Accepted by Mariano76

Hi Mariano76,

 

The VI I think you are looking for is 'Boolean Array to Number'.  This primitive interprets an array of booleans as an integer.  If you need to reverse the MSB/sign-bit before it goes into this function, you can use the 'Reverse 1D Array' function.  If you want to interpret that hex data in fixed point representation, the cast function is appropriate.  Once in FXP format, you can scale the data to the actual range of your ADC (ie +/- 10V).  You can drag this code into your LabVIEW FPGA block diagram to test.

 

Convert Array to Integer.png

 

Cheers,

spex

Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 2 of 4
(4,253 Views)

One other trick is that you can configure the output type directly on the Boolean Array to Number function. Just right-click and select Properties.

0 Kudos
Message 3 of 4
(4,240 Views)

Thank you very much Spex,

 

I've implemented the code in a SCTL and it works perfectly, the path with reverse 1d array lead to correct hex value.

 

my range actually is ±3V, positive voltage that exceed +3V returns 7FFFFFh and negative voltage that goes under -3V returns 8000000h

 

Now i have to convert hex value to real voltage measured from ADC when comprised in [-3V,+3V] so sorry if i don't understand what do you mean when you say that once in FXP i can scale data to ADC range, but exactly what actions have to be done to perform this scaling?

 

Thanks.

 

MR

 

 

 

 

0 Kudos
Message 4 of 4
(4,224 Views)