LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

scan slows down with each increment of loop

Hi
I am using labview to raster scan a piezo stage and collect fluorescence. To do the scanning, I have an X loop and a Y loop. Each iteration of the loop steps a voltage which is output (using DAQmx assistant) through a PCI 6229. It's very bizarre because the scan rate starts very fast (I monitor by probing the X) but subtly slows down after each iteration. When I stop the application and restart (without exiting labview) it remains slow and even gets slower. When I exit Labview and restart the program, it begins fast again, and then slows down. Any ideas??
0 Kudos
Message 1 of 12
(3,430 Views)
Hi

This sounds as if you were building an array dynamically in your loops. If you do, create an array before you start the loops and use the replace element function inside your loops.

Hope this helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 12
(3,428 Views)
I create a 2D array initialized with all zeros outside the loops. Then I go in to the loops, at each X iteration, the data points are indexed at the side of the loop. After this X row is complete, it exits the loop, and sends the entire row of data to the Intensity Graph using the Replace Array Subset vi, increments the Y and then goes back into the X-loop to do it all again.
0 Kudos
Message 3 of 12
(3,427 Views)
This sounds ok.

Could you post some code or some pictures of your code?
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 4 of 12
(3,423 Views)
I tried to do this yesterday, but it appears it was not successful ...
I have attached a screen print of the important section. The rest of the program only has setting of scan size and file saving.
Thanks for your help. Jim
0 Kudos
Message 5 of 12
(3,396 Views)
Hi Jim

There are some small points I would change:

1. Use the replace element-function inside your for-loop. Doing this, you do not build any more arrays dynamically.
2. Use a timer inside your loops. If you use loops without any time delay, the sooner or later the load of your cpu is increased by your vi.
3. If the three daq-assistant express vis access the same device, take care of the execution sequence of the two in the for loop. Now it is not specified which is executed first. I'd suggest you to wire the error cluster from one vi to the other.

Just have a try and let me know if something changed.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 6 of 12
(3,388 Views)
Hi Thomas,
Thanks for this advice. I cannot try this as I am no longer in the lab, but do you mean to change the Replace Element vi from being inside the WHILE loop to be inside the FOR loop? In this way I would update my graph one pixel at a time?
I am very new at Labview - I understand now that the ERROR output from one vi can control the sequence of operations?

Thanks Jim
0 Kudos
Message 7 of 12
(3,383 Views)
Yes, change the replace element vi from the while loop to be inside the for-loop. You do not have to move the terminal of the graph, so it still updates after each row, but you're right it would update every pixel if it is in the for-loop too.

To the second point - it's not just the error output. It is the dataflow - each subvi executes right after all wired data are available. So an easy way to control the execution of the vis is to link the error connectors (by the way don't forget about the error-handling).
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 8 of 12
(3,377 Views)
A very inefficient programming method is your use of "insert into array" to append new data, especially since you insert a column at a time. The way the data is linearly arranged in memory, replacing a column requires rewriting of the entire array every time because the new elements are not consecutive in memory.

(I would think that appending a row at a time would be slightly more efficient, because they would be written consecutively, and at the end of the array in your case. This would be identical to a simple "built array" node).

Still, all these methods cause a resizing operation of the array, always an expensive condition that should be avoided.

Preallocating a fixed size array, then replacing rowns as you go is the most efficient. The array memory is allocated once.

You should update your graph as little as practical, so definitely not a pixel at a time. A row at a time is probably OK but if the loop rate is very fast, you could even put the graph in a case structure and update only every 10th iteration.
0 Kudos
Message 9 of 12
(3,376 Views)
Thanks for the feedback. I thought that is what I do in my program ... Outside of the loops, I initialize an array and set all the elements to zero. Within the loops, I replace the 00000 etc rows with the data acquired in the X-loop. Is that right or am I missing something?
Jim
0 Kudos
Message 10 of 12
(3,372 Views)