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: 

Auto-update Time indicator with two while loops in parallel

Solved!
Go to solution

I'm currently trying to implement a current time indicator to the front panel, however, I can't get the time indicator to constantly update in the while loop due to another while loop running in parallel. 

 

One while loop holds an event case structure that is tied to the controls on the front panel. While the other loops holds the current time indicator. I can't get both to work simultaneously together. Here are the things that I've tried so far:

 

1) I changed my mechanical actions from latch to switch to get the two parallel loops to stop at the same time by using a local variables, but by switching my mechanical actions from latch to switch made my other VI's to stop working as it's not detecting the change in the controls.

2). I tried putting my while loop with the time indicator in the same while loop holding my event case, but of course, the time is not updating itself.

 

Is there a way to implement this?

0 Kudos
Message 1 of 7
(3,234 Views)

If the loops are actually in parallel, they will run in parallel.  My guess is that you have a data flow dependency (ie a wire) between your loops.

 

Post your VI or at least a stripped down version to only show the important things.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(3,215 Views)

Hi TeddyLu,

if you are trying to just display the current time.

use one more loop at a lower rate to update the current time.

bp
0 Kudos
Message 3 of 7
(3,205 Views)

... and make sure the Event is not configure to "Lock FP until event completes".

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 7
(3,188 Views)
Solution
Accepted by topic author TeddyLu

It would be so much easier if you would attach a simplified version of your VI!

 


@TeddyLu wrote:

1) I changed my mechanical actions from latch to switch to get the two parallel loops to stop at the same time by using a local variables, but by switching my mechanical actions from latch to switch made my other VI's to stop working as it's not detecting the change in the controls.

 


You can leave them latch action. No need for local variables. Place the terminal in the loop without event structure and wire to the termination condition. In the loop with the event, create an event for the stop button and wire a TRUE (or from the newval event data node) to the stop condition from within it.

 


@TeddyLu wrote:

 

2). I tried putting my while loop with the time indicator in the same while loop holding my event case, but of course, the time is not updating itself.

 


It would, if you use a suitable timeout event.

 

Of course all that requires that the rest of the code is reasonable, e.g. no interactive while loops inside event cases and such.

 

 

Message 5 of 7
(3,183 Views)

Thank you for the suggestion, I didn't realize I could pull an event change boolean value from the "newval" on the side of the event structure.

 

Thanks everyone!

0 Kudos
Message 6 of 7
(3,172 Views)

@TeddyLu wrote:

Thank you for the suggestion, I didn't realize I could pull an event change boolean value from the "newval" on the side of the event structure.

 


 

You really don't need the "newval"! In this case a TRUE diagram constant placed inside the event case is actually safer!

While a latch action boolean seems to be "always true" when the event triggers, it can actually also be "always false" if configured differently. Most people don't seem to know that, but a latch action button can also be configured with a TRUE default value, and in this case it is always true until pressed. When pressed it will turn FALSE until the values is read by the code once and then revert back to TRUE. Now the "newval" is always false and you would need to flip the stop condition to actually stop the loop, requiring a "true" wired from all other cases. More complicated!

Message 7 of 7
(3,152 Views)