Hi,
I'm trying to collect temperature data with the attached VI. Everything works fine until I open the exported file, which contains only the last point of the chart. I already had this problem and I think it's quite common but I can't find how to solve it.
Thank you for your help !
已解决! 转到解答。
The input of your write to text file function is connected to the last data read.
If you want to save every data point acquired you need to write after every read.
Or you can store the data read temporarily before writing, at the end but that could cause memory problems.
Best regards
Etienne
Thank you for your answer
But in this simple program (I think it's the same configuration), all the data is acquired in the file. What is the difference between that and my program ?
And how can I write after every read ?
You are right.
Notice the difference in the indicator going outside the Loop.
In you program it is a simple square whereas in the exemple it is a square with a white background.
This means that in the case of the exemple the output is an array.
If you want to convert the output of the loop to an array right click on ot and select Tunnel mode>indexing
Your output wire after the loop will contain an array with all the points you want to write.
But in my program, it's already an array inside the loop, because I have several sensors. If I activate indexing, it adds a dimension to the array (not sure about that), and it doesn't create a file with : | time | temperature 1 | temperature 2 | ... |. Instead it is many arrays of just one line.
I don't know if I explain it well, I can give you more details if you want.
Here's what you do. The middle loop is where you get multiple Waveforms. You want to write each Waveform to the output file, which means you want the Write Waveform to Spreadsheet in the middle loop. Look at its Inputs and Outputs -- put three of them, File Path/New File Path, Append to File?, and Header? on Shift Registers. Initialize (means wire to the Shift Register from the outside of the While Loop) the File Path to "data\test" (as you've already done), with the New File Path going to the "output" Shift Register Terminal. Wire False (default) to Append to File? and True (if you want Headers) to Headers?. On the "Output" side of the these two Shift Registers, wire "True" to "Append to File?" and "False" to "Headers?".
So the first time you run the middle loop, the File will be opened as a New File (since Append to File? is false) and a Header optionally written. All later calls will Append the data to the same File (because you wired "True" to Append to File on the output terminal) and no Header.
And get rid of the unnecessary Frame at the end -- Data Flow will handle sequencing.
Bob Schor
@Bob_Schor escreveu:
Here's what you do. The middle loop is where you get multiple Waveforms. You want to write each Waveform to the output file, which means you want the Write Waveform to Spreadsheet in the middle loop. Look at its Inputs and Outputs -- put three of them, File Path/New File Path, Append to File?, and Header? on Shift Registers. Initialize (means wire to the Shift Register from the outside of the While Loop) the File Path to "data\test" (as you've already done), with the New File Path going to the "output" Shift Register Terminal. Wire False (default) to Append to File? and True (if you want Headers) to Headers?. On the "Output" side of the these two Shift Registers, wire "True" to "Append to File?" and "False" to "Headers?".
So the first time you run the middle loop, the File will be opened as a New File (since Append to File? is false) and a Header optionally written. All later calls will Append the data to the same File (because you wired "True" to Append to File on the output terminal) and no Header.
And get rid of the unnecessary Frame at the end -- Data Flow will handle sequencing.
Bob Schor
I am haveing the same problem. I tried to understand what the Bob Schor explained here, does anybody have any simple schematic to show this above explanation?