Jump to content
IGNORED

Silvia PID build


Recommended Posts

Hi everyone!

New Silvia owner here... with a lot of time on my hands during lock down and a shiny new Silvia to play around with I decided to try build my own PID controller. I thought I'd post here what I came up with just in case anyone interested and may even like to club together to refine the system. I'm more than happy to share circuit details and code etc. Basically, I'm an electrical engineer, so the hardware is up to scratch, but the software still has a few bugs and I can think of many improvements I'd like to implement but don't have the skills! Apologies in advance for the long post, but here goes...

Within a couple of weeks of owning the Silvia I was already sick of temperature surfing and inconsistent shots etc, so I started looking into PID controllers and what options are available to buy. There seems to be a few options but they are quite pricey and I had a few requirements that they didn't quite meet: (1) as it's a new machine, I didn't really want to be drilling holes etc, (2) I'm short on space so didn't want a screen poking out from the side, and (3) I wanted a really simple install process that could be easily reversed if needed (machine is still under warranty, or at least it was until I messed with it!).

After studying the wiring diagram of the machine, I decided the simplest thing to do would be disconnect the brew thermostat and connect the wires to a solid state relay. This is my only change to the wiring inside the machine, literally moving two wires. I left the brew thermostat in place just in case I ever need to switch back. I left the steam thermostat in place for a few reasons, mainly because it acts as a safety net just in case my temperature control goes haywire (which it did many times during testing), this thermostat cuts power to the heating element when the boiler reaches steam temp no matter what my temperature control system is trying to do.

As I didn't want a screen on the actual machine, I decided to go with an (overcomplicated) web interface. The idea being that I can use my phone to connect to the machine via wifi and vary the temperature from the comfort of my own bed! It also gives me a nice display to plot graphs etc. One thing that crossed my mind was if the network ever goes down (which isn't that unusual) then I wouldn't be able to make a coffee if I relied entirely on my phone to control things. To get around this, I have the machine automatically go to a pre-set brew temperature as soon as it is powered on, while I can't change this temperature without a wifi connection it's fine for brewing and I can still use the steam switch to reach steaming temperature. In other words, the machine works just like any other Silvia if the network is down.

After some initial testing, I was happy enough with the performance and decided to get some printed circuit boards made, I even started work on a stand alone version with a screen and rotary encoder but have parked that for now as the web version works so well! Anyways, I've included a few photos and more details below...

 

pcb.thumb.jpg.a3ecb501db246b05e1ad9910ed77e359.jpg

This is the printed circuit board I designed, it uses an ESP32 development board, and include a thermocouple amplifier, voltage regulator and some level shifting resistors so I can connect a 5V contactless liquid level sensor (this is the white thing in the photo - it's not implemented in the software yet). I guess total price for everything (excluding water sensor) is around £30. The PCB's are really cheap (less the $1 per board), but the postage is $30 from china regardless of how many you order. I got ten, so have 9 spares. As you can tell from the photo, there's a couple of issues with the board design that needed fudging. If anyone wants a board let me know and I can send you one for the price of postage.

 

scrn.thumb.png.473ffa4476591f2cf05be1cc2281971c.png

This is the web interface, the default brew temp is set to 102C (this is the temperature of the metal boiler, not the water coming out!), the slider lets me change between 90-110C. I only enable the PID control when the temperature goes above 85C, so warm up from cold is as quick as it possibly can be. What you can't see is in this image the second slider that sets the steam temperature, I have this set to 130C. Sliding the red button to the steam position causes it to heat up.

 

 

screen2.thumb.png.a5b249bf20eb74916f8fce15485d0b15.png

The temperature stability is pretty good, it stays within +/-1C of the setpoint. But there are actually quite a few improvements that could be made with the PID control, I’ve not had time to explore all of these yet.

 

under.thumb.jpg.b28af6a0053cd4fa526e44dd392503c8.jpg

All the electronics are in a box underneath the machine. By the way, when I said the cost of the PCB and components is about £30 I was ignoring the fact you also need a solid state relay and a DC power supply. You can get both these on amazon/ebay quite cheap, probably less than £10 combined. However, I’m very nervous about using these cheap knockoff components in a relatively high power application such as this, so I splashed out on a proper SSR from RS components (cost about £25) and a decent quality DC power supply (about £15).  

 

plug.thumb.jpg.9aac392ec831462b6ff8faa7e2e3e20b.jpg

I use this TP link smart plug to switch it the machine on before I wake up so it's ready to use straight away. I also get it to cycle the power every 29 minutes at the weekend when I'll have a few drinks over the space of a couple of hours. This prevents the energy saving relay nonsense from switching things off. I was very tempted to remove this power saving device, but this would be a major modification and I kind of like the idea of having the power go off after 30 mins should I ever forget to turn the machine off... I wouldn’t want it on the whole day!

 

oled.thumb.jpg.1ecb3e81cbac7ac91839f82427a5007e.jpg

Finally, this is the small OLED screen I was working on, it's actually working to the point it could be installed and tested, but I lost enthusiasm for it as the web system has run for months without issue now… if it ain’t broke why change it!

 

So all in all, I'm pretty happy with the machine now, it's making tasty shots and most of all they are consistent. When I next have some free time I'll get the liquid sensor installed and look into setting up some kind of pre infusion step (although this would require some further wiring changes I guess).

Cheers,

Jim

 

 

  • Like 1
Link to post
Share on other sites
  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Thanks guys! My next move will be to get the liquid level sensor setup. The only thing holding me back is that it needs sticking to the side of the tank, meaning once installed it'll be nigh on i

Hi everyone! New Silvia owner here... with a lot of time on my hands during lock down and a shiny new Silvia to play around with I decided to try build my own PID controller. I thought I'd post h

@AdG For the water level sensor, I bought a non-contact capacitive sensor from Amazon (~£15), they work great and can be mounted on the outside of the tank. There's actually a photo of it in my first

Posted Images

Thanks guys!

My next move will be to get the liquid level sensor setup. The only thing holding me back is that it needs sticking to the side of the tank, meaning once installed it'll be nigh on impossible to get the tank out without entirely stripping the case off. Shouldn't be a big problem, but I'm using a Britta filter with knock-off filter cartridges from amazon, they tend to spill a bit of carbon along with the filtered water. Not a massive problem but unsightly so I like to remove the tank and give it a good wash once per week! I really like the idea of the heating element not switching on if the tank is empty though, especially as I have the machine on when asleep!

  • Like 2
Link to post
Share on other sites

@iJim what are you thinking of using for the water level sensor? 

I’ve been contemplating building a replacement for the basic washing machine part used in the Silvia Pro. That triggers with no last shot protection and lots of water in the tank. The tank is the same as on the Silvia.

I’m thinking of a solution that needs two levels, Low and very low. Low would trigger low water if the brew pump is not running (i.e. no shot in progress) and as a safely very low would trigger instantly as a final protection. Leaving enough between the two should mean it doesn’t ever trigger during a shot. The output would just match the existing sensor on the pro via a relay.

Link to post
Share on other sites

It's a shame there is no seperate "gully/tube/other" to keep a floating magnet in a fixed area so it rises up & down (but not sideways)...that way you could incorporate a few Hall effect sensors into the body (at different heights) right next to where the magnet would be rising and falling....perhaps a "tube" fixed in one corner of the tank say ??? ...just a thought.

Link to post
Share on other sites

@iJim Great work!

Some questions if you don't mind?

  1. Quite intriguing to store under the machine! I don't think I've seen a Silvia PID build with that idea. Most people prefer storing near the pump. Any reason why you didn't do it within the main compartment? 
  2. What did you end up using for a temperature gauge? 
  3. The thing that bugs me about Wifi connectivity is the fact that it makes the physical switch obsolete. Am I correct in assuming that you have it switched on all the time, and if you want to manually switch it on and off while in front of the machine, you reach instead for the TP Link controller? Basically I would want a WiFi setup where all the Silvia switches are still functional but now with additional option of Wifi. Could you do that with a retractive button? 
Link to post
Share on other sites

@AdG For the water level sensor, I bought a non-contact capacitive sensor from Amazon (~£15), they work great and can be mounted on the outside of the tank. There's actually a photo of it in my first post, it's a white cylinder about an inch in diameter. I didn't really fancy having something floating in the tank, I was just planning to use some double sided tape to hold it in place. Here's the link: https://www.amazon.co.uk/gp/product/B088PGKPJ4

One drawback with the sensor is that there's little data available on how to connect it. I spotted it was a 5V device which could be a problem for my esp32 microcontroller (3.3V io), but I factored this into the PCB design. What I subsequently learnt is that it has an npn output so it needs a resistor between the output wire and the 5V power source. Annoying, I had to fudge extra wires on the board to make it work. 

 

@Phario, there are a few reasons I avoided putting everything within the case. Firstly, it's a new Siliva so it has this enormous 'CPU' (I think that's what they call it in the manual), which basically takes up most of the free space. It's a big encapsulated block that has many wires going in/out of it, annoying as all it appears to do is cut the power off every 30 minutes! If that wasn't there I would have definitely housed everything inside. My original plan was to house all the 240V items inside for safety and just have the microcontroller on the outside; unfortunately, there wasn't even enough room for the relay inside, well there was but it would have required drilling new holes to mount it. I don't really like the idea of having live terminals on the outside of the machine, but they are shrouded, they are also hard to access being underneath, plus I'm the only one that uses the machine, so the chances of there being an issue are slim [I just have to remember not to put my fingers under it when it's on!].

The temperature gauge is an interesting one, I tried to go too fancy and use a DS18B20, which is a digital thermometer and really easy to use with a microcontroller. I tested it extensively and was happy enough to epoxy the bloody thing to the boiler. What I had conveniently ignored was the 125 C max operating temperature... not a problem when I was setting up the PID for brew temperature, but one hell of a problem when I tried to steam some milk! After this, I opted for a k-type thermocouple, which is good up to 1300 C :)  The drawback is less accuracy, +/- 1.5C and the need for some additional electronics to condition the signal. I went with the MAX6675 and made space for it on the PCB.

In terms of wifi, I decided right at the start that I wanted the machine to operate as if it had never been modified, even if the wifi doesn't work. Basically, at the moment, all my controller does is heat the machine up to 102C (which is around 96C water temp out of the group head), without wifi that's all it'll ever do. You still need to press the brew button to activate the pump. You can also press the steam button on the machine, this short-circuits the relay and uses the steam thermostat. In other words, someone using my machine would not know it even had the PID in there, it operates just as intended. Using my phone and wifi, I can vary the brew temperature and I can set it up at 130C (or whatever) for steaming, which makes pressing the steam button redundant. 

The TP link plug is not linked to the controller, it just switches the power on to the machine 15 mins before I wake up. I should also add, that this functionality is exactly why I didn't use a Raspberry Pi! A Pi takes time to boot up and needs to be shutdown properly etc, which requires a touch screen or mouse etc... way too much hassle, my controller is ready to go in seconds and is doesn't get corrupted when the mains power is cut!

 

Cheers,

Jim

  • Like 1
Link to post
Share on other sites
3 hours ago, iJim said:

@AdG For the water level sensor, I bought a non-contact capacitive sensor from Amazon (~£15), they work great and can be mounted on the outside of the tank. There's actually a photo of it in my first post, it's a white cylinder about an inch in diameter. I didn't really fancy having something floating in the tank, I was just planning to use some double sided tape to hold it in place. Here's the link: https://www.amazon.co.uk/gp/product/B088PGKPJ4

I'd forgotten all about these....good find....waaaaaay cheaper than the ones i saw yonks ago :classic_smile:

Link to post
Share on other sites
15 hours ago, phario said:

@iJim Great work!

Some questions if you don't mind?

  1. Quite intriguing to store under the machine! I don't think I've seen a Silvia PID build with that idea. Most people prefer storing near the pump. Any reason why you didn't do it within the main compartment? 
  2. What did you end up using for a temperature gauge? 
  3. The thing that bugs me about Wifi connectivity is the fact that it makes the physical switch obsolete. Am I correct in assuming that you have it switched on all the time, and if you want to manually switch it on and off while in front of the machine, you reach instead for the TP Link controller? Basically I would want a WiFi setup where all the Silvia switches are still functional but now with additional option of Wifi. Could you do that with a retractive button? 

Sorry, was half asleep last night and totally forgot that the very first modification I made was to swap out that intermittent pushbutton power switch for something latching. So yes, you're absolutely right. The front power button is on all the time, and the TP link switch is used to turn the machine on and off. I don't mind this as the smart plug has a pushbutton that is in easy to reach so I can still turn it on by hand (I also have a smart speaker, so can just ask for it to be switched on). It would be an easy mod to have it so the front switch actually controls the power into the machine, but it would involve snipping a few wires so opted not to do it.

Link to post
Share on other sites

@iJim - Thanks, just taken a look and they could be good. I can also seem some similar ones setup to work with Arduino / Pi on Farnell and The Pi Hut at a good price so might have a play with them to workout a control system. One of those had 5v/3.3v switch and looked like the same sensor as you had so looks like it shouldn't be too hard to get to work on the lower voltage.

Link to post
Share on other sites

I always felt that you could do a bit more clever stuff than a standard PID mod, like looking at when the pump gets switched on and setting the output to 100% for example. I like this project lots and have wanted to have a steam setting with my PID setup but we use the original steam switch.

Link to post
Share on other sites

@Mart1512 I was thinking the same... I don't like seeing the temperature plummet when you hit the brew switch, it takes a few degrees drop before the PID begins to compensate. At the minute, as soon as I hit the brew switch on the machine, I tap the steam switch on my phone. This basically puts the heater on full whack as the set point increases ~30C. It's still not enough to stop the temperature dropping, but without doing this you can drop 10-15 degrees over a 30 second shot! There are quite a few other things that could be done (if you're willing to start cutting wires). I saw a video of someone that implemented a PID controller to maintain a constant pressure whilst brewing. I guess they pulse modulated the pump to achieve this, although the video was only 30 seconds long with no details. I even identified a suitable digital manometer for about £50, but electronics are my bag, not plumbing, so I chickened out.

One thing I urgently need to fix though is the IP address, I have it dynamically allocated at the moment, which is fine, but every few it changes and I have to log into router to find the new address. 8 o'clock this morning was one of those times, not what you need when you're half asleep and you just want your coffee!

 

@Jordash184 Happy to send you a board, you'd need an ESP32 dev board with the same pin out as the one I used, they are a about £6 on amazon (I got three for £19 - https://www.amazon.co.uk/gp/product/B08DXSMZSB/ ). It's programmed in Arduino IDE and I'm happy to share the pretty amateur code! You'd also need MAX6675 thermocouple amplifier, these are about £10 from RS. They are minuscule surface mount devices, if you're not practiced in soldering smt components then buying a pre-soldered board from amazon might be easier, but not as compact ( https://www.amazon.co.uk/DollaTek-MAX6675-Interface-Thermocouple-Temperature/dp/B07DK8VG87 ).

 

Link to post
Share on other sites

@iJim Interesting, my PID is set to recover very quickly, so we can do two brews/flush the head without waiting for ages, but there is a fair bit of overshoot, so it's a bit of a manual process involved and keeping an eye on the temps still, this would overcome my issues.

Plumbing is the same as electricity with water, give it a go what's the worst that could happen, but that could be an interesting addition if it worked.

I never realised the newer machines has a 30m power off, something we need at times.

How about fixing the ESP32's IP address in the router to be static if you can?, that would be my first choice.

Link to post
Share on other sites
On 06/03/2021 at 10:31, iJim said:

@Mart1512 I was thinking the same... I don't like seeing the temperature plummet when you hit the brew switch, it takes a few degrees drop before the PID begins to compensate. At the minute, as soon as I hit the brew switch on the machine, I tap the steam switch on my phone. This basically puts the heater on full whack as the set point increases ~30C. It's still not enough to stop the temperature dropping, but without doing this you can drop 10-15 degrees over a 30 second shot! There are quite a few other things that could be done (if you're willing to start cutting wires). I saw a video of someone that implemented a PID controller to maintain a constant pressure whilst brewing. I guess they pulse modulated the pump to achieve this, although the video was only 30 seconds long with no details. I even identified a suitable digital manometer for about £50, but electronics are my bag, not plumbing, so I chickened out.

One thing I urgently need to fix though is the IP address, I have it dynamically allocated at the moment, which is fine, but every few it changes and I have to log into router to find the new address. 8 o'clock this morning was one of those times, not what you need when you're half asleep and you just want your coffee!

 

@Jordash184 Happy to send you a board, you'd need an ESP32 dev board with the same pin out as the one I used, they are a about £6 on amazon (I got three for £19 - https://www.amazon.co.uk/gp/product/B08DXSMZSB/ ). It's programmed in Arduino IDE and I'm happy to share the pretty amateur code! You'd also need MAX6675 thermocouple amplifier, these are about £10 from RS. They are minuscule surface mount devices, if you're not practiced in soldering smt components then buying a pre-soldered board from amazon might be easier, but not as compact ( https://www.amazon.co.uk/DollaTek-MAX6675-Interface-Thermocouple-Temperature/dp/B07DK8VG87 ).

 

Awesome, thanks iJim, that's brilliant. I'm happy to have a go at surface mount soldering, done it quite a bit previously. I'll send you a PM with my details.

Link to post
Share on other sites
On 05/03/2021 at 08:57, Mart1512 said:

I always felt that you could do a bit more clever stuff than a standard PID mod, like looking at when the pump gets switched on and setting the output to 100% for example. I like this project lots and have wanted to have a steam setting with my PID setup but we use the original steam switch.

Not sure on the PID programming Rancilio have used on the pro, but the temperature is very stable when you pull a shot.

The only time I’ve seen it drop even one degree is when I was setting the grinder up and was way off so got a gusher of a shot. 

As the boiler and heating element is the same as the Silvia it should be possible to keep the temperature stable with the right programming.

Link to post
Share on other sites

Interesting! From the sounds of it, I think there are a few things to improve in my code.

My PID settings could certainly be improved, there's barely any overshoot at the moment which is a sure sign the settings are too conservative. Also, I've seen plenty videos of PID's on the Silvia where the heating element lamp appears to flicker because it's being switched so quickly. I'm not sure if this risks prematurely damaging the element. To play it safe, my code spends 500 ms reading the temperature during which time the element is off (basically five reads from the thermocouple amp, with a 100 ms delay after each), then the PID calculates the on-time which can be either 0 (when over temp), or anywhere between 100 - 2000 ms. After this two second period the code repeats. I'm beginning to think a 2.5 second control loop is way too slow... I thought a big block of insulated metal would have quite a lot of thermal mass and it's temperature would change slowly, but pumping in cold water certainly speeds things up! I also don't like the fact that the 0.5 second read-time basically limits my max duty cycle to 80%. The ESP32 microcontroller is dual core so it's possible to have one core handle the temperature reads (and wifi etc), while the other core just handles the PID, but getting this up and running will probably take some time!

 

Link to post
Share on other sites
11 hours ago, AdG said:

Not sure on the PID programming Rancilio have used on the pro, but the temperature is very stable when you pull a shot.

I wonder where the thermocouple is in the pro, is it built into the boiler?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • About
    Coffee Forums UK is the UK's premier coffee forum Started in June 2008 by Glenn Watson, we now have more than 24000 mainly UK based members, and welcome more than 3000 members and visitors from around the world each day! With strategic investment and digital expertise from the Jackson Lockhart team (Tait Pollack and Adam Bateman), we are taking Coffee Forums UK to the next level, and are delighted to share the journey with you.

    New Members:
    We are often referred to as the friendliest forum on the web and we look forward to welcoming you onboard. Please read our Terms of Use. We stick by them, existing members please familiarise yourselves with them.


    Advertising

    Coffee Forums Media Kit

    Click Here To Buy Advertising Space 
    £100 p/m when paid yearly, up-to: 690000 banner impressions per month!


    Donate / Sponsor

    Get Your Supporter Badge Today (per year)

    image.png



    Coffee Forums Logo
     




×
×
  • Create New...