Writing Waveforms to Your Device
- Updated2025-11-11
- 3 minute(s) read
Before you can generate any data, you must write your waveform(s) to the device onboard memory. Use the Write Named Waveform VIs and functions to write waveform data from your PC memory to your onboard device memory.
The Write Named Waveform VIs and functions are shown in the following table:
| LabVIEW VIs | C Functions |
|---|---|
Use one of the following instances of the niHSDIO Write Named Waveform polymorphic VI:
|
niHSDIO_WriteNamedWaveformU32 niHSDIO_WriteNamedWaveformU16 niHSDIO_WriteNamedWaveformU8 niHSDIO_WriteNamedWaveformWDT niHSDIO_WriteNamedWaveformFromFileHWS |
Refer to the following code snippets for an example of writing a 1 MS waveform to onboard memory in LabVIEW and in C.

#define BLOCK_SIZE 8192
ViUInt32 data[BLOCK_SIZE];
.
.
.
niHWS_OpenFile("mydata.hws", niHWS_Val_ReadOnly, &fileHandle);
niHWS_GetWfmReference (fileHandle, VI_NULL, VI_NULL, &wfmRef);
/* reserve onboard memory, name the waveform "myWfm" */
niHWS_GetWfmI32Attribute (wfmRef, niHWS_Attr_WaveformSize, &wfmSize);
niHSDIO_AllocateNamedWaveform (instrHdl, "myWfm", wfmSize);
/* write waveform 1 block at a time */
numSamplesWritten = 0;
while (numSamplesWritten <= wfmSize)
{
/* Read BLOCK_SIZE samples from .hws file, put in data */
niHWS_ReadDigitalU32(wfmRef, BLOCK_SIZE, data, &actualSamplesRead);
niHSDIO_WriteNamedWaveformU32 (instrHdl, "myWfm", actualSamplesRead, data);
numSamplesRead = numSamplesRead + actualSamplesRead;
}
.
.
.If you try to write past the end of a waveform, NI-HSDIO returns an error.
The digital waveform generator/analyzers support writing waveforms according to the following standards:
| NI 654x/655x devices | Require waveform blocks be multiples of 32 samples when writing to preallocated waveforms. The overall waveform size does not have this restriction, but it must be even. |
| NI 656x devices | Require blocks be multiples of 64 samples when writing to preallocated waveforms. The overall waveform size does not have this restriction, but it must be a multiple of four (or a multiple of eight if in DDR mode). |
The last call to Write Named Waveform VI should write enough data to fill the waveform.