Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Read hangs

I have an application that reads in analog data on two channels.
Outside a while loop (delay time 120ms)I:
-Create a task and add the two analog channels
-Configure the task to acquire samples continuously at 20Hz
-Start the task

Inside the while loop I read the data with "DAQmx Analog 1D DBL NChan 1Samp".
Also, I do a lot of calculations in the while loop and output digital data.

The problem is that although I do not get an error message, the acquisition stops sometimes for up to 2 seconds.
Is this due to the configuration of the task?

Background information:
The purpose is to actuate a device with the digital output of the programm. In each cycle of the programm, the analog values are read and processed. They thus lead to an digital output pattern. My aim is to make this whole process work as fast as possible, therfore I cannot afford to loose analog data, the acquisition has to run continuously without a break.

My system:
Windows XP
Labview 7.0
NIDAQ 7.3
Hardware: M 6229
0 Kudos
Message 1 of 5
(3,943 Views)
Most likely, a couple of seconds worth of data is being buffered in the device's FIFO before it is being transferred to the acquisition buffer. Since you are going only at 20Hz on two channels, this is only 80 samples. You can change this in one of two ways: (1) you can play around with the "Data Transfer Mechanism" and "Data Transfer Request Condition" properties to decrease the latency between the time the device acquires data and when the data is available. For example, changing the transfer mechanism to interrupts, and your request condition to "onboard memory not empty" will cause the data to be transferred to the acquisition buffer as soon as it is acquired (this is not very efficient for faster sample rates, but will certainly work for the rates you're using). Alternatively, (2) you can change your sample mode to "hardware-timed single point," which will configure your task as a non-buffered acquisition in which your calls to DAQmx Read will read data directly out of the device's FIFO.

Good luck,
Joe
0 Kudos
Message 2 of 5
(3,935 Views)
Thanks for the advise!
I will try suggestion 1. As for number 2: I have tried this configuration with the same result. Also, I got the error message that the buffer was full (which is somehow surprising as the should be no buffer used !?).
I will post how I am getting on.
0 Kudos
Message 3 of 5
(3,927 Views)
It seems I succeeded in solving the problem.

Again, for those interested in the issue:
The task was to
- read single data points from multiple analog channels simulatanuously in a loop
- do a lot of calculations on those data points and eventually write digital data in the same iteration of the loop
(sounds easy, but in fact gave me some headache)

I found the best way to do it is:

1.Create, configure and start the task including all requested ai channels once outside the loop.
The task has to be configured to be "hardware-timed, single point". As well, I set the "Data Transfer Mechanism" to DMA.
2. Run the DAQmx Read inside the loop
3. Clear the task after the loop

Until now it looks as if this works fine.
0 Kudos
Message 4 of 5
(3,925 Views)
HI Isabell,
I have to test a similar application which you mentioned.
i am not clear how u did the hardware timed single point and data transfer mechanisms changed to DMA.
So, If possible, can u attach the code what you written to this application. That will be very helpful for me.

Thanks in advance.

Bye
Vishnu
0 Kudos
Message 5 of 5
(3,855 Views)