# Is there a way to use PWM to control AC mains powered heater?

Is there a way to use PWM to control the power and temperature of mains powered heater? I know that I could use triac but I am just wondering. I know what PWM is and what is it used for, but image if you only have a microcontroller PWM output like for example from Arduino, then how would you use it?

• Do you know what PWM is? How does it combine with whatever you know about AC? – Eugene Sh. May 8 '17 at 17:37
• Triac control IS PWM... – Trevor_G May 8 '17 at 17:38
• Listen to @Trevor! – winny May 8 '17 at 17:39
• @Trevor This is not PWM in the conventional sense (well, the control signal perhaps). – Eugene Sh. May 8 '17 at 17:40
• @EugeneSh. untrue, a triac does modulate of the width of pulses. However, those pulses are not rectangular, but rather a rectangular pulse gating a sine wave. Consider that the verb "modulate" is applicable in the radio context as well, where no one is surprised when the carrier is a sinusoid. – Chris Stratton May 9 '17 at 3:24

Yes, you can do this. However, anything called a "mains powered heater" has a time constant way longer than a power line cycle. You can still modulate the power to the heating element (resistor), but it is much easier to do this in multiples of line cycles or at most half line cycles.

I actually did this in a real product once. This product had to accurately control the temperature of a couple dozen line-driven heaters. The controller got temperature measurements from thermistors, then controlled the heaters by switching each one on or off for a 1/2 power cycles. This was done using solid state relays that only switched the outputs to a different state at each zero crossing of the AC line. Doing this reduces transients from switching, and keeps the heater power linearly proportional to the PWM value.

Instead of straight PWM where the output is turned on for some fraction of a fixed period, then off for the rest, I used a Bresenham algorithm to switch each half line cycle separately. The worst case low frequency content is still the same, but the average is better.

In this case, I had the control algorithm produce a byte representing the desired heater power. Since each PWM time slice was 1/2 power line cycle, and the PWM period was 255 slices, this period was 2.13 seconds for 60 Hz power. For 50 Hz power it would be 2.55 seconds. As long as the heater's response is significantly slower than that, this works fine. In my case, the first time constant was several minutes, so a few seconds was plenty fast enough for the PWM period.

• Yes! Avoid cutting transients into a high-power supply if possible – the line interference this can cause is infamous (e.g. dimmers in live production – always a source of quarrel between guitar technicians and light guys). – leftaroundabout May 8 '17 at 22:39
• @leftaroundabout -- it'd help if the guitar folks could keep their pin 1s straight... – ThreePhaseEel May 9 '17 at 0:51
• @ThreePhaseEel phhh... it would help if guitar folks stopped using “technology” that has been obsolete for half a century. An unbalanced connection (better hope at least the shield is isn't leaky), fed from a passive high-impedance inductive transducer that's hardly up to the task of handling the cable's capacitance, driving at the far end a high-gain stage only to clip the signal to basically a rectangle... seriously? – leftaroundabout May 9 '17 at 1:00
• A Bresenham algorithm to draw lines on a pixel grid...? – user253751 May 9 '17 at 11:11
• @immibis, yes, Bresenham is perfectly suited for handling a ratio (a graphical line or turning something on/off in non-integer ways) in a basically integer-only environment. It's the principle behind it that counts. In that regard, a (non-aliassed) line on a 2D display is exactly the same as the PWN for a heater element. – AnoE May 9 '17 at 12:35

You can control the power of an AC load by:

1. "Cutting" the phase (commonly used for light dimming). In this case you have to synchronize your control with the zero crossing of AC waveform.
2. Turning the triac on only for a couple of half-cycles (eg. turn on for 5 half-cycles, turn off for 100 and you have ~4,7% of the maximum power).
3. "Very slow PWM" - if it is a heating appliance, thermal response of the room/building will usually be so slow, that your PWM period can be 10 minutes, so if you turn on for 1 minute, then off for 9 minutes you will effectively get 10% of heating power.

Chances are pretty good that the dynamics of your physical problem, in terms of heat transfer, are not on a time scale such that there is any advantage of PWM control. On/Off control is likely more than adequate.

Most things that can be on\off controlled can of course be PWMed by using a simple transistor arrangement, or ever your triac, but again, there would be no real advantage to doing so.

• Isn't "On/Off" control just really slow PWM? – Jonathon Reinhart May 8 '17 at 23:21
• @JonathonReinhart I suppose, but not in the sense of setting up a controller with a timer to set period and duty cycle. In fact, there is no period, so duty cycle is undefined. – Scott Seidman May 8 '17 at 23:32
• Of course you can still use a triac, even if you apply it for entire (half) periods rather than partial half periods. – Chris Stratton May 9 '17 at 3:26

I needed just this, a PWM heater control for 230V. Just 75 Watt, a floormat under my feet in winter. But using a dimmer (for lamps) the phase cutting sharply interfered with my headset. I tried two, but the second did even worse.

What I made was a multivibrator with the 555 timer IC. The downside with that is that you need a low voltage power supply build in. I did that with a small 0.5W transformer.

The timer can be configured with a 1M potmeter to change the on/off time:

Cold = 0.1 second on, 5.9 seconds off.

medium = 3 seconds on, 3 seconds off

hot = 0.1 second off, 5.9 seconds on.

And of course every temperature in between.

The output of the 555 timer (trough a current limiting resistor) directly drives a solid state relais (its LED), which can switch 2A max. I used the cheap G3MB-202P, which has a zero crossing switching circuit, so no phase cutting noise at all.

In the end I also fitted a multi coloured LED; blue when off, red when on.

B.t.w., I think over time the term 'PWM' has been wrongly attached to the way that dimmers use a TRIAC. I always learned that that is called 'phase cutting'. A sine wave is not a pulse. A square wave is.

• A portion of a sine wave is most definitely a "pulse", it is just not a rectangular one. What you're doing is not unlike traditional open-loop heater or cooking range controls which cycle by being a self heating switching circuit. The question however hints at closed loop control. In effect, all you've done is restate in crude manner a fraction of Olin's answer of three years ago. – Chris Stratton Oct 6 '20 at 23:14
• @ChrisStratton This answer and Olin's one do overlap substantially - but it appears to be an honest independently arrived at solution and may encourage some people with its '555' approach which is functionally the same as whatever Olin used (probably a PIC). – Russell McMahon Oct 7 '20 at 10:50

You could use PWM through FETs to modulate the mains but it's tuned round the response of your averaging load, a heating element in your case. And with a relatively slow responder like that, PWM's got no advantage over phase control with a triac.

Whereas the advantages of the triac phase control over PWM is that there's only the one current surge per half-cycle and that the circuit in all likelihood will be much simpler.