LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flushing TDMS file without creating delay

Solved!
Go to solution

I have a problem where my datalogger has to run for extended periods of time (days).

To prevent loss of data in case of computer crash, I would like to flush the data into to TDMS once every 15 min.

 

The problem i have is that every thing I have tried so far results in a increasing delay between real time and the latest sample (the logger lags behind).

After 3 days of logging its about 10 mins deviation.

 

The file takes a starttime, and number of samples and multiplies it with dealy between samples to get supposed time and date.

I'm assuming it skips a few samples every time it saves the file and therefore it won't have enough samples.

 

So far I've tried closing and opening a new reference, flushing, flushing in a seperate vi parallell to the main vi.

 

If anyone has any experience in this I would be glad to know if there are any tricks to this.

0 Kudos
Message 1 of 9
(3,038 Views)
Solution
Accepted by topic author LarsAlmås

So what I'd recommend to you is to do as you are, defragging periodically, until the file size, or defrag time increases to some specified amount which will likely vary for you.  Like for instance lets say you keep defragging the file, but once the file is 24 hours old, make a new file.

 

Then after another 24 hours make a new file, and continue this until the test is done.  Then you will have one file for every 24 hours, and you can then use the TDMS merge functionality to combine them.  I presented on TDMS at NI Week 2016, but also updated the presentation and shared it here.  Slide 13 talks about a buffering technique where new files are created, then sent away for processing until all files are done which might be useful to look into.

Message 2 of 9
(3,010 Views)

I get a page error when I try to open your presentation

0 Kudos
Message 3 of 9
(1,567 Views)

Are you using a producer/consumer design pattern?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 9
(1,556 Views)

It sounds to me like you're running the acquisition and logging steps in the same loop.

I'd suggest the following:

  • Upload your code so we can make better/more targeted recommendations
  • If you are logging in the same loop as acquiring, use instead the Producer/Consumer design suggested by Bill

By separating the acquiring from logging steps, you won't have delays in the latter cause problems for the former.

 

You can also consider trying to get a "real" timestamp from the acquisition step, possibly by using Tick Count or Get Date/Time in Seconds, depending on accuracy requirements. This might improve the options you have to satisfy your goals (maybe, depending on your goals 😉 )


GCentral
0 Kudos
Message 5 of 9
(1,533 Views)

@charlieallanp wrote:

I get a page error when I try to open your presentation


That is a real shame.  It seems like the Rocket City LabVIEW user group has disappeared.  I can't remember if they recorded it or if I only had my slides.  Attached are my slides from that presentation, along with the demos I showed.  Probably 80% of it is the same as the NI Week presentation.

Message 6 of 9
(1,511 Views)

We went with a solution along the lines of Hooovahh's suggestion back when this post was created. 
Going to mark this as the answer as this was solved some years ago and I had completely forgotten about the post. 

0 Kudos
Message 7 of 9
(1,504 Views)

Oh and one other thing I forgot to add.  Since making that post I released the Tremendous TDMS Toolkit on VIPM.IO.  Here is a youtube video demonstrating it.  It has several functions like new file size and frequency, among other things..

0 Kudos
Message 8 of 9
(1,492 Views)

Thanks, I found the site (VIPM) but neither the download or install buttons work.

0 Kudos
Message 9 of 9
(1,481 Views)