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?
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:
- "Cutting" the phase (commonly used for light dimming). In this case you have to synchronize your control with the zero crossing of AC waveform.
- 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).
- "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.
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.
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.