I'm making a PID controller for Sous-Vide, using an Arduino.

I'm trying to decide how to control the output. Using an SSR as an on-off switch on 240V AC will probably give me the result I'm looking for. However, I'd rather have a more continuous proportional output, so the rice cooker can be effectively "dimmed" rather than switched on and off.

What do I need to do this? Is a TRIAC essential? Will certain SSRs do this? Will all SSRs be capable of this? Do I need to build a 240V circuit from components myself, or are such devices available at similar costs to an SSR?


I may have mislead with the word "proportional". I am building a PID with an Arduino. I will use it to drive a dumb rice cooker, and I'll have a temperature probe to detect temperature. This is the background to the question I'm asking.

I think it will be fairly easy to use a relay or SSR to turn the heater on or off every few seconds to control the heat appropriately. However, what I want is to be able to control the heating element so it runs at a fraction of full power, rather than turning on and off all the time. I would prefer this as it gives better temperature control, and I just prefer the idea of a constant electrical load as against switching 2000W or so every few seconds.

So I have a 5V digital output that I can control with a microcontroller (I believe I can control it far faster than 50Hz). I want to use this output to control the heat output of a heating element. I think the right device to use is a 240V SSR. My problem is deciding what sort of SSR I need, and then how to use it. I'd prefer a complete device with power plugs (like a powerswitch tail - http://www.powerswitchtail.com/ - but for 240V, and with the ability to dim rather than just switch on and off).

  • 1
    \$\begingroup\$ I'd try time-proportional control before going to PWM. A heater with a big pot of water on it has a lot of thermal mass and I don't think it will benefit from moving to PWM. \$\endgroup\$ Commented May 24, 2012 at 14:33
  • \$\begingroup\$ I had to look up the French Term ... Discovered it was vacuum packed slow cooking. at 60'C just above the "Pasteur temperature" but not too high to kill many of the nutrients. Looks like a great idea. Don't forget to insulate the cooker and improve efficiency. Even a slow cooker pot will do for unbagged items. \$\endgroup\$ Commented May 24, 2012 at 21:40
  • 1
    \$\begingroup\$ Proportional control of high power devices is tough, particularly if you can't PWM them (in this case, because they're AC), and it's not really necessary in this case. Even my retail Sous Vide machine (a Sous Vide Supreme) simply switches the heater on and off as required, and it maintains temperature regulation to within half a degree centigrade. \$\endgroup\$ Commented May 25, 2012 at 0:02
  • \$\begingroup\$ @Nick - That's very tight! Usually hysteresis alone is already 1°C. Add tolerances to taste. \$\endgroup\$
    – stevenvh
    Commented May 25, 2012 at 12:20
  • 1
    \$\begingroup\$ Richard, as usual most requesters fail to give specs. What are yours Setpoint, tolerance? Why has no one else failed to mention Smart rice cookers cannot be switched externally? +/-0.5'C is easy electronically. 2~5'C mechanically. NO need to spend $359~$600+ for a a Sous Vide Supreme \$\endgroup\$ Commented May 25, 2012 at 13:11

7 Answers 7


No need to use a PID. You can have a much simpler hysteresis control.

Thermal capacity of water is around $$4184 J/(kg·K)$$ In my case, the heater´s power was actually $$2kW = 2kJ/s$$ This means, it heats 1kg of water for about 0.5 K per second. In my case, 2kg water usually.

The bigger problem is precise measurement of the water temperature because of thermal convection. You want a circulator in there to keep thermal differences minimal.

Once you have established good measurement, you can do a simple hysteresis control, in my case I switched the heater on with a mechanical relays for 1s to have a 0.25 K rise.

Temp reading error is going to be around 0.5 K anyways, so don't bother with too much of a regulation.

For a purely resistive load, you will be fine with a simple relays, which also does the electrical isolation for you.

If you want to go for electronic switches, an optotriac will be just fine.

  • 3
    \$\begingroup\$ The reason to use PID rather than a simpler control method like hysteresis is to not overshoot the target temperature. In sous-vide, temperature fluctuations of the order of one degree can have a detrimental effect on the quality of food produced. This can be exacerbated by the delay between applying the heat source and detecting the temperature. Hence, I'll be using a PID, probably with either a pt100 or K-Type sensor. The PID can make up for the thermal lag. \$\endgroup\$ Commented May 24, 2012 at 15:42
  • 1
    \$\begingroup\$ any references on food quality vs control temp?I believe 0.5'C tolerance is adequate cookingissues.com/primers/sous-vide/purdy-pictures-the-charts I think the pot needs to be insulated with R100 in order to minimize setpoint error due to baseplate thermal resistance \$\endgroup\$ Commented May 25, 2012 at 13:24
  • 1
    \$\begingroup\$ I may or may not insulate the pot, but that's really outside the scope of the SSR question. \$\endgroup\$ Commented May 25, 2012 at 13:51

The device you are controlling has a very long time constant compared to 60 or 50 Hz power cycles. It is perfectly fine, in fact a good idea, to switch the heater on and off for whole line cycles or at least 1/2 line cycles.

I had a project with a PIC 18 controlling a couple dozen heaters and did exactly that. We used zero crossing solid state relays, with the PIC deciding whether each one should be on or off each 1/2 line cycle. Note that 1/2 line cycles (120 Hz at most) is a long time for a microcontroller. You can do straight PWM with a period of 256 half line cycles. Even at 50 Hz line frequency that is only 2.56 seconds, which is fast compared to the heater time constant. I actually did a Bresenham algorithm so that in some cases the period would be shorter, but that really doesn't matter in the scheme of things.

Now you have a single byte with 0-255 representing linear heater power. The outer control loop can do PID or whatever to determine what the heater power should be based on temperature measurements and other known characteristics of the heater.

  • \$\begingroup\$ Does "line cycle" mean 20ms on a 50Hz AC line? So 1/2 line cycles would be 10ms, right? Does that mean that the heater is effectively turning on and off up to 50-120 times per second, and a setting of say 15 on a scale of 0-255 would mean fifteen cycles on and 240 off (or on for 0.15s, and off for 2.4s)? Or would you spread the on cycles out through the time, so it's on for 10ms fifteen times during a 2.56 second period? \$\endgroup\$ Commented May 24, 2012 at 16:45
  • 1
    \$\begingroup\$ @Richard: Yes, you've got it. Like I said, you can try to spread the on cycles thru the whole interval, but 2.56 seconds is still fast compared to your time constant so averaging the desired heating power over 2.56 seconds should cause no problem to the control algorithm. You can use a error accumulator method (like Bresenham) to spread out pulses more, but the worst case period is still the same. Really, I wouldn't worry about it. Measure a step response and see how fast the system response. I suspect 2.56 seconds will look very fast in coparison. \$\endgroup\$ Commented May 24, 2012 at 17:28
  • 1
    \$\begingroup\$ @OlinLathrop - Bresenham was still alive and well and happy to reply to emails when I tracked him down a few years ago :-). A young friend was attempting to understand his method and I thought he would be pleased to know that beginners were still having the concepts presented to them with his name attached. \$\endgroup\$
    – Russell McMahon
    Commented May 25, 2012 at 14:28
  • 2
    \$\begingroup\$ @Russell: I have met Jack Bresenham face to face, and he is a really nice guy. He originally dropped off the world when he retired, but apparently got bored and now can be reached via email again. I once wrote a paper showing how to extend his famous algorithm to sub-pixel addressing so that the ends of lines don't need to be at pixel centers. He wrote a very nice intro to that edition of the journal and we had a interesting conversation about things at the next SIGGRAPH conference. \$\endgroup\$ Commented May 25, 2012 at 15:03

You can divide SSRs into zero-crossing and non-zero-crossing switching. The former will wait until the main's phase will pass zero before it switches on. It controls a triac, and like any other triac circuit it will remain on until the current drops below a hold current, again at a zero-crossing. This type is not suited for dimming. The other type can be fired at will, and may be used for dimming: just control the moment in the cycle when you switch it on.

A dimmer requires information about where in the the mains cycle you are, and a somewhat accurate timing for switching the triac on. You don't need that. The cooker is just a heating element, and it will be slow in changing temperature. You can easily control the average power by switching half cycles on and off, like the zero-crossing SSR will do. The inertia of the cooker will make that you don't notice it. And it won't cause the interference you have from a dimmer.

For your PID controller it won't make much difference. In one case the output will be the main's phase, in the other the on/off duty cycle.
Olin calculated that for a 256 level control you would have a 2.5s cycle at 50Hz. Again due to the thermal inertia you won't need that accuracy. I think I would choose something like a 20 level control. That would have a cycle of 200ms at 50Hz, a few orders of magnitude faster than the time constant of the cooker.

There are other ways to control a triac, but the SSR is easy to interface and provides a safe isolation between your controller and the mains. SSRs are not cheap, but you can roll your own with just a handful of parts.

  • \$\begingroup\$ you can also divide SSR into a LOT MORE categories such as time-delay type, AC/DC load types, and Linear phase control, multiple phase control, SPST, SPDT, DPST,DPDT, 3PST, 4x SPST bridge type ... and many more.... \$\endgroup\$ Commented May 24, 2012 at 21:26
  • 2
    \$\begingroup\$ @Tony - Yes, I know that. I didn't say it was the only way to divide them. I restricted myself to what's relevant in what followed. \$\endgroup\$
    – stevenvh
    Commented May 25, 2012 at 4:14
  • \$\begingroup\$ OK so if I buy a Zero Crossing SSR rated for an appropriate current level (240V, say 2400W -> 10A), then I can just set my PID loop to switch on and off at 50 or 100Hz, and choose how many levels that is, and hence, how long the cycle time is, right? \$\endgroup\$ Commented May 25, 2012 at 8:29
  • \$\begingroup\$ @Richard - Yes, if you have 20 levels, and power should be at 25% you switch it on for 5 half cycles and off for 15. A full cycle then takes 200ms at 50Hz. Note that if you use a optocoupler triac like I linked to that can't switch power. You'll have to drive a power triac with it, like this schematic shows. If you use the more expensive SSR you don't have to worry about that. \$\endgroup\$
    – stevenvh
    Commented May 25, 2012 at 8:41
  • \$\begingroup\$ My proposal meets the requestor's question, How to get Proportional Control? Consider this. Proportional control is performed by duty cycle of half cycles 50Hz @240Vac. Phase control and hence zero crossing control is irrelevant in this context, rather only relevant for EMC. Hence other categories of SSR's are MORE relevant to search for... i.e SPST SSR with ZCS for EMC. Since a SSR with ZCS will latch on for a half -cycle, you have 100 pulses of power per second for a Time Constant measured in Minutes ~10minutes to reach 70% of max temp. say.. or 1000 half cycles. That's why. \$\endgroup\$ Commented May 25, 2012 at 12:06
  • If you use PID and a PWM frame rate in the order of 0.1 seconds or longer I'd expect it to work well enough. 1 second or longer better.

  • An SSR will keep you and your equipment alive and costs not too much more than DIY as long as you buy sensibly.

A SSR with zero crossing allows 100 on/off points per second using UK 50 Hz AC mains. If you use 1 Hz PWM you can get notionally 1% control and in reality within a few % - much more than adequate for a rice cooker. Even 10 Hz PWM would probably give you good enough control.

If you use a non zero crossing SSR with a TRIAC output it will turn on at any point and off at 100 zero crossings per second. You MAY get slightly more noise - a rice cooker element will be mainly resistive so it should not make much difference.

The zero crossing version is more useful if you have inductive loads.

An SSR is about as cheap as DIY wity TRIAC and zero crossing opto coupler and the SSR designer has chosen a TRIAC that will probably survive its name plate loading. Slightly less chance of killing yourself. Slightly.

If you do a DIY version DO use optical isolation. Death of controller and user all too easy otherwise.

Do note minimum drive current that SSR or opto needs. Depending on model these may be non trivial and some turn not on even one teensy bit when under driven just slightly.

  • \$\begingroup\$ I may be misunderstanding what PWM frequency means, but I thought you'd need a frequency of significantly higher than 1Hz to be able to "dim" a 50Hz signal. I thought the idea of a TRIAC with PWM was that you could turn on and off multiple times within a cycle, or truncate the amplitude of the cycle to simulate lower voltage. But if it operates at 1HZ, doesn't that mean one switching event per second? \$\endgroup\$ Commented May 24, 2012 at 16:18
  • \$\begingroup\$ @RichardRussell - you can PWM at a frequency such that you chop each mains half cycle up into various on & off parts BUT you can't use a TRIAC to do that without special magic. You can phase control the TRIAC so it starts at a selected point in a cycle and turns off at the next zero crossing. OR with minimal effort from the microcontroller you can make the switching "frame" say 1 second long. If on for 200 mS and off for 800 mS then you will get about 20 on half-cycles and 80 off half-cycles. The rice cooker thermal time constant will be >> 1 second so it will see essentially steady heating. \$\endgroup\$
    – Russell McMahon
    Commented May 24, 2012 at 16:41
  • \$\begingroup\$ If you insist on using arduino, make sure you have 2 thermistors in case one fails and average the two readings if close to each other. Then have user setpoint control and digital display showing error. red/yellow/green/yellow/red and choose threshold of error you want. 0.1'Cdeg, 0.5'deg 1deg. simple but accurate. and remember the actual water temperature will be lower than reading due to lack of insulation..and thermal resistance in the system. So calibration is critical due to room-pot difference temp variation. But offset and gain error can be nulled by design. \$\endgroup\$ Commented May 25, 2012 at 13:38
  • \$\begingroup\$ A good designer can accomplish same as Pro cooker without Arduino !!! pot. thermistors, quad op amp , triac, LED driver. goo.gl/79vtw Pot can adjust setpoint and LED driver middle output used to drive triac. or SSR. \$\endgroup\$ Commented May 25, 2012 at 13:47
  • 1
    \$\begingroup\$ For background, I am not a good designer. This is my first electronics project. :-) \$\endgroup\$ Commented May 25, 2012 at 14:09

added: What is your spec? 60'C +/-5'C?? then use CANTHERM switch.... if tighter use thermistor/comparator/dc supply/ triac. set & forget

Can the Rice cooker can be run from a phase controlled AC source? I doubt it.

I presume (!) you have decided to intercept the heating element wires and retrofit a thermal controlled switch. If 1'C error is a tolerable error, this is solely ( no pun intended) determined by baseplate thermal resistance (Rt-bp) and sensor Rt-sensor). The reason that this is trivial is that load time constant ( time to burn rice) is in X minutes and the feedback loop bandwidth is in milliseconds..(multiples of 20mS for a ZCS SSR.)

If you want proportional control, that is easy with simply adding noise to your comparator loop that compares Sensor to preset temp.

Since smart rice cookers will have unknown circuits that may not initialize or worse, fail under the condition of a pulse or phase control AC voltage, I assume my presumption is correct.. another e.g. don't use a CFL on a Triac dimmer. It wont work well and will violently oscillate and fail early.

Assuming you have performed this assumed task of proper selection or modification, the easiest solution, readily available is a 10 Amp SSR with ZCS for EMC (Electro Magnetic Control) egress issues. (i.e. pops on AM radio)

If you really wanted to control a thermal loop faster with low mass then the normal practise is to use the standard 4~20mA DC current loop for a DC controlled SSR. Off the shelf $100. Home designed with snubbers, poly caps, fast recover diodes and MOSFETS and certified for Fire Insurance ($10 in parts, $20K in regulatory approvals). Don't forget to use sensor fail-safe design that detects an open loop.

Just teasing, I know you won't do that.

It is easy to find one of 30K different SSRs on the market...just make sure of heatsink requirements.

SSR's are easy to use but in some cases, easy to misuse. So beware of limitations.

If you are more capable and want to design a discrete Opto-isolated Triac control with potentiometer setpoint and thermistor temp sensor and linear , just ask a new question.

For those who tuned into linear control of rice cooker and have another application...

Here are some typical specs for a Linear Controlled SSR:

Model:SSR-25LA Standard Type

  • Rated Load Current:25A Input to AC side
  • Data Input:4~20mA Input DC Control
  • Resistance:Appr.1.2KΩ to photo diode.
  • Control Method :Phase Control

Operating Data

  • Operating Voltage:90~250VAC Min.
  • Blocking Voltage:600 VAC (Repetive)
  • Max. Current :275A
  • Leakage Current:≦0.5% of Full Load
  • Peak Voltage:Over 1200VAC

General Data

  • Dielectric Strength:Over 2.5KVAC / 1min.
  • Isolation Strength:Over 50MΩ / 500VDC
  • Operating Temperature:-20°C ~ +80°C
  • Housing Material:Intensive ABS
  • Weight:Appr. 105g
  • Type: Standard
  • \$\begingroup\$ Datasheet for the SSR-25LA? Am I right that this is actually a 4-20mA controlled dimmer? If it's phase control it's not a relay IMO. \$\endgroup\$
    – stevenvh
    Commented May 25, 2012 at 12:12
  • \$\begingroup\$ the 25 stands for 25Amps overkill for this project \$\endgroup\$ Commented May 25, 2012 at 13:19
  • \$\begingroup\$ The rest too. This is obviously for industrial process controller use (the 4-20mA is a givaway). For that reason probably expensive. \$\endgroup\$
    – stevenvh
    Commented May 25, 2012 at 13:22
  • \$\begingroup\$ Like I said for those who have other apps in mind and want a Linear Control SSR \$\endgroup\$ Commented May 25, 2012 at 13:30

Based on the guidance given in other answers, and a realisation that I was trying to do something too complex for my real needs, I decided to order a PowerSwitch Tail IIU 240V. It's a simple relay in a plastic box with power cables attached. It won't solve my "dimming" problem, but as a number of people pointed out, turning on and off every few seconds will likely provide me all the control I really need.

In actual fact, this doesn't answer the original question I asked, but does solve the underlying problem I had. For 110v applications, there is a ZeroCross Tail which would actually do exactly what I wanted, and I'm sure I could adapt such a device to 10A/240V with UK plugs, but for now, I'll settle with the IIU version.


I haven't seen this in another answer, so you should know that PID control will not work unless you modify the algorithm. It will build up a ton of error as it comes up to temperature, and it will overcook the food as a result. And on/off will cause convection currents which I suspect will mix the water better, compared to using a steady temperature.

A thermostat with hysteresis (software hysteresis is fine) is all you need. I've built both (for food purposes). The thermostat is less finnicky, comes up to temperature faster (because it's always on at 100%), and doesn't have errors when something unexpected happens. If your hysteresis is small, the thermostat will start to act like PID anyway, rapidly turning on and off due to noise in the measurements. If your switch is not bothered by excessive turning on and off, this can be ideal.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.