LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

execute subvi when stopping top level vi

I am monitoring a chemical reaction by using a spectrophometer, all controlled by Labview.  The spectra data are analyzed and 8 parameters are calculated.  These 8 numbers are passed to a DCS by using an analog output card as current; the traditional 4-20mA.

I want to send all zeroes to the DCS if an error occurs - easy enough to do, I just wire all the error clusters, etc.

I also want to send all zeroes to the DCS when the Labview program is stopped.  I have not been able to figure out how to do this, any ideas?

Thank you very much.
0 Kudos
Message 1 of 8
(2,842 Views)
Hello,
 
I can't see the problem in sending all the zeros when you stop the program. Maybe I'm not undestanding the problem. Can you post the program and the Labview version?
Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 2 of 8
(2,810 Views)

Thanks for responding; I don’t have the program right now as I am leaving for a trip.  I am using Labview 6.1 right now but during my trip they will upgrade to 8.2 so I’ll have to use 8.2 by the end of the week – I will post the program at that time.  This is the simplified sequence of steps in the program:

1 – Spectral collection.  This is done with an activex control and it takes 3 minutes to accumulate the spectral data.

2 – calculate absorbance (by using a stored blank spectrum) and other parameters from the spectrum (signal to noise, etc.)

3 – calculate intensities of 6 parts of the absorbance spectrum.

4 – display values of the intensities on the front panel

5 – display intensities on a bar graph

6 – save intensities with date and time to a log file

7 – send intensities to AO board as current (4-20mA) to be read by a central DCS.

go back to 1

I have done all the steps in preliminary form (I have not finished decorations, etc). 

There is a requirement that upon stopping the program all channels of the AO board should send the value zero to the DCS.

My question is:  if the program is stopped during step 1 for example, Labview will stop execution and the AO board will not send the value zero unless I am able to call a vi expressly doing this.  My initial thought is to put operations 1 to 7 inside a while loop and then when the loop is stopped I can see how I would call a vi to send the zeroes but if Labview stops execution during spectral collection for example …  My question was based on the thought that I could have a subvi execute (sending zero to AO) when the toplevel vi stopped.

Eventually, I will have to save all this as an executable but I will go one step at a time.  I hope my inability to express myself does not match my ignorance of programming.  You seemed to think the question had an obvious answer, thank you.


 

 

 

 

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

elmanco:

Another thought is that if your program always goes in a certain sequence, you could use a state machine architecture.

Thanks,

Rudi N.

 

Message 4 of 8
(2,783 Views)
How exactly are you stopping the program? You should be using a front panel control and an event structure. You should not be using the Abort Execution button on the toolbar. In fact, the toolbar should be hidden. With an event structure, you can control what happens when a VI is stopped. You can even trap the windows close functions (the File>Exit and the 'X' button).
Message 5 of 8
(2,780 Views)
In addition to what Dennis said if you need to force the outputs to a known state when LV stops for any reason (including OS crashes), then you need a hardware watchdog circuit. I am not familiar with anything readily available for 4-20 mA, but something could be built.

Lynn
Message 6 of 8
(2,773 Views)
Thank you very much everybody.  I will use an event structure no matter what the users say.  The wanted to use the abort button because as the measurement takes up to 3 minutes, they did not want to wait until the cycle was completed.  I will just hide the button.

To consider the options suggested I need a bit more time and certainly to return home.

Thank you again!!!
0 Kudos
Message 7 of 8
(2,759 Views)
Depending on how the measurement is being done, you could stop it when the front panel stop event is detected. There are queues, notifiers, and even global variables (shudder) that could be set. You would have to re-write the measurement code to some extent. It's also important that you use a structure in the measurement code that can be stopped. For example, a for loop will always run to completion and cannot be stopped early. A while loop can be stopped so you would want to replace any for loops with a while loop. A sequence structure will always execute all of it's frames. You would want to replace a sequence structure with a state machine, for example.
0 Kudos
Message 8 of 8
(2,742 Views)