LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to add date/time stamp to file name without time change creating new files

We have setup our application to save data once a trigger event occurs. We also need the date/time stamp as part of the file name. We used Format Date/Time String and concatenated it into the file name. It all works good, but as the time changes (seconds, minutes, etc.) it causes the Write to File to create a new file with the new filename. Is there a way to create the file and save/latch/buffer the time in the file name so that it doesn't create a new file for every second?
I've attached a shot of the relevant part of our VI. It's all in a big while loop. The data save is in a case/switch so that when it is triggered it starts saving. (The for loop is to split the data up
into 4 different files). Like I said, it all works except new files are created every second as the time changes instead of just putting it all in one file with the initial time in the file name.
0 Kudos
Message 1 of 17
(5,048 Views)
Change the logic to not feed the write function with a new name every time, but to get the time only the first time it is run. That first time you make the file names and hold them in a shift register e.g. The next time you just read the file names from the shift register.
0 Kudos
Message 2 of 17
(5,048 Views)
I need a loop in order to use a shift register. I cannot stop the outer while loop (because it would stop the hardware from collecting data), and I cannot add loops inside which bogs down the processor to where the app stops. I've attached a simpler version of my VI which illustrates the problem. While the button is pressed (the trigger) it should save the data (in this case just cycle numbers) into one file with the initial date/time. But, you can see that it creates 1 file/second. I tried using shift registers, but without adding extra loops I can't see how to do it. Thanks
0 Kudos
Message 3 of 17
(5,048 Views)
You've got a loop. The outer while loop would have the shift register. Running it the first time, the value in the shift register would be empty, so create the file name. Run it again and test for an emtpy path, and if it's not empty just pass the path name through.
0 Kudos
Message 4 of 17
(5,048 Views)
HI there!

It looks like you have your "append to file" enabled. I think if you switch that to false, it will take care of your problem. Once the file name is named, it can't change until it's closed..

Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 5 of 17
(4,808 Views)
Also if you had not had a loop what you do to get a shift register is to add a loop that has a stop condition wired to the conditional terminal so that it will only run once...(no loop, just a "container with a shift register").

By not initializing the left shift register terminal it will keep the previous value even if the VI is called repeatedly, just make sure the code inside the loop produces the first contents of the shift register the first time it's run.
0 Kudos
Message 6 of 17
(5,048 Views)
Thank you for posting an answer for me. However, if I change Append to false, then it just asks me repeatedly if I wish to replace the file instead of just continuosly adding the data to it.
0 Kudos
Message 7 of 17
(4,808 Views)
Thank you for posting an answer for me. If I initialize the loop it must be outside the while which means the next set of data (next trigger) has the same (initial) time/file name. If the time string is inside the loop it continues to change no matter how I try to set up the registers. If I push the trigger for a minute or so I should get I file with all the data named with that date/time. I need the loop to continue so that the next trigger creates a 2nd file with a new name. Now I'm getting seperate files for each second, because I can't figure out how to save the time for the trigger event.
0 Kudos
Message 8 of 17
(5,049 Views)
What you would want then is a shift register that holds the value of the trigger Boolean. If initially false, create the file name. Then the content of the shift register would be set to true and don't create the file name. In your false case, set it back to false so that the next time the trigger boolean is pressed, you get a new file name created.
0 Kudos
Message 9 of 17
(5,049 Views)
Here's the needed sub-VI
0 Kudos
Message 10 of 17
(4,809 Views)