04-04-2013 02:11 AM
Hi, I have build a vi which writes measured data to file every second. This vi will be used for long term data acquisition and I want to write the data to a separate file every day, else the file becomes
very large. The vi is supposed to work as follows, first set the folder to save to and then start logging with the "datalogon"button, first write the column names to the file and after that write the data
every second. If the date is the same log the data, if the date is not the same write to new filename, write the column headers and write the data again every second.As file name the date is used.
This is working pretty good only at the start of the vi I get the message "Error 1 occurred at Open/Create/Replace File in Write Spreadsheet String.vi->Write To Spreadsheet File (string).vi->RNH-
SerialDaq-03APR2013.vi. I have done some test and it seems that in the first or second run of the loop the appended path is "file name:\" and not drive:\ and this seems to be caused by the fact
that I first write the column headers and second the data (if I only write the data the problem does not occur).
So I (think) to now what the problems is but don not know how to solve it, I would appreciate it if someone could help me with this.
Kind regards, Martin
Solved! Go to Solution.
04-04-2013 04:11 AM
Please wire the shift register through the false case as well and try.
04-04-2013 01:37 PM
Hello .aCe, unfortunately that doesn't solve the issue. I get the same error.
04-04-2013 01:52 PM
I have done some test and it seems that in the first or second run of the loop the appended path is "file name:\" and not drive:\ and this seems to be caused by the fact
that I first write the column headers and second the data (if I only write the data the problem does not occur).
Does the loop work fine if you write data repeatedly? or is it just the first write that works? (this could indicate problems with how fast you are accessing the file). Every second seems excessive to me. I would store 30sec to 1min of data in an array and write it to the file in larger time intervals.
you clearly mention that the file path is incorrect. Make sure you are building it correctly (use the Build Path vi from the File I/O pallete to reduce human errors). You can use a relative path by using the "Current VI path" along with Strip and Build Path vis.
04-04-2013 02:15 PM
It's working fine for me. The two things I changed was wired the path from the shift register through the false case (when NOT logging) and initialized the shift register to the input path folder.
04-04-2013 04:01 PM
I have made the modification you mentioned and to my surprise I got the error message and also with the vi you have sent, I have taken a closer look at this and found that:
- if I first enter the "folder to save file to", then run the vi and then hit the "data log on" I do not get the error.
- if I first run the vi, then enter the "folder to save file to"and the hit the "data log on"I do get the error.
I also tried this with the original vi (without the shiftregister connection in the false case and the init for the shift) and that gives the same result as above. Further if i get the
error message and choose stop the vi, start the vi again I don't get the error because folder to save file to is entered. This issue only seems to appear when there is no "folder
to save file to"in the dialog box.
While Im writing this I realize that "folder to save file to" is outside the while loop so only executed when the vi is started maybe I have to put it inside the while loop? Tried
this and at first it seems the issue is solved, I do not get the error message on my screen but it still appears on the error handler in an other part of the vi (visa serial).
Ah, got it. The "visa resource name" and "folder to save file to"are both outside a while loop and are only read when the vi starts, at that moment they do not have a valid
value so the error is generated.
Issue solved, thank you al for your input!
Best regards, Martin