LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing problem writing to file

I am using labview 7. I am reading an analog input voltage and, based on that, adjusting an analog output voltage. I have my while loop going 20 times a second using the "Wait until next ms Multiple" = 50. I am writing the data to a file once every 10 seconds. I am doing this by taking the number of the loop and dividing it by 200, and seeing if the remainder is zero. At first the data is written every ten seconds, but slowly the data is written less and less often. After 5 hours, the data is writing only every 35 seconds. I wonder if something is bogging down.
0 Kudos
Message 1 of 3
(2,714 Views)
The subVIs are lacking.
I don't understand how you can work with a diagram that size.
Could you tidy it up a bit (make it readable, according to LV developpement guidelines) before posting it again ?
Chilly Charly    (aka CC)
0 Kudos
Message 2 of 3
(2,714 Views)
As Chilly Charlie mentioned, it is hard to determine what is wrong since all your subVIs are missing. In the future, you can create an LLB with your main VI and all its subVIs by selecting File->Save With Options... from the menu, then selecting the Development Distribution radio button on the left of the dialog that comes up.

From what I can see of your file interface code, it is very inefficient. For example, when you write your header, you open and close the file for each element in it. If you use Write Characters to File.vi to store your data, the behavior you describe is the expected behavior. Write Characters to File.vi opens the file, seeks to the end (if you append), writes the characters, then closes the file. As your file gets longer, the seek takes longer. You need to use more low level file I/O blocks. Open the file with Open/Create/Replace File.vi. This will give you a file refnum. Use this file refnum with the Write File primitive to write your data to the file sequentially. Use the current position mode and a position offset of zero (should be the default). If you are formatting your data as a tab-separated text file, use the Array to Spreadsheet String primitive from the string palette to format it before writing. Close the file when you are done with the Close File primitive.

NOTE1: Primitives have a beige background to distinguish them from VIs. Primitives are just that - the building blocks of all VIs.

NOTE2: If you are using LabVIEW version 7.0 or above, the Write LabVIEW Measurement File Express VI does all this for you a lot easier than doing it as I described above.

NOTE3: You really need to follow LabVIEW development guidelines (e.g. wires flow right and down). They are there to make your life easier, not harder. They are the equivalent of the C indenting conventions. Your LabVIEW program is the equivalent of a C program written with no subroutines on a single line. You can do it, and it works, but it is difficult to debug and maintain.

Good luck!
0 Kudos
Message 3 of 3
(2,714 Views)