12-02-2018 11:21 PM - edited 12-02-2018 11:24 PM
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
Solved! Go to Solution.
12-02-2018 11:32 PM
If you always want the latest, use a notifier instead of a queue.
Or use a lossy queue with a queue size of 1.
12-02-2018 11:37 PM
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.
12-03-2018 03:52 AM
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.
12-03-2018 05:58 AM - edited 12-03-2018 06:13 AM
@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.
12-03-2018 07:48 AM
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.
12-03-2018 08:12 AM
Just wondering, what is the difference between using a lossy queue vs a notifier?
12-03-2018 09:03 AM
@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.