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 Write Named Waveform (U32)
  • niHSDIO Write Named Waveform (U16)
  • niHSDIO Write Named Waveform (U8)
  • niHSDIO Write Named Waveform (WDT)
  • niHSDIO Write Named Waveform From File (HWS)

niHSDIO_WriteNamedWaveformU32

niHSDIO_WriteNamedWaveformU16

niHSDIO_WriteNamedWaveformU8

niHSDIO_WriteNamedWaveformWDT

niHSDIO_WriteNamedWaveformFromFileHWS

You can associate names with each waveform you write to the device. Naming waveforms is optional if you are writing a single waveform to the device and are not using scripts. You must name each waveform if you write multiple waveforms to your device. Use the niHSDIO Configure Waveform To Generate VI and the niHSDIO_ConfigureWaveformToGenerate function to select which named waveform is generated at Initiate. However, you must also name each waveform when using scripts, as the script generate statement uses the waveform name to know which waveform to generate.
Note Select Programming»Reference»Script Instructions from the table of contents of this help file for more information about the generate statement and other scripting instructions.
When using very large waveforms, it might be problematic to allocate enough PC memory to perform a single Write Named Waveform call. You can write large waveforms to your device by writing smaller blocks at a time. Use the niHSDIO Allocate Named Waveform VI and niHSDIO_AllocateNamedWaveform function and Write Named Waveform VIs or functions (listed in the previous table) to accomplish this task.
Note An easier way to handle the task in the example below is by using the HWS instance of the niHSDIO Write Named Waveform VI or the niHSDIO_WriteNamedWaveformFromFileHWS function, as they handle memory allocation for you.

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;
}
.
.
.
Each call to a Write Named Waveform VI or function writes to the end of the most previously written data.
Note Closing the session using the niHSDIO close VI or the niHSDIO_close function also deletes all waveforms from your device. You can manually delete a single named waveform from onboard memory by calling the niHSDIO Delete Named Waveform VI or the niHSDIO_DeleteNamedWaveform function.

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.