LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I input a for loop in a producer/consumer event structure?

Hello NI community,

 

I am new to Labview and my program is not completely put together. I'm trying to understand program structure.

I have a program where ..

 

                    In my producer loop: I have a DAQ device acquiring pressure data

                    In my consumer loop: the data is being processed and output as a waveform chart

                                                           

Right now I'm trying to add a more complicated feature that when a button is pressed, the pressure data for 20 iterations is collected and a slope is calculated from this data, and through a LUT, the amount of time to keep pressurizing is returned, and then I want to pressurize the device for that amount of time.

 

For this second part, do I need to have a second consumer loop? I am not sure the best event structure to apply here. Also is there a way to hold the consumer loop from executing until that button is pressed and not just when there is an element in the queue? I'm having trouble finding support documents that cover clusters, consumer/producer AND dynamic data.

 

0 Kudos
Message 1 of 6
(3,799 Views)

If you are sophisticated and adventurous enough to use Producer-Consumer, you are ready to use "real DAQmx" explained here in excellent White Paper and to banish Dynamic Data.

 

Producer should consist of DAQ acquisition of data.  Consumer should "consume" the data.  This includes writing data to disk and potentially other things.

 

Where should you be controlling the valves, making decisions based on the data?  Probably as part of the Consumer (unless you need really tight timing requirements, in which case you may want to make some decisions in the Producer).  Especially if the decisions involve multiple data points, the Consumer seems the better place.

 

Within the Consumer, you can do several things in parallel, such as logging, computing slopes, triggering valves, etc.  Think about the logic of what you want to happen, and the conditions that would lead you to do something or not.

 

Strive to keep your wires running straight and parallel.  If a function has an Error terminal, you should put it on the Error line (and use that as part of the sequencing process).  Consider "hiding" some of the messier features (like fitting lines and determining slopes) to sub-VIs, which will allow you to dramatically shrink the size of your Block Diagram (all diagrams should fit on a single modest-sized screen).

 

Note that if the Producer is always "producing", the Consumer doesn't necessarily have to Consume -- it could "Discard", instead, if the "Consume" button is not pressed ...

 

Bob Schor

Message 2 of 6
(3,771 Views)

Sounds like you need your consumer loop to be a State Machine.  Keep your 20 iteration data in a shift register and you can use it whenever you enter a state that needs it.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 6
(3,766 Views)
Also have a look at the Point by point Linear Fit VI.
0 Kudos
Message 4 of 6
(3,722 Views)

@Blokk wrote:
Also have a look at the Point by point Linear Fit VI.

He/She is already using that.

0 Kudos
Message 5 of 6
(3,712 Views)
ah, sorry, i was from mobile...
0 Kudos
Message 6 of 6
(3,668 Views)