09-21-2021 04:33 AM - edited 09-21-2021 04:36 AM
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
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
Solved! Go to Solution.
09-21-2021 04:47 AM - edited 09-21-2021 04:48 AM
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:
It adapts automatically to an array.
09-21-2021 05:03 AM
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?
09-21-2021 05:14 AM
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
09-21-2021 06:01 AM
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
09-21-2021 07:28 AM - edited 09-21-2021 07:28 AM
@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?
09-21-2021 07:50 AM
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.
09-21-2021 07:54 AM
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…
09-21-2021 09:01 AM
Hi Marcus,
the data turns out to be packed data bits, stored in 32bit values. Look at the screenshot below.
But in the data there are regularly artifacts. Do you know, where they come from?
I attach the VI.
09-21-2021 10:29 AM
@daveTW wrote:
But in the data there are regularly artifacts. Do you know, where they come from?
It looks like missing data points.