LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Corruption in a 2D after stopping a VI

I hope my problem is fairly simple, as I want to do two small things.
 
1.  I want to write an array to a comma separated value text file when exiting a file, and this works.  The problem is when I do this, my array gets corrupted, and data is scrambled everywhere.  The good news is that my data is neatly formed and organized while the VI is RUNNING.  It gets messed up when i click "stop" on it.
 
2.  Another thing, i have a 1D array, and a 2D array.  When increment/ decrement the 1D array, I want the RO index number incremented automatically on the 2D array.   
 
If this is unclear, I'm attaching my VI with comments on the front panel.  I'll appreciate ANY help!
thank you 🙂
Amal Patel
0 Kudos
Message 1 of 5
(3,052 Views)
I forgot to attach my VI
Amal Patel
0 Kudos
Message 2 of 5
(3,049 Views)
You may want to rethink the structure of your VI.
 
One thing I notice is that you are opening the file for reading on each and every iteration of the loop.  And then writing the array back out to the file.  That is loop is happening as fast as Labview will allow it.  There are no delays in the loop.
 
The program opens the file, adds some data to the array, writes the array out to the file, over and over and over again.
 
Set up your program in three parts.
Part 1:  Read the array in from the file
Part 2:  Run a loop continuously until stop is hit, but make sure it only does one thing at a time.  You may want to use a state machine, or event handling to do that action only when requested.  Also use "wait until next ms" VI to be sure there is some delay time in the loop for the computer to do other things.
Part 3:  When stop is hit, end the loop in part 2 and write the array out to a file.
Message 3 of 5
(3,040 Views)
Amal-

The problem you were seeing is a result of a questionable loop structure. There is no reason to read the entire file on every iteration of your main while loop. I simply put the read while loop in front of the rest of your program to get it working correctly (and cleaned it up a bit).

Xaq
Message 4 of 5
(3,025 Views)
Amazing.
Thank you 🙂
Amal Patel
0 Kudos
Message 5 of 5
(3,007 Views)