LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The data in a consumer loop is not changing

Solved!
Go to solution

 

Help!

 

I am reading different voltage at an interval of 500ms in a producer loop and passing it to the consumer loop. However, I notice that the values in the consumer loop dont change even when the voltage has changed?

 

What can I do?

0 Kudos
Message 1 of 6
(3,014 Views)

Post your code.

0 Kudos
Message 2 of 6
(3,001 Views)

The code is attached. Still WIP.

 

Thanks

0 Kudos
Message 3 of 6
(2,988 Views)
Solution
Accepted by topic author concacid

You are probably stuck in the inner loops. Since the value of your capacitor voltage is fed in from outside the loop, only that value will be used inside the loop unitl the loop stops executing. So, if the first capacitor voltage is less than the Upper Threshold Voltage, then the inner loop in the Charging case will never end.

 

You do not need the inner loops at all. You want to test against the thresholds exactly once for each reading of the voltage. Wire the output of the comparison to a case structure. If the condition is met, Write to the output channel and change the state. Otherwise, do not write and return to the same state on the next reading.

 

One other thing. When you stop the program you may want to set the output to discharging before shutting down so your capacitors do not sit there charged.

 

Lynn

Message 4 of 6
(2,971 Views)

Your code will deadlock in your while loop if you are in the Charging state and receive a voltage less than the Upper Threshold voltage.

Your logic in the consumer needs some more thought.

Just use a case structure on the output of your voltage comparison to either pass through and remain in charging or to set your output and switch to discharging.

 

EDIT: Lynn beat me to it.

Message 5 of 6
(2,969 Views)

Thanks Lynn and Taki!

I was able to see clearly what I was doing all wrong and now, I can produce and consume appropriately! Thanks for your help.

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