Digital Waveform Data Representation in C

NI Digital Waveform Generator/Analyzer

Digital Waveform Data Representation in C

As in LabVIEW, the NI-HSDIO C functions represent digital waveform data in two formats. Data can be represented as a one-dimensional array of binary data or in an expanded waveform data type (WDT) format.

Each integer value in the array corresponds to the state of one channel during one sample of the waveform. The following example shows writing a waveform in the waveform data type format.

ViUInt8 data[NUM_BITS * NUM_SAMPLES] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1,
...
1, 1, 1, 0, 0, 1, 1, 1,
};

error = niHSDIO_WriteNamedWaveformWDT( vi, waveformName, NUM_SAMPLES, NIHSDIO_VAL_GROUP_BY_SAMPLE, data);

If your device supports per cycle tristate, use the waveform data type format to use this feature. The digital state values for 0, 1, and Z are defined in the niHSDIO.h header file under Digital Channel States, and are defined as follows:

#define NI_DIO_0 0
#define NI_DIO_1 1
#define NI_DIO_Z 2