LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Measurement File format change

Hi,

 

I am using the Write to Measurement File VI (LabVIEW version 8.2) to store data collected from the Agilent 4294A Impedance Analyzer. It basically sweeps a desired frequency range and measures the impedance of your sample. Currently, I am using the Write to Measurement File VI to store data (x value: frequence, y value: magnitude and phase of impedance). I run several trials per sample and the VI stores the data one after the other in an excel file. I was wondering if there is any way to have the data stored in adjacent columns rather than rows as each trial is done (I have attached an excel file to illustrate what I mean). Also, I was wondering if there is any way that I could customize the header so that I can record the testing conditions each time and give the x and y columns titles (right now, the titles are "untitled" by default). If the VI I am using cannot do this, is there another VI I could use?

 

Thanks,

Nika

0 Kudos
Message 1 of 13
(5,533 Views)

The Write to Measurement File has limited options and I don't think you want to start modifying the code.

 

If you use the low level file I/O functions, you can customize the file any way you want. In order to save results side by side, you would have to defer saving until all of the runs are complete. If you don't, then after each run, you would have to read the file back into LabVIEW as a 2D array, append the new columns to the array, and then write it.

 

Look through the examples for Write to Text File and Write to Spreadsheet File functions.

Message 2 of 13
(5,515 Views)

I have tried using basic file i/o functions to write to a spreadsheet file but the resulting file is empty. I have attached my entire VI, which contains other features that can be ignored. The file input portion is in frame 5. Please let me know if you have any suggestions to fix my problem.

0 Kudos
Message 3 of 13
(5,504 Views)

Nika,

 

You have Append to file on the write spreadsheet vi set to True, but you also are manually appending the data using the array functions.  This means that you are adding the entire dataset to the already existing data set and essentially duplicating your data.  You need to either set this input as false, or do not append the array.  I know this doesn't explain why your resulting file is empty, but something you should consider as well.

 

As for the main problem, is your VI actually creating the spreadsheet file that has no data or is it not creating any file at all?  In otherwords, if you delete the existing file, is a new empty file created?

 

David

0 Kudos
Message 4 of 13
(5,473 Views)
Thanks for the correction, I shall update my VI. Unfortunately, it does not make a new file so if I don't have the file of interest prepared beforehand it returns an error.
0 Kudos
Message 5 of 13
(5,463 Views)

The write to spreadsheet file should automatically create a new file if one doesn't exist while append to file is true.  What error do you recieve?  Another workaround might be to use the first call function to decide if append to file is chosen:

 

firstcall.jpg

 

0 Kudos
Message 6 of 13
(5,421 Views)

Thanks for the reply. I tried using your suggestion regarding the first call function and made changes to my VI. Now I am able to create a new file each time I run the program. However, each time the for loop is run I am prompted to specify the file it should go to. This is inconvenient given that I would like all 3 trails to be saved to the same file. Also, it seems that although data is written to the excel file in the form of two columns (one containing impedance measurements and the other phase), each time the for loop runs, it overwrites the data.

Any ideas would be greatly appreciated.

I have attached my updated VI. The save to spreadsheet part is in frame 5.

0 Kudos
Message 7 of 13
(5,372 Views)
In your false case (first call = false) you have the first call function wired directly to the "append to file" input.  So on second, third etc iterations of the for loop, append to file is selected as false which means new file.  Put a "not" function in between these, or simply wire a true constant directly to the input.  Hopefully that helps.
0 Kudos
Message 8 of 13
(5,328 Views)

Thanks for the correction. Now my three trials are being written below one another, which is the problem I presented in my first post. I played around with the VI and realized that the Insert into Array function is not working. So, only the first trial is being written to the file. I made some changes to try to correct this problem with no luck. I checked the specifications of the VI and I believe I am meeting them all.

I have attached my updated VI. Any suggestions would be helpful.

0 Kudos
Message 9 of 13
(5,317 Views)

Sorry I didn't really catch this before, but unfortunately due to the limitations of the Write to Spreadsheet file, you can only write new data below the current data.  However you can work around this by writing everything vertically in rows.  Then when all data is added, simply re-read the whole file, transpose the data, and re-write it to the same file.  Check out the example I added to the community showing how to do this and then you can adapt this to your own needs:

 

Write spreadsheet columns_LV82.PNG

0 Kudos
Message 10 of 13
(5,288 Views)