LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

saving serial data strings to disk continuously

I have written a VI which constantly interrogates a remote serial device with different inputs, and outputs that data to an onscreen chart. I need to also log that data to a file on disk, and haven't been able to find a solution that runs constantly and doesn't stop and ask me for what filename to use each iteration (several sequence structures). Have tried placing "File Dialog" VI outside the loop, and that attached to "Write to spreadsheet file.vi" .. Data is 4 digit ascii, and is recorded to disk ok. I tried placing the WriteToSpreadsheet.vi outside the structures with the data line connected out to, but no data recorded that way.
How I get the vi to accept the first filename selected or entered, and not stop each
iteration and ask?
Thanks! (Newbie here)
0 Kudos
Message 1 of 13
(3,703 Views)
What you can do is have a create/open file vi outside of the loop. If the path is left unconnected it'll prompt for a filename. Then wire the output path or refnum (depending on what you need) from this vi to your loop where you call the write file vi's. Since the write vi's have an input path/refnum they won't prompt for a filename.
0 Kudos
Message 2 of 13
(3,703 Views)
Take a look at the examples in data acquisition for streaming data to disk. This is actually quite a simple operation, but requires the use of the advanced file functions.

What you essentially have to do is open the file, start polling the se

rial device, buffer the data, store it onto the open file, and when you are done, just close the file.

The data streaming examples will give you a good idea of what to do, but be sure to substitute "write characters to file" for the binary data functions.
0 Kudos
Message 3 of 13
(3,703 Views)
Thanks, I tried placing Open/Create/ReplaceFile.Vi outside the loop, and then outside the wait loop outside of the iteration loop.. in both cases it still asks me for a filename each iteration. Also tried the File Dialog in either place, and that also stops and asks for a filename. (Also tried using the FileDialog.vi to feed the Open/Create/ReplaceFile.vi.. Same results.)
I'll attach the file. Thank you.
0 Kudos
Message 4 of 13
(3,703 Views)
Interesting - perhaps a LV expert can chime in. In the meantime - have you tried using the normal write file vi's? They take a refnum instead of a path.
0 Kudos
Message 5 of 13
(3,703 Views)
Ok, another way you can do this. Have you used shift registers? Place a shift register on your loop that reads and writes data. Connect the left register to your input filename and the right register to your output filename. Now, the first iteration of loop will start with an empty register, so it will prompt for a filename. from then on, the shift register will feed your filename into the vi. (Make sure you set 'append to file' to true on the write to spreadsheet vi)

Alex~
0 Kudos
Message 6 of 13
(3,703 Views)
Thanks, but that doesn't help, have tried those too, still stops every time and asks for the filename..
0 Kudos
Message 7 of 13
(3,703 Views)
The shift register doesn't seem to input or output filename info or refnum info.. or how would I get this data (the filename selected) into it to start with, and then get it to pass on to either path input or refnum input. Really sorry to be so dense..!
0 Kudos
Message 8 of 13
(3,703 Views)
Try this example...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 13
(3,703 Views)
Hi DaveF,

If you dig down inside the "Write to spreadsheet file" you will find that one of the file I/O VI's has a boolean input that determines if you get the dialog box. Change the boolean and save it as a new name and this should fix your issue.


Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 13
(3,518 Views)