LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How Labview Queue manipulates data

Solved!
Go to solution

Hi,

In short, if I have a queue size of one, what happens when I have two parallel loops trying to write and read in this queue? My guess was that the writing loop would wait that the reading one finish reading the current value before writing a new one. How could I go about reading the latest added element in the loop when pausing my writing loop.

I have a VI with two parallel loops. One loop measures data vectors of 2720 16bits values at the rate of 100kHz. The second loops compute the data and display an image in ''real time''. I measure data faster than I can compute and display it. I was using Queue to send the data from one loop to the other.

My idea was to limit my queue size to one with the Obtain Queue so that when I read the data in the queue it is always the most recent one and the displayed image is always computed with the latest data so that the delay between the raw data and displayed image doesn't increase in time. However I receive an error that I believe is related to the fact that my writing loop had to pause until the reading loop finish reading the data.

Any solution?

Thanks for the help.

RMT

0 Kudos
Message 1 of 8
(2,986 Views)
Solution
Accepted by topic author RaphaelMT

If you always want the latest, use a notifier instead of a queue.

 

Or use a lossy queue with a queue size of 1.

Message 2 of 8
(2,977 Views)

Won't I meat the same problem with a Lossy queue? Can he read and write in the queue at the same time?

 

As for notifier, I'll have to look how they work, thanks.

0 Kudos
Message 3 of 8
(2,973 Views)

Post some code.

 

IIRC, Obtain Queue while setting the size only works if all Obtain Queues set it to 1. If the write loop doesn't set it, and the read loop sets it to 1, I'd expect an error, or that the size is simply ignored. Better yet, use only one Obtain Queue, and split the wire. This could be what you have, but we can't tell.

 

You get an error. What error?

 

I've never had a read queue block a write queue. Those queues are very efficient. If it would cause an error, it would cause an error in the DAQ loop, on the DAQ VIs. For instance, a buffer overflow because the DAQ wasn't executed fast enough.

0 Kudos
Message 4 of 8
(2,944 Views)

@RaphaelMT wrote:

Won't I meat the same problem with a Lossy queue? Can he read and write in the queue at the same time?

 

As for notifier, I'll have to look how they work, thanks.


No.  With a queue, once the data is read it is gone.  With a Notifier, the latest value is still stored in there.  Though, if I am understanding your situation correctly (example code would really help here), you can just use a simple Global Variable (you will just always read the latest value, no waiting necessary).
Never mind the Global statement.  I just reread your original post.  You want to use a Notifier.


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 5 of 8
(2,939 Views)

I can't share the whole code considering it's rather big and use subVi that require particular equipment but I linked an example of the queue. The queue itself didn't give me an error. It game from that custom subVi made by a company and the error messages are rather general.

 

I think the problem is cause by the fact that the device stored its measured data in its memory until it can share it with the computer ram. I was wondering if Labview waits until the display loop finish before letting the writing loop add a new value. Forcing the device to store his data in its personal memory in the mean time.

 

As testing, I've notice if I increase the size of the loop, it takes more time before it gets filled up.

 

Thanks.

0 Kudos
Message 6 of 8
(2,920 Views)

Just wondering, what is the difference between using a lossy queue vs a notifier?

0 Kudos
Message 7 of 8
(2,911 Views)

@RaphaelMT wrote:

Just wondering, what is the difference between using a lossy queue vs a notifier?


A Notifier only holds the latest value and can be sent to many locations.  A Queue is meant for a single place to receive data.  Between a Single Element Queue and a Notifier, that is the main difference.  But I would say the Notifier is more obvious of what is happening than a queue since a queue is typically used for lossless communication.


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
Message 8 of 8
(2,900 Views)