LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview - how to perform certain operations when the VI program is closed

Hi, I am new to Labview, I am writing a program to generate a voltage in USB6002. I am attaching an example program.  I also need 'enable' using digital High, and am able to do this, using a boolean (Run button). When I click off (?) the run button, the digital signal becomes low, as expected. 

 

The problem is, when I close the VI without remembering to click off the run button, then the digital high continues to be on. I want the VI to essentially 'click off' the run button (make the digital pin low) and then exit. But I am not sure how to do that. The trial version is attached here. My attempts to use event structure with 'Application Instanced Closed?' is not successful. Any help will be appreciated. Thank you.

 

Best Regards

S. Ramanathan 

0 Kudos
Message 1 of 8
(2,914 Views)

@Ramanathan_S wrote:

Hi, I am new to Labview, I am writing a program to generate a voltage in USB6002. I am attaching an example program.  I also need 'enable' using digital High, and am able to do this, using a boolean (Run button). When I click off (?) the run button, the digital signal becomes low, as expected. 

 

The problem is, when I close the VI without remembering to click off the run button, then the digital high continues to be on. I want the VI to essentially 'click off' the run button (make the digital pin low) and then exit. But I am not sure how to do that. The trial version is attached here. My attempts to use event structure with 'Application Instanced Closed?' is not successful. Any help will be appreciated. Thank you.

 

Best Regards

S. Ramanathan 


You can detect when someone clicks the [x] button, prevent the app from closing and instead execute code to shut down gracefully (e.g., send the signal low, etc.), then let the app close gracefully.

 

See this link.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 8
(2,896 Views)

You forgot to attach the vi. When you say "when I close the VI without remembering to click off the run button" what do you mean? Are you using the Panel Close (the X at the top right of the screen) or the Abort button (the Stop sign on the tool bar)?

0 Kudos
Message 3 of 8
(2,894 Views)

An Event Structure can detect these Events that might be helpful to you

 

  1. <Application> ---> Application Instance Close
  2. <This VI> ---> Panel Close
  3. Panes ---> Panel Close

Use them to perform a "safe shutdown" or warn the user if they just close the program.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 8
(2,846 Views)

Sorry, I forgot to attach the VI. As a backup, here is a dropbox link of the file. https://www.dropbox.com/s/0toq0nt9bi6cr0s/Example01.vi?dl=0

 

Will go through the suggested solutions and test and update. Thank you all for the help.

 

Best Regards

S. Ramanathan 

0 Kudos
Message 5 of 8
(2,812 Views)

There are a lot of things wrong with this code. First, if you have a STOP button to end the program then you should use that in your Event structure, and put the button in the Stop case. Also, you have a race condition. You could very well be turning the digital high OFF and then immediately back ON. Put your other code in the Timeout case and add a reasonable timeout in order to eliminate this. You really should consider a state machine.

 

Finally, I would recommend reading through the training materials at the top of this board.

Message 6 of 8
(2,803 Views)

Thanks, looks like I have to pick up quite a few things to sort it out. Thanks for the pointers

 

Best Regards

S. Ramanathan

0 Kudos
Message 7 of 8
(2,770 Views)

@Ramanathan_S wrote:

Thanks, looks like I have to pick up quite a few things to sort it out. Thanks for the pointers

 

Best Regards

S. Ramanathan


Feel free to come back with specific questions as you develop your code.

0 Kudos
Message 8 of 8
(2,754 Views)