From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

How to set rate in Producer/Consumer architecture?

Hello all,

 

I am acquiring data at a rate of 1000 samples/sec in a Producer loop. This loop then pushes data out to two consumer loops through one Notifier and one Queue element. 

 

Consumer 1 is a graph that displays the data. I want to be able to control the frequency of the data points. I am currently using a queue for this but this means it is showing all samples. I want to be able to control the rate at which the graph reads the data from queue. Should I use notifier for this? I do not care about losing data between samples. (just want to control frequency of data display)

 

Consumer 2 is a logging loop. I'm currently using TDMS write function. However, it is writing to file at the rate of data acquisition in the Producer loop. Can I change this rate on the fly? I'm using notifier to read the data from the Producer, but I want the Consumer loop to get data from the notifier at a frequency I determine. Is that possible? Should I be using another logging VI? 

 

Any help is appreciated!

0 Kudos
Message 1 of 5
(1,854 Views)

Without seeing your code I can only guess what you are doing and make vague suggestions...

 

1) You don't need to display every element you dequeue.

 

2) Huh?  I don't understand this question. Most programmers don't really care about the data storage rate beyond wanting to write data as fast as possible. Because RAM usage increases as your queues fill up and a DAQ can acquire data magnitudes faster than most computers can write it to disk.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 5
(1,816 Views)

For the fist question I would probably use a notifier with a 0 timeout and only update the chart if the notifier didn't time out (meaning you actually have new data to put on the chart).

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 5
(1,804 Views)

I've attached a png of the VI. To explain a bit more what I'm trying to achieve:  I want the graph to show data at a frequency I can control. I cannot seem to change the samples/sec of the sample clock. I also want to write data to disk at a slower pace than data acquisition. I run tests that take two-three days to finish and I don't want to have a huge file. Is there any way I could take data points from the consumer, say once every minute or so? 

 

I hope I could explain my motivations better.  

0 Kudos
Message 4 of 5
(1,789 Views)

Of course.

 

The consumer loop for logging can collect all the data.  Do you want to discard the data you don't want to log?  Or average it together?  Either way, put an elapsed time timer in the consumer loop that will only log the data when the time has elapsed.

 

Like wise for the graph plotting consumer.  You can manipulate the data as you see fit for whatever graphing rate you want.  Collect the data as it comes, and either average it or discard it as needed to fit the desired graphing rate.

0 Kudos
Message 5 of 5
(1,773 Views)