04-02-2010 11:56 AM
Dear Mr, Mrs,
I encounter a problem when I try to translate an adapted code from the PID control single-chanel example to a C++ code with NI-DAQmx. The DAQmxWAITFORNEXTSAMPLE get always to the timeout limit.
Here is a part of the code:
DAQmxCreateAOVoltageChan(m_write_taskHandle,"Dev1/ao0","",minVolt,maxVolt,DAQmx_Val_Volts,"");
DAQmxCfgSampClkTiming(m_write_taskHandle,"/Dev1/ai/SampleClock",gRate,DAQmx_Val_Rising,DAQmx_Val_HWTimedSinglePoint,1);
DAQmxStartTask(m_write_taskHandle);
for (int t=0;t<500000;t++)
{
m_write_data[0]=Out_X_1;
DAQmxErrChk(DAQmxWriteAnalogF64(m_write_taskHandle,1,1,-1,DAQmx_Val_GroupByScanNumber,m_write_data,NULL,NULL));
DAQmxErrChk(DAQmxWaitForNextSampleClock (m_write_taskHandle, 10, &m_Late));
m_write_data[0]=Out_X_2;
DAQmxErrChk(DAQmxWriteAnalogF64(m_write_taskHandle,1,1,-1,DAQmx_Val_GroupByScanNumber,m_write_data,NULL,NULL));
DAQmxErrChk(DAQmxWaitForNextSampleClock (m_write_taskHandle, 10, &m_Late));
}
Thank you in advance for your help.
04-02-2010 12:11 PM
Do you have an AI task running?
It looks like you are using the AI Sample Clock for your AO Task--one reason that you would be guaranteed to timeout is if the AI Sample Clock is not running.
Best Regards,