LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save waveform into spreadsheet file

Hello, I've got the following vi posted below (labview 7) It's the ni scope using a DAQ card and I want to write the results (the peak to peak value in this case if you look into the sub vi's) to a .xls file. Now, Labview's manual shows how to do this, but in my example it won't work. I have trouble with the data types, so how can I resolve the problem?
Furthermore, in the vi below I've got a case structure which basically switches the scope on / off. In the on case I want to write data to the file, in the off case it should write nothing. However, Labview shouts when I don't assign a value in the off case. So what should I put there?

Any help gratefully received!
0 Kudos
Message 1 of 5
(3,534 Views)
The problem you're having is that Write to Spreadsheet expects either a 1D or 2D array as inputs. Turning on Context Help and viewing the details of the function will tell you these sort of things. You are passing a scalar value out of your while loop - the very last reading taken. What will solve both of your problems is to use the Build Array and a shift register. In your true case, add a new element to the array and in your false case, the array is passed through unmodified. Attached is your VI modified to work like that. I also took the liberty to clean up your diagram a bit and eliminate the local variable. Neatness does count when routing wires
0 Kudos
Message 2 of 5
(3,533 Views)
Hello Dennis,

Thanks for 'cleaning up' my program, indeed it gave me some ideas as far as neat programming is concerned.
When playing around with the spreadsheet vi some questions occured.
First of all, when I run the scope the peak values are e.g. 1.834, 1.846 etc., the .xls file, however, rounds to 2.000, although I defined a precision of 3 digits (which is the default).
Secondly, is there a way how I can get the .xls file formatted, e.g. write consecutive values in one column rather than in one row and convert the peak values into db's and write them into a second column.
How can I add a header?
Do I have to alter the actual "Write to Spreadsheet" function or can I do this beforehand?

Thirdly, how can I assign a 'unbundle by name' to a
cluster? When I insert a new 'unbundle by name' it is empty but there is no way of typing in a name, e.g. 'status'


Any help gratefully received,

Georg
0 Kudos
Message 3 of 5
(3,533 Views)
Since Write to Spreadsheet creates a text file, you should be able to open it with something like notepad and verify that all of the decimal places are written. I suspect that you incorrectly specified a format when doing the import into Excel. I always use a comma separator and save the file with a .csv extension and then I don't have to go through the import dialog of Excel.

Instead of wiring your data to the 1D array input, make your calculations and create a 2D array of data. A for loop will work just fine. Wire this to the 2D input and create the file. Depending on how you create the 2D array, you may or may not have to select transpose array. Experiment with just Write to Spreadsheet and manually fill in some values of the 2
D array to see how the transpose array works or to see how you want to format the 2D array.

To create a header, first use Write Characters to File to write the header. Wire the file path output to the file path input of Write to Spreadsheet and wire a true constant to the append to file input. No modification is necessary.

When you programatically create a cluster, no names exist for the cluster elements so you can't just use unbundle by name. To assign names, create a cluster constant on the diagram and assign names to the elements by selecting each element and doing a show label and then enter the name you want. Wire this constant to the cluster input of the bundle or bundle by name function.
Message 4 of 5
(3,533 Views)
Thanks very much for all the information, I accidentely used integer instead of double precision and therefore got doggy results.
A more fundamental question arose when trying to trigger my DAQ-Card (Ni5102) (See vi below):
I'm sending a trigger (*TRG) to the function generator which triggers a SINGLE burst. I want the scope to retrieve the peak to peak value.
However I have the *TRG command in a for loop, so I can say trigger e.g. 15 bursts.
The thing is that, according to the .xls file, I sometimes get the right amount of values (in this case 15), but the other time I run the program it returns 30 or even 45 (multiple) values, which apparently isn't correct.
For some strange reason does the scope acquire mor
e than one trigger for ONE burst.
I can't see where the mistake in my program is, can you please help me out and have a look?
I've connected the Sync out of the function generator with the TRIG IN of the DAQ card, so that should work fine. Is there any way how to make my program more efficient?

Thanks a bunch!
0 Kudos
Message 5 of 5
(3,533 Views)