LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stream DAQ from sub VI to a chart on its parrent VI?

Hello,

 

I have a working solution for my DAQ application that acuires data from 72 DSA PXI channels, streams it on disk (TDMS) with 1 kS/s and streams it on network eith 200 S/s. It works perfect on an obsolete P4 desktop. Attached is the DAQ sub VI that uses queues to sustain all operations. DAQ can last for longer periods so I'd like to also stream to a chart on the main panel (Main_VI). However this is not possible if the DAQ-SubVI is kept in a separate VI. I can stream data to a chart if everything is within a same VI - just wire the de-queued data to a chart inside the consumer (lower) loop.

 

I prefer to keep the DAQ in a separate VI and I'd like to ask if somebody knows how to achieve that. I tried to pass de-queued data chunks form the consumer loop to a chart in the Main-VI via a "single process" shared variable but DAQ_SubVI acquires and nothing comes to the chart (I have placed the chart and its sourcing shared variable inside a while loop).

 

Can this be done, and how?

 

Thanks in advance,

Download All
0 Kudos
Message 1 of 10
(3,129 Views)

There are two things that come to mind off the bat.  Have you tried having the producer loop in the subvi and and the consumer loop in the main vi, this way you can get your data while the sub vi runs.  The other option is you could use a subpanel which will let you look at the graph that is updating in the subvi from the main vi.  To employ this I would take a look at Loading a Front Panel in a Subpanel Control

Scott A
SSP Product Manager
National Instruments
0 Kudos
Message 2 of 10
(3,097 Views)

Scott,

 

Thank you for replying.

 

(1) In the 1st solution - do you mean to move the consumer loop from the DAQ VI containing everything else? This DAQ Vi would be the SubVI, and the MainVI would be enriched wiht the consumer loop? How to pass the "queued" data? Would I still have 2 separate threads because this architecture puts my DAQ on the edge...?

 

(2) I do not fully understand this concept, can you suggest on my real VIs?

 

Thanks in advance,

0 Kudos
Message 3 of 10
(3,080 Views)

You would move the consumer loop and all it contains to the Main VI, the queued data can pass between vi's no problem.  You would just need to make sure to pass in the same Queue to the two loops, you can make the queue in the main and pass it into the sub-vi or create it in the Sub VI and pass it to the consumer loop.

 

The best way to play around with the subpanel method is to pull up Loading a Front Panel in a Subpanel Control in LabVIEW Help and there are examples there at the bottom of the article that will give you hands on experience with how they work.

 

I think for you the easiest solution will be to move the consumer loop into the main VI.

Scott A
SSP Product Manager
National Instruments
0 Kudos
Message 4 of 10
(3,058 Views)

Scott,

 

I was away for few days. Thank you for helping me out again. I have done what you say (move the consumer loop to the main VI) and it works but I seem to have a kind of race condition. Namely, After the trigger is applied to the Sub VI, it waits for the STOP of DAQ and than the acquisiton is "played" on the Main VI's chart. In 20 attempts only once I got simultaneous DAQ and chart. What must I do so the consumer loop starts before the Sub_VI? Or is something else my problem?

 

Thanks in advance,

Download All
0 Kudos
Message 5 of 10
(3,041 Views)

I would either use the error wire to enforce the proper execution order as you currently have it branching out near the start of the consumer loop, or you can look into using notifiers or semaphores.

Scott A
SSP Product Manager
National Instruments
0 Kudos
Message 6 of 10
(3,023 Views)

Scott,

 

What would be your choce and how to do it?

 

R

0 Kudos
Message 7 of 10
(3,015 Views)

In this case I would use the error wire to address this race condition.

Scott A
SSP Product Manager
National Instruments
0 Kudos
Message 8 of 10
(3,003 Views)

Why use a notifier?  Stuff the data acquisition subvi in the producer loop with the data from that subvi going into a queue, then analyze/save/display the data in the queue inside the consumer loop.  Won't lose data, your code stays modular (easy to test/maintain), and the toplevel vi's nice and compact...

0 Kudos
Message 9 of 10
(2,999 Views)

Scott,

I have played all wire-combinations, at no avail. I can see the problem is that I have to synchronize the producer and consumer loops. This way, the producer loop being packed in a VI containing the DAQ intialization seems to be the culprit - there has to be another way (if there is one). I have even tried to use a shared variable (single process)... If you know a solution I'd be gratefull to learn, but thank you anayway so far, I will get rid of the sub VI and chart from the consumer loop directly inside the main VI.

 

SnowMule,

Thank you for joining in, but Iwhat you say is actually my current status. The problem is that this (working) way, chart is presenting data AFTER the DAQ sub VI has completed acquisition. If you have an idea you are most wellcome.

 

Thank you both,

 

0 Kudos
Message 10 of 10
(2,988 Views)