Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmxStartTask taking long time to execute

I am using a NI-6009 to acquire some analog information.  It is currently running in a multithreaded  C application and is signaled to start executing by a separate thread.  The problem I am seeing is that the StartTask function is taking 2s to complete which seems a bit high.  Has anyone seem a similar problem to this?  What exactly does the StartTask trying to do?  Are there any other ways of recording data in this method without calling StartTask every time the thread is signaled?
 
Redhat Enterprise Linux WS4 Update 1
NI-DAQmx Base v1.5
Reading Channel 0 and Channel 1
P4 3.00Ghz
2Gig of RAM
 
 
Thanks in advance for any help.
Eric
 
Sample Code
...

status = DAQmxBaseCreateTask ("", &taskHandle);

status = DAQmxBaseCreateAIVoltageChan (taskHandle, chan, "", DAQmx_Val_Diff, min, max, DAQmx_Val_Volts, NULL);

status = DAQmxBaseCfgSampClkTiming (taskHandle, source, sampleRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, navg);

while( !finished )

{

/* Wait until signaled to start reading */

pthread_cond_wait(&ad_start_signal, &ad_start_mutex);

status = DAQmxBaseStartTask (taskHandle);

status = DAQmxBaseReadAnalogF64 (taskHandle, pointsToRead, timeout, 0, data, pointsToRead*NAD, &pointsRead, NULL);

status = DAQmxBaseStopTask (taskHandle);

}

status = DAQmxBaseClearTask(taskHandle);

...

0 Kudos
Message 1 of 6
(4,006 Views)
I performed some more testing and it appears that the problem is specific to the individual device.  I have an older NI-6009 from a previous system and the StartTask takes approximately .16s to complete.  Its a shame we have shipped 24 units with the problematic timing issues.  These units also will not communicate once you perform a ClearTask.  I will take this up with technical support.
 
Eric
0 Kudos
Message 2 of 6
(3,995 Views)
Hi Eric,

After looking at your sample code, my first recommendation would be to configure the task and start it at the beginning of application execution.  This would configure the device, reserve all necessary resources for the acquisition, and start acquiring data into the buffer of the device.  Whenever the acquisition thread is signaled to start, you would just make a call to the read function and the most recent samples would be returned.  The clear task function call would be made when your application is done.

Regards,
Andrew W
National Instruments
0 Kudos
Message 3 of 6
(3,980 Views)

I just wanted to follow up with the problem/solution.  It appears that the NI-6009 can be programmed with two different firmware versions.  The correct version for my use is the NIDAQmx Base firmware.  This version performs flawlessly with the application above and takes less than 400ms to complete.  The same NI-6009 with the NIDAQmx firmware version functions slowly but correctly with the application.  It does however fail to load the device the second time the application is started and the device needs to be reseated before it will work again.

So... if you have slow functionality using DAQmx Base or the device doesn't seem to disconnect properly, then you probably have the wrong firmware version.

TheWoost, I will try your solution with a properly configured Ni-6009 and see if it also improves performance.  I tried it earlier with the incorrect firmware and the device stopped reading after two attempts.

Thanks to NI support for help on this issue.

 

Eric

0 Kudos
Message 4 of 6
(3,948 Views)
Hi Eric,

The USB-6009 can use either the NI-DAQmx driver or the NI-DAQmx Base driver.  Which one to use is based primarily on the operating systems on which you plan to run your applications.  For example, if you were porting the application for use on Mac OSX or Linux, typically the NI-DAQmx Base driver is used.  However, if running in the Windows environment NI-DAQmx is recommended.

We do now have a version of NI-DAQmx (version 8.0) available for Linux, and I assume this is the one you are using since you are running Redhat Enterprise Linux.  I am unsure as to why you are running into problems when using the NI-DAQmx driver.  As long as you are properly closing the task at the end of program execution the device should be in a state ready to run again.

Regards,
Andrew
0 Kudos
Message 5 of 6
(3,935 Views)
Just to clarify, the NI-DAQmx doesn't support USB devices on Linux.  NI-DAQmx Base is required to use the 6008 and 6009 on Linux.
0 Kudos
Message 6 of 6
(3,927 Views)