Non-PID Automated Control

Discuss roast levels and profiles for espresso, equipment for roasting coffee.

#1: Post by aabud »

I started a thread a couple of weeks ago to document my attempts at using the Artisan software PID with my Kaldi Home 200g Drum roaster ( Kaldi Home and Artisan Software PID ). For better or worse, and either out of ignorance or inspiration I concluded a PID wasn't ever going to work very well with my Kaldi. Sinking further into Covid induced nerd-dom, I was intrigued with the idea of a "model based" controller (I'll call it an MBC for short) and the advantages it would have over a PID. So I started down that path... now a couple weeks later - some success! After a couple aborts due to bugs here and there, here's my first attempt that managed to take off and land without me touching the gas:

My BT thermocouple stays with the beans - it's in the beans as they're sitting beside the roaster, then pull it out when I charge, then insert it into the rotating been mass in the roaster. That's why you don't see a turning point really - only a rise. I soak for 60 seconds, more or less.

As background on what the MBC controller is exactly... it's a piece of software that runs on my laptop. It sits between my gas control (servo on a knob) and my thermocouples (BT and Exhaust Temp currently) and exposes itself via modbus to Artisan. Artisan is used simply to record the actions and events, and to mark End of Soak, First Crack, and Drop. The MBC uses the background Artisan profile curve as a target. The MBC contains the thermodynamics of my Kaldi and monitors the roast, simulating the next 60 seconds into the future to see if any adjustments are warranted. If adjustments are needed, the change is selected also by simulating various alternatives and selecting the one that offers the least variation from the background profile. The accuracy of the model is compared every 10 seconds to the actual results and the model tuned accordingly. So if a draft is lowering my BTU's, the model will adjust.

To speed up debugging, I added the ability for the MBC to take as input an Artisan recorded roast, rather than live temperature readings.

Here's a pic of what the MBC looks like currently. The UI is a mess as I keep adding and subtracting things as I get ideas or need something to problem solve. For example, I added a PID based warm up protocol so that my testing can more or less be apples to apples, as far as drum temp goes. The stuff I need to see during a live roast is all at the top, so I can resize the window to show just the top bit and place over the top left of the artisan window.

I haven't looked in detail at the above roast yet, but I'm not happy with the actual vs profile gap that developed around 7 minutes. I suspect the model had underestimated the drum temperature at that point - the gas was off, so clearly the drum and the environment were continuing to provide more energy into the beans than the model anticipated. I'll confirm that, tweak the model and then rerun this roast in simulation to see if that results in the controller taking the gas down earlier, which is what needed to happen to fit the profile.

The model does not take into account beans going exothermic, but that's something I would like to add after I get what I've got accurate.

I'm starting to wonder if a "profile curve" is really the right thing for the controller to use as a guide. It seems like it would be more straight forward to be able to specify things like development time targets, phase ratios, roast duration, and ROR angles... then let the model develop the "profile curve" to produce those results. Also something to pursue down the road.

aabud (original poster)

#2: Post by aabud (original poster) »

Here's another live roast, after fixing the drum temp modeling:

Still a little issue I think where there is too much of a gap developed that developed at around 5 minutes, where I need to open up some constraints a bit on how much I let the model adjust when it sees the burner is over or under performing.

Decent Espresso: espresso equipment for serious baristas
Sponsored by Decent Espresso
User avatar

#3: Post by AssafL »

Very interesting. I, for one, agree PID provides very little advantage to a roast. Or at least that has been my experience. BTUs or % burner do more (in my case watts instead of BTUs).

The model, while it incorporates the burner and the steel, is really up to the bean. Probably more than the bean it is in the latent heat required to release the water to vapor and maybe the release of CO2. Does it give up all the water (causing ROR to drop) or does that happen gradually. Partial percentage points in bean water content seems to make a big difference. As do processes like the Swiss process.

The big question I always toyed was is can we model between BT of 185c and say 205c. If we can model it so that we always get a controllable RoR we have a winner model. I am not sure it is easy to though. As humans we look at color, rate, smell, even out-of-band parameters like source (e.g. Ethiopians usually turn dark faster). Can that be modeled?
Scraping away (slowly) at the tyranny of biases and dogma.

User avatar

#4: Post by AssafL »

I think it is also important to define expectations:
  • 1. For a roaster that does 5-10 roasts a day - having a model that adjusts for minute changes (like the heat accumulated in the metalwork) may be enough of a goal. They setup a roast right - and now want to repeat it 10 times while otherwise occupied.[/li]

    2. For a roaster that does the same coffee every week - perhaps adding an "offset" compensation (ambient temp and humidity, bean age, etc.) may be enough to compensate.

    3. For a casual roaster that roasts different batches, the model has to predict how the coffee will behave. If you also roast samples, then you get one shot at this - so the model has to deliver something equivalent (or better) than the roaster. Perhaps a roast aid (like the RoR was a roast aid)?[/li]
It would make sense to define which one of these are you aiming for.

Scraping away (slowly) at the tyranny of biases and dogma.

aabud (original poster)

#5: Post by aabud (original poster) »

I roast maybe 2 to 5 pounds per month - its a hobby. I don't really have any goals beyond having a better tool to make those roasts of mine better/more consistent.

I haven't thought much about bean modelling yet, perhaps my naivete as a roaster. My roasting for years was two pound batches on a mesh drum where the only inputs were sight, sound, and elapsed time and the only control was a gas knob. I'm really liking all the data I have know, and already the coffee from this little roaster is noticeably better than what I'm used to roasting in the big drum. Is there a practical way of measuring moisture content? Weigh a sample green, and then weigh after roasting/baking to a known temperature? I know I've dealt with moisture content in wood this way. If I start tracking moisture content of the beans I roast, maybe I'll start noticing a pattern in the roasts. How do you adjust your roast curve/plan if you know you're dealing with a high vs. low moisture content bean?

I don't have any air control on this little roaster. I have the parts in a box for a modbus controlled fan that outputs into a flex metal hose/nozzle that I can somehow incorporate in the roaster. This roaster exhausts chaff out the front drum hole, so not sure squirting air into the "air out" hole is going to have the desired effect... maybe if the nozzle was just inside the drum hole, it would inject air into the drum and increase the velocity of air exiting. Air also exhausts out the sides of the drum box. I think squirting air into the box itself wouldn't have much affect on the air in the drum... maybe just cool the drum a bit. I need to do more research on air flow and the theory behind how it impacts a roast. I imagine air might be a nice quick reaction tool to help influence temperature.

I would love to get reliable temperature readings on the drum so I don't have to estimate it. If anyone knows of an infrared probe that can stand roaster temperatures and can be had for $100 or less, please let me know.

User avatar

#6: Post by AssafL »

I tried the farmcorp humidity sensor which is basically a chamber with a spring mounted contact that you fill with beans and the spring mounted contact ensures that the pressure exerted on the beans is uniform. And it gives you a number between 10-12% water content.

It did not help a lot - albeit I wasn't trying to calibrate a model with it.

In reality, if the water vapor robs the system of heat - the temp will drop. If however the water stays (or less water evaporates) - the temp will rise. If you try to compensate for the former but use the latter beans (ie have too much energy) it will flick.

Water vapor and perhaps CO2 I'd think would be the main ways energy gets out of the system. Sure there are chemical conversions - but won't that be a more-or-less constant for the same batch size?
Scraping away (slowly) at the tyranny of biases and dogma.

aabud (original poster)

#7: Post by aabud (original poster) »

Found this at:
The internationally accepted standard method for determining moisture in coffee is the loss of weight on heating. Although the loss in weight may not be only water, in coffee the other volatiles are not significant when using the standard drying time and temperature. For this method, you should have a scale capable of accurately determining the weight of your samples to 1 part in 1000 or better. You also need a hot-box (e.g., an oven) that can maintain a temperature of 220°F (105°C) ± 5°F, with natural airflow, for 24 hours. Airflow should not be overly restricted. Airflow is needed to carry off the moisture.

A convenient sample size is 100 g initial weight. The samples are placed in the oven at 220°F for 24 hours. They are then weighed again (final weight). The difference between the initial weight and the final weight is the water, and it is also the percent moisture in the sample if you started with 100 grams. If you use a different initial weight, you will have to divide the difference in weight by the initial weight to get the percent moisture. (If 10oz, the percent is obtained by multiplying the difference by 10.)
Also in this paper, it says that that greens will stabilize to a humidity relative to their environment... the example used was, in a room where the humidity is 70%, the beans will stabilize at 12% humidity. I could see where this could make moisture content an issue for some people (in environments with high variability in humidity) and not for others (with stable humidity).