Example Code

Multiple Producer/ Consumer DAQ, Processing, & Display

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

This VI works to display a lot of channels of data while acquiring it, doing some processing, and writing it all to file.

Description

Sometimes, you are needing to display a lot of channels of data while acquiring it, doing some processing, and writing it all to file.  To do it all smoothly is occasionally a bit of a challenge if you are new to LabVIEW.   This is one way that multiple tasks can be acquired, different processing steps run, and different displays updated, all while logging to file.

This project is made up of a couple of producer/ consumer chains.  The acquisition is done in one loop, processing done in a second loop, display in a third, and logging in a fourth.

It works a bit like this at a high level.  A Queue is used to pass the raw data to the Analysis loop.  That is used to make sure every value is passed.  Then, things such as FFTs are computed.  A copy of that data is given to an Notifier, so the display loop can grab and display the current data without having to worry about catching every value.  Also, it comes at this point so things like FFTs can be displayed.  Finally, a queue is also used to pass the processed data to a logging loop where it is written to TDMS format. 

There are two important caveats.  First is that an eye should be kept on the queue sizes.  They should stay bounded, and not increase without limit.  If that happens, the limit will be reached when LabVIEW runs out of RAM and your program crashes.  If your processing is slower than your acquisition, then you should simpy keep an eye on the length of your test.  

The second caveat is making sure the queues empty before aborting the program.  That lets the second loop work through the backlog and not lose data before shutting down.  That is the purpose of the two small loops on the right - they wait until the queue is empty before releasing them. 

In the Processing section, any number of things could take place.  Likewise in the Display.  You could have Safe/Unsafe indicators that light up when a value crosses a threshold, for example.  But anything that happens in this loop will happen less often and will also not get logged.  You should also remember that this is post-processing data, so the displays will not be live if the Analysis Queue size is large.

 

Requirements

Software

  • LabVIEW 2012 or compatible
  • NI-DAQmx 9.5.5 or compatible

Hardware

  • NI Multifunction DAQ Device

 

Steps to Implement or Execute Code

  1. Configure the file name and save type.
  2. Connect your hardware appropriately.
  3. Run the VI.

 

Additional Information or References

 

DAQ process display log.png

 

Block Diagram:

 

DAQ process display log BD.png

 

Front Panel:

DAQ process display log FP.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
punk
Member
Member
on

Hi. Looks really useful, but could you release a labview 2011 version?

mantoles
Member
Member
on

thank you for making this available. It gives me a general idea how to approach my project.  I tried running the program but I am missing the clearAllErrors_ogtk.vi

Thanks,

Sophronis Mantoles

User002
Not applicable
on

mantoles:

That VI is in the free Open G toolkit from the LabVIEW Tools Network.  The Clear Errors VI will also work.  The only thing it is doing in that place is clearing all of the errors.

mantoles
Member
Member
on

Got it,

Thanks!!

Crtomir
Member
Member
on

Excelent, a very effective and simple template for high speed data aquisition. Just a question, do you think there is a diffrence if you pass to queue, cluster data or just pure array data ? Is passing a cluster more demanding on the software than just arrays?

User002
Not applicable
on

That is a great question - it would have to be answered with a benchmark.  I simply don't know.  I would expect array and cluster performance to be similar in this respect, though.

In C, arrays and structs (the cluster equivalent) are represented similarly enough in binary - they are both consecutive memory where subsets corresponds to different elements.  While I'm not brushed up on the latest way the compiler in LabVIEW handles these things, I would expect them to be similar from a performance perspective.

DeltaVUzay
Member
Member
on

Dear Andrew,

 

I'm having a problem while running my case. While running the code some of charts does not get a value and when I stop the code I get an error. Error code is 50103. "Possible reason: The specified resource is reserved. The operation could not be completed as specified." 

 

I checked the error code and in here, I have found the explanation in case 4.

My system is NI cDAQ-9189 and using Labview 2017. At below you can see created task.

 

Would you have some comments on that problem?

 

Best Regards,

Bertan

code.PNG

 

 

Contributors