LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The vi below opens a new data file each time new data from the visa arrives. I want only one data file per logging period!

Solved!
Go to solution

The vi below opens a new data file each time new data from the visa arrives. I want only one data file per logging period!

 

Can someone bring me (Labview is new for me) to the good direction?

 

John

 

 

0 Kudos
Message 1 of 10
(3,343 Views)

Why don't you just create the file outside the loop right after you open the VISA session, and close the file at the end? That would seem to be a whole lot easier.

 

That subVI has a flaw: if you pass in a directory, rather than a file, it gets stuck in an infinite loop.

Message 3 of 10
(3,326 Views)

smercurio-fc,

 

file creation outside the loop and closing at the end doesn't give the possibility opening a new data file each time you stop and start the logging by the "save-to-file" toggle.

0 Kudos
Message 4 of 10
(3,321 Views)

Well, you hadn't defined what a "logging period" was. We can't read your mind. Smiley Wink

 

What I would do is the following:

  • Provide a path control on the front panel to specify the target directory. This should be restricted to the directory. Avoid hard-coding paths in code.
  • Provide a string control to specify the base name of the file to write.
  • Use a shift register in the main VI's loop to keep track of the current refnum, passing that into the subVI that creates the next filename. The subVI would determine whether to create a new file based on whether the input refnum is "Not A Refnum". If it's a valid refnum it knows a file has already been created, and it doesn't need to create one. If it's not a valid refnum then it can create the next file based on the target path and the base name, and the last file that exists in that directory. The subVI would not require a loop.
  • When the toggle gets flipped to False you close the file (assuming one has been opened), thereby nulling the refnum. This way when you next flip the toggle to True, you'll get a new file.
Message 5 of 10
(3,313 Views)

Help, due to my missing-labview-skills I didn't succeed in applying your hints. Using the shift register to keep track of the current refnum????? No doubts about your hints but it took me hours of puzzling... without result! Help!!

0 Kudos
Message 6 of 10
(3,278 Views)
Solution
Accepted by topic author Johnny45

See attached modification. I made one change to my suggestions and have the top-level VI check for the null refnum. See if it makes sense.

Download All
Message 7 of 10
(3,245 Views)

Smercurio_fc,

 

Your solution is very usefull for me. Thank you very much!!!

 

John

0 Kudos
Message 8 of 10
(3,231 Views)

Then if you could, please mark my answer as the solution, rather than your thank you note (though the thanks is appreciated).

 

You can unmark a solution using the Options menu at the right hand side along the message title.

Message 9 of 10
(3,218 Views)

Marking my answer to you as the solution was a mistake. I have corrected that and marked your input as the right one! Thanks again!

0 Kudos
Message 10 of 10
(3,181 Views)