LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I detect when a sub vi finishes

Hi All,

 

I'm new to labview and would like some assistance.

 

I have produced a sub vi that generates 2 half sine wave of adjustable frequency and amplitude. These are cascaded to produce a number of cycles. These are all included in a case statement. The false state produces a dc output and the true state produces the sine cycles.

Before the button is pressed a dc level is output, when it is pressed  a number of sine cycles are out and when they have finished the dc level should reappear.

 

I would like to know how to detect the completion of the sub vi in the true case so I can switch the case statement back to false asap.

I'm having problems with gaps in the output data when the sub vi teminates and the case statement reverts back to the false state.

 

Many thanks

Andy

Download All
0 Kudos
Message 1 of 15
(3,016 Views)

Hello Andy

 

Thank you for getting in touch regarding your problem, I am an applications engineer at National Instruments and I will be supporting you with your query. As I understand you have a case structure which opens a sub vi, runs for a while and then changes back to its original state, and the problem you are having is switching from the vi execution case to an alternative case.

Thank you for sending in your vi's, I have been able to look at the HalfWaveBlock vi, but have not been able to open the pulse generation vi, could you send this again please? I can then look at your code and possible ways to implement the functionality.

 

There are a few options for approaching this task.

- Time the sub vi execution and add a timing condition to the case structure in your main code.

- Have a condition in the sub vi that alerts the main vi of completion.

 

I have also found some resources which will help you understand the functions you are using and will also give you some ideas for implementing further functionality.

 

- Execution Structures: http://zone.ni.com/devzone/cda/tut/p/id/12293

- VI analyser toolkit: http://zone.ni.com/devzone/cda/tut/p/id/5046

- Sub Vi indicator: http://digital.ni.com/public.nsf/allkb/26B1D8C3629475B686256DAD005816F6?OpenDocument

- Timing, Shift Registers and case structures: http://forums.ni.com/t5/forums/replypage/board-id/170/message-id/579608/tab/rich

 

There are also a number of examples available through the help tab and example finder window within LabVIEW itself. A few that I recommend looking at are.

- Dynamic Load Example.vi

- Dynamically Monitor VI

 

If you could look at these resources and send me your code, we can then both continue to work on a solution to this issue.

 

Regards

Stephanie L
Applications Engineer
National Instruments UK and Ireland
0 Kudos
Message 2 of 15
(2,976 Views)

A sub vi is finished when you get a value from it's outputs. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 15
(2,951 Views)

Stephanie: Thanks, I will look at the links when I can grab a bit more time. I've re-attached the vi.

 

 

Yamaeda: My vi finishes when it stops producing data. How I detect this is the issue for me.

0 Kudos
Message 4 of 15
(2,947 Views)

Your question is silly. If you would choose the correct mechanical action (i.e Latch Until Released, the 'Start Waveform' button will automatically return to the False state as soon as the True case finishes (when all subVIs finish). As it is now, the button does return to the false case as soon as it is read. You are making the problem much more complex than it really needs to be.

0 Kudos
Message 5 of 15
(2,925 Views)

Your Array initialization can be simplified by alot (look at Initialize array with a 4-slot constant). It should also be placed outside the main loop.

Usually you create a sub-vi such that it returns a result through it's connector pane. If wired so, the program will wait until the result is recieved which'll also double as a Completion-indicator of the function.

 

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 15
(2,913 Views)

Hi All,

 

Dennis: My question is only silly to those who have greater experience and knowledge than me. I'm more used to writing C in microcontrollers where I know exactly what everything does because I write the code. Having said that you comments are very useful. I could not find out what released the button and when.

 

Yamaeda: I know the method of setting the waveform data was very crude but I needed to do it relatively quickly and it was the only way I knew at the time. Ideally the valuese would come from a file (text or spreadsheet) but I've not had time to work on doing it this way. Although most of the values are the same eventually they will be changed to be unique. I ill also lookup Connector Panes to see how these work.

 

Thanks to all

 

Andy

Message 7 of 15
(2,892 Views)

Dennis: That's not the way to welcome someone to this forum, by saying his question is silly. He also says he's new to LabVIEW.  

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 8 of 15
(2,886 Views)

Sorry for assuming that someone has taken a couple of hours to do the basic LabVIEW tutorial. And, since the button was automatically returning to the false state anyway when the subVIs finished, the question just did not make much sense.

 

 

0 Kudos
Message 9 of 15
(2,855 Views)

Sorry Dennis. I was too quick to answer to this thread. I suggested this in the "Forum feedback" board. 

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 10 of 15
(2,840 Views)