LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

append data to tdms file

Problem vi attached below.

 

Here's what's currently happening. Each time I call this vi from a higher level vi, data that was previously wrote to the tdms file gets overwritten with the most recent data I'm trying to save to it.

 

From looking through the tdms functions panel and the forum, I don't see anything to append data. Does the group and/or channel names have to be different each time I call the vi?

 

What I would like to happen is for each data set to appear under the time/date it was saved at which clearly isn't happening at the moment.

 

Strokes

 

 

0 Kudos
Message 1 of 13
(6,569 Views)

Hi Strokes,

 

I'd have to get to my other development machine to open your VI because it's in LabVIEW 2010.  However, a couple quick notes for you:
 

  • you're using the "open" operation on the TDMS Open function (and not a create or replace option etc.) correct? 
     
  • depending on what you're doing, you may not need to close the file reference.  if your application just needs to keep it open and make a call to a subVI which performs write operations, you could maintain the open/close file reference outside your subVI (ex. using a shift register on a loop).
     
  • depending on how much you'll use that subVI, you may even consider wrapping the TMDS functionality you need into your own module, which would maintain the file reference and provide the options you needed - ex. open, write with options, flush, read with options, close.  the idea is that the module would use an uninitialized shift register to maintain the file reference for you.  you may even have it maintain an array of such things so you could call it in parallel multiple times to address multiple files.


Hope this helps!

 

Best,
JLS
Sixclear
Message 2 of 13
(6,550 Views)

Yes i do use the TDMS open function but can't see where this is causing a problem for me. I understand it is good practice to close the TDMS file after I'm finished writing to it, hence I close it...

 

Maintaining the file reference isn't an issue. I store it in a shift register in a higher level vi. 

 

While I'm grateful for your post it doesn't really address the problem i'm facing...

 

0 Kudos
Message 3 of 13
(6,543 Views)

When you open a TDMS file reference there is an option, indicating what you want to do. I don't know the default value, but you can change this to 'open or create', that will create the file if non-existent or will apend the data to the allready existing data-set.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 4 of 13
(6,540 Views)

Hi Strokes,

 

Yep, it sounds like you've covered the bases here.  Just in case, and to clarify, I was referring to the "operation" input to the TDMS Open VI being set to "Open" vs another option which may create or replace it.  But it sounds like you have that covered.

 

I have done this many times without issue, which is why I started out with the basics.  You definitely want to close the TDMS file when you're done with it, or any other file for that matter 😉  

 

I'm assuming you've done the usual troubleshooting - probing and/or running in highlight execution mode to make sure things are happening as you expect.  An error would certainly prevent writes as it propagates the error cluster, but as long as you're handling those gracefully you'll probably have seen that.

 

Viewing your code may help.  If you can save to an old 8.x flavor I can take a look on this machine (coding against it for a few projects requiring an older version currently...).  Or even quicker, just post a screenshot or two if things are relatively clean... that might bring something to light as well.

 

 

Best,
JLS
Sixclear
Message 5 of 13
(6,538 Views)

@TCPlomp wrote:

When you open a TDMS file reference there is an option, indicating what you want to do. I don't know the default value, but you can change this to 'open or create', that will create the file if non-existent or will apend the data to the allready existing data-set.

 

Ton


The default value is Open, but I wired an 'Open' constant to it just to be sure. The problem is data is not being appended, it's being overwritten.. and a new file isn't being created each time as far as I can tell.

0 Kudos
Message 6 of 13
(6,533 Views)

@jls wrote:

Hi Strokes,

 

Yep, it sounds like you've covered the bases here.  Just in case, and to clarify, I was referring to the "operation" input to the TDMS Open VI being set to "Open" vs another option which may create or replace it.  But it sounds like you have that covered.

 

I have done this many times without issue, which is why I started out with the basics.  You definitely want to close the TDMS file when you're done with it, or any other file for that matter 😉  

 

I'm assuming you've done the usual troubleshooting - probing and/or running in highlight execution mode to make sure things are happening as you expect.  An error would certainly prevent writes as it propagates the error cluster, but as long as you're handling those gracefully you'll probably have seen that.

 

Viewing your code may help.  If you can save to an old 8.x flavor I can take a look on this machine (coding against it for a few projects requiring an older version currently...).  Or even quicker, just post a screenshot or two if things are relatively clean... that might bring something to light as well.

 

 


It's probably something silly which no doubt will be pointed out to me... I won't be able to upload any more code or even screenshots as I'm not running labVIEW on my laptop and won't have access to my computer until tomorrow. Hopefully someone comes along with a suggestion before then but if not i'll post more info tomorrow.

0 Kudos
Message 7 of 13
(6,531 Views)

Sounds good - I'll definitely chime in again if something hits me on this.  Otherwise we'll look for an update tomorrow.

 

Hopefully, as you said, it'll get solved in the interim 🙂

 

 

Best,
JLS
Sixclear
0 Kudos
Message 8 of 13
(6,529 Views)

@jls wrote:

Sounds good - I'll definitely chime in again if something hits me on this.  Otherwise we'll look for an update tomorrow.

 

Hopefully, as you said, it'll get solved in the interim 🙂

 

 


Ok here's a bit of an update...

 

When I leave the vi running and perform numerous write tdms operations, data gets appended to the file fine...

 

However, when I abort execution of the vi and run it again and try to write to the same file, old data gets overwrote by new data even though I specifically set the tdms open function operation to 'Open'

 

I'm not sure if posting code would be helpful as I'm using the jki state machine which I presume a lot people don't have installed.

0 Kudos
Message 9 of 13
(6,509 Views)

Hi Stokes,

 

Another thought came to mind - timestamps.  I'm wondering if overlapping (or perhaps using a data structure which doesn't include) timestamps could be a factor here.

 

If you're taking data straight from the DAQ API in waveform format, for example, the timestamp should take into account the current date/time (i.e. will be different on each run) - we would expect it to append new data even on independent runs of the VI.  

 

However, if you're managing data as DBL arrays or similar, this could be the scent trail to follow as there may not be an explicit timestamp.  This could cause a new run (i.e. new file open) to view data at a "default" or without a timestamp and just overwrite previously written data (which was also written the same way).

 

How does that ring (or not) with your code?

 

We'll keep trying 🙂

 

 

Best,
JLS
Sixclear
Message 10 of 13
(6,499 Views)