LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Eliminate Recording Delay When Opening a New TDMS File

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?

0 Kudos
Message 1 of 8
(2,786 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 8
(2,779 Views)

Use the DAQmx logging property, it will write and configure file automatically for you, and it is gapless. No separate loops needed.

snip.png

 

 

mcduff

Message 3 of 8
(2,750 Views)

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.

0 Kudos
Message 4 of 8
(2,713 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 8
(2,707 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(2,694 Views)

Sorry, I probably should have done this from the start, but here is my original code that experienced the 50 ms gap in data collection between files in the first place. I used the DAQmx Configure Logging block to create new TDMS files, and log the data that is being generated by the waveform in the while loop to them. I only attempted to put the waveform generation and logging aspects of the code into separate loops after Mark's suggestion, but it seems that DAQmx Configure Logging is the most efficient solution. I also tried limiting TDMS files based on their file size instead of by time to eliminate the local variables in the while loop, and the subsequent TDMS files still didn't start in the same place the previous TDMS files ended at. Unless I'm missing something, I think the 50 ms gap is a speed limit on the computer's ability to stop logging to one file and create / start logging to the next file.  

0 Kudos
Message 7 of 8
(2,662 Views)

It would be better is you posted your solution as a snippet or VI.

 

The TDMS logging function is the most efficient.

 

Another suggestion, if you are analyzing your data, do it in a separate loop. I have no idea how fast the Harmonic Analysis VI runs, but that may be a limiting step in your loop. For example assume your data arrives every 100ms, this is hard wired into the DAQmx function, but your analysis take 150 ms, you will get behind.

 

Cheers,

mcduff

0 Kudos
Message 8 of 8
(2,655 Views)