LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic save and create new file everyday

Solved!
Go to solution

Hye, using LabVIEW 2013 for my final project, I creating VI which to monitor and collect 3 data(light, humidity and temperature). The front panel will always show the current reading of 3 data every 1 second. Then at the same time, the VI also will create TDMS file to record the data every 1 minute. The tdms file can only be open/view after the VI stop. So the program need to stop to read the data log in the tdms file.

 

But can anyone help how to adjust this program as, for example I running this program for 2 days without stop. So I want to make this program able to create new file without deleted the previous one when entering the new day And also without stop the VI.

 

I provide the VI below with images and also the tdms excel file.

 

a1.JPG 

a2.JPG

 

a3.JPG

0 Kudos
Message 1 of 19
(8,619 Views)

Use the current date as the filename (20170406.tdms for example).  If file exists, append the data.  If it doesn't exist, create a new file.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 19
(8,603 Views)

I think I added something close to what you want. I didn't test it. But you've gotta do some work, right?

 

Mostly, I used shift registers which save data across iterations of a loop. Since your original code didn't use any, perhaps they are new to you. I also used some of the strip and build path functions which might be new to you as well.

 

This should be saved for 2013. Lemme know what you think.

Message 3 of 19
(8,594 Views)

I am not sure why you are using a TDMS file for a one minute sample rate, seems like a little over kill when a simple TAB delimited text file would do.

 

Tab delimited text files import into Excel very easily, and if you do it right LabVIEW will lock the file so it can be viewed read only while the program is running.  

 

I recently wrote a program to monitor a grid tie solar inverter that generate three daily data files. One for the inverter, one on the individual batteries in the battery pack, and one with current weather conditions at 10 second intervals.

 

It looks complicated so bear with me, the overall concept is really quite simple.

 

First I generate file names that include the day and date, open the daily file and put the header text on the top row. (I actually open three separate data files)

sb1.PNG

Notice I keep track of the day of the year (and day of the week but that's for something else)

 

Inside one of the Header vi's it looks like this:

SB2.PNGI open a file and pass the File Reference to the write text vi, where I write my headers, and the pass the File Reference out. Opening a file this way and passing the reference makes it so the file is locked as long as LabVIEW has it open. So you can only open the file Read Only allowing LabVIEW to continue to write to the file while you are viewing it.

 

In my timer state I also check the day of the year, if it has changed then I instantly go to the the Close Daily Files state instead of taking measurements.

sb3.PNG

 

Close the files (I also reset my watthour meters) and go to the Open Daily Files state and start over. 

SB4.PNG

Once a week I run the Create Weekly Files, that takes all three daily data files for the entire week and zips them into one file.

========================
=== Engineer Ambiguously ===
========================
Message 4 of 19
(8,579 Views)

Oh yeah, here is how I generate a filename that contains the day and date.

 

filenames.png

It's output looks like this:

filenames2.png

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 19
(8,546 Views)

@majoris wrote:

I think I added something close to what you want. I didn't test it. But you've gotta do some work, right?

 

Mostly, I used shift registers which save data across iterations of a loop. Since your original code didn't use any, perhaps they are new to you. I also used some of the strip and build path functions which might be new to you as well.

 

This should be saved for 2013. Lemme know what you think.


Thanks for trying, BUT your code did not work, for sure I cannot wait 2 day time long to see if 2 file can be generate, so I adjust the value in 1 day in second(86400) to 10 second(10000), so every 10 second new file will be generated without replacing the old file. Worry about the same name of file so I add the second value into my file name(%S%d-%m-%Y). I also adjust value of data collection from 1minute to 1 second.  Overall the program should be :

1. Generated file.

2. Collect data every 1 second and store to tdms file.

3. Every 10 second new file be created with difference name because of time difference. 

 

But this do not work, maybe you can help me again??? Im posting the VI adjust according to new condition state up here. 

0 Kudos
Message 6 of 19
(8,539 Views)

@RTSLVU wrote:

I am not sure why you are using a TDMS file for a one minute sample rate, seems like a little over kill when a simple TAB delimited text file would do.

 

Tab delimited text files import into Excel very easily, and if you do it right LabVIEW will lock the file so it can be viewed read only while the program is running.  

 

I recently wrote a program to monitor a grid tie solar inverter that generate three daily data files. One for the inverter, one on the individual batteries in the battery pack, and one with current weather conditions at 10 second intervals.

 

It looks complicated so bear with me, the overall concept is really quite simple.

 

First I generate file names that include the day and date, open the daily file and put the header text on the top row. (I actually open three separate data files)

sb1.PNG

Notice I keep track of the day of the year (and day of the week but that's for something else)

 

Inside one of the Header vi's it looks like this:

SB2.PNGI open a file and pass the File Reference to the write text vi, where I write my headers, and the pass the File Reference out. Opening a file this way and passing the reference makes it so the file is locked as long as LabVIEW has it open. So you can only open the file Read Only allowing LabVIEW to continue to write to the file while you are viewing it.

 

In my timer state I also check the day of the year, if it has changed then I instantly go to the the Close Daily Files state instead of taking measurements.

sb3.PNG

 

Close the files (I also reset my watthour meters) and go to the Open Daily Files state and start over. 

SB4.PNG

Once a week I run the Create Weekly Files, that takes all three daily data files for the entire week and zips them into one file.


I try many methods before TDMS file, but not work. Only found this method work as long as 2 day.  For your method, seem like similar what are we doing, collecting 3 data, and store it as file. But to do back my coding just like u maybe take a long time  to me to make it work because Im a just beginner with Labview software, do you have any VI attachment so I can adjust it from there?

0 Kudos
Message 7 of 19
(8,529 Views)

DON'T count the number of seconds for an entire day, that's just silly.

 

Keep track of the Day of The Year.

doy.png

Close the current file and make a new one when the Day of The Year changes (is NOT equal)

 

========================
=== Engineer Ambiguously ===
========================
Message 8 of 19
(8,529 Views)

@aputman wrote:

Use the current date as the filename (20170406.tdms for example).  If file exists, append the data.  If it doesn't exist, create a new file.


As you see my code already implement that one u mention, file name will be save according to date. But like I want the automatically write new file without deleting previous one. 

0 Kudos
Message 9 of 19
(8,523 Views)

@RTSLVU wrote:

DON'T count the number of seconds for an entire day, that's just silly.

 

Keep track of the Day of The Year.

doy.png

Close the current file and make a new one when the Day of The Year changes (is NOT equal)

 


I really dont know how to adjust it, ???

0 Kudos
Message 10 of 19
(8,515 Views)