LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop two parallel loops with stream channel

Solved!
Go to solution

Hi, I am trying to stop two parallel loops with a single Stop button, when I try this method in two loops that just count numbers it works, but not in my VI.

How can I solve it?

 

Thanks

 

P.S. I attach my VI

0 Kudos
Message 1 of 12
(1,314 Views)

Maybe the "Stopped" output form Vision aquisition is false?

 

In what way does it not work? It surely works with just the channel wire code.

 

Does one of the loops continue to iterate? Does the execution stop at/in a sub-VI... etc.

 

If you press the lightbulb you can see where the code is executing.

 

Certified LabVIEW Architect
0 Kudos
Message 2 of 12
(1,302 Views)

Not sure how you have handled in your Module.

 

Still i am using LV2020, Down converting and sharing will be nice to suggest best options.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 12
(1,301 Views)

Instead of a channel wire, use the local variable with switching mechanical action.

0 Kudos
Message 4 of 12
(1,275 Views)

@ZYOng wrote:

Instead of a channel wire, use the local variable with switching mechanical action.


That wont help. The error is not there.

Certified LabVIEW Architect
0 Kudos
Message 5 of 12
(1,271 Views)

When I read the subject line of this Post, I assumed you were using a Stream Channel in place of a Queue in something like a Producer/Consumer Design pattern.  One of the significant "good points" about the Stream Channel is that it has a built-in Sentinel that lets the Producer tell the Consumer "I just sent you the last piece of information, so when I close my Producer loop, you can safely close your Consumer loop once you see the "Last Element" output from the Consumer is True.  You can, indeed, wire this directly to the Consumer's Stop Control to safely stop the Consumer.

 

But this isn't what you are doing -- you are using the Stream Channel wire to send a single Boolean from the "sending Loop" to the "receiving Loop".  This use of a "synchronizing" structure is more similar to a Notifier than it is to a Queue, and the appropriate Channel Wire analog to the Notifier is the Tag Channel.

 

How are the two Loops related to each other?  If they are running truly independently, it might not make sense for one of them to have control over stopping the other.  In many of my programs with multiple loops tied together by Channel Wires, I have an Event Loop that would have the "Stop" button tied to a Tag Channel that branches to possibly multiple otherwise-free-running Loops and shuts them all down.  [If any loops are in Producer/Consumer patterns, I only send Stop to the Producer, and let it use its "Last Element", possibly with the "Is Valid" flag set False to signal the Consumer to just "Stop" without having to process anything.

 

Bob Schor

Message 6 of 12
(1,220 Views)

Hi all,

 

The loops are independent, each one is measuring different things at a different rate, what happens is that one of the loops stops and the other continues running. What I want is to stop the program completely with only one stop button and I was triying to link both stop loops but maybe there is another way. I attach the VI in LV2020.

 

Thanks for your responses

0 Kudos
Message 7 of 12
(1,167 Views)

As I said, the stopping code with the channel wires work correctly. Something else is happening. I asked some questions and if you answer them I can help you. 

 

To read more about stopping parallel loops: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGxRCAW&l=sv-SE

 

Certified LabVIEW Architect
0 Kudos
Message 8 of 12
(1,160 Views)

Hi,

 

When I push the button the first loop stops but the images one continues executing.

I tried to connect the wire to the stop loop but the result is the same.

Maybe this helps, one thing that I tried was to put an indicator after the read of the channel wire and it is always off

 

Thanks 

0 Kudos
Message 9 of 12
(1,153 Views)
Solution
Accepted by topic author Wavicle

You want one Stop button placed "somewhere" to stop two parallel loops.  As I said before, this is a job for a Tag Channel.  The Stop button can really be almost anywhere inside the VI (I placed it in one of the Loops, but because the Tag Channel can branch, you can add additional Channel Readers to "catch" the Stop request.

 

This is your original example, with changes, showing Tag Channels to stop both loops.  I'll note the changes below.

 Stop Parallel Loops.png

 

  1. I reset the Stop button to its default "Latch when Released" mechanical action.

  2. I used "Reset all values to default" and tied it to the first loop via the Error Line to ensure that the Stop button starts "False".  No Frame Sequences needed!
  3. I used Tick Count (ms) to get a better estimate of time for measuring Elapsed Time (read the Help).
  4. I made the top loop the "fast" loop, and put Loop Counters in which make it more obvious which loop is running faster.
  5. I used a Tag Channel to take the Stop value to the second loop.

This works.

 

Bob Schor

Message 10 of 12
(1,123 Views)