LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel csv format

Hi I am recently having a problem to writing to a spreadsheet file. Currently I am using the Export Waveform to Spreadsheet File.vi and it is working correctly except for the fact that the time column never changes. I think maybe the dt value is so small that time stamp does not have the required resolution. I got some advice to use a number (increment) instead. I found there are more file functions available for more options (write to spreadsheet, write string to spreadsheet) but the problem is I don't know how to implement this to my VI. I have attached the current VI which is still in progress and needs more work as to displaying functions(vpp,rise time, frequency) and want the .csv file to be more detailed and show date and time correctly (which right now the time is in 24hr instead of 12hr).  Is there a way I can have the VI set to a specific instrument such as "INST::7" which that is number to communicate with my 54645d scope? I used the instrument driver 54645D and using a GPIB cable to communicate with scope. Thank you in advance.

Download All
0 Kudos
Message 1 of 6
(3,104 Views)

Try formatting the time column so it show a couple more decimal digits for the seconds.

0 Kudos
Message 2 of 6
(3,079 Views)

@johnhe wrote:

 Is there a way I can have the VI set to a specific instrument such as "INST::7" which that is number to communicate with my 54645d scope?


 

On your PC, can you click on the GPIB control and have it drop down and show INST::7?  (On my PC, it shows COM1 and LPT1).  If so, set it to that value, then set this as the Default by clicking Edit (Menu Bar), Make Current Values Default.

 

Why are you saving all of the Time values?  You have the Starting Time, and dt, so you (in principle) know all of the time points (they are t0, t0+dt, t0+2dt, t0+3dt, etc.)  If you plot a Chart, you don't plot the time values, anyway -- you only need to know dt in order to scale the Time axis appropriately.  In most cases, t0 is unimportant (does it matter if you took the data at noon on a Tuesday, as opposed to at 4pm on Friday?), so you only need relative time, and for that, you only need to know dt (which you have).

 

Bob Schor

0 Kudos
Message 3 of 6
(3,078 Views)

Several points on this...

 

1. The Export Waveform to Spreadsheet  File vi writes time values to six decimal places of seconds (at least it did when I just tried it) - look at your csv file with a text editor and see what it is in your case. If this is so, then the problem is simply how you are formatting it in excel. Change the formatting column to custom and use a formatting code like HJH:MM:SS.000 to get ms resolution in this column.

 

2. Bob's comments on why do you need the time values because you already know them are valid. However, the Export Waveform to Spreadsheet  File vi gives you this anyway. (Having said that, our modelling dept. who use the captured data like timestamps on every line because it helps them align events with other data. Not needed, but convenient.)

 

3. A more efficient method would be to use the tdms file vis. These just write t0 and dt for a waveform, and there is an excel import plugin you can download from the NI website so that excel will open them. The excel file includes in it the t0 and dt values as well as other data about your waveform.

 

4. If you are going to use csv files I often find it more useful to output the time values as a numeric rather than a string. Either output the LabVIEW timestamp converted to a double (and then convert to an excel time with a formula in the spreadsheet ExcelTime=(LabVIEWTime/86400)+1462 ) or convert to excel time in your program before writing. Doing this means writing your own csv file line by line rather than using the  Export Waveform to Spreadsheet  File vi. It is more useful for non-equispaced data because, as Bob pointed out, for equispaced data you don't need a timestamp for every sample.

 

EDIT: Duh - emoticons ruined my time format string. Should read HH : MM : SS . 000 (without the spaces)

0 Kudos
Message 4 of 6
(3,045 Views)

@Stuart.Parkinson wrote:

EDIT: Duh - emoticons ruined my time format string. Should read HH : MM : SS . 000 (without the spaces)


Your original message looks fine to me.  The problem is the default setting for automatic emoticons in the forums.  (Which is a stupid default setting by the way.)

 

If you go into your profile settings, then Preferences, then Display, change the setting for the Emoticon Type from Default to None.

 

Now you won't see the automatic emoticons.

Message 5 of 6
(3,026 Views)

Thanks, RavensFan. Never looked through the profile settings before - so many of them!!

0 Kudos
Message 6 of 6
(3,016 Views)