06-29-2015 02:52 PM
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
06-29-2015 03:28 PM - edited 06-29-2015 03:31 PM
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> ---'
06-29-2015 07:11 PM
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
06-29-2015 07:46 PM
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
06-29-2015 10:10 PM
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:
06-29-2015 10:44 PM
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-30-2015 07:38 AM
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.
07-01-2015 05:26 PM
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