I have a State Machine, with a State where 3 samples of data are collected in a For Loop. I would like to save this data in a file and keep adding new data to the same file each time I get to this state. The problem I'm running into is that each time I reach this State, my old data in the Excel file gets replaced with the new data instead of being continuously added in the same file.
Ive tried Shift Registers but I may not be using them correctly since my file keeps displaying only 3 new data points.
Any ideas will be appreciated!
Thank you, so much.
Given no other information the solution is to create 4 or 5 additional states.
Append to File
Read from File
Then have your state machine execute the appropriate states to do what you need.
This keeps it simple yet scalable.
Where should I place these shift registers? Where should I place my File I/O VIs? Is it possible to use the Write to Spreadsheet File VI in this situation?
Ive attached a very simple example of the problem. Thank you.
What shift registers are you referring to? Are you actually writing to an Excel file, or are you trying to use Write to Spreadsheet File, as in your example? Write to Spreadsheet File writes a delimited text file, not an Excel workbook. For the example you uploaded you'd use a shift register to keep track of the filename. Otherwise, each time you execute the Write to Spreadsheet File you'd get a prompt asking you to save the file. Since you are wiring a True to the append to file? input then you'd simply feed it the new data. There would be no need to have another shift register to hold all of the data.
I dont have to use the Write to Spreadsheet VI as shown in my example. All I would like to do is add new data to a single file.
Im still having trouble getting the 3 iterations from the For Loop/Random Number Generator to be added to the same file each time I reach this "Write/Read/Save" state. (Image shown above this post).
Your assistance will be apprecaited, thanks
What kind of "trouble"? The example you posted works just fine. As I noted, you should keep track of the filename so you're not asked for it each time the Write to Spreadsheet File VI runs. In this case a simple feedback node will work just fine.
Thanks for all your responses. I just now realized the simple example works. The "trouble" refers to my actual code where I'm collecting three iterations of HEX serial data. I can view new data in the array with every run, but when it saves the data, It overwrites old data instead of adding to the file. Im puzzled, any ideas?
Please upload your actual VI.
I see you are still ignoring my comment regarding the file name. I guess you like annoying dialog boxes.