LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Input header into spreadsheet file.

I would like help compiling a header to attach to a data log file. I am using the express measurement to file VI. I have merged 4 different signals into one input for this VI. I would like to know how to add a header that includes labels like channel, coupling, trigger type, trigger source, horizontal scale, acquisition mode. These labels have appropriate values obtained from an oscilloscope. These values are changing with each acquisition and I would like to have them recorded along with a description of what they are, in the header. I would like to know how to convert the dbl numbers into strings so i can concatanate them with their header labels and then make list which is two columns wide including all of the labels.

 

How would I do this? I have attached my VI.

Thanks,

 

Adi

 

0 Kudos
Message 1 of 8
(5,417 Views)
I suggest that you build up a string using Format Into String and connect this to the Comment input on Write To Measurement File. Something like this
 
 
 
David

Message Edited by David Crawford on 07-31-2006 09:33 AM

0 Kudos
Message 2 of 8
(5,390 Views)
David,
 
Thank you. This works. Is it possible to tab delimit the header or input line feeds so that when I open it in excel  I have the comment spaced out over various cells. I tried concatenating individual strings constants with tab constants and i tried again with end line constants and then inputting it through the format string function but i never got what i expected. I just received all of the comments in one long line in the same excel cell. This is not a major issue but im hoping to learn.
 
Thanks once again.
 
Adi
0 Kudos
Message 3 of 8
(5,368 Views)

Adi

I can see what you mean. The Comment field is encoded by the write lvm express vi so that the read lvm knows how to format it. So if I replaced the = with a tab seperator it looks like this in the excel cell.

Channel\091\0ACoupling\09AC\0ATrigger TypeEdgeTrigger Source\091\0AHorizontal Scale\090.010000\0AAcquisition Mode\09Single\0A

The \09 is the encoding for <tab> and \0A is <LF>. I don't think there is anyway around this as the lvm read alogorithm needs the file to be in a specific format. If you intend to view this file in excel then you could either create a modified version of your LVM or use your own format. This new format could be a 2D array of strings (table) which you would populate with your data and convert this using the Array to Spreadsheet String function and write this to file using the normal file functions.

If you need more help give me a shout.

David

0 Kudos
Message 4 of 8
(5,365 Views)
The NI-SCOPE Soft Front Panel does something similar to what you want to do.  The LVM file format has a "special block" format that allows you to embed just about anything you want into the file, and still have it readable by normal readers.  You can find the format of this "special block", and the formats of the already-defined blocks here.  Unfortunately, there is nothing quite what you want, so you will need to create your own "special block".  To write the rest of the LVM file with minimum fuss, you will want to use the subcomponents of the LVM express VI.  To get them, drop an LVM write block and convert to a regular VI.  Then extract what you need.  There will be three main parts - the main header, the section header, and the data.  The last two are in the write all data VI.  As long as you get those three sections written, you file will be good.

One note of caution if you do this, the subcomponents are subject to change between LabVIEW versions.  This has only happened once that I know of, but since they are not on the palette, they are fair game.  This would mean changes, usually minor, to your code if you upgraded.  You can avoid this by making your own copies of the LVM code stack (and renaming it before using to avoid cross-linking).

Good luck.  Let us know if you need more help.
Message 5 of 8
(5,354 Views)

I managed to work around the comment field by entering into the express VI and going thourgh various sub VIs in this order - ex_subwrite-->ex_writedataall-->ex_signalstosprdsheetstr-->ex_createsignalchunksting-->ex_cleanupcomment. In this SubVI I deleted the “escape unprint chars” subvi. Then going back to my input string I just added \t and deleted the line feeds. This allowed me to input the comment into various cells. My block diagram looks exactly like above.

 

0 Kudos
Message 6 of 8
(5,338 Views)

This is my input string for the comments field:

channel=%d

\t\t coupling=%s

\t\t trigger source=%s

\t\t trigger type=%s

And it looks like this in the file:

****End_of_header***

X_value       "blank cell"      Comment

0                  .38                   channel=1

"blank cell"  "blank cell"       coupling = DC

"blank cell"  "blank cell"       trigger type = EXT

1                  .64                   "blank cell" 

2                  .94    etc.         "blank cell" 

 

Do you think there is an easy way of bringing the values back up or even bringing the zero value down. maybe insert a blank extra row into my data? If this is possible how could I do that?

0 Kudos
Message 7 of 8
(5,335 Views)
The LVM comment field was intended to host a single line of text which described the data for a particular segment.  This allows the user to put individual comments on every data segment written to the file.  The unescape code is there to prevent the file from being modified in ways that would prevent it from being read by the LVM reader.

An even easier way to use the special block is as follows.  Format what data you want in the block.  Pass this data through the program stack to the ex_SignalsToSprdsheetStr.vi.  In that VI, in the FALSE case, there is a VI labelled Create Packet Header (it is ex_CreatePacketHeader.vi).  It has an unused input called Special Blocks.  It is an array, since there can be more than one special block.  Change your text string into a one-element array and wire it in.  The separators will be added and it will be placed in your file in the packet header.
Message 8 of 8
(5,311 Views)