# Designing a controller with hard output limits

I'm trying to put together a control algorithm to use a heater to drive a 2nd order thermal system to the target temperature as quickly as possible. I've done a nice state-space model with an extra integrator to drive static error to 0, and picked my target poles, and get a lovely linear controller that would work if I could ask the heater to transiently provide a) truly insane amounts of power and b) cooling.

Neither of these being possible, what I need is a controller that gracefully handles the transition between railing the output at max power and moving back into a linear control mode without trying to overshoot back through 0. Just clamping the output of the linear system is very wrong; my simulations are grotesque.

Hard limits on what the output actuator can do has got to be the most common control non-linearity there is. But the moment I get outside linear controller design everything gets nebulous; discussions of a dozen different techniques with no discussion of how to align technique to problem.

Can anyone point me at "the right way" (or oh please the easy way) to design a controller where the output has hard limits, but the system is otherwise linear? Ultimate implementation will be digital with a sample rate of Hz and time-constants of minutes, so compute cycles are freely available and time quantization effects are negligible.

Gory Simulation Details

The thermal system I'm simulating looks like this, where the current source represents heater power, and voltages are temperature rise above ambient. One interesting thing is that the difference between e1 and e2 is proportional to the derivative at e2.

Simulation with heater power magical (green) and realizable (blue) looks like this:

And the results at e2 (the temperature I'm trying to control):

Finally, the integrator with anti-windup. Allowing the integrator to wind out farther makes the resulting overshoot at e2 worse; the 5k value was chosen to give some room for ambient temperature variation. Node looks like this:

• You don't say how your simulations are grotesque. Plots would help. Sep 16 at 21:11
• I really want to answer, but I only suspect I know what's going on. Probably the integrator that you're winding up is one of the internal states in your plant -- i.e., the thermal mass close to the heating element, or the heating element itself. The solution to that is to either measure that state and use inner & outer loops, with limiting on the inner state, or to estimate that state & ditto. Sep 16 at 21:12
• @TimWescott good to hear from you, haven't seen you since the comp.dsp days. I've tacked on the simulation data. I poked and prodded the model and cleaned it up a bit, which took some of the rail-to-rail slamming behavior out, but it still overshoots pretty wildly. Sep 17 at 0:53
• I'm gonna address this when I have time -- in the mean time, don't feel you need to change your schematic, but R1 should go to a voltage corresponding to ambient temperature, and it should maybe be split between the one you have, and one in parallel with C2 that also goes to that same ambient temperature. Sep 17 at 15:30

Hard limits on what the output actuator can do has got to be the most common control non-linearity there is.

The search term that'll get you hits on academic papers is "actuator saturation".

But the moment I get outside linear controller design everything gets nebulous; discussions of a dozen different techniques with no discussion of how to align technique to problem.

That's because it's a difficult problem. It's easy to assume that because the distinction is often "linear" vs. "nonlinear" that each realm offers about the same effort. It's more like out of all possible ways of viewing systems, linear time-invariant systems is one tiny slice (arguably so small that it doesn't even encompass anything real). Everything else is nonlinear.

Linear systems theory makes analysis and even synthesis really easy. There are some equally tiny wedges of the overall set of "the rest" that also make analysis and sometimes synthesis easy -- but that just leaves the rest of nonlinear control. If I could draw good cartoons, I'd hand you a Venn diagram, with dragons in the "general nonlinear control" problem part.

Can anyone point me at "the right way" (or oh please the easy way) to design a controller where the output has hard limits, but the system is otherwise linear?

Well, not in general. But in this specific case, there's some approaches you can take, starting easy and ending up hard.

The easiest, if you can actually measure it, is to measure the temperature corresponding to your $$e_1$$, and limit it based on the difference between your final temperature ($$e_2$$) and the target temperature. It's the thermal mass corresponding to C1 that's getting heat-soaked and causing the overshoot when you cut off power to the heater. This won't give you the fastest settling, but it'll get you pretty close, and let you control the overshoot until it's arbitrarily small (you won't get rid of the overshoot because you have an integrator in there -- but making it arbitrarily small, at the cost of making it take longer to settle, is within your power).

Second-easiest is do what I just said, but estimate $$e_1$$ from the rate of rise of $$e_2$$. Basically, differentiate $$e_2$$ with a band-limited differentiator, have an inner loop that controls on that based on the difference between $$e_2$$ and your target temperature, again with limiting.

Hardest -- and I'm going to leave this as an exercise to the reader -- is to dig into simple optimal control theory a bit. Take the 2nd-order differential equation of your system with $$e_1$$ and $$e_2$$ as your states, and find the bang-bang solution that will make them settle out as fast as possible. For any two temperatures at $$e_1$$ and $$e_2$$, the "optimal" (in the settling time sense) control will involve a simple three-step sequence: (1) full on (or off), (2) full off (or on), (3) go to just exactly the right value to hold temperature.

You may want to search on "sliding mode control" for solutions to the above-suggested technique. I think if I used a textbook sliding-mode controller I'd have it sense when it was within some small offset from the ideal temperature and transition to linear control -- a "true" sliding mode controller would just chatter, always driving the heater full on or full off. (But then -- it's a heater, so if it works to do that, it won't be less efficient than trying to drive it partially).