Hello,
I've been using a PCI DAQ (6229) for a while, and have recently switched to a USB DAQ (6211). In the program I've been using, I make use of the "SynchAIAOSharedClock" example, using the clock of the AO to sync with the AI. In the forums I read the USB DAQ doesn't support hardware time AO, so I guess this is why the code doesn't work anymore. Is there a way to share clocks the other way round (using the AI clock to drive the AO...)?
The code I'm using is:
int32 Configure_SynchAIAOSharedClock(const char *inputChan[], int numChans, const char outputChan[], float64 minIn, float64 minOut, float64 maxIn, float64 maxOut, float64 rate, TaskHandle *inputTaskHandle, TaskHandle *outputTaskHandle)
{
int32 error=0;
char outputClock[256];
char outputClockTemp[256];
int numBytes, i;
/*********************************************************************
* 1. Set the outputClock to be the sample clock on the
* device set by the Output Channel parameter
*********************************************************************/
numBytes = FindPattern (outputChan, 0, -1, "/", 0, 0);
CopyString (outputClockTemp, 0, outputChan, 0, numBytes);
sprintf(outputClock,"/%s/ao/SampleClock",outputClockTemp);
/*********************************************************************
* 1. Create a task.
* 2. Create Analog Input Voltage channels.
* 3. Define the Sample Clock source. Additionally, define the sample
* mode to be continuous.
*********************************************************************/
DAQmxErrChk (DAQmxCreateTask("",inputTaskHandle));
for(i=0; i<numChans; i++)
{
DAQmxErrChk (DAQmxCreateAIVoltageChan (*inputTaskHandle, inputChan[i], "",
DAQmx_Val_RSE, minIn, maxIn,
DAQmx_Val_Volts, NULL));
//printf("minimum = %lf maximum = %lf\n",minIn[i],maxIn[i]);
}
DAQmxErrChk (DAQmxCfgSampClkTiming (*inputTaskHandle, outputClock, rate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000));
/*********************************************************************
* 1. Create a task.
* 2. Create an Analog Output Voltage channel.
* 3. Define the Sample Clock source. Additionally, define the sample
* mode to be continuous.
*********************************************************************/
DAQmxErrChk (DAQmxCreateTask("",outputTaskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan (*outputTaskHandle, outputChan, "", minOut, maxOut, DAQmx_Val_Volts, ""));
DAQmxErrChk (DAQmxCfgSampClkTiming (*outputTaskHandle, "OnboardClock", rate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000));
Error:
return error;
}
And is called using:
DAQmxErrChk(Configure_SynchAIAOSharedClock(inputChan, nr_eeg_chan_meas, impedance_out_channel, -impedance_dac_range, -impedance_dac_range, impedance_dac_range, impedance_dac_range, samples_rate, &impedance_inputTaskHandle, &impedance_outputTaskHandle));
DAQmxErrChk(Write_Task(impedance_outputTaskHandle, wfm_data, imp_bufferSize));
DAQmxErrChk(Start_Task(impedance_outputTaskHandle));
DAQmxErrChk(Start_Task(impedance_inputTaskHandle));
Best regards,
Ward