LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data acquisition with DAQmx to slow

Hi

I just changed my data acquisition programm to daqmx-driver.
but unfortunately I'm not sure if the program is still running correctly.
Why is the acquisition not running that fast as expected????

I have attached an extracted example of my problem.
you will see that the gap between "time since start" and the "number of rows" is getting bigger the longe the program runs!

The LV is 7.1.

thanks for any help
yves
0 Kudos
Message 1 of 10
(3,630 Views)
The problem is most likely the 'Build Array' function. Dynamically building arrays, especially a 2D array sampling of 10 channels is going to cause problems. The ‘Insert into Array’ and ‘Delete from Array’ have this same problem.

The 'Build Array' function is not very efficient. Since it has no idea how big the final array needs to be, all it can do is grab chunks of memory as it needs them. This is where the slow down comes from. Your application runs fine at the start, but as the array grows, it becomes more difficult for allocate more memory for the array.

The best way to handle arrays is to initialize the array first, then use the ‘Replace Array Subset’ function to put your data into the array. Of course if you don’t know how big the array needs to be, this is difficult. One way to handle it is to initialize an array to a size you think you’ll need, and monitor where you are in the array, so if you are near the end, you can use the ‘Insert into Array’ function to add more space just once. This way you’re not constantly reallocating memory.

It takes a bit more coding, but will run a lot better.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 2 of 10
(3,623 Views)
Okay. But how can I easily replace a 2-d-array in a larger 2-d-array?
I initialized a 50000 rows and 10 columns array and want to replace 1000 rows and 10 columns.
Do I really have to handle this in a "for loop"?

yves
0 Kudos
Message 3 of 10
(3,615 Views)
There is no easy to put a 2D array into a 2D array. We can only replace a subarray into a larger dimension array.

A For loop is the best way to handle it. For loops are very efficeint at handling arrays.

The attached VI (7.1) shows how to process multiple 2D arrays into a larger 2D array. There might be a slightly easier way, but I couldn't think of anything quick.

What it does is breaks the DAQ array down into single elements and then using 'Replace Array Subset', puts them in the initialized array one at time. I added some timing code at teh end to see how fast is runs the "Replacing". Average time on my P4 1.8GHz with 512Ram is 4ms. This was acquiring 1000 samples on 10 channels.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 4 of 10
(3,599 Views)
Thanks for your help.

BUT sorry to tell you that the process is running slower when having integrated your program than without.
I inserted both sequences and the initialization and the loop went really slower.
Did you tried to integrate your program in mine?
My machine should be fast enough. because when I'm running your vi the remains below 0.004400ms!

Any other idea?

Greetings from beautiful Switzerland

Yves
0 Kudos
Message 5 of 10
(3,582 Views)
Here's a slightly improved version.

It replaces one channel at a time instead of a single element. Average replace time for a 10x1000 array is about 2ms with this one.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 6 of 10
(3,577 Views)


@Yves wrote:
Thanks for your help.

BUT sorry to tell you that the process is running slower when having integrated your program than without.
I inserted both sequences and the initialization and the loop went really slower.
Did you tried to integrate your program in mine?
My machine should be fast enough. because when I'm running your vi the remains below 0.004400ms!

Any other idea?

Greetings from beautiful Switzerland

Yves



Just so you know, I posted that Improved VI before I saw this reply, so it not help this problem.

Not sure why it would be running slower. Are you saying the example I made is running at about 4ms on your machine, but make your application run slower than befor?

Could you post your modified application.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 7 of 10
(3,574 Views)
I see your DAQAssistant is set to acquire 100 sample on each run. I had the VI setup for 1000 samples. I think what might be happening is the Case structure that has the Build Array in it to add more space when needed is running when it shouldn't be. This would drastically slow things down because. That part is going to have to be changed because it's going to cause problems.

For now, try changing the 49001.. to 49901.. and stop the While loop after 49999 iterations and see what the time is.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 8 of 10
(3,565 Views)
OK,

One last try.

This version should work with whatever you specify in the DAQAssistant for number of samples per channel, and will only add array space as needed.

One thing to watch for will be running out of memory on your computer. You'll notice the Total # of Rows indicator gets large pretty fast.

One way you might handle this would be to initialize the array at say 200000, then instead of adding more space, write the data to disk and start replacing from the beginning again.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 9 of 10
(3,556 Views)
Thanks for your great help.
I have attached my main vi with your posted repclacing vi. (see attachment)
the difference is approx. 2 seconds for 200 loops. what are your times?
when I'm running your "improved remplace" vi I get avg processing times below 0.002ms (0.00002seconds)

yves
0 Kudos
Message 10 of 10
(3,534 Views)