LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The producer loop do not start immediately after the consumer loop.

We have a code to use a 'simple streaming' example to get the measurement from USRP.

Setting: The sample rate is 20MS/s and with number of samples to 49280000 since we want to continuously collect data as much as possible.

Purpose: We use producer/ consumer with the queue to deal with data. Only when the size of the data is equal to the number that we set, the producer loop would enqueue the data and the consumer would save the data into file for the further process.

 

The problem: It takes about 10 seconds to capture the data. And I find the producer loop does not start immediately after the consumer loop (save data). Only the first producer loop starts immediately. And it takes quite a long time between two producer loops. Can I speed up the code?

 

I attached the figure below and will try to attach a simpler vi. The upper loop is the producer while the lower one is the consumer.

Thank you very much!

Download All
0 Kudos
Message 1 of 3
(174 Views)

The Producer loop almost always starts before the Consumer loop (or, at least in my routines for more than a decade, that's how it works).  You need to produce data before it can be consumed.  (Sometimes, you do start the Consumer first, since until it gets data from the Producer, it doesn't do anything;  But the general idea and "way to remember how the data flows" is that the Producer "makes" the data, and the Consumer "eats", or "consumes" it after it has been created).

 

Bob Schor

 

 

0 Kudos
Message 2 of 3
(116 Views)

The major red flag I see is your use of the timeout on the Dequeue. Generally, you do not want the consumer to have a timeout on the dequeue because you don't want the consumer to shut down just because the producer has a small delay.

 

In conclusion, my suspicion is that your consumer is getting a timeout before the initial capture from the producer gets something into the queue. Because of how you are handling the timeout, this will close the log file and stop your consumer.


GCentral
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
0 Kudos
Message 3 of 3
(86 Views)