8
\$\begingroup\$

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?

\$\endgroup\$
5
  • 10
    \$\begingroup\$ You should refine your 1% temperature accuracy definition. Suppose I rewrite your 20 C to 300 C to 293 Kelvin to 573 K then 1% is a different number. If there is a (long) time constant (thermal mass) present in your device I would say yes you can get better accuracy since that would average the value you apply so given enough time any accuracy can be achieved. \$\endgroup\$ – Bimpelrekkie Nov 22 '17 at 13:45
  • \$\begingroup\$ Are you specifically working with a solid state relay with zero-current-turn-of and 50/60 Hz mains AC powering the heater? \$\endgroup\$ – DeusXMachina Nov 22 '17 at 20:35
  • \$\begingroup\$ Depending on thermal masses, on/off control is probably good enough \$\endgroup\$ – Scott Seidman Nov 22 '17 at 21:41
  • \$\begingroup\$ I don't know about PID controllers but I wrote an application to control a potting curing oven for my work which regulates using 30s PWM period with 1s resolution that's able to maintain temperatures to within 1-2°C of the target temperature (generally around 80°C) this is controlled using a SSR, has a 2KW heating element and a fan to circulate air. Code is available at bitbucket.org/snippets/gds-uk/qj9yE/oven-controller if you're interested. \$\endgroup\$ – RobbG Nov 23 '17 at 10:49
  • \$\begingroup\$ Also note that the thermal conductivity of your load varies: unless it's a stirred liquid or something very tiny there will probably be more than 1% variation in temperature across the load. \$\endgroup\$ – pjc50 Nov 23 '17 at 11:16
21
\$\begingroup\$

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.

\$\endgroup\$
3
  • 8
    \$\begingroup\$ I'd call this 'dithering', after the equivalent technique to increase colour depth in computer graphics, but don't know how common it is to call it that. \$\endgroup\$ – Pete Kirkham Nov 22 '17 at 14:27
  • 1
    \$\begingroup\$ I found myself using the same exact terminology, so I think it cannot be that far off the mark. \$\endgroup\$ – DeusXMachina Nov 22 '17 at 20:31
  • 1
    \$\begingroup\$ @PeteKirkham I usually call it dithering. \$\endgroup\$ – winny Nov 23 '17 at 9:17
9
\$\begingroup\$

Yes.

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.

\$\endgroup\$
7
\$\begingroup\$

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.

enter image description here

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.

ADDITION

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.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Thanks. But to be fair I will add a bit of info I omitted, which is that 100% PWM yields 300degC. Of course, your answer then really applies to the bottom end of the scale \$\endgroup\$ – Dirk Bruere Nov 22 '17 at 16:34
  • \$\begingroup\$ @DirkBruere it's easy enough to test. Set it to 50% and measure the temp :) \$\endgroup\$ – Trevor_G Nov 22 '17 at 16:44
  • \$\begingroup\$ It will definitely be non linear \$\endgroup\$ – Dirk Bruere Nov 22 '17 at 16:47
  • \$\begingroup\$ NO as a straight answer is probably incorrect. See Neil_UK`s answer, that can be summarized as "yes, under precise but pretty common circumstances". Home oven is perfect example. \$\endgroup\$ – Caterpillaraoz Nov 23 '17 at 13:40
  • \$\begingroup\$ @Caterpillaraoz Ya I guess.. though I already do qualify it in the next sentence. Anyhow, it does not need to be there.. gonzo. Thanks for the feedback. \$\endgroup\$ – Trevor_G Nov 23 '17 at 13:46
6
\$\begingroup\$

It depends.

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.

\$\endgroup\$
3
  • \$\begingroup\$ +1 I agree with this and all the answers here, but nowhere in the OP's question does he indicate that this is a closed loop system, that is, with temperature feedback. That is just something everyone assumed because that is how THEY would have done it. \$\endgroup\$ – Trevor_G Nov 23 '17 at 14:19
  • \$\begingroup\$ @Trevor the title says in a PID heater loop. \$\endgroup\$ – nekomatic Nov 23 '17 at 14:25
  • \$\begingroup\$ Yes it does, but that could mean anything, or nothing. I suspect the OP is not temperature sensing, or can't do it accurately, or this question would be a non-starter. BUt without verification... who knows. \$\endgroup\$ – Trevor_G Nov 23 '17 at 14:29
6
\$\begingroup\$

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.

Real example

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.

Non-linearity

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.

\$\endgroup\$
2
\$\begingroup\$

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.

Electronically-controlled heaters

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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