LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it ok to write to the same TDMS file in two separate loops?

This worked fine when I tried it in version 8.5.1. When I changed to Version 8.6 I got errors. I have read this is possible and have been told it is not a good idea and that it is ok by different NI people. My point is to consolidate the number of data files that I create and allow all my logged data to be accessed from one file.

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

TDMS is designed to allow writing to the same file from two different loops (within the same application). You can use the same refnum or open two separate refnums, both should work. What kind of errors are you getting? Is there any way you can post a simple example VI that demonstrates the problem?

 

Herbert 

Message 2 of 8
(2,942 Views)
Thanks Herbert. I mainly wanted to make sure it was ok to do this as I had got several conflicting answers from NI tech support! I just switched the program back to 8.6. It has been a couple of weeks and I am not getting the same errors so perhaps it was something else I didn't understand at the time.
0 Kudos
Message 3 of 8
(2,924 Views)
Hello WindNRG,

The reason you received conflicting answers about “writing to the same file in two loops” is because it is possible, but has everything to do with how you plan to save the data. The problem with simply writing to the same file in two independent loops is that a conflict can occur when both attempt to write at the same moment. Data can be missed. The Learn LabVIEW section of ni.com is a great resource for these types of questions, and can help you implement the correct architecture for your application.

Have you looked at the Producer/Consumer design pattern VI that ships with LabVIEW? From the getting started screen select “More…” under New. Create a new VI “From Template” from the Frameworks>>Design Patterns tree. Select the Producer/Consumer Design Pattern best suited for your application.

I hope this helps 🙂
David G
Sales Engineer - SE Michigan & N Ohio
National Instruments
0 Kudos
Message 4 of 8
(2,911 Views)
I don't be

DjDaveNI wrote:
Hello WindNRG,

The reason you received conflicting answers about “writing to the same file in two loops” is because it is possible, but has everything to do with how you plan to save the data. The problem with simply writing to the same file in two independent loops is that a conflict can occur when both attempt to write at the same moment. Data can be missed. The Learn LabVIEW section of ni.com is a great resource for these types of questions, and can help you implement the correct architecture for your application.



I don't think a conflict can/should occur in this case at all. Producer/Consumer isn't really a bad idea in general, but it isn't necessary here, because it's safe (no data loss) to write to the same TDMS file from two loops. Hence Herbert's previous post. Just trying to avoid further confusion...

Jarrod S.
National Instruments
Message 5 of 8
(2,905 Views)
Maybe its just me, but it sounds like if you were writing to the same file from two seperate loops, wouldnt you be creating a race condition?
Cory K
Message 6 of 8
(2,890 Views)

It depends on what you're writing from the two loops to some extent. If Loop A writes only to group A of signals, and Loop B writes only to group B of signals, then it doesn't really matter at all that they're writing to the same file at the same time. Their changes don't conflict at all. There's no race condition there.

Jarrod S.
National Instruments
0 Kudos
Message 7 of 8
(2,869 Views)
I am writing to the same file from two separate loops and I am specifying different group names. This does appear to work and I have had no corrupted data. Thanks guys for the debate and clarification.
0 Kudos
Message 8 of 8
(2,848 Views)