10-30-2015 01:02 PM
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.
10-30-2015
02:37 PM
- last edited on
12-20-2024
05:09 PM
by
Content Cleaner
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
10-30-2015 02:41 PM
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.
10-31-2015 01:22 PM
10-31-2015 01:47 PM - edited 10-31-2015 01:48 PM
@Blokk wrote:
Also have a look at the Point by point Linear Fit VI.
He/She is already using that.
10-31-2015 02:31 PM