LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 producers/ 1 consumer for a Producer/Consumer Architecture

I am trying to aquire two seperate tasks (one with analog and one with digital signals).  The digital signal needs to be aquired at a much higher rate (10 times higher).  The data from both of these aquisitions is required for writing to the same file and doing calculations.  I was wondering if it is possible to use 2 Producer loops and 1 Consumer loop?  I would need to use an enqueue in each producer loop and then dequeue them both in the consumer loop.  Will this work?
 
Thanks.
 
--Robert
0 Kudos
Message 1 of 3
(3,268 Views)


knapkerd wrote:
I am trying to aquire two separate tasks (one with analog and one with digital signals).  The digital signal needs to be aquired at a much higher rate (10 times higher).  The data from both of these aquisitions is required for writing to the same file and doing calculations.  I was wondering if it is possible to use 2 Producer loops and 1 Consumer loop?  I would need to use an enqueue in each producer loop and then dequeue them both in the consumer loop.  Will this work?
 
Thanks.
 
--Robert


Certainly.  You can  pass the reference wire for the queue you obtained into 2 different producer loops where you enqueue your data.  The same wire will pass into the consumer loop where you dequeue your data.  Of course with this method, you have no control over which loop puts its data into the queue first.
 
It really comes down to what you are going to do with the data once you get it into the consumer loop.  Do you just want to write the data as you get it? What do you do with the calculations,  if you get 8 or 9 pieces of data from the one producer, then get a piece from the other producer, then get 11-12 pieces from the first producer, do you just hold on to the previous values from the older slower loop?
 
Do you want to do this with 2 different queues?  If so, you may need to put some timeout functions on your dequeue functions in your consumer loop otherwise it will only run as fast as it gets the data from the slower queue.


Message Edited by Ravens Fan on 05-07-2008 11:38 PM
0 Kudos
Message 2 of 3
(3,264 Views)
Thanks for the quick reply.  The data from the loop with the higher sampling rate will be used for front panel displays and for writing to a file.  The data from the lower sampling rate loop will be used for calculation, front panel displays, and writing to a file.  I am thinking of doing two queues so that I can be sure where the data is coming from.  I was then thinking that the faster queue would hold the values and wait for the other queue values to be passed in so that the consumer loop would work on values from the same time.  I was planning on having the number of queue passes per second of wall clock time be the same:
 
slower sampling rate
(aquisition rate 40,000) / (DAQmx read 8000 samples) = 5 loops per second of aquired data
 
faster sampling rate
(aquisition rate 400,000) / (DAQmx read 80000 samples) = 5 loops per second of aquired data
 
So that dequeueing 5 elements from both queue would be equivalent to 1 second.  I am not sure if all of this makes sense.
 
Again, thanks for the reply and let me know if anything I said wont work or doesnt make any sense.
 
--Robert
0 Kudos
Message 3 of 3
(3,254 Views)