07-10-2010 05:56 PM
I have written a data logging VI to get data from a DAQ, then write it to a spreadsheet. This worked fine. What I am trying to do now and am having trouble is to place that vi within a while loop that will automatically write a new file name after the For-loop finishes its iterations. In a text based program when the for loop finished I would just send it back to the while loop for it to write the new file name and then execute the for loop data collection and spreadsheet writing iterations. Below is the general outline of the operations of the program.
Establish file name and path based on while loop iteration (eventually this will be the current date and time)
run for loop for specified iterations:
read DAQ
write data into .csv spreadsheet
When specified iterations are over:
writley new file name
run for loop again
repeat until stop is pressed
What is actually happening is the file name and path are established, the for loop runs through its iterations but only writes the last set of data and then the program stops.
any ideas? Program attached
Solved! Go to Solution.
07-10-2010 06:57 PM
Don't know about the program stopping. I replaced the methods with a random number generator and everything seemed work okay after setting the Write to Spreadsheet to append instead of creating a new file each time.
p.s. cleaned the wiring to make it readable - neatness counts.
07-11-2010 10:53 AM
Dennis,
Much nicer, thanks. I had a couple problems there. Append to file was critical for writing to the same file each time the loop iterated. The rest was a little structure and house cleaning. The diagram looks much more easy to read.
That is basically what I needed to do. Eventually I would like to write a new file each day so I think I would need to change the number of loop iterations to a while loop that stops when the date changes.
Thanks so much for the help!
07-11-2010 12:16 PM
I tidied it a little further and compressed the wiring, no use to read those channels one by one and then convert one by one, those things always belong in a loop. 😉
(and i like tight vi's, feels less bloated and more to the point ... more C# (if you forgive my textbased referrence))
/Y
07-11-2010 12:59 PM
07-11-2010 03:39 PM
That's even better. Works like a charm and much more elegant than my original code. Didn't know about the digital out from the chart. Makes sense.
Now I just need to get it to write a new file each day. I have been looking at some of the posts here and trying to understand how to adapt example to my purpose.
Thanks to all of you for your help. This site is an amazing resource. I would have banged my head against the wall for days to achieve this.