LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use user event with event loop

Solved!
Go to solution

Hi,

I want to communicate between 2 VI, so I have a global variable (boolean)  that gives the order to an event tool to run. The problem is the fact that event loop does not accept global variable, I found in the forum that I can use user event. Of course, the second VI works normally when I push the button (boolean) in it to run the event loop. Please can someone explain to me how to do this, I am a chemist.

 

Thank you.

0 Kudos
Message 1 of 7
(3,140 Views)
Solution
Accepted by topic author ziedhosni

You need to register the receiving Event structure for the event you want it to receive.

 

Example_VI_BD.png

 

To do it in two VIs, you'll need to share the user event reference between them.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 2 of 7
(3,080 Views)

If the two event structures are in different VI (which they should be) all you have to do is give the user event a name and acquire a reference to the same event name in both VIs.

 

What you should probably do is look up the producer/consumer design pattern template. There are two versions of it, you want the version that uses the user-defined events. This template will give you a good model for using the events, and you might want to consider it as a structure for your entire program.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 7
(3,060 Views)

I'm not following you.  If this is my main VI:

 

Example_VI_BD.png 

 

My sub VI only works like this:

Example_VI.png

 

This doesn't work:

Example_VI_BD.png

 

What have I missed?

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 7
(3,046 Views)

Smiley Happy Thank you guys for your help. My program is running.

0 Kudos
Message 5 of 7
(3,034 Views)

User events can have names. If two VIs acquire event references and use the same event name, they will both end up with references to the same event. Give the same even name in both VIs and the code will work.

 

Note that you "acquire" a reference to an event, and then at the end "release" the reference (and not "create" and "destroy" references). LV does the creating and destroying of references behind the scenes by keeping track of the number of references to a named event that have been acquired and not released.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 6 of 7
(3,026 Views)

I'm still not following you.  I've named the event "myEvent" in both VIs and it doesn't work.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 7 of 7
(3,008 Views)