LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write two strings to a data file to make into a table

I am trying to write two strings(a mass read from rs232, and the current time text readout) to write to a file or table so that I can analyze the data.  I put them into an array, and tried to write that to a spreadsheet, but it does not work.  The spreadsheet sink is orange wheras the array source is pink. (also it says that the array is 1-D, i thought it was 2-D).  Any help on where to go or how to approach this would be a big help.  I have attatched the file as a reference. 
0 Kudos
Message 1 of 7
(3,234 Views)

First, you are creating a 1D array. You have two strings wired to the Build Array and the ouput is a 1D array. If you had 1D array inputs, then you would by default, have a 2D array output.

The Write to Spreadsheet File in 8.0 can not accept string arrays. There is a very simple modification that can be done to make it accept strings. There are detailed instructions on the block diagram and is a very good exercise for new programmers to do. If you make the mod, be sre to save it in a new location with a new name. However, since you are only writing one row, it makes more sense to use the Array to Spreadsheet String function on the string array and then just use the Write to File. You could also wire the results out of the for loop and do a single write when complete. And, your for loop doesn't make any sense because you don't have anything wired to the N terminal. Do you really mean to use a while loop? You should also move the VISA Close outside of the loop. You do not want to be closing the port with every iteration.

0 Kudos
Message 2 of 7
(3,230 Views)

Well I got it to write one value into one file, but it keeps asking me to save a bunch of different files, until I finally cancel it.   Only one of the files actually had the one bit of data.  The time also did not quite record as I would have liked, also working on that.  I could have used a while loop, although i dont know if that will really fix my problem.  I only did the for loop, because thats what my professor showed me what to use, as I am still trying to feel out this program.  My goal is to produce a table with a bunch of rows generating a table of data, each of the N iterations or loop being one read of data.  I very well could be going about this all wrong.  If anyone could link me to a tutorial or upload a modification of my file or one of their own to show me how the wiring goes, I would be very appreciative.  As for the previous post, thank you very much, I at least got a little further, with some direction to go, also the VISA issue could have been problematic. The only thing I had trouble with was you said there were detailed instructions on the block diagram, I did not know what you were talking about.  I did not see anything on my block diagram helping me with that.  Here is an updated file of what I have so far.  I think the problem with the constant saving part might have to deal with all the write stuff being inside the loop, but I am not quite sure how to stop it.  Thanks.

-Chris
0 Kudos
Message 3 of 7
(3,215 Views)
You are getting a bunch of questions about file names because you have two Write to Spreadsheet functions and a single Write to Text file. No reason to keep the Write to Spreadsheet and if you don't want to be prompted for a file name, provide a front panel path control to select the file before you run the VI. You have a string control wired to the prompt input (with an incorrect path anyway - you have / as a separator). That is not the way to provide a default path to save to. You could also use a shift register inside the loop. When it is first run, you would get prompted and then it would use the file you select for the rest of the iterations. Here's a modified VI that uses a file path control. Also below is the place on the block diagram with the instructions. I don't have 8.0. Just 7.1 and 8.2/8.5 but I'm assuming the directions in 8.0 are the same as the directions in 7.1
Download All
0 Kudos
Message 4 of 7
(3,209 Views)
Thanks Dennis.  I will have about two hours to work on all this after class ends at 11:30.  I will post an update before I leave the lab for today. 

-Chris
0 Kudos
Message 5 of 7
(3,180 Views)
Thank you!  The only thing that is not working now, is the stopwatch.  It just records all zero's, or with a 1 for the last number.  I tried to pull the stopwatch out of the loop, but that just made the time go to zero for all values.  Heres a copy of some of the fake data taken, if anyone cares to see it.


-Chris
0 Kudos
Message 6 of 7
(3,176 Views)
Check the properties of the Elapsed Time function. Make sure you do not have it set to Automatically reset after time target.

Message Edited by Dennis Knutson on 09-17-2007 12:33 PM

0 Kudos
Message 7 of 7
(3,172 Views)