LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

global stop

Solved!
Go to solution

Hi there, I've created a VI and in this VI there are some while-loops and subVI's. Now i want to stop the entire program with one button no mather when. (So no mather in which loop or subVI the program is in). I've tried using global variabels but that didn't work. I've attatched my VI's can somebody help me please?

 

Best Regards

 

Stefvg

Download All
0 Kudos
Message 1 of 23
(9,909 Views)

Here is a post that I had replied to in which I posted an example of using global variables and calling a subVI:

stop whole program with one button

 

Let me just let you know that there is a better way to architect your entire code. Please don't take this as criticism but I really think you should look into event structures, state machine design, queues and notifiers. Have a look at the Producer/Consumer Design (events) and the State Machine patterns by browsing through the templates that are shipped with LabVIEW (File -> New...). Your GUI should be interfaced with using event structures and not polling (like you are doing right now). If you have questions, be sure to post back.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 2 of 23
(9,886 Views)

Hi, i'm just a beginner in lv. I don't take it as criticism, i just tried to make the program work with the things i already knew in labview without searching for new (and probably better) methodes. Can you please send me the example in lv8.2 or lower? Then i can take a look at it.

 

Best Regards

 

Stefvg

0 Kudos
Message 3 of 23
(9,882 Views)

Yes, I would recommend that you go through the Getting Started with LabVIEW pdf that is available from the Getting Started window when LabVIEW opens up. Here is the example in version 8.0.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 23
(9,876 Views)

Hello Stef,

 

First I would like to recommend you not to start a new thread which is actually a continuation on an earlier thread. (Original Thread)

 

I see you already implemented some advises like using clusters.

You also used feedback nodes where it would be better to use a shift register which is also a kind of feedback node but makes your code easier to read.

 

I understand that you would like to use your current knowledge of LabVIEW to build your application, but your application will be much easier to read/understand and maintain/build when implementing some recommendations done by Adnan Z and myself.

I would at least go for the State Diagram architecture which is actually a case structure with a case for every situation you can have in your system. This is a very easy archtecture to implement.

One of the cases is the stop case which will be executed when you press the stop button.  You will only need one while loop and one stop button.

Have a look at the LabVIEW Examples or Templates concerning  the "State Diagram Architecture".

 

The State Diagram Architecture is also explained in the LabVIEW Basics II course. I know that several professors of the department "Meet en Regel" of your school already attended this course at the National Instruments Belgium facilities.  Maybe one of them can borrow you this book to give you a better understanding of this architecture.

 

If you need more assistance, don't hesitate to ask.

 

Best regards,
Joeri

National Instruments
Servicesg
0 Kudos
Message 5 of 23
(9,849 Views)

Hi, thanx for all the advise. I've changed my program in the way i think you would recommand it. Could you give it another look please and give some further suggestions or advise.

 

Best Regards

 

Stefvg

0 Kudos
Message 6 of 23
(9,833 Views)

Hi, i do have one more question in particullar. I still can't stop the subVI connection when i push the "stop programma" button when he is trying to make a connection. Can somebody tell me what i am doing wrong?

 

Best Regards

 

Stefvg

Download All
0 Kudos
Message 7 of 23
(9,826 Views)

I did not look at your complete code, but it does appear that you have a race condition.

Simply locating the stop button (and Local Variable) to the right of the while loop does not cause it to be executed at the end.  On the contrary, it will likely execute before it goes into the state machine, which means that although you press the stop programma button, it will go to the next state before the next time it reads the status of the stop button.  As such, the program will call the sub-vi and will execute it completely before the status of the stop button is updated.

 

The better architeture would have been to use an Event Structure... but that would not have solved the problem either.  You need a means of sending the boolean value to a sub-vi as soon as it changes.  The Global Variable is not the appropriate way.  A Functional Global may work.  Wiring a reference to the "stop programma" button into your sub-vi's and reading it's value using a property node (wired to the reference) would solve your problem.

 

R

 

Message Edited by Ray.R on 02-25-2009 07:30 AM
Message 8 of 23
(9,813 Views)

How can i do that? where can i find this reference? Do you have an example maybe on how to do this?

 

Best Regards

 

Stefvg

0 Kudos
Message 9 of 23
(9,799 Views)

I will prepare two very simple examples.

The first one will be using a state machine and the second using an Event Structure.

 

Will be back soon.

 

R

 

Message 10 of 23
(9,787 Views)