PID Controller rev 2

I have begun work on a new PID controller board. I’ll be documenting it here in due course.

Here are some of the improvements:

  • Much better provision for heatsinking the TRIACs. With an option to use water cooling – not sure I’ll need it, but it will definitely mean no more TRIAC overheating ever.
  • Potential to use thermocouple temperature probes. (This mainly means a negative voltage rail so the thermocouple can be in electrical contact with the boiler shell which is at GND.)
  • Water level probe.
  • Support for Gaggia Baby Twin steam boiler. (Extra temperature input and drive TRIAC).
  • Louder piezo buzzer.
  • 5V and GND exposed via pins for add-ons.
  • TWI interface available. (Rather than using the pins for something else as I did previously!). This allows communication with add-ons and (yay!) also with the Baby Twin front panel.
  • Power doubling is now done on-board so no external diodes needed. (This is why there are now five TRIACs, one for the steam boiler, one for each element of the main boiler and one for each of the pump and solenoid.)
  • Better solution for mounting the board in the coffee machine.

The schematic looks like this at present (any comments welcome): coffeepidshield.pdf

Here’s a picture of the top of the PCB layout:

The board is sized to fit where the Gaggia Baby Twin’s PCB mounting bracket lives along the left hand side of the top boiler housing. Here’s an old bit of PCB giving an idea of the location (the PCB on the picture is the correct width but slightly less tall than the real one will be):

The mounting posts for the Twin PCB bracket help to locate it and I also plan to bolt it to that nice bit of clear base plate with the heatsink. (Note: those mounting posts break off really easily and are best not to be trusted!) Obviously, there will need to be some kind of plastic backing plate to this board to insulate the exposed mains voltage solder pads.

On the bottom right of the PCB layout, you can see the outline of the copper plate I intend to bolt over the TRIACs and bend 90° so it stands flat and doubles as a mounting bracket for the whole board. You can also see the square outline of a 40mm x 40mm water-cooled heatsink. If necessary, this will be cooled by water as it flows from the reservoir to the pump. Here’s a picture of the heatsink and the as-yet-unworked copper sheet (still in plastic film):

So I mostly have the stuff together. Just want to be really really sure I have thought of everything before getting the board printed.

9 thoughts on “PID Controller rev 2

  1. Hi Tom, not sure if this site is still updated as I can’t see any dates… I have an old Gaggia Baby Dosata with what I think is a dead controller after replacing the therma fuse. I’m not facing forking out for a new controller at around £90 and wondered if this PID controller would replace the factory one. On my machine there are a few buttons on the front for measured single / double shots, to pump water etc and I wondered how these would integrate. Any info greatly appreciated… I miss my Baby.

    • Yes, I’m still actively updating the site. Just not all that frequently. I have built a 3D printer and that’s taking a lot of my attention at present. Must write about it at some point.

      Looking at the parts diagram for the Dosata, I see the internals are all common with the other Gaggia Baby machines and either of my rev1 or rev2 boards would drive it. (And also give you the freedom to improve the algorithms!) A key question is what the communications protocol is between the front panel and the controller board. My guess is it’s just a bunch of wires to the switches/lights. But it could be (as with the Twin) a logical protocol – see my notes on the Twin’s protocol. If it is a logical protocol, you’ll need my rev2 board to be able to interface with the front panel.

      I have actually completed the design of the rev2 board and had a bunch printed but I haven’t populated one yet and started testing it. I’m pretty confident about everything except the zero-crossover logic. I modified the latter after the FET burnt and haven’t yet ordered a new FET to test the new design (which is in the boards I printed). Pretty sure it will be okay, though. (Again, my attention has been diverted by the 3D printer!)

      Would you like a rev2 board to populate and try out? I’ll e-mail you to get your address.

  2. Hello Tom,
    Nice work you have there. Currently, I’m building a Pressure profiling and flow profiling for my gaggia baby, For my circuit, I’m using MOC3041 optocoupler and BT136 triac that switch the Ulka 240V pump. I’m sending the 5V PWM signal to the moc3041 from arduino. I saw your circuit that you used MOC3020 that is non-zero crossing optocoupler. I’m thorn between MOC3021 and MOC3041 for driving the bt136. I know that MOC3021 is a phase angle control optocoupler and MOC3041 just on and off the pump(still full pressure but burst).

    Thanks,
    Joseph

    • I suggest the MOC3021 for the simple reason that you probably need to be tracking zero-crossing yourself anyway. So you do not need the MOC3041 to pick the turn-on time for you. And it gives you more flexibility about what method of control to use. (Although see my caveat at the end.)

      To recap what you probably already know, I am aware of two main control methods people use:

      1. I believe some people use a high frequency PWM signal that chops the mains AC into small pulses. I suspect Gaggia do it this way with the Baby Twin (just from inspecting the controller board.) That would need something like a MOSFET or IGBT instead of TRIAC and opto-coupler. I have never looked into it because I think the electromagnetic noise generated must be rather bad. Also, I don’t like the idea that the only thing separating my logic level board (and its Arduino USB port) from mains is a MOSFET/IGBT gate insulator.

      2. Others (like me) use phase angle control to decrease the total energy transmitted in each mains pulse. Still noisy but only at 50Hz and the noise only happens at switch-on so the inherit inductances in all the wiring reduce the rate of change of current. (Switch off of a TRIAC happens at zero-crossing anyway.) For this, you need a non-zero-crossing optocoupler as you observe.

      In addition, another option that I’d quite like to experiment with is what I do actually do with the boiler elements. That is to send entire 10ms mains pulses but not to send all of them. It works wonderfully with the boiler, is nicely linear and pretty much infinitely variable. I keep wondering whether it would work with the pump. If I did it this way, an MOC3041 would be suitable. Having said that, an MOC3021 would work just as well as long as I only pulse it at zero-crossover.

      Which brings me back top my main point. You need to the mains frequency. It is close to 50Hz but not exactly 50Hz and it’s always changing as the power grid manages load. So you have to measure it real time. If you’re measuring the frequency, you might as well track the zero-crossover as well. And then it doesn’t really matter which optocoupler you pick.

      Unless you are planning on really low frequency PWM (much lower than 50Hz). That’s a really simple solution and the MOC3041 would save you tracking zero-crossover. I’d be interested to know whether that works.

      Do you have any of these or, perhaps, some other control method in mind?

      PS the pump has an internal diode and only ever conducts on alternating mains cycles. Something to watch out for if you end up giving it power on the “wrong” cycles.

      • Thanks for the quick reply tom.,
        Actually, what I’m doing now is sending PWM pulse with lower frequency, around 30Hz to 40Hz. I also tried pulsing it with 5Hz. I’m using arduino timer interrupts timer 1 to send pwm pulse on moc3041. One problem I encounter is the Triac, doesn’t off. Pump still run on negative cycle but on much lower power. I have a 330ohms resistor between gate and MT1 of the BT136 Triac. If I put a snubber circuit of 0.01uf capacitor and a resistor the pump doesn’t turn on.

      • Also, What do you mean “send entire 10ms mains pulses but not to send all of them” Can you discuss further more about this. I think this is what I’m doing now. I used Timer 1 of arduino uno to send pwm pulses.

        • With around 35Hz I would expect the circuit mostly not to work because the frequency is too close to 50Hz. The PWM output will be going in and out of phase with mains 50Hz. A lot of the time the waves will be sufficiently in phase for the PWM high pulse to miss the zero-crossover, especially if the PWM duty cycle is low. 5Hz should be much better as every PWM cycle then covers about 10 mains cycles and you should see between 0 and 10 mains cycles powering the pump each PWM cycle.

          That’s what I would guess anyway.

          What PWM duty cycle values have you tested?

          It may well be that the BT136 needs a snubber circuit because the pump is very much an inductive load. I use snubberless TRIACs which work very nicely without a snubber.

          What is your 330ohm resistor for?

          What do you mean by “negative cycle”? Is that PWM cycle or mains cycle?

          My 10ms comment was cryptic, sorry. I meant that each mains half-cycle lasts 10ms. Phase angle control switches on a certain fraction of every one of these 10ms half-cycles. An alternative is simply to turn on some of the half-cycles for the entire 10ms length of the half-cycle. This is what you are doing, but I suspect you’re being a bit hit and miss about which 10ms half-cycles are getting turned on.

          Also, do you have an oscilloscope? It helps a huge amount to be able to see what is happening. But major warning: the scope’s ground line will be connected to mains Earth. This makes it tricky to use a scope to view mains waveforms. Not to mention that it can be dangerous to attach probes to mains voltage.

          • Tom,

            330ohm is connected between gate and MT1. It is as per datasheet of moc3041. I think this is to prevent the gate to be in floating state. But im not sure also. For the “negative cycle” i said earlier, sorry for the confusion. What im talking about here is that the Bt136 triac doesn’t turn off once the gate is powered on. I tried to put RC Snubber between mt1 and mt2 pin but the pump doesn’t run with snubber.

            Also. Do you have circuit for zero crossing detection? I have here HCPL 817 and PC817 optocouplers. I just don’t know which one is better and the values i need for the resistors.

            What I have here is only handheld 1 channel osscilloscope(DSO138)

Leave a Reply

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