LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop or VI executes slower then demanded

Solved!
Go to solution

Hello LabVIEWists,

 

I developed a little VI for monitoring and saving data. Unfortunately the while loop I use to ask for samples every iteration does not execture as fast as I demanded by placing a wait until next ms VI. Even if I change the time from 100ms to 10ms the execution speed does not change.

 

Does anybody has an idea why ?

 

 

SlowVi.PNG

0 Kudos
Message 1 of 7
(5,384 Views)

The wait functions operate in parallel with your code! If your code takes a certain amount of time to run, say 352ms, putting a 100ms wait in is not going to speed things up.

0 Kudos
Message 2 of 7
(5,382 Views)
Solution
Accepted by topic author ZMK16

File IO in general is slow.  One thing you could do to speed up your loop is to move the Read Spreadsheet File VIs out of the loop and use autoindexing to iterate on your columns.  You will probably need to use Transpose 2D Array to get it to index on the dimension you want.  Also, your While loop should be a FOR loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 7
(5,374 Views)

Okay thank you Gregoryj,

 

So the better question would be, how can I make my code run fast? Or what is it in the code that needs that much time, because I have never had this problem in all the applications I built in the past.

0 Kudos
Message 4 of 7
(5,372 Views)

In addition to what Crossrulz said, we may have to see what is inside the "Collect Numeric Array" subVIs

0 Kudos
Message 5 of 7
(5,368 Views)

Moving the read from spreedsheet VIs out of the loop was the solution. Thank you guys!

0 Kudos
Message 6 of 7
(5,361 Views)

@ZMK16 wrote:

Moving the read from spreedsheet VIs out of the loop was the solution. Thank you guys!


Well, this is only a solution if the file names and file contents never change. The file names can't change (all controls are constants!), but if some other process updates these files, you would get a different result for inside vs. outside.

 

Why you are at it, also remove these "built array" nodes. converting a 1D array to a 2D array does not add any useful information, it just makes indexing harder.

 

And yes, the outer loop should be a FOR loop and just index over the three arrays (assuming that all files have the same number of points) and the loop should stop once you run out of elements. You keep indexing long after all available data is processed!

 

0 Kudos
Message 7 of 7
(5,335 Views)