# PID temperature stability issues



## phario (May 7, 2017)

I have a PID installed on my Gaggia which seems to be working in the sense it oscillates at the desired temperature (currently 102C at the brew stat). The oscillations can go on for a while, say after 20 minutes it is still varying between 101.5 and 102.5.

However, upon pulling a shot, the variance is quite large. It'll dip down to 99C or even 98C. (correction: even beyond that to 96 or 97).

I ran the auto-tune on the PID, which seemed to give values of P = 4.8, I = 177, D = 44. Curiously this gives a higher I value than I would have thought. Since I relates to the response time, I suppose I should be reducing this?

The oscillation around the steady-state temperature is also annoying. Is this a function of the souF (damp constant) parameter? I suppose a higher damping constant would reduce this oscillation.


----------



## phario (May 7, 2017)

There weren't a lot of replies in the last day on my post, so I want to be a bit more specific. I can resolve the issue of the passive temperature variation by changing souF to 0.4. This seems to stabilise my steady temperature (when not running the pump) to 0.1C. However, I'm observing a large temperature drop when I pull a shot.

*What temperature drop do you observe when you pull a shot with a PID?*

That's the basic question I want to ask. I had the impression that the PID could affect intershot temperature drops. This video from @MrShades gives a drop from around 92.6C to 89.4C or 3C. This one here gives a drop of 3C.

However, this post gives a drop of around 10C (by the way, this inspires some to create a pre-heating chamber for their Gaggia). I was observing 10C drops on my machine, which is why I was worried that I was working with the wrong settings.

References:



MrShades video: 





YouTube video of shot and PID: 





2005 discussion with graphs of temperature drop: https://web.archive.org/web/20050718214656/http://coffeesnobs.com.au/YaBB.pl?num=1118552887


Aluminium heating chamber: https://www.home-barista.com/repairs/preheating-incoming-water-on-gaggia-classic-t2794.html


----------



## MartinB (May 8, 2011)

What thermocouple are you using and where is is mounted? What pid controller are you using?


----------



## phario (May 7, 2017)

MartinB said:


> What thermocouple are you using and where is is mounted? What pid controller are you using?


 It's an Auber SYL 1512a and @MrShades PT100 mounted on the boiler (OEM position).

I found a very useful report by Auber Instruments on the Scace Thermofilter experiment that clearly explains the temperature drop and relationship between boiler temperature and water brew temperature. They also report a 10C drop during a shot. I'm digesting the paper now but still remain confused why 3C drops are observed by some people.


----------



## phario (May 7, 2017)

Okay, so I report back with two new runs. I ran a test at with my autotune settings of P = 4.8, I = 160, D = 40, souF = 0.4. Again, these seem to have much higher I values than what people try, but rather than fiddling with manual settings, I thought it was better to use autotune. But more comments below. I tried with both stock aluminium and brass dispersion plates, which had similar results (unsurprising given the temperature is at the boiler). Both returned about a 4-5C decrease on a double shot.

So there are a few useful references I've discovered. Because these references are prone to being removed (many are half a decade to almost a decade old), I'll describe some of the findings.

This is a useful quotation by D4F:



> Using the Auber PID and RTD sensor, B'stat location, I have used 215F down to 212F. A thermofilter was used to track basket/puck temperatures. Technique and volume definitely come into play. The Auber PID study
> 
> http://www.afonic.org/espresso/TempPerfomanceStudy-Gaggia.pdf
> 
> ...


 The more useful reference is to that study by Auber: link

In that study, they use a Scace device to study the connection between water brewing temperature and boiler temperature. Here is the graph that confirms the 10C drop in brew water temperature, measured from the peak temperature near the end of the shot. The different colours indicated in the legend correspond to different Sv values for the PID device.









Essentially what they are trying to do is figure out what the PID Sv temperature should be set at (measured from the boiler) so that the water brewing temperature is at a desired level (I guess around 85-95C [Scott Rao's book]). The other question is whether you should calibrate based on peak temperature or average temperature during the shot. Anyways, here is the other important graph:









So the point is that if you are aiming for, say, 93C brewing temperature, and you want to set according to the average trends, then you would set your PID Sv to about 104C. Basically read off what temperature you want on the vertical axis and find the corresponding horizontal value either via the pink or blue trends or somewhere in between. The authors recommend the average temperature since this "will be more consistent and closer to the real espresso making situation".

*Their conclusions are pretty straightforward:*



> When making a double shot (60 ml), the brew water temperature of Gaggia
> Coffee deluxe can drop 10 C (18 F) at the end of the shot. However the
> temperature change profile is reproducible and predictable. When correctly
> operated, the Gaggia can produce a very reproducible shot. The brew
> ...


 Further questions:



I do not entirely understand what accounts for the variance that some people have observed in the temperature drop, from -3C to -10C. I do not understand whether this is an effect of different ambient conditions (like a warmer day and hence warmer ambient water temperature), or the PID settings.


I still do not understand completely the effects of PID settings calibration. Can the PID be set up to really help minimize temperature variation during the shot itself? (By e.g. pumping up the P to much higher values?).


At the end of the day, I'm not sure it matters much. As far as it concerns the Gaggia Classic and its small aluminium boiler, the point of the PID is to steady the initial brewing temperature, and to provide reproducibility. Based on the Auger study, I think the advantages of fiddling with PID settings is probably minimal because you're not going to really beat the inherent mechanical limitations of the boiler. Moreover, the truth is that the advantages of having a very tight temperature range during brewing is unclear; the key is the PID providing reproducibility of the initial temperature.

As noted by the first quotation in my post, if it really bothers you, then you can either go with a shorter shot length, or you can blip the steam switch pre-brew to help deal with the initial drop.

TL;DR: Don't sweat -10C swings in temperatures during brewing. It's normal.


----------



## MartinB (May 8, 2011)

Here's a video of my PID temp on a 30 sec double shot. Set at 101c and dipped down to 98.3. All set up on auto tune - haven't ventured to play with the settings yet.

https://streamable.com/8zmyaq


----------



## phario (May 7, 2017)

MartinB said:


> Here's a video of my PID temp on a 30 sec double shot. Set at 101c and dipped down to 98.3. All set up on auto tune - haven't ventured to play with the settings yet.
> 
> https://streamable.com/8zmyaq


 Thanks Martin.

Can you share your pid settings? (P, I, d values).

Interestingly, I might have found one source of temperature variation today. I noticed my grouphead leaking slightly so pulled the portafilter much more tightly. Temperature variation was then 3-4C.

It doesn't answer the original question (of why such large variation is observed) but does hint at possible sources.

At some point I have to sit down and see if the 3-10C variation can be predicted from a back-of-the-envelope approximation.


----------



## MartinB (May 8, 2011)

Will share them tomorow for you 👍


----------



## MartinB (May 8, 2011)

This is how i've interpreted my manual as my Inkbird controller doesn't specifically call out P, I & D values. Can do a bit more digging later but i believe the values to be:

P = 12

I = 900

D = 9


----------



## phario (May 7, 2017)

MartinB said:


> This is how i've interpreted my manual as my Inkbird controller doesn't specifically call out P, I & D values. Can do a bit more digging later but i believe the values to be:
> 
> P = 12
> 
> ...


 Really weird P and I values. Does anybody know what's up? Typical recommended P values I've read from 2-6 and I values from 20-200. D values at 1/4 I values.

Does the inkbird controller use a different normalisation?

https://www.controleng.com/articles/understanding-pid-control-and-loop-tuning-fundamentals/


----------



## MartinB (May 8, 2011)

phario said:


> Really weird P and I values. Does anybody know what's up? Typical recommended P values I've read from 2-6 and I values from 20-200. D values at 1/4 I values.
> 
> Does the inkbird controller use a different normalisation?
> 
> https://www.controleng.com/articles/understanding-pid-control-and-loop-tuning-fundamentals/


 i'll do some more info gathering on it later! It may help for me to share a pic of the manual/settings so you can take a look and interpret which should make the process a bit easier?


----------



## phario (May 7, 2017)

MartinB said:


> i'll do some more info gathering on it later! It may help for me to share a pic of the manual/settings so you can take a look and interpret which should make the process a bit easier?


 Not to be ungrateful, but I don't think that's necessary unless you have an interest yourself (I say this because I wouldn't know what to make of the data anyways so don't want to trouble you!).

I haven't been able to find much info on quantitative testing of PID settings for espresso beyond the anecdotal. Most coffee enthusiasts who have been trying to set their PID either do an Autotune or have some 'mystery' trial-and-error procedure that they don't explain. Basically, in theory, it would be good to have a database of PID values for different controllers so users can be relatively certain they're in the same ballpark. But it might also be unhelpful because the truth is that actual quantitative testing seems rare or hard to do.

I would imagine that the autotune settings do some sort of algorithm similar to what is explained in that link I provided, and unless you have deep knowledge of the process, you shouldn't really fiddle with it. In theory, 'P' provides a fast response to the error (current minus desired temperature), and 'I' provides a more long-term response (error integrated over some time interval). 'D' is chosen to be 1/4 the size of 'I'. This '1/4' figure seems to come from the 1942 recommendation by Ziegler and Taylor but I've not read their paper (I think it's heuristically chosen anyways).

Anyways, going to the formula in that 1942 paper (as quoted in the article yields):









In a nutshell, you put in a desired step change of heat (the Sv value) and observe the rate of change of temperature. There is an initial 'slow' rate of change in time, which you call 'd'. And a longer time interval 'T' when the heat takes to ramp up to the desired value. The 'T_D' value is chosen to be proportional to 'd'. If you want a faster initial response, then you should decrease 'd'. The 'T_I' value should be chosen to be 4 times the 'T_d' value.

Finally the 'P' value seems to be the most important. If you want 'T' to decrease, then 'P' needs to decrease in a proportional amount. However, 'P' needs to be adjusted with respect to 'd'.

By the way @MartinB I think the above formulae clarify some of the scaling issues we've noted. Your 'P' values are 3-4 times larger than what I've seen with other people (around P = 4 to 5). However, you might think that produces an 'I' value that is 3-4 times larger. At the upper end, that brings your 'I' value down from 900 to 900/4 = 225. High but not much higher than my autotune at I = 180.


----------



## Muratozt (Mar 27, 2021)

Hello, I set up PID to my Gaggia Classic using the XMT-7100 controller unit which is the one included in Mr Shades PID kit. I first tried autotune as advised by various sources on internet but this setting gave an intrashot instability up to 10 degrees celcius. (P:2.8, I:27 D:6). Then I figured out that the reason is that the temperature behaviour during brewing is totally different than the behaviour during stand by mode. As autotune is done during standby mode which prioritizes relative slow reach to target value without much fluctuation in temperatures and long term stability on the reached target value, it does not provide solution for the requirements during a shot. During a shot, priority is responding quickly to the rapid drops in temperature using strong kicks. This actually means sacrificing the ability to keep temperature from reaching extreme highs and lows but in case of brewing it results in keeping temperature drops only within 2-3 degrees Celcius range. At the end I found the best settings for me was P:2.4, I:40, D:10 and Souf:0.2. After many trials, the stability I got with this setting is the same with what you have seen in the videos and titles you have posted. Strongly recommended.


----------

