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
(3,364 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
(3,357 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
(3,328 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
(3,291 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
(3,285 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
(3,272 View