LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dataflow problem, queuing in subvi dequeuing in main vi

Solved!
Go to solution

ive stuck on a very simple data flow problem here, I'd like to pass data being enqueue in the subvi and dequeue in the main vi consumer loop. Ive attached the vi, since im already stuck on this problem, i was hoping i could learn a few things, specially implementing action engine in this situation 🙂 

 

thanks.

Download All
0 Kudos
Message 1 of 4
(3,396 Views)
Solution
Accepted by topic author Sonofsam

Your subVI doesn't make any sense since your loop will always exit after the first iteration and you always initialize your counter to 0 every time you execute it. That is one issue.

 

Your code also suffers from multiple places that are dequeueing data from the queue. You will get undeterministic behavior since you don't know which dequeue will get the data first. Generally for a producer/consumer architecture using queues one or more loops loops should be enqueueing data to the queue. One and only one loop should be dequeueing data. These loops shuold run in parallel to each other. In your code you will only run your subVI whenever you press the start button and as stated you will always post a value of 1 to the queue. What you would need to do is have your subVI run independently once it is started. Use the "Start Asychronous CAll" to start your subVI when the Start button is presed and then let it simply run. Have it post the counter to the queue. Your lower loop in the main VI should dequeue the values and display them. You do not need the Wait in that lower loop since that is the purpose of the dequeue. That loop will be idle if there is no data present and will only run when data is in the queue.

 

In the upper loop of your main VI remove the dequeue and enqueue. You don't need them since the subVI is all that is needed to post the data to the queue.

 

Try this:

 

Main.png

 

subVI.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 4
(3,383 Views)

Thankyou so much, worked like a charm. and thanks for pointing out my mistakes, my subvi was indeed a blunder. 

 

I just have one more question, what would be the best way to stop the subvi ? 

 

should I bundle the numeric counter with enum carrying stop state in subvi, than use user generated event in main, and settle for stop vi-button event ? would that be a good choice or there is any better, more simpler way?

0 Kudos
Message 3 of 4
(3,367 Views)

As written the subVI will stop when the queue gets destroyed. If you needed to stop it for other reasons you would need to pass it a stop. There are several ways this can be done. One of the most basic would be to use a functional global/action engine and check this condition each iteration. You could also use a notofier. Again, checking if the stop condition has been met.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 4
(3,347 Views)