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

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.


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.