LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can PID VIs work in a consumer loop?

Solved!
Go to solution

Hello everyone,

I am working on controlling proportional valves with PID. To do this, I prepared a vi based on a producer-consumer design pattern, however, it does not work. When I use one while loop embedded all daq read, write, and control tasks, it works. I am confused about that.

You can see these two VIs, one of them works the other does not (based on producer-consumer pattern) below, and also in the attachment.

 

PID in one while loop.png

 

PID with pro-con.png

Egemen
0 Kudos
Message 1 of 10
(3,825 Views)

The following couple comments aren't directly related to your question, but they certainly aren't making it easier to understand what you're trying to do. Why post a screenshot saying you're trying to do PID, but show the case of the case structure where the PID loop isn't? Why do you have a formula node that multiplies by 1, and a comment saying it does something? When checking if the remainder is 0, LabVIEW has an "Equal to 0" function, yet you've decided to actually check the equality versus a floating-point zero even though you know the value is an integer?

 

Having gotten that out of the way... what do you mean by "doesn't work"? What have you already done to debug it? Fundamentally there's no conflict between a PID loop and a producer-consumer structure; I can't work through your code to figure out if there's a problem in your specific implementation. However, if you explain what you've already tried, where you've put probes to see if the code executes, etc then it would be easier to help.

0 Kudos
Message 2 of 10
(3,791 Views)

Hi Nathand,

 

I have attached the first snippet just to show what I am using for now. Please disregard the explanation on these and the formula node, they came from the original example VI, I have not clean the block diagram yet. Anyway, the problem is, I mean in the second snippet, even if the producer loop sends the data to consumer one, the PID vi in it produce "0" output. I have checked while running the vi whether the acquired data was sent through the PID vi and it is ok. However, as I said, output is 0. Is it possible that PID vi reinitialize itself for each dequeue process in the loop? I use quotient & remainder to send the data to the consumer loop for once in ten data acquired. Maybe it is better to use it in the below way. Thanks for your advices.

 

send data.png

Egemen
0 Kudos
Message 3 of 10
(3,774 Views)

Hi newbie,

 

However, as I said, output is 0.

What are the other inputs of the PID function?

 

Is it possible that PID vi reinitialize itself for each dequeue process in the loop?

Not as long as you don't program such behaviour…

 

Why do you scale the process variable from EGU to percentage using the setpoint (SP) as maximum? Why scale at all? Why use the SP as 100% mark?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(3,761 Views)

Hello GerdW,

 

The input of the PID function is pressure between 0-10 bar (0-10 volt - 0-10 bar). I checked the input of the PID function during running. It was ok, 0-10 bar data was sent through its input, however, the output of the PID fucntion was "0". I did not program to reinitialize of the PID function.

 

I planned to use EGU and scale to use a different pressure transducer with different output range. For this case, EGU and scaling are irrelevant. I use SP as a 100% mark to set the PID output according to this set point.

 

Thanks for your reply. I will give it a try again with this vi.

 

 

Egemen
0 Kudos
Message 5 of 10
(3,723 Views)

Hi newbie,

 

I checked the input of the PID function during running. It was ok, 0-10 bar data was sent through its input, however, the output of the PID fucntion was "0".

And all those other inputs? Manual setting? Auto mode? PID gains?

 

I did not program to reinitialize of the PID function.

Changing PID gains will cause an (internal) init of the PID too…

 

I use SP as a 100% mark to set the PID output according to this set point.

What do you want to achieve for this?

When you have a SP of 1bar then a PV (current process value) of 2bar will scale to 200%??? Then you change the SP to 5bar and the very same PV will now be at just 40%?

0% is minimum of working range, 100% is maximum. SP and PV should be inside this range!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(3,699 Views)

Hi GerdW,

 

PID settings were as following:

Automatic mode

Gain: 30

Ti=0.08

Td=0

Academic (standard) mode

 

I did not touch any PID settings during running, keep them constant.

 

My main intention by entering the SP as a maximum value for EGU converter to send the proper percentage through the PID vi. If I want to reach let's say 2 bar as a SP point, entering a higher value as a maximum value in EGU produces less percentage, and it produces less control signal. I did not think about over scale, since it prduces over 100%, the system, I thought, stops to send PID output. What is your suggestion on this EGU case? Should I not use it or use it with a maximum pressure range of the transducer (10 bar)? If I want to reach 5 bar maximum as a SP, should I enter a higher value into EGU maximum input?

 

 

Egemen
0 Kudos
Message 7 of 10
(3,675 Views)

Hi Newbie,

 

usually I don't use those to/from EGU conversion. What is it good for?

 

When using "real" PV/SP values all you need is to adapt the P part of the PID gains!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(3,650 Views)
Solution
Accepted by topic author newbieeng

Newbieeng - why would you configure the PID differently between the two versions (one loop versus two), then assume that the difference in performance was a result of the number of loops and not in the difference in the logic?

 

Following on what GerdW wrote about the EGU to % calculation, let's follow the math to explain what's happening. You scale your Process Variable to be a percentage of the value between 0 and the setpoint. This is, as already mentioned, a nonsensical calculation. If your setpoint and your process variable are both 0-10, then converting the process variable to a percentage of the range between 0-10 will almost always result in the percentage being larger than 10. For example, if your process variable is 2 bar and your setpoint is 5 bar, the output will be 40 (%). So, the inputs to your PID (which you should have probed, so you'd see this happening) are a setpoint of 2 and process variable of 40! Since 40 is so much larger than 2, the PID output would be negative, but you have it limited to 0 - explaining why you always get 0 output. It has nothing to do with producer-consumer versus one loop.

0 Kudos
Message 9 of 10
(3,643 Views)

Hello Nathand,

 

I did not check the EGU output through the PID vi during trials. You are right about the math of EGU to % calculation. I modified the vi by deleting this EGU convertions. It works well now. Thank you very much.

Egemen
0 Kudos
Message 10 of 10
(3,573 Views)