From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting data in waveform graph to an ASCII file

We are using a Labview program to acquire rapid voltage data, however due to specifications on the board we are employing a voltage divider factor that can be changed in the program, as well as sensing the polarity and correcting it so that the voltage is always positive.  This data is saved in raw form to a bin file.  To view this data, we have another program that has inputs for the scan rate and voltage divider factor, and then it reads the raw binary file and generates voltage vs. time data directly into a waveform graph.  No one here actually wrote this entire program, it is my understanding that NI originally helped to develop the program and no one in my group fully understands the intricacies.
 
What we would like to do is obtain data in 2-column ASCII format from the waveform graph directly (voltage vs. time) in some way.  Is this possible, and if so how can it be done?  The program is currently run off of Labview 4.1, however we also have Labview 7.0 on another computer and can copy the program and bin files if necessary.
 
Any help is greatly appreciated.
 
 
 
 
0 Kudos
Message 1 of 11
(4,107 Views)
It is not clear to me exactly what you want. Do you want to modify the data acquisition program to save to ASCII files rather than the binary? Do you want to modify the program which reads the binary and displays on a graph to also save to ASCII? Or do you want to create a new program which reads the binary files and generates ASCII files?

Do you want to do this yourselves or do you want someone to do it for you?

Lynn
0 Kudos
Message 2 of 11
(4,102 Views)
Let me attempt to explain better...
 
I don't have Labview anywhere near me...but we are using what I think is "generate waveform.vi", which lets you input a t0 and a delta(t) to create time data.  We are creating the time data from the scan rate (delta(t) comes from scan rate).  Voltage data is obtained from a raw binary file, some operations are done to this data (eg changing the sign of the data, multiplying by a division factor).  So this t, delta(t), and voltage inputs go into the waveform generator which then makes a voltage vs. time graph.  Now maybe there is a very simple way to do this by concatenating two arrays, but I'm a novice and haven't been able to figure out how to do this to create a 2-column ascii file, and it would require making a subroutine that creates the time array (whereas the generate waveform does this for you nearly automatically).  So is there a way to save the voltage vs. time data directly from the generated waveform? 
 
If not, what is the simplest way to obtain a 2-column ascii file containing voltage vs. time?
 
Thanks for your help.
0 Kudos
Message 3 of 11
(4,090 Views)
7.0 has a function that will write a waveform (or array of wavefroms) to a spreadsheet file.  In the case of a single waveform, it will be a two column, tab delimited, ASCII file.
0 Kudos
Message 4 of 11
(4,081 Views)
I have not used LV4 for quite a while so it is hard to recall which features existed then and which are newer. I still have LV4 on this computer and cold run it if needed. It sounds like the generate waveform.vi may be simulating an analog input device. Anyway, using t0 and delta(t) to generate timing is essentially what happens with DAQ devices. The time data for each voltage data point is simply t[i] = t[i-1] + delta(t). This is trivial to generate using a For loop.


Building the 2-D array from the t[i] and v[i] arrays is simple. Then feed the 2-D array to the Write to Spreadsheet File.vi and you have your ASCII file. You can set the delimiter if the default is not suitable. I am not sure whether that exists in LV7 or if you have to do an Array to Spreadsheet String conversion followed by Write to Text File. (all names of VIs are aproximate, from memory). In LV 4 you might need to do the string formatting at a lower level, concatenating tabs between columns and carriage returns between rows.

In the later versions of LV the waveform datatype includes t0, delta(t), and array y(t). One of the many reasons to upgrade.

Lynn
0 Kudos
Message 5 of 11
(4,075 Views)

That would be great (haven't used the 7.0 yet but we definitely have it available).  I found this file elsewhere in the forum, so it looks like I can go straight from the waveform graph to that data converting icon (cluster to array?), transpose the array, and use write to spreadsheet.  This looks feasible in 4.1 too.  Not sure what that icon under "first waveform in record" is though.  Hope this works.

http://forums.ni.com/attachments/ni/170/187477/1/Dibujo2.JPG

Thanks for your help!

Message Edited by chemengr on 06-15-2006 12:21 PM

0 Kudos
Message 6 of 11
(4,076 Views)
Based on a quick test, using the Convert from Dynamic Data VI will result in just writing the Y values.  There is an Export Waveform to Spreadsheet File in version 7 that is pretty foolproof, but it writes the time in HH:MM:SS format, so it's probably not very useful for anything with a frequency above 1 Hz. I would suggest either manually buildling a time array from t0 and dt, or using the Get Waveform Time Array function (not sure if that's in v4 or not). You can use the built in file-writing functions or format them to a string any way you like and write that to a file.

0 Kudos
Message 7 of 11
(4,065 Views)

Thank you all again for your help, I'll mess with some of the VI's mentioned in v7 (definitely don't remember seeing most of these in v4.1), things get very confusing with some of the higher-level vi's and their data types.  I'm out of here for the weekend, but if someone could comment on the URL to the jpg of that program I pasted - would something like this export time data as HH:MM:SS?

There is so much data I may need to parse it before even attempting to write it all to a spreadsheet...are there any parsing vi's in newer versions of Labview?  Right now my plan is to write a Matlab program (more my territory) to do this, as Excel can't even open all the data.  This will have to be some intelligent parsing (eliminate data in every x increment in time OR y increment in voltage, whichever comes sooner).

 

0 Kudos
Message 8 of 11
(4,058 Views)
You can certainly write the parsing VIs you would need in LV. I doubt you will find any pre-programmed VIs that do exactly what you want. LV has a wide selection of string and array manipulation functions from which you could build your parser. Back in LV1.2 we were writing data to spreadsheet formatted text files. We had to do all the formatting with Number to String functions and concatenation; no high level formatters existed then.

I have not used the waveform to file functions, so I cannot comment there. When you get to LV check the context help for the function. It may tell you about the available formats.

Lynn
0 Kudos
Message 9 of 11
(4,053 Views)
I'm having some trouble because the data is not technically in a waveform (brownish-red colored wire).  The program builds a waveform *graph* (cluster data with pink wire) using the bundle function, where the top input is a dbl x0 that is generated from (1/scan rate) multiplied by the first scan number.  The middle input is delta(t), which is just (1/scan rate), and the bottom input is a 2D array of two columns of voltage data, one is voltage and the second is a voltage from another channel that I don't need, and I can't figure out how the 2D array is generated because it looks like it should only be 1D (it suddenly becomes 2D after leaving a for loop). This creates a waveform graph with time vs. the 2 sets of voltage data.
 
So you'd think you could just build a waveform with the same data, but the "build waveform" function wants a t0 with a timestamp format and a 1D array for the 'Y' input, and I also can't just convert the cluster data for the waveform graph to an array using the 'cluster to array' function as it gives me a data mismatch. 
 
Does anyone know how to remove the first column or row of a 2D array and create a 1D array?  Also, how can I input a timestamped t0 if it needs to be on the order of <1 ms, since milliseconds are crucial here?  Is there any way to make a waveform with a decimal t0 instead of this ridiculous timestamp? 
 
Thanks again for any help.
 
 

Message Edited by chemengr on 06-19-2006 09:23 AM

0 Kudos
Message 10 of 11
(4,047 Views)