Sunday, November 8, 2015

Saeco Aroma PID Makeover 2.0

It has been a while since I put PID control on my original Saeco Aroma espresso machine and it has been in dependable service ever since, but I have always had a nagging dislike for the way it had mains voltages sitting out in the relative open (behind the display) above the water tank. There were also a few things that I would have done differently in retrospect given further thought and my recent experience adding PID control to my Rancilio Silvia, so with that project still fresh in mind I decided the time was ripe to re-visit the Saeco Aroma.

Here are the improvements that I set out to make over my first version:

  • Improve the temperature resolution: I wasn't using the full scale range of the ADC on the first version since I was using the default 5V analog reference and the temperature sensor output only spanned about 2.5V. This time I used the same dedicated 2.5V LDO for the analog reference that I used on the Silvia conversion.
  • Take control of the pump: I liked having the shot timer on the Silvia, and the ability to lock out the pump when the water level is low (as detected by the float switch, see next item).
  • Add a float switch: To enable the pump lock-out this was needed, and it is also just convenient even though the Saeco is better than the Rancilio in that it has a clear water tank with the level visible from the side through a cutout in the stainless steel body.
  • Install the electronics internal to the housing: No more mains voltages out in the open!
  • Have the control board mounted directly on the display: In my previous version I used a long-ish ribbon cable to connect these, and the E-M pulses from shutting the vibration motor on and off would sometimes couple into these lines and put the display in an unintended state (showing jibberish on the screen). It was easily fixed with a reset, but not ideal behavior. I wanted to keep the lines between the control board and the display short enough that this would not be an issue.
  • Replace the incandescent button backlights with LEDs: the light output of the original button lights was really weak, and by replacing them with LEDs I could both make them brighter and take control of them to make them part of the user interface (for visual feedback on what mode it is in and what the boiler is doing).
And here are a couple of improvements that I made over the Silvia project that I had just done:
  • Use quick connect tabs instead of high voltage connectors: these little tabs are way cheaper than the plastic connectors that I used in the Silvia project, take up way less PCB real estate, and are consistent with the wiring on the rest of the machine.
  • Use a mechanical relay for the pump instead of an SSR: these are way cheaper, and since it won't be switching much noise from it won't be an issue (the main reason I use an SSR for the boiler relay).
And one more feature unrelated to previous builds:
  • Add a keypad so that the machine can be locked unless the correct code is entered: now that the Silvia had displaced this machine from my kitchen for my morning coffee, I wanted to bring it into work so that I could use it for my afternoon coffee (although the baristas at Top Pot Donuts do a great job also). The problem is I work in an office space with a shared kitchen and I wanted the ability to constrain use of the machine to people who had been trained on it and knew how to use it properly. This way I could enable people to use the machine by giving them the code once I knew they were able to use it in a competent manner.
So, with those goals in mind I set out on the re-design. The first step was to figure out where to physically mount the control board/display; the Saeco is a tighter package than the Silvia so the options here were a bit more constrained. I originally wanted to have it in the upper compartment with the boiler so it would be on the faceplate of the machine with the other panel switches, but it was just too tight so after some thought I decided to drop it down to the lower panel, just above the drip tray. The issue with this was that the coffee cup could block the view of the display, so to get around that I decided to use a smaller display (2x8 character LCD instead of 2x16) and place it far enough off to one side so that it would not be blocked by the cup. This location also enabled me to put everything on one board vs. the Silvia which had a main board and a power board, making the wiring a little simpler.

I re-used most the schematic blocks from the Silvia so these went quickly, and the layout was pretty fast too since I still remembered how to use the tool unlike other projects where I have gone a few years between using the tool. Both were done in Eagle based on the merits of it being free, here they are:


I then ordered parts and built everything up, with the most challenging part probably being cutting the opening for the display since the dremel tool access wasn't as good as in the location on the upper face plate. Bring-up went smoothly also, with the most interesting thing I learned being that the Atmel ATMEGA 328 MCU doesn't have pull-up resistors on the pins used for the A6/A7 inputs. I had previously assumed that any of the analog inputs could be configured as digital inputs with full functionality, but this is not true for these pins. I would have thought this would have been documented in the Arduino reference pages, but it was not and I eventually came to this conclusion myself and then confirmed it with searches on a few forums. It wasn't a big deal since I could just tack on some pull-ups and use them as analog inputs (they were reading two of the keypad buttons), but good to know for next time. 

So, without further ado here are the images from the build. Here is the view of the machine after it is just turned on with both buttons illuminated and the LCD displaying a welcome message. You can see the keypad mounted on the side panel, just around the corner from the LCD:


When the machine is powered on it displays the welcome message and then prompts the user to enter the access code before the boiler comes on or any of the front panel buttons (brew and steam) are enabled:


You can see that is just a 4-button keypad, I was GPIO constrained on the ATMEGA 328 and I don't see this as a high value target for code crackers so it seemed acceptable. After typing in the code it goes into the normal mode, pulsing the brew button LED to indicate the warming to brew mode and then putting it solidly on once brew temperature is reached and the same for steam mode.


Here is the view of where the board is mounted, directly behind the display, between the drip tray and the water tank. The large black box is the AC/DC supply, with the relays above that and all of the low voltage circuitry below. I am holding the water tank up in this shot, the black cable going up and to the left connects to the float switch.


And here is a view of the boiler compartment. I didn't have to change much here, other than re-working the switches to replace the incandescent bulbs with LEDs. The astute observer will also notice that the temperature sensor is held on place on the boiler with a piece of metal that has the boot of Italy on it (salvaged from the lid from a jar of pasta sauce). All of the cabling is run down into the lower compartment though the existing opening for the power cord.


And now the most important question: does it work? Of course! Here is a plot of the temperature profile while making a latte (degrees C on the Y axis, time in seconds on the X axis). Here are the events labeled: At (0) the code is entered into the keypad and the temperature rises to the brew temperature of 95 C. There is a bit of overshoot here, I just re-used the PID gain constants from the Silvia project and they could probably benefit from a little tuning. At (1) I begin pulling the shot and you can see that the temperature drop down to about 80 C over the course of the 25 second shot. At (2) I stop pulling the shot and push the steam button, and the temperature then rises up toward the steaming temperature of 130 C. At (3) there is a small inflection where I purge the water from the steam wand, then at (4) a drop while I start steaming the milk. I finish at (5) at which point the temperature begins to rise, then at (6) I shut off the steam button and the temperature begins dropping back to the brew preset of 95 C.


One thing I did notice after having done this conversation and the Silvia conversion before it in quick succession is that the Saeco Aroma rises to temperature WAY faster than the Silvia. A cursory inspection reveals that this is likely due to a much higher boiler power to thermal mass ratio: the Silvia boiler is significantly larger than the Aroma, but the heating element power is not that different (950 W for the Aroma, 1100 W for the Silvia). I think I still prefer the Silvia overall, but if you are after a quick morning cup of coffee and you don't mind a sub-par steam wand then the Aroma might be the way to go.

And finally, here is the victory picture of a shot being pulled from the device under test. From the display you can see that it is 6 seconds into the shot and the temperature has dropped to 86 C.


11 comments:

  1. Could you post your code somewhere? I want to do the same thing using a teensy/arduino as a prototype. And for a non-engineer, how do you calibrate the P-I-D parts ?

    ReplyDelete
    Replies
    1. Sure, I have been meaning to put it in Git so I will do that and post a link to it. Be warned that it might be a bit crappy as I am not a firmware engineer :-). I don't think I could put a concise description here of how to tune the PID variables, but there is a good reference here that should help, this is the library that I based my code on: http://playground.arduino.cc/Code/PIDLibrary

      Delete
  2. I am building a PID for a Starbucks barista, which has a similar boiler size and I've been having a lot of trouble with the tuning. It seems no matter what I do, I get huge overshoot (15-20%) and once it gets that high, it takes a long time to get back to temp (unless I manually pull cold water into the boiler).

    This isn't a huge problem when the machine is warming up, but it adds several minutes to the shot to shot time. Did you run into this problem? How did you solve it.

    I'd also be interested if you could share the PID variables you used. At least then I could tune my own machine from there.

    ReplyDelete
    Replies
    1. Hi Luke, I actually adapted this for a Barista on a subsequent project and I shared the code on github here: https://github.com/ctcharle/barista-pid.git. One thing I did to reduce overshoot that may help you is set the I-term to zero when the temp is more than 15 degrees or so (can't remember the exact number) out from the final value. The PID variables that I used are in the .ino file on Github, and changes that I made to the PID code to reduce overshoot are in the PID_v1.cpp file. I should get around to doing the write-up for my Barista conversion sometime also. It worked pretty well, I like how the Barista has a steam switch so you know when the steam wand is active and can use feedforward control to keep the steam power strong.

      Delete
  3. What was the thickness of your trace to handle the 15 amps of the heater ? what about trace width ?

    ReplyDelete
    Replies
    1. It is 40 mils wide, with 1oz copper (standard from OSH park).

      Delete
  4. Nice work. Something I don't get is the trace width for the 12A going trough the SSR. It seems pretty narrow. From what I calculated it should be at least 4mm @2oz thick.

    ReplyDelete
    Replies
    1. Yeah, it is a bit narrow based on standard calculations (which I didn't actually do during the design :-)) but in practice the average current flowing through it is much less than 12A since once the boiler comes up to temperature (which takes a few minutes) the heating element is only on for a fraction of each cycle. It has worked fine so far.

      Delete
  5. Hello,

    Quick question, do you have any detail on how you swapped out the incandescent bulbs for LED? One of the my switches is and I want to replace it with something different but I can find the specs anywhere.

    ReplyDelete
  6. Hello,

    I'm curious as to what modifications you made to the switches to get them to run LEDs. My own steam switch is toast and I have been looking to rebuild it as replacements are hard to come by. I would replace it with something different, but I can't find the specs anywhere.

    ReplyDelete
    Replies
    1. The biggest thing is that you would need to have a low voltage DC power source present. The incandescents run from the AC line voltages that the rest of the stock machine runs off of. I had 5VDC present due to the other modifications that I had done, so I am driving them from that. I'm sure there is a way to just replace the incandescents with LEDs, but it doesn't fall out of the work that I did since the LEDs were an easy substitute based on all the other changes that I had made.

      Delete