Showing results for 
Search instead for 
Did you mean: 

Writing and Plotting Data from a Measurement File

I am developing a system that measures the CO2 concentration of 12 vessels over a 14 day test using one gas analyzer. Each vessel has its own measurement file where the data is stored, and data is only written to them when that vessel is selected. That part runs successfully.  However, I would like to the plot all the data acquired so far for each vessel as the 14-day test runs.  How can I write to the measurement files and plot the entire data set acquired simultaneously?


I have attached my program below.



0 Kudos
Message 1 of 52
You aren't building the best architecture which will lead you to problems later on. Avoid acquiring, analyzing and doing file i/o in the same loop. Have a look at the producer/consumer architecture and implement that in your application (Go to File -> New.. and look for Producer/Consumer design pattern). The producer loop can then just concentrate on acquiring data and there can be a dedicated loop each for analyses, file i/o and user interface. If you have any questions, post back.
Message Edited by Adnan Z on 05-04-2009 04:19 PM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 52

Thanks for the reply. Are you saying I need to completely redo my entire program? I'm still pretty new to LabVIEW. So, I'm not even sure where to begin with the producer/consumer template. Could you explain how I could use this template to do the following:


1)  Cycle 12 Solenoid Valves  on/off individually and control the length of time they are open

2)  Acquire an analog signal from a Flow Sensor and Gas Analyzer

3)  Write the data acquired to a dedicated file (one file for each valve)

4)  Only write the data to each file when its corressponding valve is selected

5)  Take measurements from 3 RTDs and send out a control signal, +10V, that will turn on a pump if temp gets too low

6)  Write temperature data from RTDs to one file

7)  Display trend data for each data file as the test executes.

😎  Allow user to pause/stop the test to perform periodic maintenance during the 14-day test.


0 Kudos
Message 3 of 52

I would recommend that you do. Your application isn't modular at all which will definitely lead to problems later on when debugging your application. Also, if you were to acquire data really fast, then your hardware buffer will overflow while your loop is working on other tasks. Giving this responsibility to other loops will help you avoid errors.


Look closer at the producer/consumer design pattern and you will notice that there is a queue buffer which transmits data from the producer loop to the consumer loop. 


The way you will design your application is that there will be a producer loop that is responsible for acquiring data (the analog signal from flow sensor and gas analyzer). You can have a consumer loop that is responsible for file i/o. You will place the acquired data into the queue and the consumer loop which is subscribed to that queue will read the data and write to file. You can control the selection of valves using action engines (functional global variables). 


This may turn out to be really confusing to do all at the same time. I would recommend that you start one step at a time, post your VIs here and we can help you along the way.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 52
Okay, I'm trying to start a simple Producer/Consumer program that will pull in an analog voltage and display the information in a waveform chart and write it to a measurement file. I've opened the template program for Producer/Consumer  program, but I'm not sure where to begin.  How can you continue to pull in data if it is outside of the while loops, and how do you determine the conditions to put data in the queue?  I've looked at the Producer/Consumer Application Design Patterns on the website, but it doesn't give adequate information to actually begin building my own Producer/Consumer program.   I wish NI would put more focus on design development techniques instead of listing just the capabilities of Producer/Consumer designs.
0 Kudos
Message 5 of 52
Did you look at this? If you use the LabVIEW help and look up Producer/Consumer, a link in the help will take you there.
0 Kudos
Message 6 of 52
Yeah, that's the one I was talking about. It gives an example, but it doesn't explain the process steps to create a Producer/Consumer program.
0 Kudos
Message 7 of 52

Okay, I finally found an example of a producer/consumer VI that acquires an analog voltage, and I understand most of the VI. However, I am not sure of the purpose of the array that is connected to the element data type terminal of the obtain queue function and has the time stamp, a constant, and another array inside of it.  Could you explain what the element data type terminal is and what the array is for?  I've looked at the data file it creates and there is no time stamp and only the voltages acquired from the DAQ board. 


I've attached the VI to this post as well as a screenshot with the array in question.


Download All
0 Kudos
Message 8 of 52
That constant is used to define the datatype that is being passed into and out of the queue.  That way LabVIEW knows the size and the data structure of the data being stored.  You will notice that the queue wire itself reflects the data type.  The outer shell of the queue wire is the color green used for references (since the wire is a reference to the actual queue).  The inner core of the wire looks like the waveform datatype.  If you were passing a double (defined by wiring a double constant to the obtain queue) it would be orange inside of green.  If you were passing a double array, it would be a thicker orange inner wire.  A cluster would have a pink inner wire. 
0 Kudos
Message 9 of 52
Thanks for the reply. Now, my next question is where do you find all of the attributes that are inside of the array (timestamp, 1d array, and the constant)?  Also, are you expected to know that you need all three of those attributes for the waveform or the for any data type, or do they automatically show whenever you select the correct data type?
0 Kudos
Message 10 of 52