Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

ANSI C Create Task vs. Reconfiguring

Greeting fellow data acquirerers,

 

I have a question regarding the NI DAQmx C API. I have a very basic application in Qt (for GUI) to start, stop, reconfigure and plot a measurement with a USB-6255 DAQ. The program is built up as follows:

  • At the start of the program I create a task
  • The task is configured with some initial parameters
  • Upon button press this task can be started and stopped
  • There are button for changing the sample rate, samples per channel and dynamic range
  • Upon changing a value in any of the aforementioned controls the task is stopped, the parameters reconfigured and started again

The initial initialization consists of:

  • DAQmxCreateAIVoltageChan to add the required channels to the task
  • DAQmxCfgSampClkTiming to configure the sample clock
  • DAQmxSetBufInputBufSize to 10 times the samples per channel value
  • DAQmxRegisterEveryNSamplesEvent to configure the callback

The problem seems to be, when I choose certain parameters (for example 10000 Hz rate and 10000 samples per channel) DAQmx issues an error that my application can't keep up with the acquisition. I reconfigure the task in the following way:

  • If the task was running, stop it
  • Call DAQmxCfgSamlClkTiming with the new parameters
  • Call DAQmxSetAIMax/Min with the new parameters
  • Call DAQmxSetBufInputBufSize to set the buffer to 10 times the new samples per channel value
  • Unregister my EveryNSamplesEvent
  • Register an EveryNSamplesEvent with the new parameters
  • Restart the task, if it was running before

Now comes the twist. If, instead of stopping, reconfiguring and restarting the task, I clear the task and just perform the initial configuration with the new parameters everything works well. So my question in short would be: What happens between deleting, recreating and configuring the task that calling the configuration functions repeatedly does not do? In my opinion I am performing the same configuration steps (obviously without the channel creation) in the initialization and in the reconfiguration, so it seems odd to me that I get different results.

 

I would be happy about any suggestions. Thanks in advance,

FB.

0 Kudos
Message 1 of 1
(4,225 Views)