LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UserEvents to communicate between subVIs and a main VI

Solved!
Go to solution

Continued from question http://forums.ni.com/t5/LabVIEW/2-parallel-state-machine/m-p/3247857#M946309

Want to start 2 state machines running parallel. Have been suggested to use UserEvents

 

Mainvi:

main.png

 

subvi:Capture.PNG

 

I have 2 questions:

1)

Am I right when is say that I can place my state machine in the subvi instead of the random generator and the waveform chart?

2)

how to start subvi with arguments?

 

 

 

 

0 Kudos
Message 1 of 16
(3,546 Views)
Solution
Accepted by topic author Michael.Koppelgaard

@Michael.Koppelgaard wrote:

Continued from question http://forums.ni.com/t5/LabVIEW/2-parallel-state-machine/m-p/3247857#M946309

Want to start 2 state machines running parallel. Have been suggested to use UserEvents


I have 2 questions:

1)

Am I right when is say that I can place my state machine in the subvi instead of the random generator and the waveform chart?

Yes, one way if you create your state machine by using a shift register (with Enum or string) located on the While loop around the Event structure. Note that, the timeout of the Event structure which is creating the random numbers at certain intervals. You could have your DAQ here. Of course, there are other options, like using two parallel loops in the subVI, top loop only for the GUI and Dynamic Events, and the bottom loop would do the DAQ, and even hold the state machine logic...

2)

how to start subvi with arguments?

Also have a look how I did in my example project: I call the subVI with two arguments: an ID (numeric U32) and the typdef cluster holding the UserEvents references. You can just easily create another input terminal for this subVI, like a cluster which could hold several parameters (like DAQ parameters, COM ports, device ID, etc...). After modifying this subVI, do not forget to update the "Type specifier VI refnum (for type only)". You can right click on this object, and browse your modified subVI, so the new input terminal will "appear" on the "Start async call" icon.

 


 EDIT: start to design your state machine in the subVI, and later post your VI so we can comment and help if you need.

Message 2 of 16
(3,520 Views)

I have to keep it as simple as possible for now. Have to finish this program and the equipment by the end of this mount.
But later in March I'm going on a Labview course which hope can teach me about this - I find it difficult to understand despite your help. I will properly return with more questions

0 Kudos
Message 3 of 16
(3,490 Views)

Is it possible to have to to instances of the subvi in 1 form, 1 in each tab i a tabcontrol?

0 Kudos
Message 4 of 16
(3,481 Views)

@Michael.Koppelgaard wrote:

Is it possible to have to to instances of the subvi in 1 form, 1 in each tab i a tabcontrol?


I think for this case you need to use subpanels. However I never used subpanels before, but if i get some time I can have a look how to load two clones of the single subVI into two subpanels (i guess this is what you want?).

Maybe someone with better LV skills will come here, and show us how to deal with subpanels in this case...?

(no time right now, I have German lesson in 3 hours, and my home work is not done yet 😄 )

0 Kudos
Message 5 of 16
(3,475 Views)

Okay - you are a student Smiley Very Happy

I better not answer more questions today.

Do you have some spare time tomorow ?

0 Kudos
Message 6 of 16
(3,471 Views)

Haha, it is offtopic, but I am not a student unfortunately anymore 😞 I am a "wissenschaftler mitarbeiter" (physicist, got my PhD back in 2011) in a research center in Germany. It is pretty hard to start learning German when you would like to spend more time with programming and research 😄

Yes, I might have some time tomorrow, lets see...

 

edit: have a look at this doc in the mainwhile: http://digital.ni.com/public.nsf/allkb/60A749CF788726088625766200537F65

0 Kudos
Message 7 of 16
(3,461 Views)

Nice !!!

Now I can load the same vi twice - but can't start I though. 

0 Kudos
Message 8 of 16
(3,414 Views)

Here is my main ViCapture.PNG

0 Kudos
Message 9 of 16
(3,412 Views)

Ups  - this must be more correct

Capture.PNG

0 Kudos
Message 10 of 16
(3,389 Views)