LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

two producer loop for fast DAQmx and for user commands?

Solved!
Go to solution

Hi,

 

Sorry if my question is a bit maybe too general (I do not have an implemented VI yet).

I think about solutions for a Producer-Consumer Structure with Event loop in the producer part.

 

So far, If I had to make a project with DAQ, data analysis, data logging, and capturing user commands, I followed usually this kind of approach:

I used the producer part to capture user interactions, and I had also a state machine in the producer part, with shift register. I also acquire data from DAQmx device (not faster then 10ms) in the time-out part of the event structure in the producer loop. I have several consumer loops down, like data analysis, data logging, etc... I send the measured data in a cluster with state enums from the producer loop to the consumer loop with Queue.

 

I am not happy with my approach because of the following reasons:

1.,

If I need to acqure data from DAQmx device faster than the operation system clock can handle (like 1MHz), then I cannot put it in the time out part of the Event structure of the producer loop, since here I can iterate the while loop with minimum 1ms.

2.,

If I put this DAQ part into a fast consumer loop, It will not be responsive for commands coming from the QUEUE line after it starts to run (assuming I use the standard producer-consumer structure, so consumer loop every time iterates once, when a package comes from the Dequeue). 

 

So lets say, how can I control a fast (timed by DAQmx device internal clock) DAQ loop from a Producer loop's Event structure? Like start DAQ loop, stop it, restart it, etc...

 

Thank you very much for advices!

0 Kudos
Message 1 of 6
(2,734 Views)
Solution
Accepted by topic author Blokk

You can certainly have multiple producer loops.  Having a User Interface, event driven loop to send commands and a separate DAQ loop to send data is not a problem.  Each loop needs a separate queue. (You might be able to make it work with just one, but using two queues avoids lots of issues).  I often used a three loop system long before anyone was talking about calling it Producer/Consumer.

 

Lynn

0 Kudos
Message 2 of 6
(2,710 Views)

@Blokk wrote:

<mini-snip>

 

So far, If I had to make a project with DAQ, data analysis, data logging, and capturing user commands, I followed usually this kind of approach:

I used the producer part to capture user interactions, and I had also a state machine in the producer part, with shift register. I also acquire data from DAQmx device (not faster then 10ms) in the time-out part of the event structure in the producer loop. I have several consumer loops down, like data analysis, data logging, etc... I send the measured data in a cluster with state enums from the producer loop to the consumer loop with Queue.

 

<snip>

You *do* realize that if you put your DAQ aquisition in the timeout, it will NOT be aquiring anything while the event structure is servicing an event?  Or if you do realize it, then I'm curious as to how you get around it.  I admit there are plenty of things left for me to learn in LabVIEW...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 6
(2,701 Views)

Thanks very much for advice! I like this idea with the two producer loops. But how can I send commands from the Event Producer loop (capturing user interactions) to the DAQ producer loop? I mean, what is the best way to do this? A third queue? (for example during runtime, I want to stop and restart the fast DAQ producer loop any time I wish)

 

billko:

I do realize this problem, but in my case loosing some data was not a problem at all (large volume radiocalorimeter, 2 week long measurement time, 1Hz DAQ).

Message 4 of 6
(2,696 Views)

You can use another queue.  If the same command is going to both of the other loops, try a notifier.

 

In my three loop systems I usually had six queues. I send commands in one direction and status and data in the other. Each pair of loops had a pair of queues.  This system does not scale well to larger numbers of loops but works fine with three. At four or more loops (rare) I find that making one loop the master and having it control all inter-loop communications works better.

 

Lynn

0 Kudos
Message 5 of 6
(2,693 Views)

@Blokk wrote:

Thanks very much for advice! I like this idea with the two producer loops. But how can I send commands from the Event Producer loop (capturing user interactions) to the DAQ producer loop? I mean, what is the best way to do this? A third queue? (for example during runtime, I want to stop and restart the fast DAQ producer loop any time I wish)

 

@billko

I do realize this problem, but in my case loosing some data was not a problem at all (large volume radiocalorimeter, 2 week long measurement time, 1Hz DAQ).


Thank you, Blokk!  I thought maybe you thought of a way around the problem that I wasn't aware of.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(2,680 Views)