LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write measurement to file slows data presentation

I am sampling a light sensor at 1000Hz, and displaying the value using a waveform chart, and outputing to a file (using Write measurement to file), using a boolean.  Whenever i activate the write to file module, the acquistion rate slows down (i.e. I see the waveform propogate much slower). Has anyone else had this problem? Any solutions?
0 Kudos
Message 1 of 29
(4,140 Views)
One problem would be writting to the disk each time you acquire a point. Since drive is mechanic and relatively slow. Opening a file, write a single data, close the file, Windows switch to update screen or whatever else, is a very overheaded task. Instead, I suggest, it your needs allow it, acquire the data into larger arrays, even 1K, then write them in a single step into the file. We do this writting whatever Windows can collect when it switch back to LV (remember Windows is multitasking and switching between all your opened programs), and computer keeps up even at 10K / s. Another problem is: If your samplings is controlled by Windows Labview, then there would be the problem. Our 10K sampling is done completely by our hardware.

Good Luck.
Message 2 of 29
(4,132 Views)
It would help if you posted your code.

If you are using the higher level VIs to do your file logging, that could be a big problem.  The high-level VIs open and close the file everytime.  You want to open the file once, write your data, then close the file when you are done.
0 Kudos
Message 3 of 29
(4,129 Views)
thanks for your inputs. They have been helpful. I think the last entry might be correct, as I'm just editing one of the provided example VIs; so it might be a "high level" VI that opens and closes.

I've attached it to see if you can tell (i'm still pretty new to this).

thank you,
dave

0 Kudos
Message 4 of 29
(4,121 Views)
Yes, you have used a VI that opens and closes the file continuously and you are doing that for every data point you collect.  This particular VI will run even slower than "normal" file I/O because it has lots of overhead for the file formatting.

What do you want your file to look like?
0 Kudos
Message 5 of 29
(4,118 Views)
I still need to make some changes to it, but basically I just want to be able to select from one of the 8 channels on my device (Pidgetinterfacekit) and have it display the running values (waveform chart), and store them to a file (Write measure to file) whenever I choice (Boolean button).

Thank you for looking over my code btw.

dave
p.s. Just a general question: Since the opening/closing is slowing the data storage, is it missing points in time? That is, as the light sensor is collecting data, are points being missed becuase of slow processing, or it is getting all the data, but at a delayed rate?
0 Kudos
Message 6 of 29
(4,116 Views)
Yes, now I remember I should have mentioned that, one of the tricks to speed up the process, you use the lower level vis. Open the file at the beginning of the file, then keep it open and just read or write to it (no more Open / Close overhead), then close the file when you finish.

Good Luck.
0 Kudos
Message 7 of 29
(4,104 Views)
So, you said to open the file, at the beginning; you mean the file i'm going to store my data in?  Do you know how to do this, or perhaps what commands I should look to?  (sorry..i'm definitely a newbie).

Also, just for an example, what is considered a lower level VI, as compared to a high level VI?

thank you,
dave

0 Kudos
Message 8 of 29
(4,102 Views)
Something along the lines of this VI.  I open the file you specify before the while loop starts and pass a reference into the loop.  The file remains open until the while loop closes and I close the file.  When you set the boolean to true, then I take the number from the measurement, convert to a string and add a line feed.  That gets written to the file.

One issue with what I wrote is that the file gets created whether or not you ever make the boolean TRUE.  If you want smarter code, then you need to open the file only the first time you try to write, then never again.

Your original VI would not look for the next point until the file write finished.  So, you wouldn't drop any data that LabVIEW collected, but you were sampling at a slower rate.

You also should probaby add a time delay, as your CPU usage is probably very high.  LabVIEW will execute the loop as fast as possible.  With no delays built in, it may peg out your CPU.


Message Edited by Matthew Kelton on 02-20-2008 07:54 PM
0 Kudos
Message 9 of 29
(4,098 Views)
Hi:

     Yes. We refer to low level vis as in programming languages. As higher the level, more "luxury" we give to the user, everything is done in a few steps, in a single step if possible. Low level ones do single tasks at a time: Open file, read file size, read some bytes of data (not the entire file), close the file, etc. etc. These instructions, even more troublesome for many people, gives you more control over the process. I'm attaching 2 files, one is a vi with some of LV menu vis which perform these smaller tasks (sorry it's in LV5, but any later version of LV you have, you would be able to open them), the other file is just a picture of the screen with the menus where those vis are (sorry again it's LV5, but you must be able to locate the corresponding menus in your version of LV).

     Good Luck.
Download All
0 Kudos
Message 10 of 29
(4,090 Views)