09-20-2023 11:48 AM
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?
Solved! Go to Solution.
09-20-2023 11:51 AM
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.
09-20-2023 12:09 PM
@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.
09-20-2023 12:18 PM
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.
10-18-2023 12:31 AM
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.
10-19-2023 02:18 AM
@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