How can I design PID control with restrictions? - Page 1
Forum section: electronics / projects

author: axero
author_rank: Regular Contributor
timestamp: November 03, 2016, 11:00:09 pm
content: I'm undertaking the challenge of designing the control of a heat pump (HVAC) system using R410A refrigerant and a variable speed compressor that is controlled using a variable frequency driver (VFD). I don't know that much about HVAC systems and I'm not that familiar with PID controllers, except the basics. Here's an illustration of the problem:A diagram showing the function (f(p) above) that correlates saturated vapor temperature, or condensing temperature with pressure:The compressor is regulated by a variable frequency driver that can drive the compressor over a specified range of available frequencies. The main rule is that the higher the frequency, the faster the compressor builds the pressure up in the system.In its simplest form, the compressor regulates against a specified reference temperature. I'd assume that a PID-regulator controls the VFD against the difference between a desired reference temperature, and a temperature measured from output signal 2.The problem with the simplest form is that the PID-regulator can ramp up the compressor and drive the pressure in the system above maximum allowed pressure that I set to 37 bar.Question 1: So, how do I impose a restriction on the system or PID controller such that as the pressure gets close to the upper limit it will "flat out" and stay there? It's only an upper restriction, i.e. the pressure should be allowed to drop once the water temperature starts to react desired levels. Some overshoot is fine, the mechanical pressure protection switch won't trip until system pressure hits 42 bar.Ideal pressure should be such that the condensation temperature, which I assume to be saturated vapor temperature should be 1-1.5°C above the water temperature. Probably a regular PID-control of the compressor speed against the reference temperature will converge to this optimal value. But perhaps it is possible to tweak its efficiency further:Question 2: Is it possible to ramp up the compressor such that the condensation temperature (that is evaluated as a function of current gas pressure) gets 1-1.5°C above water temperature, then let it adjust accordingly as the measured water temperature increases and then stop increasing it as the measured water temperature reaches desired temperature?Question 3: What types of PID-control units do you recommend? Is there any other type of control that would be more suitable for this kind of application than PID, or to be used in conjunction with PID?Anyone know?

author: pelule
author_rank: Frequent Contributor
timestamp: November 03, 2016, 11:22:47 pm
content: to Q1: why not, just set the limit, if above the limit, switch off, if below, let the regulator work.By the way - it is same as you have a PID with no D, a very small I-Fakotr and high P factor (2-point regulator)to Q3: out of my experiance a PID regulator is not the best for compressor systems, especially cooling/regrigerators.It it quite difficult to find the correct P and D factors as the compressor is behaving different, depending at what point of curve it is.Better to my experiance is a in German "verzögert nachgebender Regler" - delayed soft regulator (I am not sure if this is the correct english expression).It is a PT1 (soft) regulator, with a PT1 (delayed) feedback.

author: axero
author_rank: Regular Contributor
timestamp: November 03, 2016, 11:46:45 pm
content: Can you program an ordinary PID controller to have that kind of behavior you describe, i.e. to shut it off just like that?When you talk about your experience, are you talking about "on/off" compressors or are you talking about VFD/inverter controlled variable speed compressors?I'm unable to find a PID-controller for pressure, it seems that all of them are geared towards use for temperature control. Perhaps there are "generic" units one could use?

author: IanB
author_rank: Super Contributor
timestamp: November 04, 2016, 12:17:31 am
content: I think perhaps to begin with it looks like you have your block diagram back to front:Usually the thing you want to control comes in as a measurement on the left, and the things you can manipulate to achieve that control leave as outputs on the right.So your starting question should be what are you controlling? I can't tell from your diagram what it is you are trying to cool down, and where is that temperature measured?Once you have that temperature measurement you compare it to the desired set temperature and the controller output adjusts the speed of the compressor.As far as the maximum pressure is concerned, that may be implemented as a secondary control loop. You have a measurement of the actual pressure and compare it to the allowable maximum pressure. If the actual pressure exceeds the set pressure a control output is generated that overrides the compressor speed and reduces it (perhaps using a low selector between the two control outputs).

author: Someone
author_rank: Super Contributor
timestamp: November 04, 2016, 12:55:13 am
content: Quote from: axero on November 03, 2016, 11:46:45 pmAn off the shelf "controller" is unlikely to have any of the features you are looking for. You can model the actuator (compressor) and use an open loop model as an estimator:https://en.wikibooks.org/wiki/Control_Systems/Estimators_and_ObserversAnd wrap the control loop around that, but that needs a fully programmable controller not just a PID in a box.Quote from: axero on November 03, 2016, 11:00:09 pmIt will be unlikely to end up stable around that point, when you have multiple sensors there are many ways to approach the control system. A common technique used in industry is to have cascaded PID loops:http://controlguru.com/the-cascade-control-architecture/These can be designed to maintain known limitations.It sounds like you're in for a lot of learning

author: axero
author_rank: Regular Contributor
timestamp: November 04, 2016, 01:20:15 am
content: This is not a cooling application, this is a heating application. This heat pump is supposed to heat water from say 0/32 degrees Celsius/Fahrenheit to say 55/131 degrees Celsius/Fahrenheit by running it through a plate heat exchanger that also acts as a condenser unit for the refrigerant.I want to control the water temperature leaving the condenser/plate heat exchanger.The measurement of the outgoing water temperature is supposed to be used as an input signal to a programmable controller of some kind that is set to control the VFD.But also the pressure from the charge line should be used as an input signal in such a way that the pressure doesn't exceed 37 bar during the regulation.It is also beneficial to have the pressure in such a way that the condensing temperature of the gas/refrigerant is 1-1.5 degrees above the outgoing water temperature. The diagram in my first post shows at what pressures that temperature occurs.In more practical terms, do you know what kind of hardware that is used for such controls, such as low selector and override, or generally for decoding signals and regulating things like this? The only controllers that I can find are temperature controllers.Yes, I've been looking into cascaded PID control. I just recently read about anti-windup, which could prevent exceeding maximum pressure. How stable it would be is hard to tell. I think that either using a logic based control that switches regulation type/style upon the event of reaching target temperature, or simply regulating directly against temperature while letting an override prevent the pressure to exceed maximum allowed pressure would yield a fairly stable regulation.But still, what kind of hardware is used in such applications? What can I use that doesn't cost an arm and a leg? I understand that there aren't any off the shelf controllers that do exactly what I want, but there must be some more generic controller that isn't too difficult to program that would do the job?

author: IanB
author_rank: Super Contributor
timestamp: November 04, 2016, 01:38:06 am
content: The generic hardware that is used industrially for such applications is the PLC or Programmable Logic Controller. However, I do not know whether you can find one to fit your budget. They are usually ruggedized and sold at industrial rather than home automation prices. You may find some that come as small modules with displays that fit in a rack mount.As far as the pressure and condensing temperature is concerned this will be, to a degree, self-regulating. The temperature/pressure chart you showed for various refrigerants is a law of physics. If the refrigerant is condensing at a certain temperature, then the pressure will be the saturation pressure from that chart. The pressure will be locked to the temperature (modulo restriction orifices, regulation valves and other pressure drops in the system). Furthermore, the condensing temperature will be closely tied to the water temperature due to the expected high thermal performance of the plate heat exchanger.

author: Rerouter
author_rank: Super Contributor
timestamp: November 04, 2016, 06:23:09 am
content: I would say you would be looking in PLC territory to do it all in one. just because you can use math functionsMy thoughts are, Inner pressure loop, That has has a control range of 0-37 Bar, And whose output controls the VFD, as the pressure will be noisy, it should likely be a PI controller.Next layer of the cascade is the temperature, The input is your process temperature, and the output is the setpoint for the pressure loop, he can be PID, as the temperature should be quiet.If you really want to try and regulate the vapour temperature differential, it would mean adding a middle step to this cascade, whereby its input is the differential between vapour temp, and process temp.

author: _Wim_
author_rank: Super Contributor
timestamp: November 04, 2016, 08:32:39 pm
content: Quote from: axero on November 04, 2016, 01:20:15 amYou can do a PID-loop is any programmable device you want, as the PID algorithms are quite simple in their basic form. As others have said, the hard part is tuning the system (finding the correct gain-constants). Anti-windup is not for limiting, for that you use a limiter. Anti-windup is to prevent the integrator function (I-part of the "PID") to become too strong (wind-up) because of a sustained deviation between desired set point and actual value.PID stands for proportional, integral and derivative, the 3 parts that make up the PID-output. Basically, a PID has 2 inputs (desired value and the actual value, for example, desired temperature and actual temperature) , and 1 output that is used to control the process (in your case VFD frequency)To calculate the output value, it is as simple as this:error = desired_value – actual_valueprop = error * Kpint = int + ( error * Ki)der = (error – previous error) * Kdoutput = prop + int + derprevious error = errorThe above coded needs to be called once every fixed period of time (for example on a timer interrupt). This time need to be long enough to generate an actual change in the process, otherwise the above routine does not work (previous_error will always be equal to error).Kp,Ki and Kd are constants that determine how “strong” the PID controller reacts to a certain type of error, commonly called gain constants. Desired value is typically called setpoint (SP), and actual value typically process value (PV). The output is sometime called manipulated value (MV)The P-part is the easiest the understand, “the bigger the error, the bigger the output”. The I-part you must interpret as “the longer the error remains, the bigger the output”. So if your temperature is too low for a long period of time, the I-part will ensure the output gets bigger and bigger (hence the risk for wind-up) in an effort to eliminate that error. The D-part people also sometimes call “damping”, because its function is to limit the rate of change of the process. You must interpret this as "if I previously had a big error, and a fraction of time later I only have a small error, I am probably approaching the desired set point way to fast and will have an overshoot."More complex PID controllers typically add additional functions on top of this (limiters, manual control, anti-windup,multiple sets of gain constants…), but the basic principle is always the same.I would recommend to search for an online PID-simulation tool, and play around with one of these for starters. I hope this simple explanation makes PID-controllers a little more clear, if not, there is tons of information to find on the web of people that probably can explain this more clearly. Just stay away from explenation full with math (pole-zero, laplace...), you do not need these to understand the basics.

author: pelule
author_rank: Frequent Contributor
timestamp: November 04, 2016, 09:00:25 pm
content: A usual "pressure controller" in "noisy" systems is, as Rerouter mentioned absolut correct, a PI controller."noisy" in the sence of a loop controlled system means the input signal (= difference between setpoint and actual value = input signal of the controller) has sudden changes.A typical example: the pressure of a fluid passing a cleaning filter - the dirt in the fluid blocks more or less the filter and thus the pressure is quite unstable (noisy).The "D" part, the dynamic reaction to input changes of an PID controller, that part of the controller "looking into the future" - would overreact on that changes and so a stable regulation would be impossible.In fact this is true for any control loop, having dynamic (noisy) signals (another example: a motor driving a incosntant load)As I understood we have a heat/cooling pump:Thats a compresor based heat energy transmission system - it does not matter if you say cool or heat, that just depend on how you look to the system - it's energy transmission in any case. Such compessors have low torque motors and the pressure MUST be low at start and does increase as long as the motor/compressor rotates. If the motor stops (or slows down), the pressure falls (so the system is not noise in the above sense).Such compressor based systems have another issue to deal with to get a good regulation - the transfer characteritic (efficiency) is not stable over the pressure curve, thus the shown diagram of temp vs pressure is not showing the "truth". In fact the "cooling" power of the system is strongly depending on the actual archieved temperature - how long the system is at that specific pressure - and last but not least the disturbance value (the actual effective heat capacity the system).Example: if you drive the R410A with a constant speed, you will not have a constant pressure. If you manage to keep the pressure constant at 20 bar, this does NOT ensure, you will have 35°C (better say 35°K) heat energy transmission. The system remains not stable.That's the reason, I would recommend the "soft delayed regulator".A PID solution is possible, but only, if the P, i and D faktors are constantly adopted. That's not a simple PID controller unfortunately, it is a dynamic adopting PI controller, most solved using a kind of look-up table for the required faktors.Protection / Limit the extremesThis is not a regulation specific task, it is a protection task- during that "protecion" phase there is NO actiev regulation.A bit more general:In the theory of regulation the effective form of the control output signal (how the power of the system is controlled) does not matter, as long the change is fast related to the response time of the system - exactly the same as a DAC made with a PWM ouput / you need a low path filter after. That's why room temperture controller typicall use cheap relays = on/off witha 2-point regulator. The room is very slow responding, thus a very good low path filter.If you use the on/off (PWM) with dittering, you can archieve a very precise regulation.Thus I don't care in my thinking if you use a VFD or on/off PWM.

author: pelule
author_rank: Frequent Contributor
timestamp: November 04, 2016, 09:23:27 pm
content: I fully agrre to _Wim_.If I have understood correct, he tried to explain the math behind in a more simple way and recommend: "try to understand".With formal math spoken - a digital PID controller is an analog PID controller digital transformed.Transformation of a "continuously differentiable system" into a "time discrete" system using the Z-transformation._Wim_. "explanation of P, I and D is very good to get a better understanding of the basics.I personally trued to explain myself in "time related" expression, that also gives the important view of timeP = now, act immediately (just looks to the actual status and does not care abouz the past or the future)I = take the past into accountD = try to act in advance "the future"

author: Yansi
author_rank: Super Contributor
timestamp: November 05, 2016, 01:54:02 am
content: Quote from: pelule on November 03, 2016, 11:22:47 pmThat will not work well. Few days ago, my friend has dealt similar issue: A constantpowersource (for LED lighting) with voltage and amperage limits: One of the usable solution is to have a seprate regulator for each limit and switch between them with some hysteresis.In this case, just run the speed regulator. If pressure gets too high, switch to the other regulator, that will regulate for maximum pressure (if you need to keep the system operational, at maximum allowed pressure). Make sure, there is enough hysteresis, so that oscillation between switching the two regulators cannot occur.

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 05, 2016, 06:05:39 am
content: VFDs in HVAC applications typically try to regulate the space temperature or evaporating temperature, not the condensing temperature.

author: pelule
author_rank: Frequent Contributor
timestamp: November 05, 2016, 10:02:59 am
content: QuoteSorry, my words seem not clear enough (my limited english may the cause).It is not a "switch to another regulator" (a too complicated few) - it is like a "fuse" to protect the system against damage.Protection: If value exceeds the maximum allowed pressure, just switch of the pump (Y = 0).Just a very simplle flow chart:loop:W = pressure_target_value;X = get_actual_pressure();Y = PID(X, W);if (pressure > pressure_maxlimit) then Y = 0;output(Y);goto loopHope it's more clear now.Just anothe simplified example (complete would become an excurs in math):In reality a PID controller is "outside the P-range" a simple ON/OFF controller.That because small changes of input have no effect to the ouputsY = f(P)*(W-X) >> Ymax.ExampleY = 0...100P = 10X = 50W = 60|W-X| exceeds 10 - |Y| become |Ymax| - on/off controller

author: Yansi
author_rank: Super Contributor
timestamp: November 05, 2016, 11:34:19 am
content: I have understood you welll. But still your code won't work properly in reality. You are missing a lot of thing. For example: hysteresis. If the pressure was exceeded, you will turn the pump off. But when will you turn it back on? How do you prevent frequent cycling? The pump won't be happy if you will turn it on-off just like that, mostly because compressors don't like to start under pressure.

author: retrolefty
author_rank: Super Contributor
timestamp: November 05, 2016, 01:41:22 pm
content: Quote from: axero on November 03, 2016, 11:46:45 pmYes generic PID controllers are equally useful for pressure control application, just the proper tuning constants are harder to achieve as pressure is a faster feedback changing 'process' then typical temperature controllers. Just have to have proper input/output voltage/current sensors and control elements.