LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop whole program with one button

Hi, I've written a program for reading some values out of a measurement instrument. Now i want to have one button which stops the entire program no matter in which loop or which subVI the program is in. I have a subvi to make a connection to the device and i can't get out of this when he is trying to make that connection. Also the stopbutton i've used now is only read when the program is in a specific while loop. Can is solve this problem. I've attatched my program.
0 Kudos
Message 1 of 5
(5,367 Views)

HI

You can do this, but you have used the stacked seqeuence that will force the vi to go sequentially.

use while loop seperately without any dependancy. and connect the local variable of stop button to each loop. so when you stop the program it will stop all you while loops.

Hope this helps

Regards

Santosh

Message Edited by SantoshJaiswal on 02-17-2009 06:22 AM
0 Kudos
Message 2 of 5
(5,359 Views)

You will need to use global variables to communicate between VIs. Don't make it a habit since using them can lead to race conditions and synchronization problems, so I would recommend that you look into functional global variables, semaphores, notifiers and queues. The Help document in LabVIEW has detailed explanations on each one of them.

 

You will need to call a subVI in parallel if you want to continue with the execution of other tasks in your mainVI. I have created a quick example which shows the use of a global variable and using a subVI in parallel.

Message Edited by Adnan Z on 02-17-2009 04:31 PM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 3 of 5
(5,354 Views)

Hello,

 

I can confirm the recommendations of Adnan Z by using the functional global variable.

 

I can also recommend you to remove the local variables.  

You can put all variables into a cluster and simply use the "Bundle", "Bundle by Name", "Unbundle" and "Unbundle by Name" functions to read or write one or more elements from/to the cluster.

This is what you did with the "MB Ethernet Master Query.vi" functions.  Here you unbundled the "Register" element out of the cluster.

This way you keep the dataflow structure typically for LabVIEW and it will make your code easier to read.

Just by wiring the cluster wire throughout your VI, you will be sure that your applications runs in the correct order. You will be able to remove all your Flat Sequence structure.

The for the Stop function, just use a functional global variable which can be written to or read from by only one at a time.

Best regards,
Joeri

National Instruments
Servicesg
0 Kudos
Message 4 of 5
(5,303 Views)
User started new thread here
Best regards,
Joeri

National Instruments
Servicesg
0 Kudos
Message 5 of 5
(5,251 Views)