FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone answer this question? What is used to format a string so that it falls into a certain Row/Column in excel? see text for indepth question.

I'm attaching a file that may help. Just remember this is my FIRST attempt at using NI/FeildPoint so things that would be obvious to the normal users more than likely would slide right by me. So I'll try and explain what the text contains as to make my problem more clear. I'm using a FP-1000, FP-AI-100, and a FP-TB-10. i'm creating a application where I'm using the 8 channels from the FP-AI-100 to monitor a control system ,that we manufacture. The control system is in an environmental chamber. I use the FP-TB-10 to monitor the temperature while in the chamber. The control system is ran for 4 hours under varing enviromental conditions while I monitor vital system voltages with the FP-AI-100. Now the application that i'm building starts with the obvious FP CREATE.VI and so forth I have no problem communicating with the FP's, but the information that I'm monitioring needs to be placed into a file with Headers describing the information below it. Now I use a "WHILE LOOP.VI" to monitor the FP-AI-100 & FP-TB-10 for the 4 hour period. but before that I create and open a file where I use a "CONCATENATE STRINGS.VI" to enter the headers I need. I do this by CONSTANTS, CONTROLS, TABs, AND CARRIAGE RETURN being entered into the "CONCATENATE STRINGS.VI" in the order I want them to appear. I use ROW 1 to enter (OPERATOR:with a CONSTANT) an a (CONTROL so the operator may enter his name and be recorded into the file) using a TAB to seperate Columns and a CARRIAGE RETURNto drop down to ROW 2 for the next headers. I use header names and TABs to seperate the columns. This part works great. I end up with ROW 1 having the operator information then ROW 2 having the headers for all the channels I'm using to monitor the control system with in their own column. The trouble happens when I write to this file during the "WHILE LOOP". The information recorded for DATE:, TIME:, and Channel 0 of the FP-AI-100 end up right under their corresponding header on ROW 3, but the rest of the data ends up on ROW 4 in column 3 and goes down many rows with some of the data not being stored at all. It varies on how many rows are used starting at ROW 4 but hey always stay in column 3. I use the "FP READ.VI" outputing to a "ARRAY TO SPREADSHEET STRING.VI" outputing to a "CONCATENATE STRINGS.VI" for each channel within the "WHILE LOOP" then into the "WRITE.VI". I use the "CONCATENATE STRINGS.VI" to place my data OR atleast I thought you could do that some how I'm not quit doing something write either there is a sampling/timing issue or writing to file issue where things are being confused in the "WHILE LOOP" if someone know a better route to perform what I'm tring here I would be interested. Its not like I'm not giving it the old colledge try here but without proper training and the vagness of the manuals it's difficult to understand what every connection actually does.I'm tring though for everyone who happens to fill pity for me

Thanks for your help

John Morris
Glendinning Marine Product, Inc.
0 Kudos
Message 1 of 4
(4,108 Views)
Hi John,
you did pretty flat programming there, just as I did 2 years ago as I begann,
learning LabVIEW.

I work at a pretty similar program to yours, so I extracted some my code,
which should save you lots of time.

There are two main things to mention.
First:
I prefer using the EXCEL CSV- format to feed EXCEL with data. Look there for
more info.
In short,
- text strings need a " as prefix and suffix.
- Each string is separated by a coma : ,
- A period is used as decimal number separator
- lines have to be terminated by

Example:
A 3- column header could look like this:
"col0","col1","col2"\r\n

A 3-column number line:
1.23,+45.6,-7.890\r\n

Second:
Use "all" as Item Name in Create Tag.vi

My VI supports one and more I/O-modules per bank. So dele
te the contens of
element 1 and 2 in the control "Device Name MF1". And edit element 0 for your
needs.

By,
Rainer
0 Kudos
Message 2 of 4
(4,108 Views)
Hi Rainer,

I appreciate your effort to help me, but there is still a slight cloud in front of my eyes here.(I must mention that I'm using Labview 5.1 and I can't open your File I get a LabVIEW load error code 8. So I haven't had the oppertunity to look at your application at this time. I will be up grading soon though to 6.1).

Lets start with the easy one which is the SECOND main thing you wanted to mention. In my application I used individual Create Tag.vi's "so your saying that I can use just one Create Tag.vi and one Read.vi and what ever I use to display the values will automatically to show the individual channels" in other words if I use a "Indicator(DBL)" comming out of the Read.vi what ever I use in the "PANEL" layout will expand to show all 8 channel if I was using a FP-AI-100? Cool...

Now as for the FIRST main thing you advised me of this is where my ignorance really shows.

#1--How do I change the delimiter (TAB) to a delimiter (comma) in a Array to Spreadsheet String.vi? For example is used the FP_Analog_Logging example to record all eight channels it uses a Array to Spreadsheet String.vi with a delimiter (TAB) when I open the file in excel all the channels come open in their own column, but being a txt file it goes through that routine at the beginning the "Text import wizard" where it ask you "choose the file type that best describe your data". If I leave it as default and leave the delimiters set to TAB and the column data format as general the file opens up with each of the channels' data in thier own column which is fine with me but if you change the delimiter to COMA in the wizard all the data for the channels still comes up in their own colume but now they have squares at the end numbers. Is this because I needed to set something before I was to open the file in excel?

#2--If using just one Create Tag.vi and one Read.vi and I have the Item Name listed as ALL I take it that the information comming out of the Read.vi is data for each channel in a String format starting with channel 0 and ending with channel 7 for the FP-AI-100.

#3--Now I use the following to "Format String" in the Array to Spreadsheet string.vi (%.4f)but I don't see anyway of changing the delimiter from (TAB) to (COMA)

#4 you stated text strings need a "as prefix and sufix" and each string is seperated by a coma, a period is used as decimal number separator and lines have to be terminated by my question is WHERE IS THIS ACCOMPLISHED? WHAT VI OR WHAT CONNECTOR PIN?

#5 You gave me an example of what a 3 column header could look like: "col0","col1","col2"\r\n Now is this something that you enter somewhere cause I know that \r is carriage return and \n is newline so I take it that the above is entered somewhere maybe in the Write.vi to the connector called Header (F)? See this is what confuses me because NI manuals have no examples of certain connectors types being used or any reference as to how they manipluate data with there varing type inputs. Or maybe I'm just missing them.

I think I'm getting it if you could just answer the above inquiries at least I'll be own the road of trial and error where one learns the most.


Thanks again

John Morris
Glendinning Marine Products, Inc.
0 Kudos
Message 3 of 4
(4,108 Views)
> I appreciate your effort to help me, but there is still a slight cloud
> in front of my eyes here.(I must mention that I'm using Labview 5.1

Oh, to bad. I'm using LV 6,02 and tried to save the application as LV5.1,
but it didn't work.

> Lets start with the easy one which is the SECOND main thing you
> wanted to mention. In my application I used individual Create Tag.vi's
> "so your saying that I can use just one Create Tag.vi and one Read.vi
> and what ever I use to display the values will automatically to show
> the individual channels" in other words if I use a "Indicator(DBL)"
> comming out of the Read.vi what ever I use in the "PANEL" layout will
> expand to show all 8 channel if I was using a FP-AI-100? Cool...

Allmost right. The 8 channels come out as 1D-array, ch0...ch7.

> #1--How do I change the delimiter (TAB) to a delimiter (comma) in a
> Array to Spreadsheet String.vi?
> ...cut

I don't use this Spreadsheet VI, because files coming out there allways
start this time consuming EXCEL wizzard. Because of this, I programmed my
own CSV-conversion vi. Maybe you could just use a common texteditor, like
wordpad and put the csv-examples from my last reply down to a text file
and rename it to *.csv. Texteditors terminate lines with "\r\n" by
default, so this is a very quick way for testing.

> FP_Analog_Logging example to record all eight channels it uses a Array

I didn't find the vi you metione above, but there is another good one:
Look at examples\FieldPoint\DataLogging\FP Logger.vi.
In a little case structure, at "false", there is a function called "Format
into string".
Pop up on the format string and adjust >>'\' Codes Display<<.
Then you change the format string into: %.;%-f%s
A Tab string is connected to the lower input of this function. Replace
this one with a comma.
That should do.

>
> #2--If using just one Create Tag.vi and one Read.vi and I have the
> Item Name listed as ALL I take it that the information comming out of
> the Read.vi is data for each channel in a String format starting with
> channel 0 and ending with channel 7 for the FP-AI-100.

Yes, just as explained above. If you put a indicator at the output to
display the values, you can expand the display to show all 8 channels, but
you can't name induvidual cells. In a array, all cells have identical
named labels. If you want to name the individually, you have to attach the
array to cluster function and put the indicator after this one. Enable
labe display and name the output values individually.

> #3--Now I use the following to "Format String" in the Array to
> Spreadsheet string.vi (%.4f)but I don't see anyway of changing the
> delimiter from (TAB) to (COMA)

Explained above.

> #4 you stated text strings need a "as prefix and sufix" and each
> string is seperated by a coma, a period is used as decimal number
> separator and lines have to be terminated by my question is
> WHERE IS THIS ACCOMPLISHED? WHAT VI OR WHAT CONNECTOR PIN?

Well, modifying strings are done with string functions.
Above, as I explained how the sample FP Logger.vi can be modified to do
the job for numbers. The pre- and suffixing with ", you only need for
strings, which EXCEL should interpret a string and as nothing else as a
string, even if there's a number inside. You usually need this only for
headers. So its easyest, if you just write your string into a string
constant or control and concatenate it to the previous csv-file contents.

Oh, I just see by looking at the above mentioned example... Inside the
case structure, but in the "true" case, there are error messages
concatenated to the logfile. At this point it is importent, to use " for
integrating the message into the CSV file, because a error message usually
looks like this: >> ERROR 2345 in vi yxz <<
Here you have text and number strings mixed in one line. EXCEL does not
know, if it should interpret the number inside the error line as separate
number, separating the line into three colums i.e. string before number,
number and string after number. So tell EXCEL by putting a " before and
after the line each.
For this, expand the Format To String function by one input, move down all
connections, to be able to insert a string constant with a " to the first
argument connector. Change the contents of the string constant at the
bottom argument from tab to ", (quotation mark AND comma)


> #5 You gave me an example of what a 3 column header could look like:
> "col0","col1","col2"\r\n Now is this something that you enter
> somewhere cause I know that \r is carriage return and \n is newline so
> I take it that the above is entered somewhere maybe in the Write.vi to
> the connector called Header (F)? See this is what confuses me because
> NI manuals have no examples of certain connectors types being used or
> any reference as to how they manipluate data with there varing type
> inputs. Or maybe I'm just missing them.

The example I mentioned above help here to.
Look at the Write File function. This function receves data from a
function named concatenate strings. Expand this function to have one more
spare input at the bottom. Create a string constant. Switch the constant
display to "\" mode. Enter "col0","col1","col2"\r\n into the constant.
Connect the constant to the spare input.
Doing this, every dataline in the csv file is followed by
"col0","col1","col2"\r\n .


I wish you a nice weekend,

Rainer Ehrt
0 Kudos
Message 4 of 4
(4,108 Views)