From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

producer-consumer design for temperature and pressure acquisition

I am working on my first LabVIEW program in version 8.6.  I eventually want to be able to take both temperature and pressure measurements (6 RTDs and 2 pressure sensors), write them to files, compare the temperatures, and then turn 9 heaters (2 zones) on and off depending on the temperatures and temperature differences. I will also need to have necessary alarms and emergency shut down if something overheats.

To start, I am just working with temperature. I have made a program that reads 2 RTDs with the NI9217 in the cDAQ 9172. It plots the temperatures and writes them to file. Then it compares the 2 temperatures. If the temperature difference is greater than the user defined difference, an LED alarm lights up. This loops until the user presses the stop button.

The program runs, but then I get a 200279 error. It says that increasing the buffer may do the trick; however, I read online and watched a video on the producer/consumer design, which I think might do the trick. I am hoping with the producer/consumer design that I will be able to sample the temperatures faster (especially once I have 6 RTDs and 2 pressure sensors). Right now it takes about 11 seconds for the loop to run.

I have played around with trying to do the producer/consumer design, but I am not having much luck. I am not sure how to set it up.  Do I need to have one producer loop with the DAQ assistant, and then 2 consumer loops (one for each RTD)? If I have 2 consumer loops, how do I then synchronize the data to compare the temperatures that were taken at the same time?

If I only use 1 consumer loop, how do I separate the data that is coming from one RTD vs. the other RTD?

Any comments or suggestions would be greatly appreciated.

I have attached my current VI for reference.

0 Kudos
Message 1 of 5
(2,220 Views)

I have attached my attempt at the producer-consumer design.  It runs much faster than the VI I attached in my first posting; however, it has bugs.

When I press the stop button, I get an error 1 (occurred at Dequeue Element).

Also, how do I get the graphs to plot with a fixed axis? For example I would like to see the plot of 5mins worth of data. I have tried turning off the autoscale, but it does not keep the axis from changing.

Any suggestions on how I can clean up this program? When I get to adding more RTDs, should they all be in this same consumer loop? 

What would be the best way to add in the pressure data? With another producer loop and another consumer loop?

0 Kudos
Message 2 of 5
(2,199 Views)

Hi Sunshine37,

 

The producer consumer is a good architecture. It could be that you releasing the queue before all the elements are read. I would put a while loop in-between the producer loop and the release queue that checks the if there are any elements left in the queue with the queue status.vi

 

Also, I would recommend not using express Vis, you should use the examples instead by going to help-> find examples... Take a look at the daqmx folder in hardware input and output.  Also, you want all the read processes in the producer loop and everything else in the consumer loop.

TimC
National Instruments
Applications Engineer
0 Kudos
Message 3 of 5
(2,164 Views)

Tim,

 

Thank you for your response. 

 

I have attempted to make your suggested changes; however, I am still struggling to get the program to run properly.

My issue now is that I get Error 91 at Variant to Data in my consumer loop.

I am not sure how to take my queue and split the data into the 2 signals.

I am also unsure how to correctly wire in my A,B,C constants for the custom RTDs.

Do you have any suggestions?

0 Kudos
Message 4 of 5
(2,115 Views)

You don't need to use variant to data on the reference output of the deque element vi. The data you are storing in the array is comming out of the element output on deque element. That is the data you want to be reading. you can enque and deque multiple elements in one loop, so you could pull elements from the data array (if you get the data as an array rather than a waveform) and store just the ones you want and pull that same number out each time. Just make sure to use wires to control order, and that it's first in first out. 

 

You can show the data with a chart or something if you want to see the old values. Also you can do that difference measurement with simple subtration nodes now.

 

I hope this helps.

TimC
National Instruments
Applications Engineer
0 Kudos
Message 5 of 5
(2,088 Views)