It sounds like your best bet will be to use a continuous task and turn off regeneration of data from the buffer. With regeneration turned off, you aren't allowed to generate the same point in the buffer twice without writing to that point in the buffer again. I would also make your buffer 1000x16 to cover the full 20 milliseconds and just extend the last 200 points of each channel to be the same as your 800th point. With this strategy, you will write your first 20 milliseconds of data, start the task, and then continue to write to the buffer during each 20 millisecond interval to update the pulse amplitude of each waveform as appropriate. If you fail to write new data before it gets transferred to the device a second time, you will receive an error. This will tell you whether your application is keeping up or not. If you know the waveforms you want to generate well ahead of time, you can increase your buffer size and write multiple sets of waveforms before starting. This may give your application a little more breathing room if you're having trouble keeping up. If you're computing your waveform on the fly, then you'll probably have to be content with the 1000x16 buffer and hope you can keep up. Also, with this setup, you may decide you no longer need a start trigger. Some pseudo-code illustrating this concept is shown below:
err= DAQmxCreateTask("",&taskHandle);
err= DAQmxCreateAOVoltageChan(taskHandle,"Dev2/ao1","",-10,10,DAQmx_Val_Volts, NULL);
err= DAQmxCfgSampClkTiming(taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,numSamples);
err= DAQmxCfgDigEdgeStartTrig(taskHandle, "/Dev2/PFI4",DAQmx_Val_Falling);
err= DAQmxSetWriteRegenMode(taskHandle, DAQmx_Val_DoNotAllowRegen);
err= DAQmxWriteAnalogF64(taskHandle,numSamples,0,10.0,DAQmx_Val_GroupByChannel,data2,&written,NULL);
err= DAQmxStartTask(taskHandle));
while(programRunning){
//update value of data2 variable here as appropriate
err= DAQmxWriteAnalogF64(taskHandle,numSamples,0,10.0,DAQmx_Val_GroupByChannel,data2,&written,NULL);
}
err= DAQmxStopTask(taskHandle);
I hope this helps. Good luck!