LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to reinitialize a stopped while loop

Hi everyone.

 

If I have two while loops running in parallel, and I stop one of the while loops with a stop boolean, how can I restart that while loop again from another boolean button?

0 Kudos
Message 1 of 14
(5,774 Views)

Hi David-Baratheon,

 

There's several way to do it.

The first thing to do, is to include the loop you want to restart in another high level loop. Then you could use an event structure insithe the high level loop to run the low level loop each time you click on your boolean.

 

Regards.

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
Message 2 of 14
(5,765 Views)

Hi Sabri, 

 

Thank you for your input.

 

I am looking for the second loop to run continuously until I stop it, and then start again when I start it.

 

At the same time I have some various booleans in my first loop that I want to continue to run in parallel.

 

If I put the second loop inside the first loop, I found that labview gets stuck inside the second loop and so nothing from the first loop works in parallel.

0 Kudos
Message 3 of 14
(5,755 Views)

I tthink there's a misunderstanding.

 

The high level loop goal is to allow you to restar one or several loop on demand.

So you could include all the parallel loops inside the high level one.

Do you want an example?

Regards

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
Message 4 of 14
(5,744 Views)

Yes please if you have one.

 

It sounds good.

 

So how would the event structure be used?

 

Could I just use two parallel while loops inside a "master" while loop?

0 Kudos
Message 5 of 14
(5,737 Views)

My example is based on producer consumer with event structure.

There is one loop to handling event, one loop that you can restart and one that you cannot.

 

Hope this helps

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 6 of 14
(5,726 Views)

Perhaps something like this would suit your needs.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 14
(5,674 Views)

Hi Jatlaoui,

 

In your example the top loop should have a "False" wired out of it in the "run loop" case. Then you can make another exit case which has a "True" wired out. As it is right now, you can only run it once, not stop and restart.

0 Kudos
Message 8 of 14
(5,648 Views)

Yes, true, I forgot to change it.

 

Thx.

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 9 of 14
(5,637 Views)

I made the correction. And change the stop button behavior to lacth when pressed.

 

😉

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 10 of 14
(5,632 Views)