LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Spreasheet File Question

Solved!
Go to solution

Hi Guys. I've actually got a couple of questions as to the most effective way of doing a couple of things. The purpose of this VI is to gather a voltage every so many seconds as determined by the user and then plot the voltage vs the time it was taken. Also i want to record all of these into a text file.

 

As of right now it works quite well but i'm not sure if graphing my functions as i have them (dropping the voltage and time values into an array and using build xy graph with the arrays as the inputs) is the best way to do it. Because i'm only taking data every ~5 seconds max will the array sized ever become an issue? I might run the program for a period of ~24 hours so  that's 17280 values in the array by the end of the day. 

 

I'm also having a problem with how the values are saved in the spreadsheet file. How i have it set up now the values are appended to the current file which is not a problem. However they are not seperated by anything so when i open the txt file they are in the same column. I know i need to put something inbetween them such as a tab or comma for excel to put them in different columns. What's the best way to do that with numbers? Before i've just converted them to strings then concatenated a tab/comma to the end of the data point then reconverted back to a number but it seems like there must be an easier way to do this.

 

Any other random comments on streamlining etc my code is appreciated:)

 

Thanks!

 

Mark

0 Kudos
Message 1 of 4
(2,789 Views)

To answer your specific question regarding the array size being an issue: Eventually yes, it will be if the program just keeps growing the array. 17,280 values isn't really that much unless you have a pittance amount of memory. Does the graph need to show all data taken, or, say, just the last hour or something?

 

As to your code: A few comments. Smiley Wink

  • That is not a good design structure. You should not place data acquisition stuff or anything that may take a long time in an event structure. As it is, if someone uses a large value for the time between measurements then you are forced to wait that long before the event structure can respond to a new event.  A much better approach is a producer-consumer architecture.
  • You are thinking too "text-based". It appears based on the way you've coded that you have a background in text-based programming. "Sequencitis" and "local variablitis". None of your local variables are required, and the sequence frame just hides code. You can use a shift register to carry around your arrays. 
  • You are feeding in a comma as the delimiter for your columns, so that should not be a problem. However, if you are trying to open this with Excel by double-clicking the file from the file system (i.e., you give it a .xls extension so you can double-click it) then Excel will not automatically parse this as a delimited text file. You have to use the File->Open command in Excel. If you use a tab as a delimiter then it's less of an issue.
Message 2 of 4
(2,767 Views)

Thanks for the comments smercurio!

 

I guess i won't worry about the array getting too large for this then at the moment... but i might as well figure it out so i know anyway! I'm guessing one solution would just be to pick out a certain part of the array ie the last 1000 data points and plot them instead of plotting the entire thing? If i did want to plot the entire time i'm guessing there is a way to skip data points, ie a for loop and just take every nth point and drop it into a new array. Shouldn't be to hard. 

 

Thanks for the additional comments. My only programming experience besides my past week with labview is definitely "text" based. Shift registers do seem like a nicer approach than calling the local variable each time. 

 

As for the producer consumer approach i'm guessing that i would simply put the DAQ assistant in it's own sequence that takes a data point every x seconds while the graphing/writing/etc is it's own loop. 🙂 Looks like a much more viable approach.

 

One last thing:) I wasn't very clear on the delimitter problem. I want to actually insert a delimiter inbetween the two arrays, not just after them. So right now they are being put into one array together. Voltage then below it Time. I want a delimiter between the voltage and time so that when the file opens Voltage appears in one column and Time appears in the next. Then have the file drop down a row and repeat Voltage | Time. So i think i still need a way to append something to the voltage or perhaps insert an ascii value between them that will work as a delimmiter? 

 

Thanks again!

0 Kudos
Message 3 of 4
(2,762 Views)
Solution
Accepted by topic author Mark.E

Mark.E wrote:

As for the producer consumer approach i'm guessing that i would simply put the DAQ assistant in it's own sequence that takes a data point every x seconds while the graphing/writing/etc is it's own loop. 🙂 Looks like a much more viable approach.


I wasn't suggesting to put the DAQ assistant into its own sequence. In a producer-consumer architecture the consumer is typically (though not always) a state machine. The state machine gives you far more flexibility than a rigid sequence structure.

 


Mark.E wrote:

Thanks for the comments smercurio!

 

One last thing:) I wasn't very clear on the delimitter problem. I want to actually insert a delimiter inbetween the two arrays, not just after them. So right now they are being put into one array together. Voltage then below it Time. I want a delimiter between the voltage and time so that when the file opens Voltage appears in one column and Time appears in the next. Then have the file drop down a row and repeat Voltage | Time. So i think i still need a way to append something to the voltage or perhaps insert an ascii value between them that will work as a delimmiter? 


Your problem is that you are wiring to the 1D array input of the Write to Spreadsheet File. I had not spotted this when first looking at your VI. The Build Array that's creating the array for the Write to Spreadsheet File should have the "Concatenate Inputs" option unchecked, and you should be feeding the data to the 2D array input of the Write to Spreadsheet File function.

Message 4 of 4
(2,721 Views)