LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to keep data from getting over-written in a loop structure?

I am acquiring event triggered data in a sequence structure with an embedded while loop. In this while loop I would like to acquire 2000 samples every time the acquisition loop is triggered for as many times as it is triggered. My output format is a text file and the vi is working great except for the fact that if I trigger the loop more than once, I still only get 2000 scans in my text file, the most recent 2000. So the older data gets written over every time the loop is triggered. Any idea how to get around this? (Using LabVIEW 7.0, Windows 2000)
0 Kudos
Message 1 of 6
(3,240 Views)
Wire a "pos mode=1" to "write file". This way the new write operation starts at the current end of the file and the new data is thus appended.
0 Kudos
Message 2 of 6
(3,240 Views)
Hi Altenbach - I tried your change - adding a numerical constant of 1 to the pos-mode connection of the "write file" but it didn't work.

Interestingly, running the vi still showed only the last loop in the output although if I didn't delete the output file after every separate run, the vi would append the last loop from the previous run to the output from the last loop of the current run. So, this method DOES append, but I need to be able to append different loops in the same run, not the same (last) loop from separate runs. If that makes any sense...
0 Kudos
Message 3 of 6
(3,240 Views)
You are closing the file each time you save the data. (close file +.vi

The close file .vi should be used once when the test is finished,and no more data are collected. In this case, each time data are saved, it will be appeneded to the current position. Closing the file will reset the current position to the begining
0 Kudos
Message 4 of 6
(3,240 Views)
Dr. Iman, thanks, but I made your suggested change and the same result applies. I removed the "Close File" vi from the loop and even wired a "False" boolean variable to the "Close When" port of the "Write to C" vi. The results from previous loops are still being over-written by later loops leaving only one loop of data by the time the vi is finished running.

Any other ideas? I have attached the latest version of the vi that I am working on this.
0 Kudos
Message 5 of 6
(3,240 Views)
examine the attached vi, and duplicate whatever fits into your work

It will write to file 4 times, each time appending existing file
0 Kudos
Message 6 of 6
(3,240 Views)