LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nested while loops issue

Solved!
Go to solution

Hey guys,

I've got three while loops, 2 of which are in series, running in parallel with the third, all nested in another while loop. I want the first loop in series to run, then the second, while the third is continuously running. Then repeat. My issue comes in when trying to create a master stop button. I've had success in doing so when using an event structure paired up with notifiers, but that doesn't work for my needs because then the big loop just sits and waits for the event structure to execute. I've attached one VI with the program without any attempt of mine at a master stop, and then one with. Hopefully you guys can help me out as I feel like I've hit a bit of a wall. 

 

Here's a screenshot of my attempt as well: 2018-07-16 11_34_38-Example2.vi Block Diagram.png

 

 

Download All
0 Kudos
Message 1 of 13
(4,011 Views)

@Kai456 wrote:

Hey guys,

I've got three while loops, 2 of which are in series, running in parallel with the third,

 


Nope, the bottom loop is dependent on the queue reference coming from the loop on the right. 

Scratch that.  I just couldn't interpret the drawing with all the backwards wires and wires exiting from the wrong terminal of the subVIs. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 13
(4,003 Views)

Sorry. I need to work on organization. Any ideas?

0 Kudos
Message 3 of 13
(3,997 Views)

Move the Event Structure into a loop that is in parallel with your main loop.


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
Message 4 of 13
(3,994 Views)

That makes more sense, but it's giving me an error that I can't figure out. Here's what I've changed:

image.pngAnd I get this error message when I try to stop it:

image.png

Could it be that I'm playing my grab notifier in the wrong place? 

0 Kudos
Message 5 of 13
(3,975 Views)

Do not close your Notifier until all potential readers are done.  In other words, close the Notifier after your top loop as completed.


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
Message 6 of 13
(3,943 Views)

So far I've put he release inside of the main loop, tunneled into, but outside of the main loop, inside and outside of the event loop (just trying stuff at this point). How would I ensure that it is released when the main loop has stopped? I'm stumped. 

0 Kudos
Message 7 of 13
(3,930 Views)
Solution
Accepted by topic author Kai456

@Kai456 wrote:

How would I ensure that it is released when the main loop has stopped?


Do exactly what you did with your bottom loop in your last image.  But instead, use the top loop.  Wire the Notifier reference out from the Wait For Notification to a tunnel on the loop and to the Close Notifier.

 


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
Message 8 of 13
(3,927 Views)

I see. My mistake was thinking that it always had to come out of the Send Notifier vi (don't ask). The issue with this solution now though is that while it does terminate the loop, the program still resets and starts over when you hit stop!

0 Kudos
Message 9 of 13
(3,917 Views)

It looks like the three loops receive the notification before the larger main one does? It has to iterate one more time before it sees the notification. Why is this?

0 Kudos
Message 10 of 13
(3,914 Views)