05-27-2016 08:23 AM
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.
Solved! Go to Solution.
05-27-2016 05:34 PM
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.
05-28-2016 04:51 AM
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.
05-28-2016 12:02 PM
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?
05-30-2016 05:19 AM
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.
05-30-2016 01:45 PM
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!
05-31-2016 01:11 AM
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?
05-31-2016 10:37 AM
05-31-2016 11:02 AM
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.
06-07-2016 07:11 AM
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.