LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping two parallel while loops with a single boolean action

Solved!
Go to solution

Hello,

 

Title explains it pretty well.  I am having trouble ending my two parallel while loops with a single stop button.  I currently have two separate stop buttons, one in each while loop, which both must be pressed to stop the VI. 

 

I tried changing the mechanical actions on the front panel from latch to switch, but that did not work.

Any other ideas?

 

Thanks1

Message 1 of 19
(6,092 Views)

Have you tried branching the top while loops boolean control output wire and connecting the branch to the bottom loops stop button? That was both loops are controlled by one control on the front panel.

 

Edit: Upon testing that does not work properly - I can see if I can figure it out in the morning. Maybe someone else will chime in before then!

0 Kudos
Message 2 of 19
(6,083 Views)

Are you using LabVIEW 2016 or later?  If so, your best solution is Channel Wires, with a "Tag" channel.

 

 

0 Kudos
Message 3 of 19
(6,056 Views)

Another simple solution would be an event structure, using the timeout event to determine loop timing. Place the Boolean terminal in loop 1 and create a stop event in loop 2.

 

Other options would be queues, etc 

 

You really need to be more clear, even show us some code.

Why do you need two loops?

What was the problem with changing the mechanical action?

What was the original mechanical action and what did you try to set? (With switch action, you could use a local variable, but you need to make sure to reset on run.)

Message 4 of 19
(6,051 Views)

@etvg wrote:

Have you tried branching the top while loops boolean control output wire and connecting the branch to the bottom loops stop button? 


This cannot work as desired because of the principles of dataflow. The bottom loop cannot start until the top loop has completed, at which time the Boolean is true and the bottom loop will iterate once, then stop too.

 

Message 5 of 19
(6,048 Views)

I was going to demonstrate stopping two loops using a Tag Channel Wire, but got carried away and added two more loops (and could just keep adding them ...).  Here are four loops, running in parallel and being stopped by a single Stop button in Loop 1, using Tag Channel Wires to carry the Stop to the other three loops.

Stop 4.png

This Snippet is in LabVIEW 2018, but if you have LabVIEW 2016 or 2017, it is very easy (and very educational!) to create.  I recommend making Loop 1 without the Stop Control (or Channel Writer), duplicate it to make the other three Loops (arrange as you wish -- I tend to arrange parallel loops vertically and "snake" the Channel Wire "out the right", loop back, and "in on the left", but a horizontal arrangement (as in Loops 3 and 4) is also common.  Anyway, create the Stop Indicator, the Channel Writer, the Tag Channel Wire from Loop 1 to Loops 2, 3, and 4, and finally the three Channel Readers.  Be sure to choose the Tag Channel when you create the Writer.  Note that the Channel Wire is a nice shade of Boolean Green.

 

Bob Schor

 

0 Kudos
Message 6 of 19
(6,039 Views)

I wish I was, because your solution seems very effective and logical.  However, the version I am using is 2014.

0 Kudos
Message 7 of 19
(6,012 Views)

Hello,

Thanks for the reply.  My problem is that I am a summer intern, who just started learning Labview at the the start of the summer 3 months ago so I am very new.

 

I attached an image of my code.  The purpose of this VI is to control and monitor a duct system with a filter, fan, and heating element about 7 feet long.  We followed ANSI 210-16 standard to set up the system.  We are using thermocouples and a pitot tube hooked up to a pressure transducer to monitor heating element temp, airflow, and static pressure.  The purpose of the PWM is to control the electrical load being supplied to the element with an SSR.  

 

My modules being used are: NI 9219 AI to monitor temperature.  NI 9215 AI to monitor voltage signals from the pressure transducer.  NI 9472 DO 24V to generate pulses to the SSR.  

 

The original mechanical action for the stop button on the front panel was 'latch when released' which I believe is default.  Playing around with the actions was confusing, and I couldn't seem to find an appropriate action.  I like the idea of using a switch action to local variable with a reset on run, but am unsure on how to do set up the reset.  

 

Thanks!

0 Kudos
Message 8 of 19
(6,007 Views)

Also, the group of functions just below the static and total pressure indicators is a low pass filter to reduce noise from the transducer signal.  The IIR control is how much you trust the voltage output (values 0-1).  Values closer to 0 will reduce the most noise, and a value of 1 will reduce none.  

0 Kudos
Message 9 of 19
(6,005 Views)

Well, if a Tag Channel is a Notifier on Steroids, you could do it that way ...  If you do, be sure you use Wait on Notification and set the TimeOut to 0 (so, paradoxically, it doesn't Wait).

 

Bob Schor

0 Kudos
Message 10 of 19
(6,004 Views)