06-04-2009 04:28 PM
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
Solved! Go to Solution.
06-04-2009 05:44 PM
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.
06-04-2009 06:15 PM
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!
06-05-2009 10:24 AM
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.