LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Terminate LV program with digital input

Solved!
Go to solution

Hi...

I have a labview 2010 program which is working fine... 

I have 4 nested while loops. 

 

Now inwant to add a new functionality in the code... 

 

I want to read a digital signal using my daq card, and whenever that signal goes HIGH i want to terminate my entire  labview program. Pretty much similar to pressing the STOP button on the toolbar. 

 

 

Currently, i have my digital read function in the inner most loop (this loop runs the most of the time). And whenever the input goes HIGH i terminate the inner most loop, then the outer one and so onnn. But this approach is causing some issues (i dont want to discuss those issues as i know i could make it work).

 

Is there any built in function  which can terminate  a program completely  regardless of whichever loop it is currently running?

 

0 Kudos
Message 1 of 6
(867 Views)

Yes, there is a function QUIT LABVIEW  on the pallet Application Control. 

You can read the digital input and execute it if true. It will quit the application.

LVNinja_0-1695228660351.png

 

0 Kudos
Message 2 of 6
(864 Views)

@LVNinja wrote:

Yes, there is a function QUIT LABVIEW  on the pallet Application Control. 

You can read the digital input and execute it if true. It will quit the application.


Beware.  Using this function is like stopping your car with a tree.  You should properly shut down your system, making sure outputs are reset and references are properly closed.  The fact that you have nested loops tells me you have a bad design.  Rethink your architecture, most likely as a State Machine.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(852 Views)

If you don't mind pushing the power button on your PC without shutting down Windows, or you don't mind using a brick wall to stop your car, then the Quit Labview function may be the perfect option for you. If that is not you, then for the love of all that is engineered and well-thought-out, please find another solution. 

 

I recommend a state machine architecture.  Four nested while loops sounds like a nightmare in the making. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 6
(846 Views)
Solution
Accepted by AlphaBetaGamma

I had the program already working on a PC and one of my seniors developed it a long time ago. therefore i had to work with the same program with four nested loops. 
I simply added the Stop function in each loop (the program always stays in one of those four loops) and it worked. i didn't have to reset, properly shut down or safely close the program, i just needed it to STOP no matter whatever it was doing. So the STOP function worked perfectly for me. 

the link to the STOP function is:

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/stop.html 

Thanks for all the great ideas. 

0 Kudos
Message 5 of 6
(684 Views)

@AlphaBetaGamma wrote:

I had the program already working on a PC and one of my seniors developed it a long time ago. therefore i had to work with the same program with four nested loops. 
I simply added the Stop function in each loop (the program always stays in one of those four loops) and it worked. i didn't have to reset, properly shut down or safely close the program, i just needed it to STOP no matter whatever it was doing. So the STOP function worked perfectly for me. 

the link to the STOP function is:

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/stop.html 

Thanks for all the great ideas. 


 

I'd say, this is a legit usecase

0 Kudos
Message 6 of 6
(659 Views)