LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping a SubVI from the MainVI

Solved!
Go to solution

Hello,

 

I am creating a program in which a power supply will apply a bias for X seconds, step up the voltage for X seconds and so on.  While the bias is applied, I want to use a digital multimeter to measure the current every Y seconds (Y < X).  I am just starting out the framework of my code, and I haven't written anything that controls the instruments yet.

 

I am really working on having "neat code", and have the main code fit onto one screen.  I am trying to use subVIs as much as possible and make my code more modular.  On Thursday, I am actually taking the Core 2 class!

 

In the meantime, I have a problem.  I have two while loops running in a subVI.  One is use to determine when to change the bias, and the other is use to determine if a measurement is required (eventually I will append the data to a file which is while you'll see an "append" label if the if statement.  The problem occurs when I press stop from the Main VI, I still have to wait for that subVI to finish.  If it was just a few seconds, I wouldn't care, but the bias could be applied for hours.  

 

I've looked online and some articles have suggested using global variables which I don't have any experience with (yet).  I wasn't able to get a notifier to work, but I am not sure if passing a notifier is even possible.   The SubVI is called Elapsed Time.

 

I'd really appreciate some tips!

 

Thanks in advance!

0 Kudos
Message 1 of 5
(1,981 Views)

When attaching more than one file, please put them all in a single zip file. Thanks.

 

(For example, my downloads folder already has a several files originally named main.vi, so yours would get renamed to "main(25).vi" causing endless confusion. A zip file can be extracted into a new folder, making cross-linking much less probably)

0 Kudos
Message 2 of 5
(1,969 Views)

Certainly 🙂

0 Kudos
Message 3 of 5
(1,964 Views)
Solution
Accepted by topic author _natalie_

Some quick comments:

 

  • For the notifier to work across subVI boundaries, you wither need to give it a name or wire the notifier as an input to the subVI. (details)
  • Make your units button into a radiobutton control. No need to "check units". And to convert to seconds, just use it to index into an array of multipliers.
  • There is probably no need to spin the upper loop in "elapsed time" as fast as the computer allows if there is nothing to do.
  • You are only using relative times, so "high resolution relative seconds" is probably cleaner.
  • ...

 

Message 4 of 5
(1,943 Views)

Great suggestions!

 

Thanks, I got it working.

0 Kudos
Message 5 of 5
(1,862 Views)