02-14-2018 04:48 AM
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?
Solved! Go to Solution.
02-14-2018 05:41 AM
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.
02-14-2018 06:44 AM
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.
02-14-2018 02:59 PM - edited 02-14-2018 02:59 PM
... and make sure the Event is not configure to "Lock FP until event completes".
Ben
02-14-2018 04:02 PM - edited 02-15-2018 09:33 AM
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.
02-15-2018 02:39 AM
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!
02-15-2018 09:43 AM
@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!