Updated high voltage output stage for my Es(pi)resso Machine (muhahaha…)

Here are the latest plans for the high voltage side of my Es(pi)resso machine controller. Obligatory warning: working with mains voltages as shown in this circuit is potentially very dangerous – use this circuit at your own risk.

Click to embiggen (to promulgate a neologism):

gaggia_v3_draft1

This diagram is a slight refinement of the circuit currently inside my machine. Basically, I’ve added a TC426 to drive the IGBT for improved switching times (replacing the BC556 used previously), and replaced the opto-couplers with the 4 pin HCPL-817 for reduced board area and pin count. This also leaves one spare TC426 output for future expansion, which I plan to expose on a 0.1″ header. Otherwise the circuit is exactly the same as the current working version in my Gaggia Classic.

The OC1 coupler enables the Pi to detect when the pump is powered on. As soon as mains power is applied to the pump, this open-collector output goes low. This makes it easy for the software to know when a shot is being pulled, and to count shots etc.

There are two SSRs in the circuit: K4 is used to switch the boiler elements, and K3 is used to switch power to the pump. The pump can still be manually controlled with the brew switch. When the pump SSR K3 is on, this also powers up the pump modulation circuit. The PUMP_PWM input is a 3V3 logic level PWM input for the pump. This goes through opto-coupler OC2 and the TC426 via 1K gate resistor to switch the IGBT Q3. It’s arranged so that a logic high on PUMP_PWM will switch on the pump. Therefore, PUMP_OUT and PUMP_PWM together can be used to automatically power the pump on/off, and to modulate the pump pressure via PWM (I’m currently working with 1kHz PWM frequency).

Today I carried out a low voltage test of a subset of this amended design (the HCPL-817, TC426 and IGBT), and it performs well. The next stage is to test this at mains voltage with the pump, and then I’m planning to design a custom PCB to replace the current strip-board used inside the machine.

igbt_low_voltage_test

40 thoughts on “Updated high voltage output stage for my Es(pi)resso Machine (muhahaha…)”

    1. I think the ‘scope was connected to the IGBT gate when I took that photo. The IGBT switches a little slower, but still quite respectable. It may be at the limit of measurement for the little DSO Nano, but I’ll see if I can get a decent trace from the IGBT collector on my bigger ‘scope.

    1. Hi Philippe

      Yes, certainly: D7 is to avoid the risk of Q3 being damaged by current flowing in reverse through Q3 and D6 on the negative AC cycle. This is because we’ve added the snubber diode D6 (which would create a reverse path for the AC through Q3). On the positive half of the AC waveform, current flows from LIVE through PUMP1 then D7 then Q3 back to NEUTRAL. On the negative half of the AC waveform, current is blocked by D7. Without it, current could flow from NEUTRAL through Q3 and D6 back to LIVE. I guess Q3 would explode and release the magic smoke (I once destroyed an SSR in a similar way).

      Hope this helps? Happy to discuss further, and help if I can. I’m still looking to improve the snubber circuit to improve the solenoid switching times (currently this is a simple diode D6).

      Best regards
      James

      1. Your detailed response is much appreciated 🙂 It contributes to my learning experience.

        I’ve used your work (electronics and code) as my template up to this point I got:
        – flow-meter
        – PID temperature control
        – brew control via SSR

        I’ve run successful test circuits (breadboard) of your IGBT based pressure control, which I will solder together into my board as a next step. I’m still waiting on some cheap Ebay datasheet-less Chinese analog pressure sensors to arrive, so I’ll do the pressure profiling before I get the pressure meter in.

        I’m honestly a bit worried about the AC/DC interface on your IGBT circuit, and I am not quite sure I understand what the implications are of having AC N and DC GND connected together, but hey…

        As an additional note, I’m using an MBED LPC1768. It has a slightly easier to use web-based IDE and has analog inputs with internal pullup/pulldown resistors and hw based PWM, so makes for less circuitry. As an example, I was able to connect the flow meter directly into a digital input pin with a pullup and it worked fine.

        1. Great! It sounds like you’ve made really good progress so far. I would be interested to know how the pressure sensor performs.

          The LPC1768 sounds a good choice. I’ve used the LPC2378 for another project (albeit with raw C rather than MBED) and those are really nice, very capable chips with tons of peripherals and I/O.

          With the IGBT circuit, note that the DC GND is completely isolated from the CPU (and more importantly, from you!) by the opto-isolators. If you look at the diagram, note that there is no GND connection between the IGBT circuit and the CPU side (very important). The DC supply 5V_RN from RG1 is only used to drive the opto-isolator LEDs, IC1 and Q3. You could equally use a capacitive dropper or similar to replace RG1.

      2. About your snubber circuit, my plan was to add a resistor in series to D6, which should in theory “snub” the current faster (unless the properties of the pump make it so that the loop is only really being run through once).

        1. I’ve also experimented with a resistor in series with D6 (around 200R). This works (better in fact), although be aware that the resistor will dissipate a lot of heat (you need a high power wire wound resistor) and the IGBT will also run hotter.

          1. Yes I was thinking of a low resistance/ high power resistor, but didn’t consider the fact that this would increase the voltage at the IGBT. It bothers my OCD a bit even though it’s inconsequential specially considering how much heat is generated by the boiler and the fact that the pump only runs for short amounts of time… Nonetheless I’ll do a bit of research on stubbers and see what comes up.

          2. My initial research seems to be pointing to either TVS diodes [1] or reverse-biased rectifier diode in series with a Zener diode as good options as well. I think all options will cause heat dissipation at the snubber, I will look for the ones that are fast and cause the least strain on the IGBT. I might even try several options and compare for fun.

            https://en.wikipedia.org/wiki/Transient-voltage-suppression_diode

          3. I’ve done a little experimentation with TVS diodes, series resistors etc. but need to do further research & testing to find an optimal solution.
            What I found was that with a single diode, the pump solenoid is slow to switch off, which effectively reduces the power because the pump isn’t oscillating effectively. If you add a series resistor, Zener or TVS diode, that helps a lot because there’s a larger voltage drop so the solenoid current decays more quickly. However, the catch is that this results in a higher voltage at the IGBT also, so you must be careful not to exceed the maximum ratings of the IGBT.
            I have a spare pump now, so I might do some more experimentation myself (without disrupting my morning Espresso routine, ha ha!)

          4. Thanks Philippe
            Coincidentally, I read the same forum posts (that’s probably the best practical discussion of solenoid snubbers I’ve seen). Well this weekend it looks like I might finally have a little free time to experiment, so perhaps we could continue the discussion by e-mail and share our results? I’ll drop you an e-mail so you have my direct contact.
            Kind regards
            James

  1. Hi, I noticed your heating elements are in series instead of parallel. This reduces your power by a factor of 4. Why did you choose to do this? The original parallel configuration is very optimal for putting as much wall power into the boiler as is possible. Do you have different heating elements than the original 22.4 ohm parts?

    1. Hi Tyler
      As standard, the elements are normally wired in series for 240V mains (UK, Europe etc) and wired in parallel for 120V mains (US etc). This part is the same as stock factory wiring, and I assume is a simple cost saving trick for the manufacturer (i.e. so they can use the same boiler worldwide, with different wiring).
      For 240V we have I=240/(2*22.4)=5.36A therefore P=240*5.36=1.29kW approx.
      For 120V we have I=120/(22.4/2)=10.71A therefore P=120*10.71=1.29kW approx.
      Comparing 120V to 240V, at 120V there is half the voltage, double the current, but the same power of about 1.3kW.
      Now we could obviously wire them in parallel on 240V and get 2.6kW, but that’s more than the original rated power as it came from the factory. It would probably be OK for short duty cycles though.
      James

  2. James,

    I finally got some time to play around with my project – I’ve soldered together an IGBT based AC chopper as per your design. It worked fine when testing it on my workbench with low voltages (power supply, oscilloscopes, a sinusoidal function generator and a pwm function generator). But when I plugged everything into my machine, it seems like the IGBT wasn’t switching anymore when in a high voltage environment. I’ve done some measures on the DC/low voltage side of things and everything looks good, but my multimeter is clearly showing an off IGBT at all times no mater what goes into it.

    Any idea where to start debugging this issue? My circuit can be found here: https://imagebin.ca/v/3hDkdIQsYE8n

    1. Hi Philippe
      What you have looks reasonable to me at first glance. What type of IGBT and gate driver are you using? The first things I would check are the obvious (which I’m sure you have already): power supply, input to gate driver, output of gate driver.
      I assume you’ve already tried simple and slow on/off switching with the IGBT (i.e. get that working first, before graduating to PWM).
      Regards
      James

  3. James,

    My IGBT is this one:

    https://www.digikey.ca/product-detail/en/infineon-technologies/IRGB14C40LPBF/IRGB14C40LPBF-ND/812232

    So I’ve tested the power supply by simply replacing it with my workbench power supply, no change

    I’ve checked both input and outputs of gate drivers and they seem to be doing the right thing.

    The only caveat is that while trying to measure the DC side of the circuit, there seems to be a baseline, 60hz sinusoidal distortion of all my signals (so my output signal from the power supply for example is not straight 5V). I am assuming this is simply due to the AC GND. I will replug things and get some screenshots.

    As for simple on/off switching, I tried with 100% PWM so basically a DC going in, but no cigar.

    1. Well, it looks like you are using the same IGBT as me, and in a very similar setup. Strange!
      It’s difficult to take measurements with a ‘scope in situ, because the scope will be grounded to earth, so you will see 60Hz AC superimposed on everything. I used a battery powered ‘scope to avoid this.
      At the moment I don’t have any immediate ideas of what the problem might be, but I’ll give it some more thought.

        1. In case anyone is following this thread – my circuit works and the problem ended getting solved by reversing the connectors on the pump (the internal pump diode was in the wrong direction!).

  4. Can you share your Eagle file/schematic for this project? Also would it be possible to use the extra opto-coupler (OC3) and the extra TC426 (IC1G$2) to control the heater? I had issues with controlling my SSR-40A relay with my 3.3V arduino and thought I may have to use a 5V to get it to work but his seems like a better option as I am not a big fan of the 5V arduinos.

    Last question, is it possible to also power an arduino with AC/DC converter and not have have a shared ground with main?

    Thank!

    1. Hi William
      Yes, I can certainly share the Eagle schematics (bear with me, and I’ll look them out and e-mail you).
      I’m surprised the Arduino 3.3V output can’t drive the SSR directly. You could add a transistor as a level converter to drive the SSR.
      It would be possible to use the spare optocoupler to drive the SSR, but I think the transistor would be a better option. The shared ground with mains is unfortunately necessary for the TC426 to drive the IGBT. Because the ground of that circuit is referenced to mains Neutral, it’s not safe to use the AC/DC converter to power any circuitry that you are likely to touch. It’s designed to be a self contained module, connected to the microcontroller only via the opto isolators. I would recommend using a separate 5V or 3.3V power supply for your Arduino, as it’s much safer, and they are so cheap these days anyway 🙂
      James

  5. I am experimenting with this by building the following approaches and testing them:
    1- IGBT with high frequency PWM
    2- IGBT with phase control (zero cross detector circuit + micro-controller phase control)
    3- random-fire SSR (zero-cross detector circuit + micro-controller phase control). This requires the least circuitry.

    I’ve finished 2 and will soon be finishing 1 and 3.

    Here are some quick/initial results:

    https://imgur.com/a/z9Ji9

    As you can see, I am able to get very precise pump control using a phase control circuit and the following equation to calculate the required phase delay for linear control:
    1000000 usec / 120 * (acos(2*x/100 – 1) / pi)

    The IGBT/flyback resistor still get hot but significantly less than I get on solution 1 since I am only having a sudden voltage change at the pump once per cycle. I am able to use a normal resistor instead of a high power wire-bound resistor (as long as I don’t run the pump for too long! so this should still be built with a high power resistor).

    I will post more details and code when I get some time to compare the 3 approaches.

  6. Hi Philippe,
    I’m not sure how do you made your measurements – with IGBT or triac in phase mode? With or without flyback circuit?
    With triac and without flyback diode I got some flow instabilities by lowest values – pump starts to work at about 30% of setting – then it’s possible to go down to about 20%. If I start from 20% pump doesn’t flow the water.
    Another point is that what we adjust is flow – pressure (on blind portafilter basket) goes almost immediatelly to 16 bar.

      1. Hi Philippe,
        thanks for your link. It’s very interesting. The problem I mantioned is not that below 30% pump doesn’t work. The problem is a hysteresis I have observed – if you go from the bottom side pumps starts abruptly to work at 30%, at 25% only humms. After the pump starts to work I can go down to 25% and everything is OK.

    1. Sounds curious as I’m using very similar to yours triac SSR solution (MOC3023 optotriac and BT 131-600 triac instead of AQH3223 1,2A optotriac) and Arduino controlled phase control – and in this configuration I notice hysteresis.

  7. MOC3023 is random fire as well. I do not have the diagram but if you want I can draw and post it. It’s same like AQH3223 but made with discrete parts.
    In the meantime I realised that both Tom and me we use 230V 50Hz and you use 127V 60Hz.

        1. Hello Piotr & Philippe
          Excuse my radio silence, I’ve been really busy with work – but I enjoyed reading these as a spectator 😉
          Regards
          James

Leave a Reply

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