A Logging Tamper

Three years ago I built a simple “oedometer” to measure how coffee compresses under pressure, and I immediately started thinking about how to build a device that could log displacement vs. applied force while tamping an espresso puck. The project got a big boost when a friend on Home-Barista offered to send me a small arbor press to act as the base of the tamper.

Since then, the project has gone through a few iterations. In this post, I will describe the current design and how it was shaped by some of the lessons I learned along the way.

As usual, ESP32 firmware and client software have been uploaded to GitHub. Please let me know if anything is missing.

Overview

An oedometer is a laboratory instrument used in soil mechanics to measure how soil compresses under load. Usually, the sample is placed in a cylindrical container which prevents it from expanding sideways, and then a vertical load is applied. This should sound familiar—it’s basically the same process as tamping an espresso puck.

The resulting deformation is recorded, and after a little calculation, the data is usually represented as a plot that looks something like this:

The curve starts at the top left. As we apply force (effective stress) to the sample, we move toward the bottom right, with void ratio (the amount of space between particles) decreasing as more force is applied. When we release the applied force, the sample sometimes rebounds a little, and we move more toward the left, but also a little bit upward.

We can use this curve to characterize the compressibility of the sample, usually expressed as the compression index. This is the slope of the compression curve:

    \[C_c = -\frac{\Delta e}{\Delta \log \sigma'}\]

The following table gives approximate compression index ranges for a few common materials:

MaterialCompression Index
Sand (dense)0.02-0.03
Sand (loose)0.05-0.06
Clay (low plasticity)0.1-0.3
Clay (high plasticity)0.3-0.6
Peat10-15

Hardware

The quantitative tamper is really just an arbor press with a digital caliper to measure the displacement of the ram and a scale to measure the total force applied. The design is simple and compact, but does require that the measurement be made with the basket separate from the portafilter.

To achieve this, I built a simple cylindrical collar which supports the basket under the rim, and holds the bottom of the basket above the platform during the measurement.

The arbor press is a PanaVise PanaPress. To this, I’ve added a couple of small supports which connect a cheap digital caliper to the body of the press on one end and to the ram on the other end.

Digital calipers are a wonderful component for a project like this, first, because a fairly accurate caliper can be purchased for a very low price; and second, because they almost all include a digital interface, even if it’s not visible from the outside. There are a few variations on this interface, but generally it includes four wires: ground, VCC, clock, and data. The variation is usually in exactly how the data is clocked, but this is something that can be worked out in a few minutes with an oscilloscope or logic analyzer.

The caliper’s digital interface is connected to an ESP32 development board via a Schmitt trigger. This acts as a level converter and also cleans the signal up a little. I initially used a simple level converter, but this resulted in a large number of glitches in the data. Adding the Schmitt trigger resulted in glitch-free data.

I’ve borrowed the base from a Normcore tamper, which is secured to the ram with a 3D printed adapter. The two washers visible in the photo above ensure metal-to-metal contact between the base and the ram, which again simplifies calibration. The 3D printed adapter passes through the washers, and serves only to hold the ram, washers, and tamper base tightly together.

Below that, we have a simple scale constructed from a 20 kg load cell and a small piece of 3 mm aluminum plate. Small washers are used as spacers to separate the load cell from both the aluminum plate and the base of the arbor press. The scale connects to a 24-bit HX711 A/D module and then to the ESP32 development board.

Finally, a small OLED screen is used to show the current force and displacement. This allows me to stop my tamp at a predetermined tamping force.

Software

The ESP32 development board collects data from the caliper and the load cell and streams this data over a Bluetooth connection at a rate of 10 samples per second. Client software on a laptop collects this data and automatically logs each tamp to a separate file.

Calibration

For each sample, we also collect a calibration curve, measured with a 3 mm aluminum plate placed on top of the portafilter basket. This allows us to correct for the compression of the measurement apparatus itself, and also allows us to determine where the top of the basket is—something we will need to know in order to determine the volume of the tamped puck. The raw data looks like this:

The bump at the top of the sample curve is an artifact common to many of these measurements. What’s happening here is that the tamper is “sticking” momentarily on ground coffee stuck to the wall of the basket, then “slipping” when enough force is applied.

To calibrate, we fit a curve to the calibration data then subtract this curve from the sample data. The resulting plot looks like this:

Note that the rebound curve is now almost flat. There is a small downward slope initially, but this is likely due to a small amount of hysteresis in the measurement system, which we will discuss later.

Next, we want to convert the displacement measurement to depth below the rim of the portafilter basket. To facilitate this, in addition to the data from the tamper, for each shot the depth of the puck was measured using a digital caliper. Then a “best fit” offset was calculated.

By applying this equation to the displacement measurement, we get depth below the rim of the portafilter basket for each point in the sample curve.

Void ratio vs. effective stress

At this point we have a plot of depth vs. tamping force, but what we really want is a plot of void ratio vs. effective stress. Let’s start with the easy one… Effective stress is just tamping pressure, and we can calculate this from tamping force using:

    \[\text{Pressure in kPa} = \frac{\text{Force in kgf}}{\text{Area in mm}^2} \times \text{9,806.65}\]

The 20 g VST basket used for this shot has a diameter of about 58.74 mm, which gives it an area of 2,710 mm2. So our plot becomes:

Void ratio is a little harder. Void ratio is given by:

    \[\text{Void ratio} = \frac{\text{Void volume}}{\text{Solid volume}}\]

We don’t know the void volume, but we can calculate it from total volume and solid volume:

    \[\text{Void volume} = \text{Total volume} - \text{Solid volume}\]

Then void ratio becomes:

    \[\text{Void ratio} = \frac{\text{Total volume}}{\text{Solid volume}} - 1\]

We can calculate the total volume of the tamped puck from the depth below the rim of the portafilter, and we can measure the solid volume (actually the particle volume of the ground coffee) directly using a gas pycnometer. The total volume changes as we tamp the puck, but we assume the solid volume does not—the particles just get closer together.

The most accurate way to calculate the total volume of the tamped espresso puck is to start with the empty volume of the portafilter basket, which we can measure by filling it with water, then subtract the volume of the cylinder between the top of the puck and the top of the basket:

    \[\text{Total volume} = \text{Empty volume} - \text{Area} \times \text{Depth}\]

For the 20 g VST basket, the empty volume is 66,903 mm3 and the area is 2,710 mm2. Depth is just the measured depth below the rim of the portafilter basket.

For this particular shot, we measured the solid volume of the ground coffee using a gas pycnometer as 14,766 mm3.

Now that we know the total volume and the solid volume, we can calculate void ratio for each point in the sample curve. Our plot becomes:

Compression index

Finally, if we fit a line to the compression curve (avoiding the obvious artifacts at low tamping pressure), we can estimate the compression index for this coffee and grind setting:

This gives a compression index of about 0.41. Roughly speaking, this is similar to many clays; more compressible than loose sands; and less compressible than organic materials like peat. This may suggest that ground coffee has both granular and deformable organic characteristics.

The moderate compression index also indicates that the void volume of the puck, and therefore its permeability, will be significantly affected by applied pressure.

In addition, we see that ground coffee shows very little rebound after compression. This suggests that most of the compression that occurs during tamping is due to plastic deformation—e.g., particle rearrangement or fracturing—rather than elastic deformation—e.g., compression of the individual particles.

Error analysis

Tamper stick-slip

Most of these measurements show some kind of “bump” at low tamping force due to stick-slip as the tamper passes grounds stuck to the wall of the portafilter basket. The following plot gives an idea of the prevalence of this artifact:

To address this, when we calculate the compression index, we consider only those points with a tamping force greater than 2 kgf. However, we could extend this range if the stick-slip were reduced, allowing us to characterize compression a little better.

Stick-slip could likely be reduced with better alignment of the tamper and portafilter basket. At the moment, I’m just eyeballing this, but some kind of alignment feature on the weighing surface would make a big difference.

Measurement hysteresis

In the plots above, we showed only the compression portion of the calibration curve. If we look at the full calibration curve, this is what we see:

Although we are well within the elastic limits for the measurement apparatus, meaning there are no permanent deformations, we see that the curve does not follow the same path during rebound as it does during compression. It seems likely that this is due to hysteresis in the displacement measurement, as we see a short section at the bottom right where tamping force changes but displacement does not.

The issue does not seem to be related to a lag in one measurement compared to the other, as it is independent of the speed at which the tamp is performed.

I have been able to reduce this hysteresis by making the mounts holding the caliper to the arbor press more rigid, but I have not been able to eliminate it completely.

Conclusion

The accuracy of the quantitative tamper seems to be quite good. Measurements could be improved quite easily by adding an alignment feature to the weighing surface.

One thing I would like to try is to change the 20 kg load cell for a 100 kg version. This would allow us to measure the compression curve at higher tamping pressures, and to check the effect of extreme tamping pressures on coffee extraction.

It would also be interesting to measure the compression curve for wet and spent coffee pucks.

In the meantime, the current quantitative tamper has provided some really interesting results which I will be sharing in upcoming posts.

5 comments

  1. Good work. I’ve been playing with a similar setup: scissor jack, digital caliper, scale, to measure puck density.

    1. That’s awesome! I’d love to see what you’ve built, and any results you’re willing to share.

      1. I am still evaluating and tweaking the setup. I will pull together the puck density data so far and post it in another comment.

  2. this is amazing!

    I keep reading that “you can tamp as hard as you want because once the puck is compressed all the way, any extra effort has no effect”.

    Clearly, from your data, at least up to 20kgf, you get more compression the more force you apply.

    1. I think there may be a couple of phases to tamping. During the first phase, you’re sort of compressing the puck from the top down, eliminating space between the particles. Once that space is gone, pressing on the top transfers force all the way through the puck.

      I suspect we can see that transition here around 10-20 kPa, but it’s hard to say for sure because we don’t go much further than that. I’ve got a 300 kgf load cell ready to be installed on my tamper so that I can extend these tests much further, which should give us a better idea of where any transition occurs—I just need to find the time to install it. 🙂

Leave a Reply to Nils Tonning Cancel reply

Your email address will not be published. Required fields are marked *