01-26-2018 03:06 PM
I am currently working on a program that continuously logs waveform data and writes the data to multiple TDMS files. Data is written to each TDMS file for a user-specified amount of time before a new file is created and data is written to it for the same amount of time. This process continues indefinitely. The problem I am having is that in the time it takes to stop recording to one file + create and start writing to the next file, I am losing about 50 milliseconds worth of data. Is there any way I can create a new TDMS file and have it pick up immediately where the previous file left off?
01-26-2018 03:20 PM
Separate your file operations from your data acquisition. Put the code to write the TDMS file into a separate loop and use a queue (or channel wire in the most recent versions of LV) to transfer the data from the data acquisition loop to the logging loop. That way the time required to open a new file will not impact your data acquisition.
01-26-2018 05:33 PM
Use the DAQmx logging property, it will write and configure file automatically for you, and it is gapless. No separate loops needed.
mcduff
01-29-2018 12:54 PM
Hello Mark,
I took your advice and attempted to separate the data acquisition and TDMS logging portions of the code into separate loops. I saw an example on how to use queues to transfer data between the two loops, so I attempted to implement that into my code. However, when I did this, the data I was acquiring from my waveform graph was not being written to the TDMS files I was creating. Do you see where I went wrong? I attached a picture of the trouble area of my code for reference.
01-29-2018 01:03 PM
You are constantly creating the TDMS file. Create the file once (or on some specific file size or time). You are starting with a new file every time you write data to it.
01-29-2018 01:28 PM
Other than the constantly creating a file as Mark already stated...
1. DO NOT put a wait in your logging loop. You need that loop to run as fast as the data is coming in.
2. Instead of using local variables to stop your logging loop, send a command through the queue telling it that there is no more data to log. You can miss a bunch of data if the file falls behind.
3. As mcduff already stated, it will be A LOT easier if you just use the DAQmx Configure Logging. This will tell DAQmx to log the data straight to a TDMS file, avoiding many layers of software. This will greatly help your performance and eliminate the need for the logging loop.