04-17-2012 07:54 PM
I would like to repeatedly make n Analog readings in a program, however, I am unable to accomplish this without creating a new task each time... perhaps I'm doing something wrong.
Here is my pseudo-code:
DAQmxErrChk(DAQmxCreateTask("", &taskHandleAI));
DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandleAI, ...));
DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandleAI,...));
Loop start
DAQmxErrChk(DAQmxStartTask(*taskHandleAI));
DAQmxErrChk(DAQmxWaitUntilTaskDone(*taskHandleAI, 0.001));
DAQmxErrChk(DAQmxReadAnalogF64(*taskHandleAI, ...));
DAQmxErrChk(DAQmxStopTask(*taskHandleAI));
do_something();
Loop end
The first read seems to work fine, however, all subsequet reads gets the following error message:
DAQmx Error: Measurements: Task specified is invalid or does not exist.
Status Code: -200088
Does anyone have a clue what is happening?
04-17-2012 08:50 PM
04-17-2012 10:31 PM
Sorry... is it possible to move a post, or should I simply start another one?
Also. I don't fully understand what you mean by moving start & stop outside of the loop... the 'do_something()' part parses the reading results that was just read...
are you saying I should not run StartTask/StopTask for each iteration of the loop?
04-17-2012 11:49 PM