LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why dose data can not be written into file instentaneously?

Hello all, I am using labview to creat a data aquisition system. I sample the data and then write it into a text file I created. However, I found that the data can not be written into file instentaneously, but after I click the red button to abort execution, the data would be stored in the file.
As you can see in the VI attached, the Write to Text File Functions have this kind of problem in the case 3 and 4 in the while loop on the top which includes the function of Wait on IRQ and Acknowledge IRQ. While the Write to Text File Functions in case 1 and 2 works very well.
I use the probe watch window to check the wire connect to text terminal of "write to text file", there are data coming in. Could I ask is there any reason for this to happen and how can I fix it?

 

Thank you so much for your help in advance.

0 Kudos
Message 1 of 6
(1,707 Views)

It may be just a function of your operating system.  I believe Windows has some settings that will buffer up writes to a file until the OS feels it is an appropriate time to write them out.

 

Why would you be using the the abort button to stop your VI?  How instantaneously do you actually need the data written to the file?

 

You could try using the Flush File function in the Advanced File I/O palette to force the data to be written to the file.

0 Kudos
Message 2 of 6
(1,692 Views)

Nevermind. Sorry wrong idea.

---------------------------------
[will work for kudos]
0 Kudos
Message 3 of 6
(1,680 Views)

You are continuously opening and closing the reference.txt file at several places in your loop, and it happens on each loop iteration.  No need for this.  Open it once, before the main loop.  Wire the refnum out to each place you read or write.  Then wire the refnum to the right border of the main loop and close the file after the loop.  All of these open-read-close, open-write-close all over the place is probably wreaking havoc with the operating system.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 6
(1,656 Views)

 

 

 

"You could try using the Flush File function in the Advanced File I/O palette to force the data to be written to the file."

 

how to use the Flush File function .

 

Thanks.

0 Kudos
Message 5 of 6
(1,443 Views)

hooverNI wrote: 

how to use the Flush File function.


Try looking for it in the LabVIEW Help.  It is pretty self explanatory.


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
0 Kudos
Message 6 of 6
(1,435 Views)