LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The basics of creating continuous aquisition

Highlighted

Hi

 

Simple as it sounds, I've been searching, feels like I've turned the internet upside down, yet I have not found any answer.

 

I have a "VI" including a standard while loop and state machine. Within the loop I want to aquire signals from my DAQ (currently using DAQ assistant express), recompute/ scale the signals using some formulas and then compress/ average, and finally save to a file. How can I do this while achieving a repeatable/ controllable iteration rate between each data point I aquire and print? 

 

I can aquire i.e. 100 samples from the DAQ VI, then process the signal and then save, but that means I will sample continuously, pause aquisition while computing and, then start over, missing out on some of the signals during computation and saving until next loop iteration? Even if I set the DAQ aquisition to a certain sampling rate, that rate will only be valid during each aquisition sequence.

 

Do I have to make several timed loops and make my own buffer which I process and compress, or is there a smooth way of actually achieving this?

0 Kudos
Message 1 of 18
(365 Views)

I should also point out that yes, I have a VI but it is rather huge so haven't attached it. In worst case, if I am completely in comprehensive I'll try to make an example instead

0 Kudos
Message 2 of 18
(357 Views)

Have a look at the Continuous Measurement and Logging template.  

 

http://www.ni.com/product-documentation/14031/en/

 

I think this one does a good job of illustrating some very important DAQ concepts and puts it into an example you can easily modify for your own use.  

 

In the example, the DAQ function is handled in a separate SubVI that doesn't have to stop acquiring while other parts of the code scale, display or even save that data.  

---------------------
Patrick Allen: FunctionalityUnlimited.ca
Message 3 of 18
(346 Views)

Start at the menu "Help-->Find Examples...".   There's a simple example in there to illustrate continuous acquisition of a voltage using a device's clock to keep the sample rate extremely consistent.  Buffering is done for you by DAQmx in the background.

 

After that, search for info on the "Producer Consumer" pattern which will be helpful for having a nice tight DAQ loop while deferring post-processing to another parallel loop.

 

 

-Kevin P

 

[Edit:  Nevermind.  Follow the advice from pallen who responded while I was still typing.  That's a better starting point that sounds like it'll give you more detailed help on both things I briefly mentioned.]

Message 4 of 18
(343 Views)

Have you looked at the examples that ship with LabVIEW? One of those should point you in the right direction.

 

Get away from the Express VIs and use DAQmx. It's easy and much more versatile. You set your acquisition rate and set to continuous acquisition. The buffering is then handled in the hardware/driver. Your other code does still have to keep up (might be a good idea to study the Producer/Consumer architecture).

 

Edited to add: Looks like others beat me to the punch.

0 Kudos
Message 5 of 18
(339 Views)

Any particular example in mind?

 

I have looked through some so far but haven't found any that seems to be doing what I want and most of them are also wrapped in several layers of UI dialogs or other accessories that makes it more difficult to distinguish the essentials

 

Thanks you all for all your replies so far

0 Kudos
Message 6 of 18
(312 Views)

Hi KRICLA,

 

The information in this thread may be of use to you.  I posted a snippet showing a very basic method of continuous acquisition and display/processing using a queue to transfer data from producer to consumer loop.  The posts following the snippet by Henrik_Volkers and Kevin_Price suggest a few further additions and things to watch out for.

 

Andy

Message 7 of 18
(301 Views)

So in the end, the answer is basically no, there's no simple way of making a consistent timed sequence using what I have.

 

So DAQmx and producer/ consumer are what I need to get around. The producer loop will then be "time consistent" if I don't slow it down and I can time and load my consumer at whichever rate I may choose?

 

Is there a convenient way of creating and saving a timestamp consistent with my sampling and pass it on to my file export so that the processing and consumer timing won't affect my time-array in my result file? Of course the timestamp will have to be an average value depending on the signal compression of my choosing

0 Kudos
Message 8 of 18
(238 Views)

@KRICLA wrote:

So in the end, the answer is basically no, there's no simple way of making a consistent timed sequence using what I have.

 

So DAQmx and producer/ consumer are what I need to get around. The producer loop will then be "time consistent" if I don't slow it down and I can time and load my consumer at whichever rate I may choose?

 

Is there a convenient way of creating and saving a timestamp consistent with my sampling and pass it on to my file export so that the processing and consumer timing won't affect my time-array in my result file? Of course the timestamp will have to be an average value depending on the signal compression of my choosing


It is certainly easier to achieve the timing when you're not bogging down the loop with other stuff - especially since Windows is not a real-time operating system. You can possibly get away with it for low sample rates though.

 

If you collect your data as a waveform timing information will be included. A waveform has a start time (t0), the interval between data points (dt), and an array of data values. The waveform also has attributes such as Channel Name and Units which may be useful. You can set your DAQmx acquire to acquire as waveform. You can then use this timestamp to compute your average timestamp for your compression.

0 Kudos
Message 9 of 18
(215 Views)

@KRICLA wrote:

So in the end, the answer is basically no, there's no simple way of making a consistent timed sequence using what I have.


If you want a solution based on the code you already have, then post that code to the forum here so that others can see what you have so far. 

 

The producer/consumer is probably the easiest framework to understand that will give you the results you're describing.  

 

The basic gist is that one loop only captures data and feeds it into a queue.  Another loop can then empty the data out of that queue a "chunk" at a time, to scale it and display it.  This allows the data capturing loop to run at full speed while the queue acts as a "buffer" to hold the data while the other loop is processing it.  

 

There's a good forum thread on the subject here: https://forums.ni.com/t5/LabVIEW/Implementing-and-Understanding-the-Producer-Consumer-Template/td-p/...

---------------------
Patrick Allen: FunctionalityUnlimited.ca
Message 10 of 18
(198 Views)