04-12-2022 07:09 AM
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.
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
Solved! Go to Solution.
04-12-2022 08:49 AM
Not enough info.
What specifically isn't being displayed?
Which case is run?
Try turning on execution highlighting .
04-12-2022 08:57 AM
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:
(Here it's shown with highlight execution)
The init case isn't run.
Thank you for your time.
04-12-2022 09:13 AM
Hi Blancoys,
replying to your original post:
your values are not updated because you simply overlayed the terminal and shift register:
<<<before - after>>>
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.
04-12-2022 09:19 AM
@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:
(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?
04-12-2022 09:38 AM
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😀
04-12-2022 09:53 AM
@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.
04-12-2022 10:05 AM
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).
04-12-2022 10:18 AM
Thank you for your replies,
Yes, I think I enqueued the init state right after the obtain queue:
But it still runs all the time.
The Data to variant node, you mean this part?
I thought it was going to take the new state?
Here is a whole picture:
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😋
04-12-2022 10:28 AM
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
Also, Init shouldn't have any data to dequeue so that variant to data vi is completely unecessary.