Dynamic Signal Acquisition

cancel
Showing results for 
Search instead for 
Did you mean: 

4472B lossless compression

Hi All,

 

I learned from here that 4472B supports a lossless compression from 32-bit to 24-bit. I have tried but no luck now; so I'd like to seek advices here from you guys. There are three channels in my prototype. The compression type was set to the lossless mode in the CVI code. The function DAQmxReadRaw was used to read the data. The numBytesPerSamp, one of the return parameters of the function, always gave 12 bytes, which indicates every sample read had 4 bytes. Should I expect 3 bytes here as the compressed data should have 24 bits instead of 32 bits?

 

Thanks in advance for your suggestions!

 

XR

0 Kudos
Message 1 of 12
(8,942 Views)

Hi,

 

Thank you for your post.  The behavior that you have seen is as expected.  All DMA transfers on a PCI bus are always 4 bytes in length (32 bits).  Additionally, the only devices that support hardware lossless compression are the 446x and 449x series devices.  You can, however, configure you program such that it will accomplish lossless compression in software.  However, you will be unable to do lossless compression using the DAQmx C commands with this device.  Please let me know if you have any other questions!

 

Have a great day!

 

Regards,

 

Todd V.

National Instruments
Applications Engineer
NI Prototyping Community
Message 2 of 12
(8,922 Views)

Hey XR,

There is one thing to understand here: 


     Lossless compression for the 447x devices is only done in software after the samples have been returned from the device.  Basically, you get a 32-bit (4-byte) transfer across the PCI bus, then the driver "packs" the data by throwing away the unused byte.  So even though the hardware does not support packing itself, the driver packs for you so that it takes up less room on your HDD.

     In your case, the numBytesPerSamp property returns 4 because the device is actually returning 4.  Rest assured, though, that the raw data returned will be compressed in 3-byte samples.


 

Good luck!

Oh, and I should mention that newer devices (446x,449x) will compress *on the device* which means that software does not have to do it after the transfer.  This helps HDD space and throughput.

 

-gaving Smiley Happy

Message 3 of 12
(8,921 Views)

Smiley Surprised Hey Todd, why can't XR do lossless compression with the C API?  He can do it with LabVIEW, so why wouldn't he be able to do it in C?  That makes no sense...

 

-gaving

0 Kudos
Message 4 of 12
(8,916 Views)

Hi Todd and gaving,

 

First, thanks a lot for your inputs and explanations! 

 

When preparing for the array for the DAQmxReadRaw, I set its type to unsigned char (1 byte/array element). When setting the size of the array, I followed the example (ContAcqVoltage-ToFile-Compacted.c) found on the NI website, more precisely, a sub function called CalculateReadBlockSize in the example. When the lossless mode was set, it gives the expected 75% of the size of the non-compact mode. 

 

It turns out that, however, the program always breaks at the DAQmxReadRaw complaining that the buffer is too small to fit the data with an error code -200229. The reason, to me, is that the card returns x bytes of raw data while the array to store it, defined in my program, is only 0.75*x bytes. So I guess I have to do it manually in the program to drop the 8 bits from the raw data, as mentioned in Todd's reply. 

 

Also in the example code mentioned above, the array is defined to store unsigned short with 2 bytes per element to store the data from DAQmxReadRaw. But when writing the data to file, unsigned char (1 byte/element) is used in the fwrite function. 

 

Any hints and comments?

 

I will try more and post back. Thanks!

 

XR

0 Kudos
Message 5 of 12
(8,910 Views)

Hey XR,

You should be able to tell the DAQmxReadRaw what size you want to read...if you read U8 (1-byte), you shouldn't be getting 4-byte samples if the lossless packing was turned on in the driver correctly.   Can you post the CVI code that turns on the compression?  Are you reading Raw U8?

 

-gavingSmiley Happy

0 Kudos
Message 6 of 12
(8,898 Views)

Hi gaving,

 

Here is the command I was using to set the compression mode.

DAQmxSetChanAttribute (probe_TH, NULL, DAQmx_AI_RawDataCompressionType, data_compression ? DAQmx_Val_LosslessPacking: DAQmx_Val_None);

 

Each channel has its own name and here NULL was used to set all the channels. 

 

Immediately after that, I can confirm the compression type using the following function.

 

DAQmxGetChanAttribute (probe_TH, NULL, DAQmx_AI_RawDataCompressionType, &data_compression);

 

I am using DAQmxReadRaw to read unsigned char data. 

 

Thanks!

 

XR

0 Kudos
Message 7 of 12
(8,896 Views)

Hi gaving,

 

Just to reiterate, you can do lossless compression with this device, but only in software.  This device does not support lossless compression in hardware.

 

Regards,

 

Todd V.

National Instruments
Applications Engineer
NI Prototyping Community
0 Kudos
Message 8 of 12
(8,874 Views)

Hi All,

 

Do you know which byte of the 4 bytes returned on the PCI bus could be throwed away in 4472B?

 

Thanks!

 

XR

0 Kudos
Message 9 of 12
(8,871 Views)

Hey XR,

 

I looked really quick for you and what is returned by the following function is "Left Justified", which means the LSB is what you will discard

 

-gaving

 

<<From the NI-DAQmx C Reference>>

Get/Set/Reset AI_RawSampJustification

int32 __CFUNC DAQmxGetAIRawSampJustification(TaskHandle taskHandle, const char channel[], int32 *data);


Purpose

DAQmxGetAIRawSampJustification gets the Analog Input >> General Properties >> Digitizer/ADC >> Raw Sample Justification property.

<<>>

0 Kudos
Message 10 of 12
(8,846 Views)