LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to communicate data from single primary loop to multiple secondary loop in LabVIEW?

Solved!
Go to solution

I have one primary loop (while loop) and multiple secondary loops (while loop). 

I would like to send command vice versa.  

Command send from multiple secondary loop to single primary loop:
--------------------------------------------------------------------------------------------
If I would like to send command to primary loop from secondary loops then I am using custom user event. I am generating custom user event in secondary loop with some identifier, and custom user event is only handle at one place, in side the primary loop. Identifier is help to figure out command is came from which secondary loop.  

Command send from primary loop to specific secondary loop.
-------------------------------------------------------------------------------------------
Is there any way?  I can send the command from primary loop to specific secondary using any mechanism in LabVIEW.
if there is single secondary loop then I can send command using Queue, but Here I have multiple secondary loops. I need to send command to specific secondary loop.

Here I am placing the example.

Capture.PNG

 

Here I have example. 
Experiment 1 and Experiment 2 is communicating to main loop using User Custom event. I am try to figure out the way which will help report data back from Main loop to Experiment 1 and Main loop Experiment 2.

Number is Experiment is not fix in actual version it will be very depending on requirement.


I thought notifier will work for this functionality but there is one thing which I found in Solution that it may overwrite the data. Data rate is very high in my application. 
  
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kFGfSAM&l=en-US
 

Any one please give me suggestion how should I need to handle this issue? 






 

0 Kudos
Message 1 of 11
(1,990 Views)

I have a similar experiment setup where there are a handful of conditions. I think your best bet here would be to use a finite state machine so you can take the user to the appropriate options based on their button presses. 

0 Kudos
Message 2 of 11
(1,984 Views)

Yes, I can change to finite state machine but I did not able to figure out the way of communicator. 

should I use another custom user event, Queue, notifier or anything else? 

If number of Experiment is fix then I can use specific number of Queue and send the data from FSM. But Here It will be very. I want something like user can provide just two wire to experiment loop. One for sending command to Experiment and another one get commend from Experiment. 

0 Kudos
Message 3 of 11
(1,978 Views)

You are using LabVIEW 2018, so you have access to Asynchronous Data Wires.  The Messenger Data Wire provides one-to-many and many-to-one communication opportunities.  It isn't obvious to me from looking at your code just what you are trying to do, but you might consider using Messenger Data Wires and building a structure similar to the Queued Message Handler, but with Messenger Channel Wires (I call this a Channel Message Handler, a CMH).  One important metaphoric advantage to Channel Wires is that the Channel Writer (the "output" side) can be placed on the right side of an enclosing Structure (like a While Loop) and can exit on the right side (as though the data is flowing "out on the right" (which it certainly is).  Similarly, the Channel Reader (which gets inputs) can be placed near the left ("input") edge and accept a Messenger Channel coming in from the left.

 

Bob Schor

Message 4 of 11
(1,914 Views)

Thank you @Bob_Schor for you replay. I don't have much knowledge about LabVIEW. I will do research about channel wire in depth. 

I figure out the solution with help of Queue per experiment.  did you see any draw back for this structure? 

Capture.PNG

0 Kudos
Message 5 of 11
(1,905 Views)
Solution
Accepted by Y@sh001

If your loop has an event structure, then you should use a User Event to send messages to it.  Do not use a Queue like you show.  

 

Put your Experiment User Events in an array if you have a variable number of Experiments.  You can then send info to a specific Experiment, or to all of them, as needed.

0 Kudos
Message 6 of 11
(1,883 Views)

I'd say you could use a dequeue, just put the dequeue in the timeout case of the event structure with a timeout value wired that lets it regular handle items in the queue.  Otherwise someone mashing buttons and triggering events faster than the timeout value would never give the timeout case a chance to get data from the queue.

0 Kudos
Message 7 of 11
(1,865 Views)

While sending the data to Main loop I am generating event from experiment loop, and handle the Custome User Event in Main loop, event is contain information queue reference which you seen in block diagram.

are You try to say use another User event which will inform data back to experiment loop?   

0 Kudos
Message 8 of 11
(1,818 Views)

@

Thank you for suggesion, and pointing out the issue. Sure I will use  the timer in while dequeue elements in experiment loop.

0 Kudos
Message 9 of 11
(1,814 Views)

Y@sh001 wrote:


are You try to say use another User event which will inform data back to experiment loop?   


Yes, just use User Events for communicating both ways, instead of using Queues.  

0 Kudos
Message 10 of 11
(1,788 Views)