LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing waveforms to file

I have been toying with the Waveform File I/O palette, in an attempt to write a waveform to a file (duh).  The issue I'm running into, is that if I write a waveform to a file, I can't write anything else into that file, which is fine, I can somewhat understand that.

So what I did was use "Export Waveform to Spreadsheet File", and simply appended the waveform to the file after I had written all the other stuff I needed to write to it.  Now the problem is, I can't read the info back as a waveform.  There's no "Read Waveform from Spreadsheet File" (as far as I could find anyways).  I realize I could obviously just use two files to write all my data to, but it would be ideal to use just one.

The writing is a "save" operation, and the reason it'd be best in one file is because I also have a "Load" operation, and if there's only one file, there's less of a chance of someone losing one or both of the alternative files.

Thanks for any suggestions or help!
0 Kudos
Message 1 of 13
(4,869 Views)
In the Waveform palette is a Build Waveform function. You can feed the array you get from the spreadsheet file to that along with the To and dt data to recreate the waveform.

Lynn
Message 2 of 13
(4,868 Views)
I wish I'd thought of that...  Sorry for the stupid question, but thanks for the quick answer!
0 Kudos
Message 3 of 13
(4,866 Views)
Okay, well your solution is well and good, but I got to playing with the waveform file I/O palette again and am confused about some things.

Say for instance, I wanted to write a waveform to a file using the "Write Waveform to File" vi.  How do I provide a path to it programmatically?  If I wanted the filename to be say a serial number along with date and time, how would I go about this?

I just use the string to path, since the Write Waveform vi doesn't accept it, because it doesn't think there's a file there to open.  Which is true, however, all the other file I/O vi's can just have a path wired to them, and they allow you to use that method to name the file as well.  I can't figure out how these ones work.

Could it be because they use a non-native dialogue?  So it's some internal LabVIEW thing whereby it has to create the file itself instead of having Windows do it?

Thanks for any help...
0 Kudos
Message 4 of 13
(4,861 Views)
I am not sure I understand your problem. On my system Write Waveform to File.vi gives a file dialog if the File Path input is empty. If it is not empty and contains a path to a valid file it opens that file and either appends to it or overwrites it depending on the setting of the Append to File? boolean. If if contains a valid path (including the filename) but no file exists at that location, it creates on. Are you sure you created a complete, valid path? One bad or missing character can be enough to upset the file I/O VIs.

Lynn
0 Kudos
Message 5 of 13
(4,858 Views)
Yeah, I know for a fact that the path works because I use the same path (different file extension) for a different file (if I use the aforementioned two-file idea).

What I meant was that (at least on my system over here), the Write Waveform to File gives a LabVIEW dialog, while every other file I/O vi I've used uses a Windows dialog.  I guess I was asking that could my problem be arising from the fact that LabVIEW's dialog has less functionality than a Window's one?  I don't know if my problem and the dialog difference are even related, but I traced the error back to the "Open File" vi buried in the Write Waveform to File.

I have wired a false constant to the Append to File terminal (to create a new file), so I'm not sure why the error is coming from the "Open File" vi...
0 Kudos
Message 6 of 13
(4,855 Views)
Could you attach your vi, or at least the part that is giving you trouble.  The Open File vi has an input called "function" that allows several choices on how to open the file, such as Open, Open or Create, Create or Replace, etc.   If you use Open and you are trying to open a file that is non-existant, you will get an error.  You can use Create or Replace and the file will be created automatically by the Open File vi.
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 13
(4,853 Views)
Thanks for looking at this.  The vi in which I write this is too big to warrant attaching, but this is the exact thing that's causing the problems.  Unless I let it create the file (by not wiring a path to it), it gives me an error.
0 Kudos
Message 8 of 13
(4,851 Views)
I ran your vi (after wiring a constant to the loop N terminal to fix the broken arrow) and it worked fine.  No errors, the file was created.  I deleted the path input and got the Labview dialog box instead of a windows dialog box because the vi uses "Open Create Replace WDT Array Dlog File.vi" to open the file instead of the standard "Open/Create/Replace File.vi".  I don't see any problem here.  Are you trying to write to a file or directory that is "read only"?  I don't know what else would cause a problem on your computer but not mine.  Try using a different path/file.  Also try using a front panel path control instead of a constant on the block diagram.
- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 13
(4,846 Views)
I am on a Mac so I had to change the path constant. I used a control. If empty, I get a dialog. If I put in a valid path, the VI runs without producing an error.

Internally the Write Waveforms to File.vi uses the standard File Dialog and Open File functions. These are supposed to follow the selection under Tools >> Options..>> Miscellaneous >> Use native file dialogs. I would not expect that some file I/O would use that and others would not.

So I guess I am not much help on this part of your problem.

Lynn
0 Kudos
Message 10 of 13
(4,846 Views)