4 ms·
In my case I built a model of espresso machine consisting of various thermal masses with different properties and impedancies between them. (Boiler heater eleme
by lmilcin 5y ago
In my case I built a model of espresso machine consisting of various thermal masses with different properties and impedancies between them. (Boiler heater element, water in boiler, scale on the boiler walls, boiler walls, grouphead, water in pipe between boiler and grouphead, water in pipe and pump between reservoir and the boiler, water in reservoir tank).
This model can estimate future temperature of brew water based on current and past temperature measurements in various points in the system as well as on amount of water being pumped through the system.
There are four temperature measurements being made:
- ambient temperature
- water reservoir temperature (the thermometer touches the reservouir), though I am pretty sure this one could be estimated from past operation of the boiler.
- boiler temperature (the thermometer glued to the outside of the boiler at a selected point below water line)
- group head temperature (the thermometer glued to the outside of the group head at selected point). This one could also potentially be estimated from past operation but I tried it and it complicates my model too much.
In particular the model is designed to be able to calculate a single parameter, what is going to be the water temperature if used for brewing coffee, at a point in future, if heating element keeps adding given amount of energy and pump pumps given amount of water.
The way the model is being used depends on what the machine is waiting for. For example, when you want to brew coffee, it delays start of brewing until it can achieve stable temperature.
To achieve this as fast as possible (ie power on from cold to stable temperature) the machine is heating water at maximum power and the model is being executed 50 times a second to estimate what will be maximum temperature attained by brew water if we shut the power now. The idea here is we want to run the heater at max power for as long as possible and shut it off at exact moment so that the heat that spreads will cause the brew water to achieve the exact desired temperature.
Mind that brew water temperature is not measured directly. I can only measure it experimentally with a modified portafilter.
The parameters of the system are being observed and I use other filters to correct the parameters as system changes. For example, the system can detect amount of boiler scale developing rather precisely, mainly due to how it affects impedance between water in the boiler and the temperature sensor.
---
Now, I am pretty sure it is overkill for an espresso machine. I am doing this to teach myself some control theory. But the effects are real and the algorithm works like magic -- the machine starts and achieves optimal temperature in shortest possible time and then keeps it stable with no over or undershoots that could affect the brew.
In todays world the chips that can run this model are being sold for pennies and the only real complication is rather precise, noise free temperature measurement that you need for this plus measurement of amount of water being pumped.
- rblatz 5y agoThis all sounds extremely cool. What is the base espresso machine you are building this on top of? Do you have a blog where you document your process?
- lmilcin 5y agoSo many people ask this. The base machine is Rancilio Silvia, selected because it is relatively cheap, well made, simple, and has no electronics in it. It is a collection of AC switches, thermostats and other AC-powered components. I don't care about making a blog. I do it for fun. Given choice I would prefer to spend the time doing some more cool projects.
- wenc 5y agoThis sounds like an on-off controller with a predictive model. In this configuration, the predictive model (PM) predicts the temperature p-steps ahead (using 4 measurements) and then feeds the predicted output to the on-off controller, i.e. something like PM(yₖ, uₖ) → Tₖ₊ₚ uₖ = {uₘₐₓ if Tₖ₊ₚ < Tₛₑₜ else 0} (on-off control law) where k = current time, yₖ = 4 temperature measurements, uₖ= manipulated variables (heating), Tₖ₊ₚ = controlled variable, i.e. temperature p-steps ahead (k + p), Tₛₑₜ = setpoint temperature. If you're doing predictions, I'm not sure the estimator is technically called an MHE since MHEs only estimate the current state, not future states (it cannot because one technically cannot know future measurements), so I call it a predictive model here. (unless you're doing MHE to estimate the current state xₖ and then feeding that into the predictive model to get Tₖ₊ₚ predictions...) This can indeed provide smoother, more accurate control than PID alone because (1) it uses a model that accounts for more variables than just the controlled variable, (2) it requires less tuning to avoid over/undershoot because it is guided by a model vs simply through setpoint errors; (3) it's a special case. I think it's a very practical control configuration for on-off temperature control, which has tons of applications from oven control to immersion circulator control etc. I don't think this configuration has a name, but it resembles a simplified version of model predictive control (MPC) except for the lack of an optimizer (the control law is on-off vs an optimal control law computed via an optimizer). It is however a much less general configuration than a PID because in the general case (not on-off) you still need a control law to do trajectory tracking, and that law tends to either be a PID or similar.