I need to set a temperature between 20 °C and 300 °C. I am using a PWM output with a resolution of 1% duty cycle. Can the overall PWM period, and PID loop timing, get better than 1% accuracy of the temperature span in the load?
It depends on the time constant of the load. A heated load will often respond in 10s of seconds.
If you generate 30% PWM for one second, then 31% PWM for the next second, that will look like 30.5% averaged over several seconds.
Oven thermostats tend to operate a minute on, a minute off, and still achieve oven temperatures stable to single digits of C. A 1% PWM adjusted once per second could do several orders of magnitude better than that.
Given the fact that relative to other regulations (voltage, current, etc.), temperature regulation is quite slow, what you can do is use a microcontroller (i'm guessing you already do), but add a cyclic variation of the PWM signal's width.
imagine that for your system to be stable, you need to have a pulse width of 3.8%. you simply have to apply a 3% duty cycle during 20% of the time, and 4% during the remaining 80%. doing that over one second or so should allow you to achieve the precision you need.
Oddly worded question, but what I think you are asking is will the temperature of the load increment by 1% steps with a PWM of 1% step resolution. i.e. 2.828C per step.
Although it sounds like it should, the answer to that is probably no.
The reason being, in order for that to happen there needs to be a 1 to 1 relationship between power in and temperature rise in the load. However, depending on the geometry and environment of the load, that is unlikely to be true.
In order to heat something to a specific temperature you need to add in enough power to balance the power the object loses to it's surroundings at that temperature. The problem is, as the temperature rises, the heat transfer efficiency from the surface of what you are heating normally changes too.
For a small temperature range, power to temperature, can be considered almost linear, but 300C is not a small temperature range.
How linear whatever it is you plan on heating is, and how accurate 1% needs to be (i.e. 1% plus or minus what?), is of course, beyond the scope of this question, and answer. But I would suspect you will need to put in a LOT more incremental power to get it up the last 50C than you did to get it up to 70C.
It is very unclear from your question whether you have included temperature sensing in your control loop. I suspect, since you asked the question, that the answer to that is no, hence the focus in this answer.
If you need to set the temperature accurately under all conditions, you really would need to tie that measurement back into the system control loop. At that point you can time vary the PWM modulation to hold the temperature as accurately as you can measure it, all be it with some thermal lag and hysteresis.
But of course, measuring temperature accurately on a large object can be a challenge all to itself.
If your controller, or control algorithm code, can measure the load temperature and keep track of the desired output with better than '1% resolution' (noting that the output to temperature relationship is not linear), then it's possible to achieve much better than 1% effective output resolution by dithering, as Neil_UK's answer suggests. The actual improvement you can manage will depend on how long the load's time constant is relative to your output's cycle time.
If your controller or code can't do this then you will get some fluctuation in the load temperature. For example if the setpoint and the environmental conditions are such that the 'correct' output for the required load temperature would be 30.5% then the closest the output can get is either 30%, in which case the load will cool to slightly below the setpoint, or 31% in which case it will heat to slightly above the setpoint, and only by 'noticing' this deviation in the actual load temperature can the controller alter its output to correct the deviation.
I guess that the size of the fluctuation in the latter case will depend on the proportional and derivative coefficients in your control algorithm, and your task will be (as always) to tune the controller for best accuracy without risking instability or excessive overshoot.
Also, think about what exactly you mean by accuracy. Do you need absolute accuracy (a setpoint of 100 °C gives a controlled value that really is 100 ±0.1 °C) or just stability (the controlled value may stabilise anywhere from 98 to 102 °C but then stays stable to within ±0.1 °C)? Absolute accuracy of temperature measurement is harder to achieve than people assume, but there are many applications where absolute accuracy isn't so critical as long as stability is good.
Most likely yes. I've done exactly what you are asking about in a commercial product.
The reason I say "most likely" instead of just "yes" is that getting higher temperature resolution than the PWM resolution requires the PWM period to be significantly smaller than the dominant thermal time constant. Unless you have a very unusual heater (the filament of a incandescent bulb might be one example), this requirement is going to be met.
I was writing the firmware that controled the current and voltage thru a Xray tube. Higher level logic would specify what the voltage and current were to be, and the job of my firmware was to make it so.
In this case, the tube was only a cathode and anode, with no grid. Beam current was controlled by changing the drive level of the cathode heater. That's about as small and nimble of a heater as it gets, but its time constant was still many milliseconds.
The PWM to the heater was running at multiple kHz, many times faster than any meaningful heater response frequency. Unfortunately, the PWM resolution was too low to achieve some of the desired currents within the desired error tolerance. This was not helped by the function of cathode temperature to beam current being highly non-linear.
If this were the only constraint on the PWM, I could have just increased the PWM period to get higher resolution. However, this processor did a bunch of things, and due to hardware restrictions, the same clock was used for other things and couldn't be changed.
The solution was to implement dithering of the PWM duty cycle. If I remember right, I used 8 different duty cycle values. In this case I could use a DMA engine in the microcontroller to sequence thru the 8 values automatically. The duty cycle setting routine did the math and adjusted 0 to 7 of the values one count higher than the first one.
This effectively provided 8x higher PWM resolution. The PWM period x8 was still short relative to the heater time constant, so the heater was still easily averaging the multiple duty cycle values.
I see Trevor has already touched on this. The temperature of heaters can often be quite non-linear with input power. This is usually due to convection not reacting linearly with temperature, and therefore cooling a hot object disproportionately more than a cooler one. At much higher temperatures, black body radiation becomes significant. Radiated power is also quite non-linear with temperature.
In my case, not only was the cathode predominantly cooled by black body radiation (it was in vacuum), but the function of temperature to beam current was also highly non-linear.
Non-linear systems are difficult to control. Simple means like PID, or anything derived from S-domain analysis don't work well with non-linear systems. If you try, you end up over-damping parts of the range just to maintain stability in other parts of the range. That can lead to unacceptably long settling times in the parts of the range that are over-damped.
The solution I used in this case, and which I've used on a few other projects too, was to linearize the system from the control loop's point of view.
I did this by inserting a piecewise-linear lookup between the controller output and the system input. During manufacturing, the system was run open-loop at a number of set points. The results were used to populate the lookup table stored in non-volatile memory unique to each unit.
The system is still non-linear within any segment of the lookup table. However, these segments are a small fraction of the system's range, so the system characteristics don't change much over one segment. If they do, then use more segments.
The result worked very well. Yes, all this is running in a commercial product you can buy off the shelf today.
Several people already mentioned this, but I'd rather clarify.
Note: if your heater has a built-in electronic temperature control, please jump to the last section of my answer.
PWM does not control temperature of a conventional heater
Instead it controls how much energy is expelled by the heater. If the space heater is in is ideally insulated, constant PWM signal would control how fast temperature increases - until the heater melts itself or its enclosure.
In reality heat is inevitably lost through convection, radiation or other processes, so a stable equilibrium can form: if a heater is heated up to 100% cycle it could be rated to heat to 300°C in some predefined circumstances.
However those circumstances can never be reliable: wind, air pressure, humidity and ambient temperature could skew duty-cycle-to-temperature ratings of your heater.
If your temperatures are very high (higher than about 200°C) you may be able to get away with variations due to outside factors being somewhat negligible, but in that case exact temperature is not very precise anyway, so sub-1% adjustments would not make any sense.
Refer to a temperature sensor
A reliable way to control a temperature would be using a temperature sensor: If desired temperature is higher then sensed one, power the heater at 100% power; if it is lower, cut the power entirely.
The reason for using 100% or no power is that heaters are always reactive, and you most likely want the temperature to reach desired level as fast as possible.
Let's suppose you have a heater that can normally do 20° to 300°C, and you need it to heat up from room temperature to 100°.
If you power it with 30% PWM duty cycle, it will start gaining temperature fast, but then gradually slow down. Depending on type of heater it could take hours before it actually reaches desired temperature. That's because heat loss increases with heat difference, so the last few degrees take the longest.
Instead you should power the heater with 100% of power available to make it reach desired temperature much much faster.
When temperature reaches the desired value you still need to react fast to occasional sudden gust of wind blown on your heater or similar consequences.
Possible PWM application
In some cases a heater, its load, and the sensor may be all be quite reactive, so the circuit may need to predict temperature changes caused by the heater to some extent.
If that is not feasible, feeding the heater with fractional power might be actually useful to make temperature stay at desired level.
In that case exact details (including the answer to your question) may depend on physical parameters of the heater, its load and environment. Or temperature needs to be really really stable.
In those cases a PWM signal does not need to be precise, instead it should still tune itself up and down depending on the probe reading.
Electrical switching concerns
An electric heater may not be designed to work on PWM power. Depending on how exactly is it built it might start vibrating and eventually destroy itself or cause other unforeseen problems.
Almost all heaters consume a lot of power. PWM control thyristors or transistors for such applications can be quite inefficient and require substantial cooling on top of being expensive.
On topic of phase-correct thyristors (for AC), a sub-1% precision may not be achievable reliably with them because AC power may not be a perfect sine.
Some "heaters" may actually be electronic devices that sense temperature and control power themselves. The desired temperature may be set through a PWM signal. Those are rare but it is the only theory that could explain direct relation between duty cycle and temperature.
In this case, answer to your question depends on the heater's built-in control electronics. Precise adjustments described in the question would probably work assuming said electronics is precise enough itself - that fact should be stated in its documentation.
Because almost all such heaters internally work as I described earlier, they often do fairly long on-off-on-off cycles, so actual temperature may fluctuate up and down with time no matter how precise PWM signal is.