From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open new TDMS and write into it during running

Hello!

 

I have a project when I save to TDMS file. I would like to add a button, which would open a new file and continue to write into it.

My idea is:

Event structure to handle the "new file"  button. When I press the button, a new state would come to a state machine, in which I close the previous file and open the new one, and then go back to the "save" state.

It works until the new file is created, and I get back to the saving state, and one record is saved into the file. After it seems, that I lose the reference and the program writes to the memory. So when I stop the program only 1 record what I can see in the new file, the old (first) file is ok.

Any idea why can this happen?

 

Thank you in advance!

0 Kudos
Message 1 of 3
(2,257 Views)

Hi,

 

Use any structure that can losslessly store your measurement data, specifically I recommend queues, typically used in a producer-consumer architecture. You already have a state machine, so you can use the state machine loop as the consumer loop to write data from a queue to the TDMS. Add the data source as a separate, parallel loop that acquires your measurement data, and puts it in the queue. This way, even if your state machine is busy doing other things such as opening or closing TDMS files, your data does not get lost.

 

Note that what I mean above is NOT necessarily the Queued State Machine Architecture. In QSM the she state machine transitions are stored in a queue, however in my recommendation above, the queue is independent of the state machine.

 

If you have further questions, it would be great if we could take a look at your code, maybe there is some simpler issue with the way your are using the TDMS VI-s.

Best Regards,
T Simon
National Instruments
Applications Engineer
Certified LabVIEW Developer - Certified TestStand Architect
0 Kudos
Message 2 of 3
(2,218 Views)

I just can't get it work 😕 I attached the VI-s. I read the channel/group names from the csv files attached, so you have to set the paths for them.

0 Kudos
Message 3 of 3
(2,169 Views)