This example shows how to generate a finite number of cycles of a given waveform using NI-DAQmx.
Generating a finite analog output with DAQmx is quite easy if you don't care about memory. You can create a waveform with N samples and use the method shown in the Voltage - Finite Output.vi shipping example with no hassle.
However, if you need to generate n cycles and the waveform has a large number of Samples and/or the minimum amount data must be loaded in memory, you may not want to simply use the method in the example, because it will load N*n samples in memory.
You can take advantage of the regenerative capabilities of NI-DAQmx to load only one cycle of the waveform into a buffer and simply generate it n times without having to load the whole amount of samples. The attached, modified version of the Voltage - Finite Output.vi does precisely this by limiting the size of the output buffer to a single cycle of the waveform.
This all started when I was helping someone migrating Traditional NI-DAQ based code that used the Number of buffer iterations input of the AO Start.vi to do precisely that. It is not immediately obvious what's the easy way to do this with DAQmx, so I though I'd share this in case it becomes useful for someone else.
There are no specific steps in addition to the shipping example other than setting the Number of Iterations value.
If you want to test, you can set a loop back from the AO channel into an AI and share a trigger. If you use an MIO like I did, you can set this VI with a Digital Start trigger set to /<your device>/ai/StartTrigger. Set the AI task number of samples larger than the value displayed in Total number of samples in the example VI so you can verify and count the number of cycles generated.
The shipping example was modified for single channel output.
The VI is saved in LV 2015. If you need it in an older version, you can ask, but this may be quicker.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.