LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronise loops - passing large arrays

i need to pass large Arrays from loop 1 to loop 2

 

loop 1 - Aquires data from DAQ device (loop execution time decided by daq card ~ 100ms)

loop 2 - processes arrays (synchronised by loop 1)

 

is it an efficient way to use functional globals to pass data? does the queue help to synchronise the two loops?

 

 

processed data in loop 2 is again written to a Functional Global. if another loop (loop 3 - faster ~ 50ms) is reading this FG, can the loop 2 write data to the FG?

 

Any help will be appreciated.

 

RENN

Kudos always welcome for helpful posts 🙂
0 Kudos
Message 1 of 12
(3,585 Views)

Instead of simply synchronizing the loop with the queue, why not also pass the data?

 

As the expression says, there is more than one way to skin a cat.  Of course I am not suggesting anything cruel to animals..  😉

 

You can use a Functional Global, but personally, if there is a nice queue setup for me, I would also use it to pass the data.  As a matter of fact, you don't need the boolean that you are using for the queue.  When data is available in the queue, the 2nd loop will run one iteration, so basically, it will be throttled by the queue getting data.

 

Just to keep the code standardized, I would move the producer loop to the top.

Message 2 of 12
(3,579 Views)

 

Hello Ray.R

thanks for reply.

 

as you said i have used to que to pass the data.

 

can i trigger more than one loop with the same queue?

 

17121i3C394DB48A8B0214

i hope i can save the Queue references in an FG. whats your suggestion?

 

RENN

Kudos always welcome for helpful posts 🙂
0 Kudos
Message 3 of 12
(3,566 Views)

More than one dequeue can read from a queue, but the two readers will 'fight' for data. Think of a single line in your favorite bank or eatery with 3 cashiers; each asking 'next, please'. Once the item is removed from the queue, it will not be available to the other readers.

 

My typical use case has been high rate data that needs to be logged and simultaniously subsampled for display to the operator. I use two queues, and the producer places data in each; one logger queue and one UI queue. I typically use a quotient and remainder function with the iterator count in the producer loop to pass a decimated stream of data to the UI loop. If my sampling is 120 Hz, I use Q&R to divide the i count by 4. If the reaminder is zero, I enqueue the data to the UI at ~30 Hz.

 

You can store the references to a queue in a functional global, but you can also name your queues when created. Use the obtain queue with the previously created name and you get the same queue ref (as long as the names are unique).

 

Message 4 of 12
(3,547 Views)

Can you explain why you want to trigger more than 1 loop with the same queue?

There may be alternative solutions if we know what you are trying to do.

Message 5 of 12
(3,541 Views)

 

Hi....

 

my goal is to Process data (Analog Input voltages ) read from 2 DAQ cards.

 

my doubt is - if DAQ 1 / DAQ 2 loop execution time is a bit different, both loops generate an Array of data, at different times.

 

i think i can write the data read to Functional globals and use both FGs to process the data at another 3rd loop. one the DAQ starts writing to FGs,

both the FGs (contains 2D double arrays) are not empty. so that i can process the Data from both arrays together.

 

pelase see the image below.

 

 

17547i96C173E2B1C4789D

 

Thanks

RENN

Kudos always welcome for helpful posts 🙂
0 Kudos
Message 6 of 12
(3,483 Views)

If DAQ1 and DAQ2 have different rates and you want to process data in one loop only, this means you don't care if you lose some data point.

 

What I wuold use in your case is a notifier. Or better, two notifiers, one for DAQ1 and one for DAQ2.

Notifiers can be used to syncronize and send data among loops.

 

The process loop can simply wait for a notification for both the Notifiers and it's done (no need to poll functional globals..).

 

As a quick and dirty example see this:

17559iC03D0E781090C69C

 

Message 7 of 12
(3,463 Views)

 

Hallo  MarcoMauri

 

i just tried with a VI. please see the code.

 

hope it works.

 

MarcoMauri said: ''you want to process data in one loop only, this means you don't care if you lose some data point.'' -

 

can i synchronise the DAQ loops with an RTSI cable withiout loss of data??? i have no experience with this. please give suggestions.

 

 

thanks a lot. 

 

RENN

Kudos always welcome for helpful posts 🙂
0 Kudos
Message 8 of 12
(3,447 Views)

Hi RENN!

Could you please post a LV 8.5 or LV 8.6 version of your vi?

thank you in advance,

Marco

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

LV85

Kudos always welcome for helpful posts 🙂
0 Kudos
Message 10 of 12
(3,434 Views)