Close

Hardware in the Loop: Pressure Sensors, Flow Limits, and a Phase-Lag Mystery

A project log for oximite - rust espresso control

Help Pico W to brew a shot.

pchalapchala 04/06/2026 at 13:571 Comment

The physical plumbing is finally coming together! I received the necessary Tee-connectors and an analog manometer, which allowed me to successfully plumb the pressure transducer into the hydraulic system.

Here is what the test bench looks like right now:

With the hardware in place, it was time to validate the software.

1. Linearizing the Pump (The LUT)

Vibratory pumps are notoriously non-linear. To make the PID controller's life easier, I previously built a Look-Up Table (LUT) to map the AC phase delay to actual expected pump output. I ran a quick manual power-output sweep to verify this, and the results are excellent. The LUT successfully forces the vibratory pump to behave linearly across its pressure range!

2. Taming the Pressure (PID Control)

With the pump behaving linearly, I closed the loop. After running some experiments with the p_kp and p_ki coefficients, I successfully brought the system under control. The machine can now rapidly hit and hold a target pressure without oscillating. (Note: Ignore the temperature line in the graph below—the NTC sensor is currently disconnected while I focus on hydraulics!)

3. The "Shot Saver" (Dynamic Flow Limiting)

One of the coolest software features I’ve implemented is a dynamic flow limit. In standard espresso, if your coffee puck cracks (channeling), the physical resistance disappears, the flow rate spikes, and the shot is ruined.

I tested my safety clamp: I set a hard maximum flow limit in the active profile. As you can see in the telemetry, the exact moment the flow hits the limit, the system aggressively drops the pressure to clamp the flow rate, effectively "saving" the shot!

4. Hardware Quirks: The 3ms DAC and a Phase Mystery

While scrutinizing the high-speed telemetry on the oscilloscope, I noticed two fascinating quirks about the hardware.

First, despite the pressure transducer having an "analog" voltage output, looking closely at the signal reveals a distinct digital stepping nature. It looks exactly like an internal DAC updating its output buffer every 3ms. It is fast enough for PID loop, but an interesting reminder of how modern "analog" sensors actually work internally.

Second, I found a mystery: When plotting the pump's Triac trigger pulse against the pressure wave, I noticed that the absolute peak of the pressure wave happens right before the Triac trigger pulse fires. 

At first glance, this seems impossible—how can the peak pressure arrive before the electrical signal that turns the pump on?

I have my theories, but I want to hear from the community. Drop a comment below with your ideas on why this electromechanical phase-lag happens!

Discussions

pchala wrote 04/08/2026 at 08:09 point

The Solution: The Vibratory Pump Mystery

For everyone wondering about the oscilloscope graph, here is why the pressure peak precedes the trigger pulse. Vibratory pumps (like the Ulka EX5) move water using a spring, not just electricity. They operate in a 2-stroke cycle:

Stroke 1: Suction (Electricity ON)
When the RP2040 fires the Triac, the coil's magnetic field pulls the piston backward, compressing the spring. This creates a vacuum, sucking water into the chamber. (Note: Forward pressure drops during this phase).

Stroke 2: Discharge (Electricity OFF)
At the AC zero-cross, the Triac turns off and the magnetic field collapses. The released spring drives the piston forward into the water. This physical impact generates the pressure wave.

The Phase-Lag (The Graph Explained)
The PTFE hose leading to the sensor is elastic, acting as a hydraulic capacitor. It absorbs part of the pressure wave, delaying it.

By the time the spring fully extends and that delayed wave reaches the sensor, the AC waveform has looped. The RP2040 is already firing the next Triac pulse to pull the piston backward.

You are seeing Cycle 1's mechanical pressure peak overlapping with Cycle 2's electrical trigger pulse.

  Are you sure? yes | no