Showing results for 
Search instead for 
Did you mean: 

TDMS logging from multiple loops

Go to solution

TDMS logging from multiple loops

Hi All,


As part of thrust measurement system, I am have setup a VI to output PWM and log RPM, temperatures and power. I have grouped my read channels into different loops (mostly based on cards) and they output at rates from 10 Hz - 1 KHz. I am read trying to use TDMS advanced palletes to log this data together possibly in same .tdms file under different column headers but no success so far(as based on my reading so far it appears I need to use advanced TDMS than simple since I have mulpile data inputs). My questions are;

1. Can we use TDMS advanced  or standard version to log data from multiple loops ?

2. If so, whats the best way to setup this ? Do I setup "TDMS file open", "TDMS set file info" for each loop and first loop creates the file and rest just opens it OR should I just use this once and branch it to different loops ?


I had a success of logging 2-3 loops output to a single file with standard TDMS but when I added more loops it didn't work very well.  


I have attached a part of my VI where I am trying to get 2 loops to output the data to same file. 


PS: This is my first post, so please let me know if I can post additional info or use different board for this topic. 

0 Kudos
Message 1 of 6
Accepted by topic author AnandBiradar
11-17-2016 11:11 AM

Re: TDMS logging from multiple loops

What I like to do is have a seperate loop that does nothing but handle the logging.  It should be a Queued Message Handler, a variation of the Producer/Consumer.  So the idea is that you create a queue that the other loops can use to send the data to the logging loop.  You can go OOP if you want, but the simple solution is to make the data type of the queue a cluster with a string and a variant.  The string is used to tell what the data is and the variant actually holds the data.


Oh, and you can just use the simple TDMS functions.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 2 of 6
Accepted by topic author AnandBiradar
11-17-2016 11:11 AM

Re: TDMS logging from multiple loops

  1. Use the simple TDMS file functions, and only at a single "Consumer loop".
  2. You can have multiple Producer loops with different rates.
  3. Use the same Queue to enqueue data elements into the queue.
  4. Dequeue data at a single place, in your TDMS / consumer loop.
  5. Use separate group names to separate the data coming from the different producer loops.
Message 3 of 6

Re: TDMS logging from multiple loops

Using a proper QMH is just better, but here I show you the basic idea how to use Queue with variant data (this is just an example, lots of things need to be changed/improve/added!):


ProducerConsumerData 1_BD.png

0 Kudos
Message 4 of 6

Re: TDMS logging from multiple loops

Thank you all for your prompt responses, I actually recently learned about Producer/Consumer loops and working to integrate it. This is very interesting way and deffinietly seemed to be more efficient way of logging.


I ran my RPM measurement loop and setup logging. (due to some reason I don't see the producer Enqueue outputing and data, I am still working on debugging it, VI attached if you are curious)


And yes, it's much more easier to use simple TDMS functions.



0 Kudos
Message 5 of 6

Re: TDMS logging from multiple loops

Still many things to be improved/fixed in your VI, some hints:

  1. You have a Stop button outside of the top while loop. After your while loop start to run, this button value will be never read again. Think about data flow! Put this Stop button inside the top while loop! Either you can use this Channel to stop the bottom loop, but you could just simply stop the top while loop, and Release Queue. This will create an error in the TDMS loop what you can handle (see my example). So you even do not need that channel!
  2. You put a "Wait Until Next ms Multiple" with 1 sec value in your top while loop. Delete this, and instead configure the DAQmx read with explicite timing: DAQmx Timing VI before you enter the top While loop. So your DAQmx Read will work in a proper timed manner. See the DAQmx example VIs for hints...
  3. You have set a 10 mseconds timeout for the "Dequeue element" in the bottom loop. Delete this value! If not value specified, it takes the default one: -1. It means never time out! You do not want this Dequeue function to time out, you only want to log data when it is present!!!
  4. If you want to write a single double value to your TDMS file in your logging loop, just wire it through a build array function, to get a single element array. Now the TDMS Write will accept it. Delete that Initialize array function, it is just not needed! Do it like this:


0 Kudos
Message 6 of 6