09-06-2016 11:44 AM
Hello,
I am trying to measure analog signal using PXI-6143 in a hardware timed single point manner using CVI.
It is said here that for for doing hardware timed DAQ using PXI-6143 you have to have even number of channels.
Though we only need one channel, we have create the second channel to have even number of channels.
The following is the part of the code that create the channels.The problem is that the DAQmxErrChk issues an error when the code tries to start the Analog input data acquisition.
//creating the tasks DAQmxErrChk (DAQmxCreateTask("",&gAItaskHandle)); DAQmxErrChk (DAQmxCreateAIVoltageChan(gAItaskHandle,gAIchan,"",DAQmx_Val_Cfg_Default,gAImin,gAImax,DAQmx_Val_Volts,NULL)); DAQmxErrChk (DAQmxCreateTask("",&gAItaskHandle2)); DAQmxErrChk (DAQmxCreateAIVoltageChan(gAItaskHandle2,gAIchan2,"",DAQmx_Val_Cfg_Default,gAImin,gAImax,DAQmx_Val_Volts,NULL)); // sampling configuration DAQmxErrChk (DAQmxCfgSampClkTiming (gAItaskHandle, "", gRate, DAQmx_Val_Rising, DAQmx_Val_HWTimedSinglePoint, DAQ_SpC_in)); DAQmxErrChk (GetTerminalNameWithDevPrefix(gAItaskHandle,"ai/SampleClock",trigName)); DAQmxErrChk (DAQmxCfgSampClkTiming (gAItaskHandle2, "", gRate, DAQmx_Val_Rising, DAQmx_Val_HWTimedSinglePoint, DAQ_SpC_in)); DAQmxErrChk (GetTerminalNameWithDevPrefix(gAItaskHandle2,"ai/SampleClock",trigName)); // start task DAQmxErrChk (DAQmxStartTask(gAItaskHandle)); // here is where the code issues an error DAQmxErrChk (DAQmxStartTask(gAItaskHandle2));
I wonder why the DAQ task wouldnt start, although two channels are made. Any idea is highly appreciated.
09-06-2016 03:00 PM
Made a mistake. You only have to add another channel to the existing task, not creating a new task:
DAQmxErrChk (DAQmxCreateTask("",&gAItaskHandle));
// adding two channels to the task DAQmxErrChk (DAQmxCreateAIVoltageChan(gAItaskHandle,gAIchan,"",DAQmx_Val_Cfg_Default,gAImin,gAImax,DAQmx_Val_Volts,NULL)); DAQmxErrChk (DAQmxCreateAIVoltageChan(gAItaskHandle,gAIchan2,"",DAQmx_Val_Cfg_Default,gAImin,gAImax,DAQmx_Val_Volts,NULL));
It now works fine.