06-14-2024 02:19 PM
I know how to use queue, global variable, functional global variable, etc. to pass data from one VI to another, but can the same be done with event structure (generate user event,...)?
Solved! Go to Solution.
06-14-2024 03:57 PM
Yes. Attached are excellent examples from years ago that still apply from a presentation by a LabVIEW expert. Look at it, then come back with additional questions if you have any.
I almost exclusively use User Event for Communications; they take a little more work, but are highly flexible.
06-14-2024 04:04 PM
Right click Event structure to select show dynamic event terminals.
06-15-2024 12:03 AM
Thanks McDuff for sharing. These are great examples. I will definitely come with more questions.
06-15-2024 12:47 AM
@GRCK5000 wrote:
I know how to use queue, global variable, functional global variable, etc. to pass data from one VI to another, but can the same be done with event structure (generate user event,...)?
I see you are off exploring again. 🙂
06-15-2024 12:20 PM - edited 06-15-2024 12:22 PM
😂 Yeah Bill, I'm back. The forum is my refueling spot. Haha
08-01-2024 08:12 PM
Most programmers advise not to pass data between two or more VIs using global variables. I had a post some time ago and I asked if it was possible to pass data between two VIs and @mcDuff said that it was possible and even provided great examples. In these examples, events are being used to pass data between two loops, more like producer-consumer architecture, but not between VIs.
I have attached a VI called sender and I would like to pass string "hello" to receiver.vi
Sender
Receiver
Also, if anyone knows of a better way of accomplishing this besides using global variables and events, please share.
08-01-2024 08:19 PM
@mcduff
Can you please answer the question about events I posted in here https://forums.ni.com/t5/LabVIEW/Trouble-passing-data-between-two-VIs-using-events-create-event/td-p...
08-01-2024 08:35 PM
@GRCK5000 wrote:
Most programmers advise not to pass data between two or more VIs using global variables. I had a post some time ago and I asked if it was possible to pass data between two VIs and @mcDuff said that it was possible and even provided great examples. In these examples, events are being used to pass data between two loops, more like producer-consumer architecture, but not between VIs.
I have attached a VI called sender and I would like to pass string "hello" to receiver.vi
Events can send data between different VI's but there are some caveats:
In the picture below I wire the "Main Message Bus" which is my User Event to multiple loops. Then I can send and receive messages in any of the loops that use that User Event.
08-02-2024 12:24 PM
As a side-note, you can look into DQMH. This has tools to automate the creation of user events, and uses Queued Message Handlers as the main VIs which communicate with each other.