01-14-2016 10:04 AM - edited 01-14-2016 10:31 AM
Hi
I'm trying to write a program where I log values that I measure and send to a host VI as network published shared variables
I'm looking for the following end result
- First column displays time
- Second column displays measurement signal nr 1
- Third column displays measurement signal nr 2
- Fourth column displays measurement signal nr 3
- Etc
I'm a bit confused as to how to work with the the TDMS write function, and I'm currently just getting all measurements and the time stamp in one single column
Also, I'm trying to figure out how to automatically name each log file according to the date; for example: 01/14-Data, 01/15-Data, etc and have a functionality that auomtiatcally creates a new file each time the program is run, for example:
01/14-Data1
01/14-Data2
01/14-Data3, etc
Any advice?
Screenshot of code and the VI are attached
Thanks
Solved! Go to Solution.
01-14-2016 10:31 AM - edited 01-14-2016 10:36 AM
I haven't used TDMS files, but I found an example that came with LabVIEW. I wanted to learn a little myself, so I edited your VI. You can see if it's useful 🙂
01-14-2016 10:34 AM
To make a file name, just use the Build Path VI
01-14-2016 10:36 AM
Wow, thanks! This is perfect
Also, is it possible to add data to an existing file, without loosing the old recordings?
Thanks
01-14-2016 10:38 AM
Yes, open it using "Open or Create"
01-14-2016 10:45 AM
Thanks!
01-14-2016 11:04 AM
What is the name of the symbol between the build path and date/filename string?
01-14-2016 11:07 AM
It's Format Date/Time String. If you have LV 2014 or higher you can drag that picture right onto the block diagram and it will make code for you. Unless you're using firefox like me, then you have to drag it to the desktop, and then from the desktop into your block diagram 🙂
01-14-2016 12:01 PM
@Gregory wrote:
I haven't used TDMS files, but I found an example that came with LabVIEW. I wanted to learn a little myself, so I edited your VI. You can see if it's useful 🙂
There isn't anything inherently wrong with how you're doing it. But TDMS can become quite fragmented if you are writing one sample at a time the way you are. Here's an article on file fragmentation:
https://decibel.ni.com/content/docs/DOC-20522
Basically a TDMS file has the binary data stored in it, and some XML like data that keeps track of where the data is (the index). This is sorta like a database, and then come cached information about where offsets are, so that reading and writing can happen faster. If we change how we write the data so we are writing more data, and use less Write functions, the file will be less fragmented, and the index data will be smaller, making reading the data faster too. That means writing N channels in one write function, or writing N samples, or a combination with multiple channels and samples at once. Attached is two improved versions which either write all channels at once, or all channels and 50 samples at a time.
Keep in mind to use a single write for N channels, those channels all need to be of the same data type. Luckily the order of the channels is based on the first time the channels are written to. So in the past I had a column of a numeric, then a column of a string repeated 10 times. I could write all the doubles with one write, then all the strings and the order in the file was based on the first write (or setting of properties).
There's a ton of other great information on TDMS and why it is amazing for fast writes, but to keep read times down, and file size down, you need to consider how the data is being written. Oh and then knowing what types of properties to set, so that looking up the data later can be done faster. Using DataFinder or Diadem you can setup a query like: Find all Files created after this date, where the serial number of the part is 123 and the test failed, while on nest location 2.
Many of these types of TDMS tips, or features are not inline with how most programmers think of making text or CSV files, which might be why adopting TDMS can be difficult. If you treat a TDMS file like a text file, you're gonna have a bad time, and...
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-14-2016 12:06 PM - edited 01-14-2016 12:11 PM
Edit: got it working!
Thanks for the details and alternative solution!