Electronics-Related.com
Forums

PID Heater Control

Started by rickman November 22, 2015
On Mon, 23 Nov 2015 01:32:22 -0500, the renowned rickman
<gnuarm@gmail.com> wrote:

> >Digital samples. Typically the delta between the last and the current >measurement is considered to be the derivative.
It's not nearly as simple as that. https://en.wikipedia.org/wiki/Finite_difference_coefficient#Forward_and_backward_finite_difference Of course, only the backwards difference is causal. But difference between samples may be small compared to quantization or other noise (especially if you are sampling at a relatively high rate) so that method (alone) is typically not sufficient either- filtering is required if you really want the D. --sp -- Best regards, Spehro Pefhany Amazon link for AoE 3rd Edition: http://tinyurl.com/ntrpwu8 Microchip link for 2015 Masters in Phoenix: http://tinyurl.com/l7g2k48
On 11/23/2015 1:54 AM, Spehro Pefhany wrote:
> On Mon, 23 Nov 2015 01:32:22 -0500, the renowned rickman > <gnuarm@gmail.com> wrote: > >> >> Digital samples. Typically the delta between the last and the current >> measurement is considered to be the derivative. > > It's not nearly as simple as that. > > https://en.wikipedia.org/wiki/Finite_difference_coefficient#Forward_and_backward_finite_difference > > Of course, only the backwards difference is causal. > > But difference between samples may be small compared to quantization > or other noise (especially if you are sampling at a relatively high > rate) so that method (alone) is typically not sufficient either- > filtering is required if you really want the D.
He posted a series of temp samples and they showed very low noise, none that I could see by inspection. So that's not an issue. -- Rick
On 11/23/2015 1:26 AM, Spehro Pefhany wrote:
> On Sun, 22 Nov 2015 19:44:25 -0500, the renowned rickman > <gnuarm@gmail.com> wrote: > >> On 11/22/2015 6:13 PM, Spehro Pefhany wrote: >>> On Sun, 22 Nov 2015 14:33:55 -0500, the renowned rickman >>> <gnuarm@gmail.com> wrote: >>> >>>> If a heater is controlled by turning it on and off, does a PID algorithm >>>> help in more closely controlling the temperature? >>> >>> It can help. You turn the heater on and off fast enough that it is >>> effectively an analog output. It's called 'time proportioning' in the >>> industry. >> >> How does the PID loop turn the heater on and off any faster than a >> simple set point? Add an anticipator and overshoot is minimized. > > The PID output feeds into a modulator with an independent time base > that is much shorter than the dominant lag of the system.
Ok, now you are adding a unit to take the range of values output by the PID controller and generate a pulse train from that. That is not the design I was asking about. I was discussing direct, on/off control from the output of the PID.
> Say we have a proportional cycle time of 2 seconds. With a PID output > of 0.5 you have the output on for 1 second and off for 1 second. With > the PID output of 0.1 on for 200ms and off for 1.8 seconds. > > >>>> Will running the PID loop faster than the temperature measurement >>>> improve anything? >>> >>> Certainly not. There's no new information. >>> >>>> How would a PID control be an improvement over a simple temperature >>>> comparison with or without an anticipator? >>> >>> With an anticipator it might be fairly similar. Comparison normally >>> needs some deadband so you would tend to get higher temperature ripple >>> with comparison that with a time-proportioning PID. The output will >>> turn off earlier in the latter case, as it needs no information from >>> the sensor to do so (it can turn on and off many times per temperature >>> measurement if you want, but it's commonly not done that way). >> >> When you say "time-proportioning PID", you mean an output that is not >> just on or off, but a number that is used to control PWM? That would be >> above and beyond just PID. > > Yes, it is. But it's still called a PID controller (by everyone).
Fine, but that is not what the design in question is using.
>> Someone in another group seems to be saying his PID loop running at 10x >> the temperature measurement rate gives him this fine on/off control. >> But his temperature measurements have lots of variation. Well, by >> "lots" I mean a lot more than I expect could be done easily by just >> setting a temperature and turning the heat on and off possibly with an >> anticipator. He is getting maybe &#4294967295;1 C&#4294967295;. > > Well, in a simple thermal system with a fast temperature sensor (one > and only one dominant lag) you may be able to turn the gain of a > proportional controller up as far as you like and get pretty good > control. At infinite gain, it's just a comparison. If you have a > sensor or an actuator that responds relatively slowly, however, you > will not get as good control.
This is the issue I want to discuss. In this system a thermocouple will respond much faster than the heating element.
> So it's dependent on the sensor and the > rest of the system. But suppose you are using a typical industrial > mica-insulated band heater- the internal parts get much hotter than > the shell when it is on, so when you turn the heat off the heater > surface temperature continues to rise for a while. Similarly, a > sensor, especially an air sensor or a sensor in a protective housing, > will lag behind the actual process variable. So when you turn the heat > off the temperature reading continues to rise.
Even if the heater doesn't have the "shell", it will remain hotter than it's surroundings for some time. The heat in the element has to dissipate into the oven.
> Think of an amplifier with negative feedback that has phase shifts in > each element. > > A PID controller can be tuned (or many can self-tune) to give > acceptable control even with a less ideal system. Like most other > things (amplifiers and negative feedback, for example) it's best to > make the system as good as you can make it before trying to add > complexity such as PID. > >> My house thermostat keeps the >> temperature within 1 F&#4294967295; and it is not really trying. He doesn't really >> want to discuss it. I would like to understand the reality. > > Room air temperature as read with a fast air sensor normally varies a > bit more than that, though the *average* should be stable. You can't > cycle forced air central heating fast enough to maintain the air > temperature quite that constant- it's a limitation of the actuator in > that case- so you get a ripple on top of a stable average.
I have taken measurements of the air temperature with a thermocouple and found it to be very stable. I'm not sure what you are talking about.
> The anticipator in an old-style bimetallic thermostat is sort of a D > function, but not quite since it's an on-off controller. It's also > sort of a time proportioning modulator. BTW, modern thermostats have a > setting that's something like cycles per hour rather than an > anticipator.
The anticipator is nothing like a D function. It doesn't react to the temperature at *all*. It simply models the temperature of the heating element to help prevent overshoot at the end of a heating cycle. -- Rick
On Mon, 23 Nov 2015 02:12:54 -0500, the renowned rickman
<gnuarm@gmail.com> wrote:

> >He posted a series of temp samples and they showed very low noise, none >that I could see by inspection. So that's not an issue.
No. You _really_ can not conclude that until you know the required D gain for the tuned system (the time constant for D). It more than likely is an issue in a real system (as opposed to a simulation with double-precision numbers). Avoiding the math (you shouldn't) to get an intuitive idea- if you want to cut the heat back 50% when the temperature is rising at 1 degree per 60 seconds, and your sample rate is 10Hz then you need a gain of several hundred, so a fraction of a hundreth of a degree of noise (including quantization noise) is important. --sp -- Best regards, Spehro Pefhany Amazon link for AoE 3rd Edition: http://tinyurl.com/ntrpwu8 Microchip link for 2015 Masters in Phoenix: http://tinyurl.com/l7g2k48
On 11/23/2015 2:34 AM, Spehro Pefhany wrote:
> On Mon, 23 Nov 2015 02:12:54 -0500, the renowned rickman > <gnuarm@gmail.com> wrote: > >> >> He posted a series of temp samples and they showed very low noise, none >> that I could see by inspection. So that's not an issue. > > No. You _really_ can not conclude that until you know the required D > gain for the tuned system (the time constant for D). > > It more than likely is an issue in a real system (as opposed to a > simulation with double-precision numbers). > > Avoiding the math (you shouldn't) to get an intuitive idea- if you > want to cut the heat back 50% when the temperature is rising at 1 > degree per 60 seconds, and your sample rate is 10Hz then you need a > gain of several hundred, so a fraction of a hundreth of a degree of > noise (including quantization noise) is important.
If the resolution of the temperature measurement is just 0.1 degree, then that will be difficult. -- Rick
On Sun, 22 Nov 2015 14:33:55 -0500
rickman <gnuarm@gmail.com> wrote:

> If a heater is controlled by turning it on and off, does a PID > algorithm help in more closely controlling the temperature? > > Will running the PID loop faster than the temperature measurement > improve anything? > > How would a PID control be an improvement over a simple temperature > comparison with or without an anticipator? >
I don't know the nature of your heater (system), but if the transfer function is linear then I think it can be approached as a discrete-data control system. The Laplace representation of the heater's system you can be transformed into the Z-domain. Then you can design something like a dead-beat controller for it. That might be the fastest you can get. http://www.facstaff.bucknell.edu/mastascu/eControlHTML/Sampled/Sampled1.html A good book would be the one by Benjamin C. Kuo: "Digital Control Systems" if you had the time. joe
On Sun, 22 Nov 2015 17:44:09 -0800 (PST)
whit3rd <whit3rd@gmail.com> wrote:

> On Sunday, November 22, 2015 at 4:44:37 PM UTC-8, rickman wrote: > > On 11/22/2015 6:13 PM, Spehro Pefhany wrote: > > > On Sun, 22 Nov 2015 14:33:55 -0500, the renowned rickman > > > <gnuarm@gmail.com> wrote: > > > >> Will running the PID loop faster than the temperature measurement > > >> improve anything? > > > > > > Certainly not. There's no new information. > > Moreover, it takes two or more measurements of temperature to update > a 'D' (differential) value. It's unclear whether this is about a > time-sampled temperature measurement (with discrete approximations of > integral, proportional, and derivative terms), or an analog > measurement of temperature with analog differentiation and > integration elements. > > > >> How would a PID control be an improvement over a simple > > >> temperature comparison with or without an anticipator? > > This is confusing; the 'D' term, in PID, is an anticipator.
Maybe someone meant 'feed forward control'? https://en.wikipedia.org/wiki/Feed_forward_%28control%29 If (just for example) the water heater is an electric shower, the feed forward signal would be proportional to the flow of water and subtracted from the proportional negative feedback term. joe
> > Someone in another group seems to be saying his PID loop running at > > 10x the temperature measurement rate gives him this fine on/off > > control. > > If he is computing a new proportional term (or integral, or > derivative), it means he has an extrapolation of his temperature > measurements, and is applying that extrapolation to compute the PID > response. The issue then becomes the accuracy of the extrapolation > (which depends on the system and the extrapolation scheme). > If he's not computing a new term, his 'PID' latches a heat setting > until the next temperature update.
On Mon, 23 Nov 2015 01:54:21 -0500
Spehro Pefhany <speffSNIP@interlogDOTyou.knowwhat> wrote:

> On Mon, 23 Nov 2015 01:32:22 -0500, the renowned rickman > <gnuarm@gmail.com> wrote: > > > > >Digital samples. Typically the delta between the last and the > >current measurement is considered to be the derivative. > > It's not nearly as simple as that. > > https://en.wikipedia.org/wiki/Finite_difference_coefficient#Forward_and_backward_finite_difference > > Of course, only the backwards difference is causal. > > But difference between samples may be small compared to quantization > or other noise (especially if you are sampling at a relatively high > rate) so that method (alone) is typically not sufficient either- > filtering is required if you really want the D.
Sampling at 'a relatively high rate' is useless. Filtering would then indeed be the logical thing to do. joe
> --sp > > >
On Sun, 22 Nov 2015 16:55:04 -0500
rickman <gnuarm@gmail.com> wrote:

> On 11/22/2015 4:11 PM, Tim Wescott wrote: > > On Sun, 22 Nov 2015 14:33:55 -0500, rickman wrote: > > > >> If a heater is controlled by turning it on and off, does a PID > >> algorithm help in more closely controlling the temperature? > > > > Compared to what? Yes, compared to a lot of things. > > A conventional type thermostat with a set point and a hysteresis band. > > > >> Will running the PID loop faster than the temperature measurement > >> improve anything? > > > > Probably not much, however pulsing the heater on and off faster > > than the temperature measurement may well improve things -- it > > depends on whether you can turn the heater on and off quickly, and > > what it's thermal time constant is. In the extreme, turning power > > on and off to a heating element significantly faster than it's > > thermal time constant will give you steady, rather than pulsating, > > heat. > > If the temperature measurement isn't updated, how would the PID > provide any better control over the temperature? At best it > essentially does the same thing for 10 periods until the temperature > reading is updated, at worse the integral term ramps up resulting in > overshoot and oscillations.
That is correct. Given a fixed temperature measurement period, the best thing to do is synchronise the on/off switching with the measurement, transform it into the z-domain and calculate the analogue components needed to get the right control. I think this book 'sums it up' quite (very) comprehensively: http://een.iust.ac.ir/profs/Jahed/digital%20controll/e%20book/discrete-time_control_systems.pdf joe
> >> How would a PID control be an improvement over a simple temperature > >> comparison with or without an anticipator? > > > > Most on/off thermometer-ish systems need to see the temperature > > actually change to work. This is less the case with an > > anticipator, but that brings its own problems. > > What problems does an anticipator create? > > > > In the case where the thermal loss is constant and the temperature > > needs to be held steady, and where the heating element is being > > pulsed significantly faster than the thermal time constant of the > > plant (if not the heater), then the PID would, in theory, hold the > > temperature dead steady -- or at least as steady as it can given > > how fast it is being pulsed on and off. > > How does a PID controller cycle the heat in absence of updated > temperature readings? On the update of temperature, the differential > and proportional terms will give a constant input to the calculation > until the temperature is updated again. The integral term will push > the integrator in a direction with a constant ramp for the duration > of the temperature reading period. I suppose this could result in > one pulse during the temperature reading period, but will create an > internal overshoot for the next period which will show up as a too > short pulse. > > Obviously this is all dependent on the parameters of the PID > controller, but I'm having trouble picturing how the faster PID loop > would provide any useful benefit rather than just causing > oscillations. >
On Mon, 23 Nov 2015 01:24:38 -0500, rickman wrote:

> On 11/23/2015 1:15 AM, Tim Wescott wrote: >> On Sun, 22 Nov 2015 16:55:04 -0500, rickman wrote: >> >>> On 11/22/2015 4:11 PM, Tim Wescott wrote: >>>> On Sun, 22 Nov 2015 14:33:55 -0500, rickman wrote: >>>> >>>>> If a heater is controlled by turning it on and off, does a PID >>>>> algorithm help in more closely controlling the temperature? >>>> >>>> Compared to what? Yes, compared to a lot of things. >>> >>> A conventional type thermostat with a set point and a hysteresis band. >>> >>> >>>>> Will running the PID loop faster than the temperature measurement >>>>> improve anything? >>>> >>>> Probably not much, however pulsing the heater on and off faster than >>>> the temperature measurement may well improve things -- it depends on >>>> whether you can turn the heater on and off quickly, and what it's >>>> thermal time constant is. In the extreme, turning power on and off >>>> to a heating element significantly faster than it's thermal time >>>> constant will give you steady, rather than pulsating, heat. >>> >>> If the temperature measurement isn't updated, how would the PID >>> provide any better control over the temperature? At best it >>> essentially does the same thing for 10 periods until the temperature >>> reading is updated, at worse the integral term ramps up resulting in >>> overshoot and oscillations. >>> >>> >>>>> How would a PID control be an improvement over a simple temperature >>>>> comparison with or without an anticipator? >>>> >>>> Most on/off thermometer-ish systems need to see the temperature >>>> actually change to work. This is less the case with an anticipator, >>>> but that brings its own problems. >>> >>> What problems does an anticipator create? >>> >>> >>>> In the case where the thermal loss is constant and the temperature >>>> needs to be held steady, and where the heating element is being >>>> pulsed significantly faster than the thermal time constant of the >>>> plant (if not the heater), then the PID would, in theory, hold the >>>> temperature dead steady -- or at least as steady as it can given how >>>> fast it is being pulsed on and off. >>> >>> How does a PID controller cycle the heat in absence of updated >>> temperature readings? On the update of temperature, the differential >>> and proportional terms will give a constant input to the calculation >>> until the temperature is updated again. The integral term will push >>> the integrator in a direction with a constant ramp for the duration of >>> the temperature reading period. I suppose this could result in one >>> pulse during the temperature reading period, but will create an >>> internal overshoot for the next period which will show up as a too >>> short pulse. >>> >>> Obviously this is all dependent on the parameters of the PID >>> controller, >>> but I'm having trouble picturing how the faster PID loop would provide >>> any useful benefit rather than just causing oscillations. >> >> Did you ACTUALLY READ what I took the time to write, in a spirit of >> helpfulness? ?? ???? >> >> "However, pulsing the heating element ..." >> >> If that statement doesn't make sense, ask about it -- because it makes >> all the difference. > > Yes, I read it. But that is very little detail. I think my reply > showed I gave it consideration. If you don't want to discuss this, why > reply? If you want to discuss it then perhaps a bit more clarity would > be helpful.
Think sigma-delta, or PWM, with the heater on/off being a one-bit DAC. If you PWM the heater at a faster rate than the control loop, or if you run the output of the PID into a sigma-delta stage (that's either going as fast as, or faster than, the control loop), then the heater command will get low pass filtered in both the heating element and in the plant's thermal mass. This will make the heater & driver act much more like a continuous element than a relay element. At that point, a PID becomes fairly worthwhile. -- www.wescottdesign.com