Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

HDSIO 16-bit data width

Solved!
Go to solution
I am using a NI 6541 HSDIO card together with the DynamicGeneration.c example file. This example includes:

niHSDIO_AssignDynamicChannels (vi, "0-15")
...
niHSDIO_GetAttributeViInt32(vi, VI_NULL, NIHSDIO_ATTR_DATA_WIDTH, &dataWidth)

When executing this code, dataWidth becomes 4, so that is 32 bits, while I would expect it to be 2 (16 bits).

The NI Digital Waveform Generator/Analyzer Help gives for the NIHSDIO_ATTR_DATA_WIDTH attribute:

Valid Values: Vary by device.

NI 654X 1, 2, 4
NI 655X 1, 2, 4
NI 656X 1, 2

So alternatively I tried to do a niHSDIO_SetAttributeViInt32( TxSession, VI_NULL, NIHSDIO_ATTR_DATA_WIDTH, 2 ) but that did return an error:

Attribute is read-only. Attribute: Data Width

Now my question is: How to make the NI 6541 use a 16 bit data width?
0 Kudos
Message 1 of 3
(3,702 Views)
Solution
Accepted by topic author emvee

Hello emvee.  The data width attribute is mainly an aquisition attribute - you can call "set attribute" and change it's value only when performing acquisition.  You can still perform a "get" to see what the driver's default value is for generation sessions; for a 32-channel device, data width is 4, and all waveforms written to onboard memory will contain 32-bit samples.  If your channel list is 0-15 then only the first 16 bits of each sample are generated.

As for the example returning 4 bytes even though there are only 16 channels, you'll see this behavior in acquisition as well.  The driver does not automatically adapt data width based on what channels are selected.  The fetch and write functions are closely tied to data width (if data width is 4 bytes, you MUST use a U32 flavor of fetch or write)... thus the driver doesn't try to guess what fetch/write you'll be using by changing data width based on the user's channel selection.  However, a 16-channel device (such as the 656x) will default to a data width of 2.  A 32-channel device (such as the 654x) will default to a data width of 4.  Since most of the NI-HSDIO examples can run on multiple devices, they all call "get" on the data width attribute to determine which fetch/write function to use.

I hope this helps.

Chris

Message 2 of 3
(3,692 Views)
Hi Chris,

Thanks for the answer, it sure helps.

It is a bit unhandy as size considerations makes me want to use U16 and while that's possible for an acquisition session, I will have to do data conversion for the generation session. Anyhow, it is understood and I can work with it.

Martin.
0 Kudos
Message 3 of 3
(3,686 Views)