04-06-2017 08:43 AM
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.
Solved! Go to Solution.
04-06-2017 09:00 AM - edited 04-06-2017 09:02 AM
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.
04-06-2017 09:17 AM
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.
04-06-2017 09:45 AM - edited 04-06-2017 10:12 AM
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)
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:
I 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.
Close the files (I also reset my watthour meters) and go to the Open Daily Files state and start over.
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.
04-06-2017 11:04 AM
Oh yeah, here is how I generate a filename that contains the day and date.
It's output looks like this:
04-06-2017 12:16 PM - edited 04-06-2017 12:39 PM
@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.
04-06-2017 12:25 PM - edited 04-06-2017 12:41 PM
@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)
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:
I 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.
Close the files (I also reset my watthour meters) and go to the Open Daily Files state and start over.
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?
04-06-2017 12:26 PM
DON'T count the number of seconds for an entire day, that's just silly.
Keep track of the Day of The Year.
Close the current file and make a new one when the Day of The Year changes (is NOT equal)
04-06-2017 12:30 PM - edited 04-06-2017 12:40 PM
@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.
04-06-2017 12:38 PM
@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.
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, ???