LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxStartTask failure after ai range change

Hello all,
 
I have a panel with a control for the expected input voltage. I use it to set graph vertical range, and I use it for defining a task. I can start and stop the task with a command button. After start, the callback retrieves the maximum expected input, defines the minimum as zero, creates a task, and starts the task:
  min = 0.0;
  GetCtrlVal (mainpanel, PANEL_INPUTRANGE, &max);
  DAQmxErrChk (DAQmxCreateAIVoltageChan(gTaskHandleInput,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
  ... ... ...
  DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(gTaskHandleInput,DAQmx_Val_Acquired_Into_Buffer,gSamplesPerChannel,0,ChartModeSingleSampleCallback,NULL));
  DAQmxErrChk (DAQmxStartTask(gTaskHandleInput));
I can start and stop the task without errors, and the function for EveryNSamplesEvent puts data on a stripchart.
However when I change the expected input range, e.g. from 1V to 2V, I do not get any data from EveryNSamplesEvent (or maybe only once instead of continuous stream). When I push the stop-button and then the start-button again, the task runs again without errors. So after changing expected input range, it needs start-stop-start where both starts are identical including the creation of a new AIVoltage-task.
This error occurs with simulated devices as well with one tested real instrument (6015). DAQmx is version 8.5.
 
Q: what happens here ?
 
Regards, Jos 
 
0 Kudos
Message 1 of 3
(3,107 Views)

Hi Jos,

My understanding of a "task" is: the allocation and customisation of hardware resources.

Having started a task, the hardware resources are held in the required state, while aquiring data.

To change the state of a hardware resource, having started the task, I would expect
the task to be stopped so that the task\hardware resource could be redefined,
e.g. change the value of expected input.

To resolve your problem, perhaps you could add "stop the task" to the control callbacks
which adjust hardware resources, prior any change, followed by "start the task".

regards,

Gary.


 

 

0 Kudos
Message 2 of 3
(3,090 Views)
Hello Gary,
 
Thanks for the input, but this is not yet the solution.
 
When I start a task, I disable (dimm) the control for the range input. Next I have to hit the STOP control. This one will stop the task and subsequently it will clear the task. And finally it gives access again to the range control.
When the task is stopped and cleared, I can change the input range. This only changes the value in the control. When I hit the START control, it will disable this control, and retrieve the value. Subsequently I create a new task with the new - maximum - value for the range. The minimum value is always zero.
 
So I cannot - on purpose or by accident - change the input range when the task is running.
However I do not know if stop and clear task are sufficient. For example, I did not find any references buffer on-board or in the driver that have to be cleared additional. Or maybe the callback for EveryNSamplesEvent was just running and did not get the opportunity to finish.
 
I keep waiting for additional ideas !
 
Jos
 
P.S.
Because of this sequency - retrieving the range value and not using a callback - I know that it is not really neccesary to dimm this range control. But it shows the users that it is not possible to change the range while the task is running.
 
 
0 Kudos
Message 3 of 3
(3,076 Views)