Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple tasks allowed for software-timed acquisition?

I use some code like this for software-timed or one-at-a-time data acquisition:

DAQmxCreateTask
DAQmxCreateAIVoltageChan do this N times for N channels
DAQmxReadAnalogF64(h, 1, 10.0, DAQmx_Val_GroupByChannel, &values, N, &samplesWritten, NULL)

Everything I've seen tells you that you can't make more than one analog input task for a single device (one of the most-frequently-asked questions for beginners, I think). But my observation is that I can use the outline above to make more than one task. I presume that the limitation is on the use of clocks, and the above doesn't use a clock.

Is that right?

Thanks!
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 1 of 3
(2,708 Views)

John,

The general rule is that you can only have one analog input task at a time.  Because of the way you have coded your application and the way the DAQmx driver works, you never end up having more than one task active at a time.  At the heart of a DAQmx task is a state machine which defines the software and hardware state.  A task moves from created to verified to reserved to committed to running as you read your task.  However, if you never explicitly change the state of a DAQmx task (ie.. calling DAQmx Control Task or DAQmx Start Task), it will implicitly revert to the state it was in before it began running.  In your case, since you never explicitly reserve, commit, or start your tasks, they will transition back to a state in which no hardware is reserved after you call read.  This allows the other tasks you use to do the same thing.  The downside of this, is for every time you call read, the driver must re-program the hardware (the analog input subsystem of these devices is coupled in more ways than just in the clocks... ie all channels share the same ADC, data FIFO, etc).  As such each call to DAQmx Read will take longer than if you combined all of your channels into a single task, explicitly called DAQmx Start Task, then performed your reads).

To answer your question, the behavior you are seeing is a result of DAQmx's state model.  Assuming that you are using an MIO (E-Series or M-Series) device, there are more limitations than just the use of a clock or not.  To test this, take one of your tasks, and call DAQmx Start Task on it before attempting to read one of your other tasks.  I would expect that in this case you would receive a resource reservation error.

Hope this clears things up for you,
Dan

0 Kudos
Message 2 of 3
(2,698 Views)
Oh! I knew that...

Thanks, Dan.
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 3 of 3
(2,695 Views)