LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 producer/1 consumer loop failure.

Solved!
Go to solution

I am having problems with using two producer and one consumer code. I am reading in digital data and also analog measurements in one producer loop. In another producer I am using a counter to take pulse width measurements.  In the consumer loop I am displaying the analog,digital, and counter data. The problem I am having is only the Analog and Digital data are displayed but not the counter data( pulsewidth measurements). This setup requires that I monitor a digital input and utilize Change detection both rising and falling edges. On Detection of the edges I do an Analog acquisition. This is done in one Producer loop.

My other producer loop uses a counter to take pulse width measurements. The data in this loop is obtained and is accurate. It just never shows up in my consumer loop.

If I disable analog measurements it does show up. Racing condition maybe exists? If so what can be done to get this to work right. I have uploaded the project here. Thank you, help is greatly appreciated.

0 Kudos
Message 1 of 7
(771 Views)
Solution
Accepted by topic author BrianSw

You should not be updating all indicators with every dequeue element. If data is sent from the top loop, then cnt0 will be the default value (0). If data is sent from the bottom loop, all other values besides cnt0 will be default. Usually there would be an enum or string which tells the "consumer" which case to run. Then inside each case you can do different things with the data.

 

My guess is that the top loop is running much faster than the middle loop, so any data with cnt0 gets drowned out.



CLA // LabVIEW 2016 // BALUG // Unofficial Forum Rules and Guidelines
Message 2 of 7
(765 Views)

Why can't we have another consumer loop and a second queue?

Chase
NI Technical Support Engineer
0 Kudos
Message 3 of 7
(703 Views)

I think I tried a few different variations using producer/consumer loops, but I'll look into trying that.

 

Thanks

0 Kudos
Message 4 of 7
(697 Views)

That appears what I see to be happening also. The top loop is running faster. Thanks I'll look at putting in a case statement to handle the data differently as is arrives.

0 Kudos
Message 5 of 7
(696 Views)

@Chase.E wrote:

Why can't we have another consumer loop and a second queue?


You could, but the consumer loop does so little here, it makes more sense to get rid of it and just update the indicators right where the data is generated.

 

It is still a good exercise to code up the functionality where the queue also includes an instruction or message to the dequeueing loop as part of the data, because this is the way queued message handlers work.



CLA // LabVIEW 2016 // BALUG // Unofficial Forum Rules and Guidelines
0 Kudos
Message 6 of 7
(690 Views)

@Chase.E wrote:

Why can't we have another consumer loop and a second queue?


That is called a Notifier Chase

0 Kudos
Message 7 of 7
(675 Views)