Showing results for 
Search instead for 
Did you mean: 

Is this a bug or feature in Continuous Measurement and Logging (NI-DAQmx) LV2015


The built-in template for continuous measurement and logging (NI-DAQmx) template is a pretty impressive example of queued data acquisition.  However I ran into a problem whilst playing with it:

  1. In settings screen, set trigger to "Always Log"
  2. On main screen click "start", then "stop".  A TDMS file is created.
    Main Screen.PNG
  3. Change your DUT (in my example I was feeding a DC voltage source for testing)
  4. Click "start", then "stop".  A TDMS file is created.  
  5. Repeat steps (3) and (4)


However, now the beginning of the TDMS files after the first will have some data from the previous start/stop cycle.




I think the problem is with the Logging module. In Logging.lvlib:Logging Message, the Data Queue is not being flushed when the system is changing from the "Idle" state.  See my fix (flush the Data Queue) in the diagram below, stuffed into the left side of the "Idle" case.  It now behaves as I expected.  


So is this a bug or a feature of the template?



Logging Message Loop Fix.png



EDIT: Attached the final PNG as well, not sure why it is mucked up by forum software.

0 Kudos
Message 1 of 3

Hey mzaleski,

I've been looking into this. Looking through the code, when you click "Stop" from the Main Front Panel, eventually the Logging.lvlib:Flush Data to Log should eventually be called. This would flush the queue and write the last few elements to the TDMS file.


Since there is still some old data left when you restart acquisition, it appears that this last step of flushing and writing the last few data points never occurs. With the "Flush Queue" step that you added, this ensures the queue is flushed before acquisition begins again. However, you may be losing your last few data points here since they are only flushed from the queue, not flushed and written.


I'm still wokrking on tracing this further to determine how to ensure the Flush Data to Log File VI is called at all necessary points. I just wanted to give you a brief update.


Thanks for the information!



0 Kudos
Message 2 of 3

If I had to guess, I'd guess that the "bug" was in your Acquire routine in Acquisition.lvlib.  The Template itself looks fine -- when you push Stop, it sends a Stop message to the Acquisition Message Loop, which calls Stop Acquisition and puts nothing on the Data Queue.  It also sends Stop to the Logging Message Loop, which calls Flush Data to Log File, which flushes the Data Queue and writes it to the Log File, closing the file afterwards.  This seems logically correct.


The one thing that's missing in the Template is the actual code to acquire data.  I'm assuming you are not using the Dreaded DAQ Assistant (if you are, all bets are off -- don't combine an elementary "Even a Sales Guy Can Set This Up" Express VI (sorry, my prejudice is showing) with a (fairly) sophisicated Project Template that creates a multi-loop (five loops are shown on Main) Acquisition Template that allows logging to be turned on and off.  Why don't you attach the VIs in Acquisition.lvlib?  [The easiest way to do that is to compress the Acquisition folder that contains them all, and attach the resulting .ZIP file].


Bob Schor

Message 3 of 3