LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/Consumer variables not displaying into front panel.

Solved!
Go to solution

Hello, I've been working on doing a vending machine to practice the basics of LabVIEW. 

 

I want to build the exact past code for the vending machine but using the producer/consumer loop. (Normal one can be found on "self-driven" as main.vi)

 

I am using a simple producer consumer loop with enums. (It's saved as "mainevent.vi")

 

My problem is, my variables won't display on the front panel.

Blancoys_0-1649765307009.png

 

Blancoys_1-1649765339371.png

 

I've tried debugging it with Probe, and it shows that it does go into the case but it still doesn't display it. 

 

Any ideas? 

 

Kind Regards

0 Kudos
Message 1 of 21
(1,800 Views)

Not enough info.

What specifically isn't being displayed?

Which case is run?

Try turning on execution highlighting paul_cardinale_1-1649771334196.png .

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 21
(1,774 Views)

So my problem is I'm trying to make a producer consumer loop using enums. 

 

I summarized the diagram so the picture is more descriptive: 

Blancoys_1-1649771692305.png

 

 (Here it's shown with highlight execution)

 

The init case isn't run. 

 

 

Thank you for your time.

0 Kudos
Message 3 of 21
(1,769 Views)
Solution
Accepted by topic author Blancoys

Hi Blancoys,

 

replying to your original post:

your values are not updated because you simply overlayed the terminal and shift register:

Ajskrim_1-1649772734898.png<<<before - after>>>Ajskrim_0-1649772521362.png

so every iteration you were feeding the empty array of clusters.
You did enqueue the message and executed the init state of the consumer but the values updated the "products" were not the ones from the init state of the previous iteration.

 

In your second reply, that's a completely different story. The init case is not running, because you don't enqueue the "init" message. You obtain the queue, and then in the consumer loop waiting for the message but it never comes.

 

_______________________________________________________________

-Patrik
CLA || CTA
If it helps - Kudo it, if it answers - Mark As Solution
Message 4 of 21
(1,758 Views)

@Blancoys wrote:

So my problem is I'm trying to make a producer consumer loop using enums. 

 

I summarized the diagram so the picture is more descriptive: 

Blancoys_1-1649771692305.png

 

 (Here it's shown with highlight execution)

 

The init case isn't run. 

 

 

Thank you for your time.


When I run your program the Init case does run, but there is an error at the variant to data node. Have you looked at that? 

Message 5 of 21
(1,754 Views)

Thank you, I don't know why I didn't look at it.. 

 

I've checked it does run, but for example, how do i dequeue it now? the init case, because now it does it every-time non-stop. 

 

Thank you for your time😀

0 Kudos
Message 6 of 21
(1,743 Views)

@Blancoys wrote:

Thank you, I don't know why I didn't look at it.. 

 

I've checked it does run, but for example, how do i dequeue it now? the init case, because now it does it every-time non-stop. 

 

Thank you for your time😀


 

Did you fix the error? If not then it's going to continuously run your default (init) state because the error is propagated back to the dequeue.

Message 7 of 21
(1,733 Views)

Init should only ever happen once (or after a hardware reset).  Enqueue the Init state immediately after the Obtain Queue function (that is to say, before the while loop starts).

Message 8 of 21
(1,729 Views)

Thank you for your replies, 

 

Yes, I think I enqueued the init state right after the obtain queue:

Blancoys_0-1649776504358.png

 

But it still runs all the time. 

 

The Data to variant node, you mean this part? 

 

Blancoys_1-1649776572444.png

 

I thought it was going to take the new state?

 

Here is a whole picture: 

 

Blancoys_2-1649776627518.png

 

 

It's my first time attempting to use the queue-dequeue functions, I'm sorry if I'm bad at understanding what you mean. 

 

Thank you for your replies as always😋

 

 

 

0 Kudos
Message 9 of 21
(1,720 Views)

It's running all the time because your state is "init", Default.  any invalid state will execute the "init" state as a result.

Move the Default to an empty case.  you should also add some error handling.

 

Your "Variant to Data" is generating an error due to the data mismatch.  the dbl doesn't match a cluster

proland1121_0-1649777202816.png

 

Also, Init shouldn't have any data to dequeue so that variant to data vi is completely unecessary.

 

0 Kudos
Message 10 of 21
(1,715 Views)