Ulka EP5 Pump PWM Pressure Modulation

Recently I’ve been experimenting with using PWM to control the pump pressure in my Gaggia Classic. People have used various methods to control the pump pressure, ranging from triac/thyristor dimmers to using series resistance. A few have used PWM (notably Jonr on CG forums), and this looked by far the best solution, so I decided to use high frequency PWM with an IGBT. This would need to be opto-isolated so it could be driven safely from the Raspberry Pi.

I started off looking at the HCPL-3120 optocoupler with gate drive outputs. There are hundreds of suitable IGBTs. However, as I started sketching out the design, including 15V supply etc. it seemed a lot of components were needed for this solution. Instead, I decided to look at using an IGBT with logic level gate drive to simplify the design, preferably one with a TO-220 package. It turns out that there are very few which meet those requirements, so I’ll list them here in case it helps someone else:

  • IRGB14C40LPBF (430V / 20A) from IRF
  • ISL9V3040P3 (21A) and ISL9V5036P3_F085 (46A) from Fairchild
  • STGP18N40LZ (30A) from ST

From that list, the only one I could find at reasonable cost without importing was the IRGB14C40LPBF, so I settled with that one.

To safely interface with the Raspberry Pi, I use a 4N25 opto-isolator with a 270R series resistor, which is driven directly from a 3V3 GPIO pin (tested at a little under 8mA). Note that the series resistor would need to be increased for 5V input.

The NPN output of the opto-isolator is inverted by a BC556 PNP transistor to switch the IGBT input through a 1K series resistor.

The power supply is the VTX-214-003-105. This is a compact module which provides 5V at 600mA from 90V-240V AC mains input. Caution: in this circuit, note that the DC output GND is connected directly to mains NEUTRAL, meaning that the 5V and GND lines in this circuit are not isolated from the mains. This means that they should be insulated and boxed up.

On the output side, the IGBT is wired in series with the pump. There’s a series diode to prevent AC passing, and a flyback diode in parallel with the pump for protection.

Here’s the current circuit diagram for this design (to be used strictly at your own risk):

EP5 Pump PWM with IGBT

To test it, I built a small prototype on strip-board. Note that the IGBT is separate, as I plan to mount the board inside an enclosure, and mount the IGBT externally. Ultimately I would like to make a custom PCB for this. After extended testing, the IGBT is absolutely stone cold so the heat-sink appears redundant.

Pump PWM Prototype

Since I’m using the Raspberry Pi’s one and only hardware PWM pin to drive the boiler, I used the excellent ServoBlaster which provides high resolution software PWM on any GPIO pin. Initially I set this up for 1kHz PWM, and varied the duty from 0% to 100%. For example, to set up 1kHz PWM on GPIO pin P1-22 and using the PCM hardware, you would use:

sudo ./servod --pcm --cycle-time=1000 --min=0% --max=100% --p1pins="22"

To set up 50% duty cycle on that pin, you would use:

echo P1-22=50% > /dev/servoblaster

Before testing this with the pump, I tested with a 60W incandescent light bulb and series diode. Adjusting the duty cycle allowed the lamp to be smoothly and precisely dimmed. The average voltage drop across the IGBT was around 0.33V and (after fully disconnecting mains power) it was cold to the touch.

I then moved onto testing this with the EP5 pump. For easier testing, the machine was temporarily rewired so that the brew switch supplied power to the entire circuit above, so that I could kill power if needed, without relying on the IGBT alone.

Using a Portafilter pressure gauge, the pump was tested at various duty cycles from 0% to 100%. I found that the pump only seems to start operating at about 30%, and then pressure rises to about 1 bar. Increasing the duty cycle allows the pressure to be controlled quite easily between 1 to 9 bar (or wherever your OPV is set).

So far I’m really pleased with performance. The next step is to box it up and wire it in more permanently. I’m also thinking of adding a small SSR to switch the solenoid. Once I’ve done some further testing, I’ll upload graphs of duty cycle versus pressure.

Update: check out the slightly amended design here which replaces the BC556 with the TC426 driver.

30 thoughts on “Ulka EP5 Pump PWM Pressure Modulation”

    1. Yes, although the circuit on the web-site is tested and working in my machine, I’m thinking of some small improvements. Specifically, I put a ‘scope on the output of Q1 (BC556) and noticed that although it switches the IGBT on very quickly, the gate voltage is a little slow to decay. That said, it works fine as is (can regulate pressure betweeen 1 to 9 bar reliably). Nevertheless, to improve this further, I’m planning to replace Q1 with a TC426CPA for faster switching. Also thinking to replace the 4N25 opto-couplers with the 4 pin type HCPL-817 which take up less board area and remove the external 470K resistor. Having tested that in prototype, I’m considering getting a custom PCB made to clean it up.

      I’ve actually bought the components to do this, but haven’t had time yet. Perhaps at the weekend!

      1. Thanks! Thats good to know. Im just putting together my BOM now, but ill let you know when I build and test. If you want to split the cost of the custom pcb I could be interested.

        This is a long shot, but did you have a chance to test the AC pump side of the IGBT? My scope wont be able to do this, but Im wondering what the waveform looks like, and if we are doing any damage because of the pumps large inductive load. Seems like the 1khz and the inductive load would sort themselves out though.

        1. I didn’t put a ‘scope on the AC side yet, as I was uneasy about damaging the ‘scope (or myself!) That said, I’m also curious, and might try… will certainly update the blog with images if I do 😉

          I’ll also post any progress on the PCB layout.

  1. Hi James,
    Excuse my ignorance, but why can’t you control the ulka pump with a simple SSR relay?

    Best regards
    Jacques

  2. Hi Jacques
    Well, it’s a good question (one more deserving of a long blog post than a brief answer here!) The short answer is that you could control it with an SSR, but there are some issues. Most SSRs are zero-crossing, so they will only switch complete mains cycles. There are so called “random turn on” or “random fire” SSRs, which turn on immediately and can therefore be switched on for part of a cycle. Basically, control with a random turn on SSR would be similar to using a dimmer switch to control the pump. You would be able to modulate the pump to an extent, but not with the same type of proportional control you can get by using PWM at a higher frequency.
    Now, it’s debatable whether that matters in practice. I think you probably could get sufficiently good control with an SSR and simply control the SSR based on the output of a pressure sensor exceeding some threshold pressure level, and it’s certainly much simpler to implement. However, I decided to try the IGBT route as I felt it would be the “optimal” solution to allow full proportional modulation of the pump. It may be overkill of course!
    I might expand on this further with a better explanation in a blog post at some point.
    Best regards
    James

  3. I see, many thanks for your explanation!
    For the time being I will see what i can do with a simple SSR as i don’t have as much ease with electronics as you do 🙂
    Ill let you know

    Best regards
    Jacques

    1. Hi Jacques,

      I thought this may be helpful to you. This page has instructions to PWM your pump using a standard zero crossing SSR: http://www.pidgene.eu/surfing.html

      I’ve tried it and while it does appear to work, I didn’t really feel like it was an ideal solution, since the pump will still be delivering full pressure, just in shorter bursts. However, it may be worth a try for you since it is much easier to implement.

      Good luck with your project!

    1. Hi Khalid
      Unfortunately, I don’t think the instructables link above would be suitable for driving an inductive load like the Ulka pump. If you are looking for a simpler alternative to my approach, you could try with an SSR – this obviously wouldn’t allow fine grained PWM control, but may be good enough, and obviously much simpler to implement.
      I’ll drop you an e-mail in case you want to discuss further.
      Kind regards
      James

  4. Hi James – maybe a stupid question, but what was the intended purpose for having this level of control over the pump?
    Do you use it for pre-infusion or simply to maintain the pressure better?
    Have you logged the pressure in the line during a shot from your pressure sensor? Was that not consistent enough?

    1. As well as pre-infusion, I was interested in experimenting with pressure profiling during a shot. That said, I haven’t done much work in that direction lately. I’ve done the “hard part” with the hardware and got that working, but the relatively easy part with the software is yet to be written!

  5. Hi James, been researching how to make my Gaggia Classic Pro since I purchased it. I was just curious if you had updated this at all or had gained anymore ground. I was hoping to use an Arduino microcontroller to adjust pump pressure and control the boiler temperature like a PID controller. Currently have some PT100 M4s on the way to replace the temperature sensor. Would like to be able to display the current pressure and possibly have a scale built into the tray with the measurement and time. Of course I’ve never messed with Arduino, just dabbled in Raspberry Pi.

    I’m not sure if you’ve seen this article but someone claims they were able to get much more stable temperatures with the Arduino PID setup. http://tomblog.firstsolo.net/index.php/solved-temperature-control/
    Not sure if this code could be used as he has a Gaggia Baby Class which has a different set of controls on the front. Thank you again for all of your time and work that you’ve put into this and actually sharing.

    1. Hi Chris
      The Arduino is definitely suitable, and also has some advantages compared to the Raspberry Pi (for this application) such as:
      * Already has ADC inputs
      * Instant start up (no need to boot Linux)
      * No need to apply OS updates
      * No riak of SD card corruption if power is interrupted

      Of course, the Pi has some advantages, such as being able to log in remotely over WiFi, to save logs and share them via Samba.

      Have you considered using the new Raspberry Pi Pico? I would choose that over Arduino for new projects.

      You will get much more stable temperatures using PID. His code or mine could be adapted to either platform. There should be no real difference with The Baby, the principles are the same (but if you need help, drop me a line).

      Kind regards
      James

  6. Hi James, been researching how to make my Gaggia Classic Pro since I purchased it. I was just curious if you had updated this at all or had gained anymore ground. I was hoping to use an Arduino or Raspberry pie microcontroller to adjust pump pressure and control the boiler temperature like a PID controller. Currently have some PT100 M4s on the way to replace the temperature sensor. Would like to be able to display the current pressure and possibly have a scale built into the tray with the measurement and time. Of course I’ve never messed with Arduino, just dabbled in Raspberry Pi.

    I’m not sure if you’ve seen this article but someone claims they were able to get much more stable temperatures with the Arduino PID setup. http://tomblog.firstsolo.net/index.php/solved-temperature-control/
    Not sure if this code could be used as he has a Gaggia Baby Class which has a different set of controls on the front. Thank you again for all of your time and work that you’ve put into this and actually sharing.

  7. Sorry about the double post, I didn’t see it load the first time.

    No, I wasn’t aware Raspberry had released a micro-controller. I think I may order a couple of them and try to start playing. I know absolutely nothing about Python but I could learn it and think that it could make for an interesting project.

    I’ll flip back through the pages, did you share your code on the blog? I know I seen one users video with a Gaggia Classic that had the machine wired so that it would operate with wifi and with the control buttons on the front of the unit. I’m guessing in that state it is bypassing the main switch on the wifi with a relay? Let me know your thoughts.

    Chris

    1. Hi Chris
      Excuse the delayed reply, things have been a bit hectic at work.
      Yes, the source code is linked (somewhere) here on the blog, but here’s a direct link to save you searching:
      https://github.com/jam3sward/espiresso
      Re: Python, it’s very easy to learn (although I do most of my development in C++, I’ve dabbled with Python also). You can use C or Python for the Pico, whichever you prefer.
      On my machine, I don’t operate the machine over the WiFi (although the hardware would be capable of doing that: it can turn the boiler and pump on under software control using Solid State Relays, I have no reason to need that functionality so haven’t implemented it). On my setup, I use the WiFi only to do OS updates, and it also shares its logs (temperature, pressure, flow, time etc in CSV format) over Samba, so I can view them in Excel.
      If you wanted to remote control it over WiFi it would be pretty easy: e.g. create a simple web-server, and use buttons in a web page to operate the machine.
      Please feel free to drop me a line if you have any questions!
      James

      1. ‏Hi James,
        I’m trying to comment on your updated design here because it does not let me do that on the other page.

        ‏Your project is inspiring.
        ‏I am trying it myself now with just the pump modulation section for now but there a few missing pieces.

        ‏Could you elaborate on what are the 0.1uF and 100Ohm capacitor and resistor in parallels to the pump?
        ‏They weren’t there on your first design and they aren’t marked with a number so I’m not sure if it’s something original from the Gaggia.

        ‏I did try to build a the circuit and power it with 220v without load, and the D6 Diode busted. So I was wondering if it had something to do with the pump missing.

        ‏Also, I’d be really happy if you could contact me via email for a bit of help with electrical debugging 🙂

        1. Hi Jonathan
          Sorry for the delay in approving your comment on here. I’ve just installed a new version of MS Outlook, and it was sending all my WordPress e-mails direct to the junk mail folder, so I didn’t see this…
          In brief:
          * D6 is there to suppress the back-EMF spike when the solenoid is switched off. However, I wonder if you also had D7 installed as that is essential to prevent current flowing back through D6 and destroying it (which may be what happened…)
          * The 0.1uF and 100R in the dotted box is a “contact suppressor” which helps to suppress high-voltage back-EMF spikes when the solenoid is switched off
          We could discuss further by e-mail if you like, I’ll drop you a line later this evening.

  8. Hi James,

    I am working too in the same project. I am considering use phase control with a triac and a snubber. Do u think u can have better control with pwm method? I am also concerned about damaging the pump, do u think pwm is safer than phase control? Thanks

    1. Hi Rod
      I think your solution with a triac would be fine. Having experimented with higher frequency PWM, I’m not sure the added complexity is justified, so a simpler phase control approach is arguably a better approach.
      I wouldn’t worry about damage to the pump, you should be fine.
      Kind regards
      James

      1. Thanks for your kind reply.

        Another consideration that pushed me in favor of phase control is the availability of premade board ready to use. I couldn’t found an arduino-ready-like board with an IGBT or MOSFET able to drive 220V. SSR cannot be switched that fast.

        I am using the RobotDyn AC Dimmer, which already have an arduino library RBDDimmer.h. I plan to implement a PID to drive the dimmer, based on pressure readings at the pump outlet.

        My temp PID is already implemented and working fine.

        1. Sounds like a good plan. I hadn’t seen the RobotDyn board before, but it looks very suitable. I see that it even has a zero-crossing output which can be used to trigger an interrupt on the Arduino – a very neat board (and it looks reasonably priced too!)

    1. My IGBT is on the Neutral side of the pump (the IGBT gate driver is similarly referenced to Neutral). I wanted to retain the manual brew switch, so the Live supply to pump is still interrupted by the brew switch. I have an S202S02 SSR connected in parallel with the brew switch, so the pump can be switched on/off by the SSR or brew switch, and modulated by the IGBT.

      For the RobotDyn Dimmer board, it appears that pin 2 of J1 is directly connected to pin 1 of J2, and I would think those should probably be neutral, with the remaining pins used for the live input and live output to the load. Assuming you want to also retain the manual brew switch, I would think you want the switched live from the brew switch to go to pin 1 of J1, and the live output from pin 2 of J2 would go to the pump, and the common pins (pin 2 of J1 and pin 1 of J2) would go to neutral (as does the other pump terminal).
      Not sure if that explanation makes sense – a diagram would probably be clearer.
      There’s a schematic for the RobotDyn board here:
      https://robotdyn.com/pub/media/0G-00005677==Mod-Dimmer-5A-1L/DOCS/Schematic==0G-00005677==Mod-Dimmer-5A-1L.pdf

Leave a Reply

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