LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

producer consumer missing channels

Hi everyone,

 

 I have a mysterious problem.  I am aquiring and writing data from two daqs in a producer consumer archetecture.  One with 4 channels (Tempurature ) and one with 8 active channels (Current). Everything seems to work fine in the consumer loop.  I can probe the data and all channels seem to be working.   The consumer loop writes the data to a spreadsheet file.  The data from the  4 tempurature channels always appears in the file.  However I only get data  from 4 of the 8 channels on the current daq.  So something is getting lost before writing.  Attached is the program.  It is a work in progress. If anyone has any ideas I'd love to hear about it. 

 

The daqs these are attached to are a 9217- tempuerature and a 9208- current on a 9174 4 slot chassis because, who knows, maybe it it s a hardware problem.

 

 

Thanks,

 

Jo

0 Kudos
Message 1 of 8
(4,452 Views)

You have three loops: Producer, Producer, and Consumer. This means that the consumer is going to be limited to the slowest of the two producers. You need to either combine your producer loops, or add another consumer loop.

 

Here's what's happening. Pro1 spits out 4 data points. Pro2 spits out 8 data points. Consumer loops 4 times, each grabbing a single element from each queue. Now in the fifth loop, Consumer just sits there waiting for the 5th data point from Pro1 even though Pro2 has a data point ready.

 

 

By the way, to figure out what was going on in your code, I had to do a Diagram Cleanup. If your code looks better after a Diagram Cleanup, you need to do something differently. You should try to use more subVIs for sure. Also, I saw a STOP node in there somewhere... This isn't the way to stop parallel loops. Instead, you should use a local variable at a minimum and also close your consumers by just closing your producer queue references.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 8
(4,434 Views)

I have tried both suggestted methods.

 

Making two producer and two consumer loops means (I think) that I need to make two seperate data output files, or conversly write several lines of temperature data followed by several lines of current data.  As this will run for many hours, this would be a pain to process later. 

 

Making one consumer and one procucer loop yeilds a unified file with alternating chuncks of missing data (thatr apper as zeros). 

 

Idealy, I would have for each iteration of the consumer loop a single line of output with all of the data channels (4 temps, 8 currents). 

Is there a way to maybe make the 8 channel daq master and 4 channel slave?  So that the iteration isn't done till all channels are written. Or even just hardwire the consumer to look for 8 data points from each and fill the empty points with zeros.

 

Thanks so much for your prompt response,

 

Jo

0 Kudos
Message 3 of 8
(4,370 Views)

Jo,

 

Why not put all the Analog Reads in one loop? Then you can make one array of waveforms and use one queue to send the data to the File loop. Extract the one signal which is used by the PID process and send it to the PID loop on a different queue. So you end up with one loop which is a producer and two consumer loops. But each consumer loop only dequeues from one queue.

 

I have not read through theis entire thread in detail so someone may have already pointed out that you do not need the 1-iteration for loop. Just move the shift register out to the while loop.

 

Lynn

0 Kudos
Message 4 of 8
(4,351 Views)

I'm not able to see the code you posted right now (Upgrading about 35 NI Products on this machine)

 

However, 2 producers and 1 consumer are perfectly fine as long as both producers enqueue to the same queue   My 8-Ball suggests that you are using seperate queues for each producer.  Don't do that! the best rules of thumb are:

  • 1 Queue per consumer regardless of number of producers (multiple to 1)
  • 1 Notifier per Producer regardless of number of consumers (1 to multiple)
  • If you need mutlple producers to multiple consumers use User Events

"Should be" isn't "Is" -Jay
Message 5 of 8
(4,291 Views)
Jayelle,

Here's what I think you want (coming from what I remember from looking at the code earlier today):
- Producer loop that grabs all of the analog input data. Your DAQmx tasks should handle the sample rates just fine and you can pull different numbers of data points from each task.
- Consumer loop that receives the data and writes to file. You can cluster the data with more information if you want so that you can split it up to its respective file location. Ex: array of data bundled with an enum telling the consumer loop which data this is.

If you need two producer loops to grab two separate sets of data, that's fine, but still enqueue to the same queue that goes to the consumer loop and decipher which data is which like I said above.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 8
(4,264 Views)

t Just to add to Lynn's comments.  If using the same DAQ card, you can create a single task to get all of your data (temperature and currents).  That would greatly simplify your code.  Even if using different cards, you may be able to combine the tasks into a single one (depending on the cards).

 

If that is not possible, then just put both into a single loop and then you just have 1 loop and queue to maintain.


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
Message 7 of 8
(4,187 Views)

Thanks for the reply!

 

I am now getting all of the data to print by using one producer loop and one consumer.  

 

My problem now is that it prints one set of data (one item from the queue)per second each on a different line.

 

"current

temp

current

temp

current "  

 

 I want it to print once current followed by one tempurature, one every second.

 

"current temp

current temp

current temp"

 

I'm sure this means I need to some hown group the data or tell it to dequeue in chunks of two.   I'm not sure how to go about doing that.  Any help is always appreciated. The better working code is 

0 Kudos
Message 8 of 8
(4,134 Views)