ni.com is currently experiencing issues.
Support teams are actively working on the resolution.
ni.com is currently experiencing issues.
Support teams are actively working on the resolution.
03-15-2016 07:31 AM
Hi,
I'm having troubles with the wait function in a while loop.
I'm using the loop to make sampling from my instrument every 2000 ms.
The test last more than 5-6 hours and I've noticed that only in the first hour the sample rate is the one I set, than it keeps falling behind and after 3 hours the sampling rate is of 7 second.
Don't now if it matters but I'm exporting every sample in an excel file via Write to measurement file funcion.
I was wondering what could be the cause of the problem.
03-15-2016 07:42 AM
Switch to producer/consumer archtitecture.
Your file writing is slowing down your sampling.
The next fix will be to open the file once, append as you go,and close it only when the test is over.
Ben
03-15-2016 07:46 AM
Giving us a look at your code would probably go a long way towards finding the answer to your problem. Other than that, one possible thing that will cause a program to get slower during execution is if you are building an array in a loop, and the array continues to grow in size as the program executes. The execution will get slower and slower as the array grows bigger ang bigger.
Good luck.
03-15-2016 07:47 AM
But the Write to measurement file function is already inside the while loop how do you suggest to do it?
03-15-2016 08:13 AM
Hi mattecst,
putting the FileWrite function inside the main loop isn't a proper producer-consumer scheme!
Just create an example VI as offered in LabVIEW's "File->"New…" dialog…
And please clean up your VI! You don't need a constant at the FOR loop "N" input, when you autoindex an array…
03-15-2016 08:18 AM
I'm sorry I started using Labview one week ago.
Can you be more specific?
03-15-2016 08:21 AM
We really should not ask you to "give us a look at your code", as it might encourage you to attach a picture of a part of your code. What we really want is for you to attach your code -- put the entire VI (or, if multiple VIs are involved, compress their enclosing Folder and attach the resulting .zip file) in the attachment.
This lets us look at all of the code, including the parts that may be causing you the problems.
To understand the Producer/Consumer Design Pattern, open LabVIEW, click "New ..." (the dots are important!), choose "From Template", and choose "Frameworks, Design Patterns, Producer/Consumer Design Pattern (Data)". Study this example and apply it to your problem.
Bob Schor
03-15-2016 08:22 AM - edited 03-15-2016 08:23 AM
Hi mattecst,
in LabVIEW "File" menu you select "New…". Then a dialog window opens which offers several predefined example VIs and projects.
Here you will find a "producer consumer" example VI!
Edit: Bob named the correct English names…
03-15-2016 08:23 AM
Here's the VI
03-15-2016 08:44 AM
I don't see growing arrays that would cause a problem.
I see you have the Write to Measurement File set to .xlsx, which is a relatively newer addition to that function. I was recently involved in a thread where the user found what I would consider a bug with it. (Formatting, not performance.)
I don't know how it handles all of the file writing inside. But since Excel is a proprietary format, I'm wondering if it is so busy rewriting the file on each use that as it grows, it takes longer and longer.
Try changing that over so that it writes to a text file. That should just append to data to the end. See if that helps.
How big is your .xlsx file getting when it starts to take 7 seconds per iteration?