Hi,
I'd like to write into multiple channels Analog Outputs and my doubts are around the configuration of the timing and buffer.
Let's put an example:
double SamplesPerChannel = 1000.0;
double ao1_freq = 100;
double a01_amp = 2.0;
double ao2_freq = 20;
double a02_amp = 1.0;
double dataToWrite[2000]; // buffer os size =numChannels *SamplesPerChannel
int numChannels = 2;
int i=0;
double sampleClockRate = a01_freq*SamplesPerChannel ; //I've used the maximum frequency
for (i=0; i<SamplesPerChannel ;i++)
{
data[i] = amplitude*sin((double)i*2.0*PI/SamplesPerChannel );
}
for (i=SamplesPerChannel ; i<SamplesPerChannel *numChannels ;i++)
{
data[i] = amplitude*sin((double)i*2.0*PI/SamplesPerChannel );
}
DAQmxCreateTask("",&taskHandle);
DAQmxCreateAOVoltageChan(taskHandle,"cDAQ1Mod4/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCreateAOVoltageChan(taskHandle,"cDAQ1Mod4/ao1","",-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCfgSampClkTiming(taskHandle,"",sampleClockRate ,DAQmx_Val_Rising,DAQmx_Val_ContSamps,XXX);
DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL);
DAQmxWriteAnalogF64(taskHandle,SamplesPerChannel ,0,10.0,DAQmx_Val_GroupByChannel,dataToWrite,NULL,NULL);
DAQmxStartTask(taskHandle);
..............
1.- ¿Is correct the way I've calculated the sampleClockRate ? ¿ Or should it be: sampleClockRate=a01_freq*SamplesPerChannel *numChannels?
2.- XXX is the buffer size, but again I'm not sure if it should be 2000(numChannels *SamplesPerChannel ) or 1000 (SamplesPerChannel ).
As you can see my problem is to understand how affects having more than one channel in the timing configuration.
Thanks in advance