LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unpacking I32 into 10bit format , then from 10bits to 16bits Integers using MSB

Solved!
Go to solution

Hi there, 

 

I've an ADC card which reads the waveform and outputs data streams. The acquired samples are output in a int32-bit data format array. Each int32 data returned contains a number of 10-bit raw data.  In order to read the data correctly, It is required to unpack the output data to retrieve the samples in 10-bit format, then converted from 10-bit to 16-bit Integers using the most significant bits.

 

Meanwhile, I have no idea how to unpack this int32 array into 10-bit  then into 16bit integers with MSB since 10-bit conversion is not a built-in function in LabVIEW.  The only post that I found similar is this one

https://forums.ni.com/t5/LabVIEW/How-do-you-read-in-and-work-with-I24-binary-data-into-LabView/td-p/...

which is trying to convert 24bit to 32/16bit. But I'm still not sure how could I apply this into my case. Any help would be appreciated.

 

Thank you for your help in advance!

 

Marcus

0 Kudos
Message 1 of 12
(3,380 Views)

Hello Marcus,

 

your ADC seems to be a 10bit AD-Converter. So it should deliver values from 0 - 1024 (decimal, unsigned) or -512 .. 511 (decimal, signed). Since these 10 bits occupy the lowest part of your I32 data, you just have to use the "To Word Integer" funktion from the Numeric / Conversion palette. The Symbol is:

 

To Word Integer.png

 

It adapts automatically to an array.

Greets, Dave
0 Kudos
Message 2 of 12
(3,356 Views)

Your use of the word unpack is ambiguous. How is the data packed? Do you have 1, 3 or 3.2 samples per 32 bit integer?

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 12
(3,346 Views)

Hi Dave,

 

Thanks for your reply. Yes, it is a 10-bit adc, but I tried "To Word Integer" as you mentioned and it doesn't work....

 

I tried to input a sine wave into the adc and here attached are the output I32 data and the converted I16 data file. The I16 data are either at the max 32767 or at the min -32767 which doesn't seem like correct.

 

Marcus

Download All
0 Kudos
Message 4 of 12
(3,341 Views)

Hi Rolf,

 

I've tried to read the CPP example that the adc provided. It seems like it outputs 2 samples (last 20bits?) under Normal mode (as stated in the last function void SaveRecord). I'm still digging into the cpp as attached and I will let you know if I find where it clearly states the number of samples during data acquisition.

 

Marcus

0 Kudos
Message 5 of 12
(3,310 Views)

@hobmarcus wrote:

Hi Rolf,

 

I've tried to read the CPP example that the adc provided. It seems like it outputs 2 samples (last 20bits?) under Normal mode (as stated in the last function void SaveRecord). I'm still digging into the cpp as attached and I will let you know if I find where it clearly states the number of samples during data acquisition.

 

Marcus



I cannot see any data conversion going on here. When you compile and run that code, does it not output the expected numbers?

0 Kudos
Message 6 of 12
(3,291 Views)

The code you posted does not do any data unpacking. It simply reads an array of 32-bit values from the device and then writes the first 5 and the last two 32-bit values of that array to the file. That's it.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 12
(3,278 Views)

Hi marcus,

 


@hobmarcus wrote:

I tried to input a sine wave into the adc and here attached are the output I32 data and the converted I16 data file. The I16 data are either at the max 32767 or at the min -32767 which doesn't seem like correct.


So we now have an I32 output file: what is the expected data/waveform after converting/unpacking those 10bit samples?

How is the "unpacking" algorithm defined? Which dataformat is defined for those I32 values?

 

As most values in your I32 file are outside the valid range of -32768…+32767 for an I16 datatype you get mostly those min/max values for I16 datatypes in your I16 file…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(3,276 Views)
Solution
Accepted by topic author hobmarcus

Hi Marcus,

 

the data turns out to be packed data bits, stored in 32bit values. Look at the screenshot below.

 

Unpack 10Bit data.png

 

But in the data there are regularly artifacts. Do you know, where they come from?

I attach the VI.

Greets, Dave
Message 9 of 12
(3,249 Views)

@daveTW wrote:

But in the data there are regularly artifacts. Do you know, where they come from?


It looks like missing data points.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 12
(3,225 Views)