LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can multiple vis share input from a DAQ simutaneously

How can multiple vis share data input from a DAQ simutaneously?

Recently I am building a EMG measurement platform and somehow DAQ data need to be shared by several vis at the same  time.

Are there any ideas?

0 Kudos
Message 1 of 12
(3,408 Views)

How many VIs do you have? Are all the vis running parallel?

How are these vis called? Are they all sub vis called inside the same main VI? Are they all running inside the same while loop or in different loops?

 

The best way is to use Queues. If you have the vis running at different rates and from different locations, use multiple Queues. Create a Queue ref for each vi, enqueue the data into the queues from the DAQ, dequeue in each sub vi, and process

 

if all the vis are inside the same Main vi and if they all run at the same rate, then use one queue, enqueue from DAQ and dequeue in the Main VI

 

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 2 of 12
(3,402 Views)

I need to run 3 VIs parallel.

0 Kudos
Message 3 of 12
(3,388 Views)

They are running in the same project but independently.

0 Kudos
Message 4 of 12
(3,387 Views)

Use a single loop to acquire your data.  You can then use separate queues to send the data to the other VIs.  This is a form of the Producer/Consumer Architecture.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 12
(3,374 Views)

If you may need to add/delete tasks that will need th edata you may want to consider a publich/subscribe pattern. Basically your DAQ task will post a message to a single queue. The process listening on this queue (message broker) will determine if there are other processes registered to receive this message. When a device registers for a message it provides a queue to receive it on. The message broker will then post the message to all interested processes. The nice thing about this pattern is that you have dedicated code to handle broadcasting the message and it is very easy at run time to change the number of processes that get the message. The DAQ task will always send the message and will not care how many processes are listening.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 12
(3,357 Views)

Thank you guys. The producer/consumer pattern is good.

 

However, if all 3 Vis are placed as subVi in a big one, I will have to run them all everytime. Sometime I don't need to run all 3 programs, maybe only 2.

I am looking for something resembling the global variable of a project, a buffer that can be shared by multiple Vis. But the global variable does not support two dimension arrays or dynamic data.  

 

Is there any substitute for that?

0 Kudos
Message 7 of 12
(3,329 Views)

I provided an architecture that would work for you in the above post. It will require a but of extra work to create the message broker and the mechanisms to publish your messages and subscribe to them but this architecture is flexible and will support varying number of tasks. You can even change the number of tasks at at runtime.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 12
(3,324 Views)

@bdtofu wrote:

Thank you guys. The producer/consumer pattern is good.

 

However, if all 3 Vis are placed as subVi in a big one, I will have to run them all everytime. Sometime I don't need to run all 3 programs, maybe only 2.

I am looking for something resembling the global variable of a project, a buffer that can be shared by multiple Vis. But the global variable does not support two dimension arrays or dynamic data.  

 

Is there any substitute for that?


There is no need for producer/consumer. It is just a "popcorn-machine" that "rattles away" with everything you enqueue, that is usually stuff for handling sporadic events and not continous processing.

 

You can use the already existing device buffer by handling the DAQ buffer pointers. This thread could give you some hints:

 

http://forums.ni.com/t5/Multifunction-DAQ/Asynchronous-circular-buffer-read-with-overwrite/m-p/14809...

 

Br,

 

/Roger

 

0 Kudos
Message 9 of 12
(3,319 Views)

When you want to acquire the data and share the data to multiple loops, 'Queue' is not a option; instead 'Circular Buffer' is the option for you.

 

The 'Circular Buffer' data structure is used to share the data between multiple loops but with same synchronized manner.

Like 'Queue' (FIFO, LIFO, FILO), circular buffer also can be clasified diffrently.

 

You can use 'LV2G' as a 'Circular Buffer' and you can customize also.

Below are the links talk about Circular buffer.

http://www.ni.com/white-paper/7188/en

https://decibel.ni.com/content/docs/DOC-14554

 

How to use array as a circular buffer?

https://decibel.ni.com/content/docs/DOC-3414

 

Regards,

Yogesh Redemptor

Regards,
Yogesh Redemptor
0 Kudos
Message 10 of 12
(3,315 Views)