From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple loops with error handling and controll

Solved!
Go to solution

I have a project where I am running 4 loops at the same time and need to stop all loops with one stop button and stop all loops if one of the loops gets an error.

 

Loop 1.

Start up loop

controlls the other 3 loops

 

Loop 2.

Read analog voltage

 

Loop 3.

Read Digital inputs

 

Loop 4.

Write Digital output

 

Any one know how to do this?

kls
0 Kudos
Message 1 of 5
(3,633 Views)

Hi Kim,

 

use a notifier for your stop condition!

Loop 1 can set the notifier upon pressing the stop button.

The other loops set the notifier in case of an error.

Loop 2-4 read the notifier to stop execution…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,629 Views)

Many ways to stop parallel loops. I agree with Gerd, the best way is a notifier.

 

Here a useful document.

 

http://digital.ni.com/public.nsf/allkb/267704CDE91156D186256F6D00711AAE

 

Good luck



-Matt
0 Kudos
Message 3 of 5
(3,609 Views)
Solution
Accepted by topic author Kimlorentz

Two other methods not mentioned in the otherwise-excellent document Matt mentioned are use of a Global "Stop All" variable and a related use of a VIG/Functional Global Variable.  The reason to mention them is that they can be used to additionally stop "detached" VIs, VIs that are set to run asynchronously (and thus somewhat "out of control") with respect to the main VI.

 

I'm using a "combination of ingredients" for some Projects I'm currently developing using LabVIEW 2016 and its support of Channels.  For example, I use a Messenger Channel to create something analogous to a Queued Message Handler.  When the Event Loop detects the Exit button has been pushed, it puts an "Exit" Message on the Messenger Channel and also stops itself.  When the Message Loop sees "Exit", it sends an Exit Message on to whomever else needs to see it (in one case, the Producer of a Producer/Consumer pattern) and stops itself.  When the Producer gets the Exit Message, it puts a "Last Element, Not Valid" on the Stream Channel to the Consumer, and stops itself.  When the Consumer gets the Last Element message, it ends itself.  A glorious cascade.

 

And I'm working out (not yet 100% complete) how to extend this to Start Asynchronous Calls, which don't (yet) support Channels as easily ...

 

Bob Schor

0 Kudos
Message 4 of 5
(3,569 Views)

Tnx for the information. I was looking at this too. I will test this out but will take some time to edit my codes and connect the loops. 🙂

kls
0 Kudos
Message 5 of 5
(3,542 Views)