From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying message for a certain period of time within a while loop


@ICCR-Lab wrote:

I have been told to use a producer - consummer VI. But I am quite new to Labview and beside my research I don't really understand/ see how to transform my code into P-C version. 

 

Help !! 😞

 

 


Take the Core 1 training. You can go through it in 3 days...At the end you will understand how to design state machines.

0 Kudos
Message 11 of 20
(1,202 Views)

Another advice, do not use your actual VI for testing other examples, in the VI which you attached, I can see 2 Event Structures, 2 Notifiers, and 1 Queue... Taking some training would really help you, if you have licence, you have also free access to the Core1-2-3 training material online...

 

0 Kudos
Message 12 of 20
(1,199 Views)

That will sound wrong, but I don't have 3 days... maybe in November, but this as to be due by friday 😕

0 Kudos
Message 13 of 20
(1,197 Views)

I am not sure, but that kind of overusage of local variables looks also dangerous. I hope this code does not need to control hardware equipment where human injury can happen.

 

Anyway, if somehow this code can run for you, and only that msg part is the problem, just use a single Notifier as I wrote. Delete that other loops with the second Event Structure and the Queue. What do you get now? I cannot test your code, since I do not have the HW you have, also many subVIs are missing...

 

edit: the other problem is that, you send Notification at every iteration of the While loop. Put the SEnd Notification into the corresponding Event case, delete it from the main While loop!

 

0 Kudos
Message 14 of 20
(1,189 Views)

ok, here a slightly modified VI, But, If the message stays , it doesn't seem to correctly works once I do another action (click on another button for example).

 

Also, when I stop the VI I get an error.

0 Kudos
Message 15 of 20
(1,181 Views)

You did not do what I have asked for. See my above post. I can still see that extra two loops (with the Queue test), and also the "Stop condition" Notifier (also that error wire goes backward in a silly way from that Send Notification at the top right of the main While loop, you even have a Feedback node on it, by accident??). It is really difficult to follow what your code should do, it is a nice spagetti monster...

I put here a little example how a single Notifier could be used to send msgs alongside with an Event Structure:

 

notifier1.png

 

 

 

 

 

0 Kudos
Message 16 of 20
(1,172 Views)

All these suggestion seem way too convoluted. All you need is a shift register to keep the current message unless a new message arrives or a certain time has elapsed.

 

This would need minimal changes to your current code.

 

Don't overcomplicate things with multiple loops and queues and such!

0 Kudos
Message 17 of 20
(1,164 Views)

altenbach wrote: 

Don't overcomplicate things with multiple loops and queues and such!


Here's what I had in mind. Right now it will display the last message until it is overwritten by a new message. It would be trivial to modify to e.g. reset the message to an empty string after a certain time or even to display the last N message, each with a timestamp, for example. Modify as needed.

 

 

(Also note that the terminal of the OK button belongs inside it's event case. There should be an event for the stop button and since you are discarding all decimals anyway, the numeric input should be integer (blue!). Your Visa session needs to be wired across the other cases, else closing it will fail if the timeout case is the last event executed.)

0 Kudos
Message 18 of 20
(1,159 Views)

 waouh, what a very easy and convinient way to do the job !!

 

The simple VI I showed you is just an simplified version of my (very messy) code.

And it works perfectly fine !!!

 

Thank you !

0 Kudos
Message 19 of 20
(1,136 Views)

Also note that if "numeric" is a user control, you can define the allowed input range in the control (right-click...data entry...). Once you do that, the values are always in range (because out of range entries can no longer be entered!) and you can even eliminate the inner case structure and the in range function.

 

0 Kudos
Message 20 of 20
(1,124 Views)