LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To start and end the multiple subvi in the project from the parent Vi

I am trying to create the multiple subvi for my simple program.
A. Sine wave program
B. Cos Wave program.
C Main Program:
I have created the global variable which can show their value in the main program. Can I start and stop multiple subvi together?

 

I have enclosed the vi file with this. 

0 Kudos
Message 1 of 6
(1,417 Views)

Hi Skdubey,

 

You can run them all together by simply placing the SubVIs outside of the main loop:

JGoebel_0-1617230946093.png

Though I don't really see where you're going with this, and if you want to have parallel loops doing different things, you should consider looking at the "Producer Consumer" or "Queued Message Handler" Design Patterns.

https://www.ni.com/de-de/support/documentation/supplemental/21/producer-consumer-architecture-in-lab...

https://www.ni.com/de-de/support/documentation/supplemental/21/using-a-queued-message-handler-in-lab...

If you want to dynamically start and stop the VIs, you may also have a look at the call by reference or asynchronous call functions:

https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/dynamic_loadcall_vis/

https://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/acbr_call_and_collect/

https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/asynchronous_vi_calls/

 

Hope this helps!

Cheers,

Jan Göbel

0 Kudos
Message 2 of 6
(1,386 Views)

Hi,

 

a. I tried to create two subvi in my main program itself. But When I start they all start together but when I click on the stop button on the top of the tab. It stops all the programs at the same time but I don't see the same value for both trigonometric functions, feels like there is a delay in time. I am preparing an application that requires synchronization. Not sure why it's happening?

 

01.png

 

 

b. if we click on the stop sign(in a circle) in the main program, only the main program stop but both sub vi keep running. any suggestion?

 

02.png

 

0 Kudos
Message 3 of 6
(1,330 Views)

Hi,

 

I haven't looked through your code yet (posting from phone) but a few points from the images:

  • If you want reliable synchronization, don't use Global Variables for passing data
  • Consider a more structured message passing system,probably involving either Queues or Notifiers (or both, depending on usage).
  • If you describe the eventual goal, we might be able to suggest a better way of approaching the problem.

GCentral
0 Kudos
Message 4 of 6
(1,323 Views)

Hi I wanted to create project with the feedback control system. If you can just share good way to create this project it will be really helpful:


Single Project File
A. Subvi: To check if the all the port is working (Motorport, Sensorport and the Inital Encoder position)
B: Subvi (global): Error: to preserve the online error:
C. Subvi: Motor commands: (Directory for all the command but I can choose few commands from the main control panel)
D. SubVi(global): Motor setting
E. Subvi: Motor Position and encoder step
F. Subvi: Set variable for the temperature
G. Subvi: Motor adjustment
H.Subvi: ( PID way to calucalte the differnce in the set temperature and issue the desire rotatin for the motor)
I: SubVi : Encoder read position
H: Main Panel: Parent Vi : all the important parameter: Encoder steps, temp vs time , temp vs posiiton of the valve and PID constant and start and stop for all the subvis...
You can also suggest, How can create the controlling loop espcecalliy PID? any basic to build the PID in the LabVIEW?
thanks

 

 

Need to implement the following block diagram into Labview program:

I have stepper motor, temp sensor and encoder. 

 

 

skdubey_0-1617463520832.png

 

0 Kudos
Message 5 of 6
(1,307 Views)

Ok, thanks - that should help me ask better questions and give some suggestions!

 

A - So this is a setup/initialization step. You want one (or perhaps more - might be better to have one per instrument) subVIs to connect, set any communication properties, maybe test communication. You'll call this/these VI(s) before you enter the main loop(s) of your Main VI.

B - I don't really understand what you want here - I'm guessing some sort of log of all of the errors that have occurred, possibly in a list? Or the most recent error? But this should be updated by anything that throws an error. Note that you might not need a VI for this if you have a simple case, an Error Indicator and a shift register might be enough...

C, D - I think the goal here is to take some desired command for the motor, and send the message to the motor to instruct it to do that thing? Probably what you might want here is one VI per command (possibly in a library - (LVLIB file)), and then to choose which one to use. This could be via an Event Structure, perhaps.

E - I guess these are Reads of the position of the motor? You mention motor + encoder, is this that both report a position and you want to see both/compare?

F - Bit confused here when I also consider your diagram. Is this a measurement of temperature, or something else?

G - How is this different to C? It might be that in the creation of your library for C+D, you also include the code for G?

H - numeric inputs and outputs, do maths inside. No connection to hardware, so should be straightforward to test 🙂

I - Is this different to E?

 


@skdubey wrote:

H: Main Panel: Parent Vi : all the important parameter: Encoder steps, temp vs time , temp vs posiiton of the valve and PID constant and start and stop for all the subvis...
You can also suggest, How can create the controlling loop espcecalliy PID? any basic to build the PID in the LabVIEW?
thanks

 


H-again: I guess the first few of these are graphs? You'll probably need a Shift Register to store historical data and update it with the loop's new values from 'this' iteration. If you implement the VIs B-I as non-loop VIs (such that they do something once and then stop, taking only very short times, ideally) then stopping becomes straightforward - you only have a single Main While loop in your main VI. The subVIs are called every time they're needed, and almost immediately finish.

You can also look at Feedback Nodes if you prefer their appearance to Shift Registers - they can fulfil the same goals in most cases.

 

If you use an Event Structure to handle button clicks, make sure that either a) your PID is in a separate loop, and you have message passing between your loops, or b) you have a short timeout (perhaps 0) wired to the Event Structure, and then it will continue if there are no buttons clicked.

 

Partial demo sketch in Paint 😉 Lots left out here, mainly because it's hard to draw in Paint...

cbutcher_0-1617467228572.png

 


GCentral
0 Kudos
Message 6 of 6
(1,302 Views)