12-05-2017 08:47 PM
Dear friend,
Please check the attached vi. The function is very simple, just queue the array from lower while loop to upper while loop. That's it!
The style A is working, but B is NOT working.
My questions:
1. why B is not working ? I didn't get any error.
2. If I want to queue an array from one while loop to another while loop (outside and parallel ), the way I do is correct or not? I am new with queue, please advise me. Thank you
Solved! Go to Solution.
12-05-2017 10:07 PM
@sunson29 wrote:
Dear friend,
Please check the attached vi. The function is very simple, just queue the array from lower while loop to upper while loop. That's it!
The style A is working, but B is NOT working.
My questions:
1. why B is not working ? I didn't get any error.
2. If I want to queue an array from one while loop to another while loop (outside and parallel ), the way I do is correct or not? I am new with queue, please advise me. Thank you
1. Dataflow. In A the loops run in parallel. In B, the top loop can't begin until the bottom loop ends because of the wire that LEAVES the bottom loop and ENTERS the top loop. Execute both pieces of code with Highlight Execution (the light bulb) turned on and watch how data flows.
2. It's correct as long as you do it like in A. But you proved that yourself when you said A is working for you.
12-05-2017 10:17 PM
1. why B is not working ? I didn't get any error.
Because the upper loop cannot execute until the queue wire has data. The wire is coming from the OUTPUT tunnel in the lower loop meaning it doesn't have data until that loop stops. What error would you expect? It's perfectly valid to code that, you just need to know how data flow works. Once the lower loop stops, the wire connected to the output tunnel has data and can continue. Spoiler, the release queue and dequeue element will have a race condition.
2. If I want to queue an array from one while loop to another while loop (outside and parallel ), the way I do is correct or not? I am new with queue, please advise me.
The basic design will work, but there is a timing issue. You are enqueing elements every 100 ms and dequeueing every 200 ms so your queue will constantly be growing the number of elements to dequeue and be out of sync. I would remove the wait function in the upper loop and let the dequeue element function determine the timing, and wire the error output to the stop terminal.
12-06-2017 06:19 AM
StevenD wrote:
2. If I want to queue an array from one while loop to another while loop (outside and parallel ), the way I do is correct or not? I am new with queue, please advise me.
The basic design will work, but there is a timing issue. You are enqueing elements every 100 ms and dequeueing every 200 ms so your queue will constantly be growing the number of elements to dequeue and be out of sync. I would remove the wait function in the upper loop and let the dequeue element function determine the timing, and wire the error output to the stop terminal.
Just to add to this. The general idea behind a queue is to offload some processing to another loop. That loop should be able to run as fast as possible in order to keep up with the producer. If the producer is slow, the consumer will sit there idle until more data enters the queue (waits at the Dequeue Element). So let the rate of data determine your consumer's loop rate and don't try to slow it down.
12-06-2017 11:33 AM
Thank you!!!
12-06-2017 11:34 AM
Thank you!.
12-06-2017 03:28 PM
Allow me to have a quick follow up question. Thank you:)
I did the highlight execution, and I do see what you said! If in B, there will be no data unless bottom loop stopped.
BBBBUUUUTTT, why the A will work? I mean, the wire of A is still outside of bottom loop, right? Why if i make the wire on the left (outside of bottom loop) will work, and the data will transfer to upper loop? My thought is : any data from bottom (to outside) will be available only bottom loop stopped. Please current my understanding. Thank you again.
oh, btw, the first time I do the queue, I use C style, because I thought dequeue should be after queue, so, the wire should be out after queue. but, this is wrong. I think the answer will be the same as the question above. Thank you.
12-06-2017 03:48 PM
Yes, it does not matter whether your wire is exiting to the left or to the right, it is still seen as an output of the loop either way.
For the future, you may also want to think about using the queue to stop the loop as well, this way you only have to push one stop button instead of 2 🙂
12-06-2017 04:07 PM
Another way to think about the Queue "wire" is that it is a "pointer to a storage area". Once you tell the Enquer where to put the data, the function "knows" (or remembers) and doesn't need "new" information, hence can "use the old data" on subsequent loops. The Dequeuer also needs to know where the data are stored -- if you don't tell it, it can't get it.
Bob Schor
12-06-2017 09:41 PM
Time to suggest:
LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours