EmbeddedRelated.com
Forums
The 2026 Embedded Online Conference

PID Without a PhD, Finally

Started by Tim Wescott April 14, 2016
On Mon, 02 May 2016 17:53:31 -0700, Paul Rubin
<no.email@nospam.invalid> wrote:

>John Larkin <jjlarkin@highlandtechnology.com> writes: >> Sure, but it's not generally practical to make a voltage regulator >> using an ADC and a DAC and a lot of code. Analog PID is still useful. > >Voltage regulators typically aren't really PID though, I thought. >More like P without the I or D. > >> We sometimes do temperature controllers as analog PID loops, too. For >> things like crystal ovens. > >That seems like a more interesting application.
This is sort of PID: https://dl.dropboxusercontent.com/u/53724080/Circuits/Power/HV/28S840A_sh6.pdf -- John Larkin Highland Technology, Inc lunatic fringe electronics
On Mon, 02 May 2016 17:53:31 -0700, Paul Rubin wrote:

> John Larkin <jjlarkin@highlandtechnology.com> writes: >> Sure, but it's not generally practical to make a voltage regulator >> using an ADC and a DAC and a lot of code. Analog PID is still useful. > > Voltage regulators typically aren't really PID though, I thought. > More like P without the I or D.
It's been a while since I've watched the turn-on ramp of a voltage regulator. But about 25 years ago, when a 7805 was causing a part to go into CMOS latchup, it had a classic integrator windup then overshoot event on power-up -- that's not behavior you can get from just proportional. I'm pretty sure that even today any precision regulator is going to have a built-in integrator. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
John Larkin wrote:
> On Mon, 2 May 2016 19:07:06 -0500, Les Cargill > <lcargill99@comcast.com> wrote: > >> John Larkin wrote: >>> On Thu, 28 Apr 2016 22:02:08 -0500, Les Cargill >>> <lcargill99@comcast.com> wrote: >>> >>>> John Larkin wrote: >>>>> On Tue, 26 Apr 2016 21:45:06 -0500, Les Cargill >>>>> <lcargill99@comcast.com> wrote: >>>>> >>>>>> John Larkin wrote: >>>>>>> On Thu, 14 Apr 2016 19:09:26 -0400, DJ Delorie <dj@delorie.com> wrote: >>>>>>> >>>>>>>> >>>>>>>> You leave out math but include C code, I think that's defeating the >>>>>>>> purpose. If you can't explain it in non-technical words or a simple >>>>>>>> picture... well, try harder :-) >>>>>>>> >>>>>>>> You spend only one page on tuning, and give no examples of "If you see >>>>>>>> this, try this" which is much more useful to the practical user. >>>>>>> >>>>>>> >>>>>>> Engineers tend to do >>>>>>> >>>>>>> Actuator = error * (Kp + Ki + Kd) >>>>>>> >>>>>> >>>>>> Uhhhhh... no. >>>>>> >>>>>> Actuator = (error * Kp) >>>>>> + ( filter1(sum(error)) * Ki ) >>>>>> + ( filter2(delta(error,lastError)) * Kd) >>>>>> >>>>>>> whereas old-time analog controllers did >>>>>>> >>>>>>> Actuator = Kp * (1 + Ki + Kd) >>>>>>> >>>>>>> with the idea being that it's easier to tune on-site. >>>>>>> >>>>>>> >>>>>> >>>>>> Because trimpots are awesome. >>>>> >>>>> Oh, you know what I mean. Old-time analog PID controllers often used a >>>>> different sigal flow path than sum-of-terms. >>>>> >>>>> >>>> >>>> Oh, I'm sure. I haven't done anything directly with analog >>>> PID other than read about them. >>> >>> We do it all the time on boards: voltage regulator loops, power amps, >>> that sort of thing. >>> >>> >> >> Unlike PIDs, most of those should have a pretty simple method for >> figuring out it's at balance. > > Things like output impedance, loop stability, line and load transient > regulation sometimes matter. >
My understanding is that almost all those things are run well in the very linear operating region these days. But I've not dealt too much with load transients. Heck, I've go at least three amplifiers around here that turn themselves off if you short the output. Done by microprocessor. A nice feature.
>> >> I dunno, I've made some things self-calibrating in software lately. >> I like that better. > > Sure, but it's not generally practical to make a voltage regulator > using an ADC and a DAC and a lot of code. Analog PID is still useful. >
Analog PID is fine. It's probably the most common way, really. You won't beat it for size weight and power ( and cost) . But the software voltage regulator might be a thing soon.
> We sometimes do temperature controllers as analog PID loops, too. For > things like crystal ovens. > > >
Sure. The chambers we used to have all ran PID control. -- Les Cargill
On 05/02/2016 11:31 PM, Tim Wescott wrote:
> On Mon, 02 May 2016 17:53:31 -0700, Paul Rubin wrote: > >> John Larkin <jjlarkin@highlandtechnology.com> writes: >>> Sure, but it's not generally practical to make a voltage regulator >>> using an ADC and a DAC and a lot of code. Analog PID is still useful. >> >> Voltage regulators typically aren't really PID though, I thought. >> More like P without the I or D. > > It's been a while since I've watched the turn-on ramp of a voltage > regulator. But about 25 years ago, when a 7805 was causing a part to go > into CMOS latchup, it had a classic integrator windup then overshoot > event on power-up -- that's not behavior you can get from just > proportional. > > I'm pretty sure that even today any precision regulator is going to have > a built-in integrator. >
Well, it'll have dominant-pole compensation, anyway. I very much doubt that that was integrator windup, because the slowest thing in the loop is not the actuator (pass transistor), it's the output filter cap. Thus there's nothing corresponding to overspeeding a motor. It sounds to me like ordinary slew limiting followed by an underdamped transient response. ISTM that fixed-coefficient PID is merely a subset of the usual frequency-compensation problem for amplifiers, with the addition of windup control. Separate P, I, and D knobs are convenient for manual tuning, of course, but they're pretty limiting compared to what you can do with RC networks and op amps. IME PLLs are generally a lot harder to compensate well than (small) temperature control loops, at least once the nonlinearity is removed. Cheers Phil Hobbs -- Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net
On Mon, 02 May 2016 22:31:36 -0500, Tim Wescott
<seemywebsite@myfooter.really> wrote:

>On Mon, 02 May 2016 17:53:31 -0700, Paul Rubin wrote: > >> John Larkin <jjlarkin@highlandtechnology.com> writes: >>> Sure, but it's not generally practical to make a voltage regulator >>> using an ADC and a DAC and a lot of code. Analog PID is still useful. >> >> Voltage regulators typically aren't really PID though, I thought. >> More like P without the I or D. > >It's been a while since I've watched the turn-on ramp of a voltage >regulator. But about 25 years ago, when a 7805 was causing a part to go >into CMOS latchup, it had a classic integrator windup then overshoot >event on power-up -- that's not behavior you can get from just >proportional. > >I'm pretty sure that even today any precision regulator is going to have >a built-in integrator.
Not a true integrator, but close, a bunch of gain with a rolloff. Voltage regulators have the problem that they may dump into all sorts of capacitive loads with various ESRs, or some weird combination of, say, electrolytics in parallel with ceramics. A programmable reg also has a loop gain that varies with the programmed voltage. If you are lucky, the data sheet will have a map of the safe zone of C and ESR, where the reg is stable, but it could still have a bit of overshoot if the input is applied suddenly. And the load capacitance includes all the bypass caps on other sheets of the schematic. If you are lucky, you'll have a useful Spice model. If not, breadboard and scope the damping of the load step response. For a 3t reg, like an LM317 or an 1117, it is often useful to separately bypass the ADJ pin to ground. -- John Larkin Highland Technology, Inc lunatic fringe electronics
In article <87vb2wdklf.fsf@nightsong.com>, no.email@nospam.invalid 
says...
> > John Larkin <jjlarkin@highlandtechnology.com> writes: > > Sometimes the only practical way to design a temperature control loop > > is by breadboarding it; the thermal structure can be too fuzzy to even > > simulate. > > I wonder how close you can come by sticking temperature sensors all over > the place during development. Then apply heat in a single place and see > how the temperature map evolves over time; then move the heat source to > another place and repeat, etc. The idea is to get enough info to let > you simulate the system accurately using basic thermo equations.
BTDTGTS _sometimes_ you can do that but often this is a SYSTEM based problem, involving many aspects and best guesses can be made but until a complete system is built the thermal and other effects of adjacent components affect the whole system. I remember a light box for behind some very high brightness LCD screens (4 x 11W fluorescent tubes and their holders), that required fan cooling. The thermal properties got difficult to model, depending on things like slight change of positioning of cabling, of the tube holders let alone slight changes in fan position or ducting or variations between fans. Then we get to heat profile, measured by array of thermistors, that varied depending on how tight the mounting screws of the light box secured it to the frame. Trying to work best way to run 12 thermistor cables to avoid interrupting air flow or changing effects was 'interesting'. -- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.pcserviceselectronics.co.uk/pi/> Raspberry Pi Add-ons <http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font <http://www.badweb.org.uk/> For those web sites you hate
On Mon, 2 May 2016 23:23:31 -0500, Les Cargill
<lcargill99@comcast.com> wrote:

>John Larkin wrote: >> On Mon, 2 May 2016 19:07:06 -0500, Les Cargill >> <lcargill99@comcast.com> wrote: >> >>> John Larkin wrote: >>>> On Thu, 28 Apr 2016 22:02:08 -0500, Les Cargill >>>> <lcargill99@comcast.com> wrote: >>>> >>>>> John Larkin wrote: >>>>>> On Tue, 26 Apr 2016 21:45:06 -0500, Les Cargill >>>>>> <lcargill99@comcast.com> wrote: >>>>>> >>>>>>> John Larkin wrote: >>>>>>>> On Thu, 14 Apr 2016 19:09:26 -0400, DJ Delorie <dj@delorie.com> wrote: >>>>>>>> >>>>>>>>> >>>>>>>>> You leave out math but include C code, I think that's defeating the >>>>>>>>> purpose. If you can't explain it in non-technical words or a simple >>>>>>>>> picture... well, try harder :-) >>>>>>>>> >>>>>>>>> You spend only one page on tuning, and give no examples of "If you see >>>>>>>>> this, try this" which is much more useful to the practical user. >>>>>>>> >>>>>>>> >>>>>>>> Engineers tend to do >>>>>>>> >>>>>>>> Actuator = error * (Kp + Ki + Kd) >>>>>>>> >>>>>>> >>>>>>> Uhhhhh... no. >>>>>>> >>>>>>> Actuator = (error * Kp) >>>>>>> + ( filter1(sum(error)) * Ki ) >>>>>>> + ( filter2(delta(error,lastError)) * Kd) >>>>>>> >>>>>>>> whereas old-time analog controllers did >>>>>>>> >>>>>>>> Actuator = Kp * (1 + Ki + Kd) >>>>>>>> >>>>>>>> with the idea being that it's easier to tune on-site. >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> Because trimpots are awesome. >>>>>> >>>>>> Oh, you know what I mean. Old-time analog PID controllers often used a >>>>>> different sigal flow path than sum-of-terms. >>>>>> >>>>>> >>>>> >>>>> Oh, I'm sure. I haven't done anything directly with analog >>>>> PID other than read about them. >>>> >>>> We do it all the time on boards: voltage regulator loops, power amps, >>>> that sort of thing. >>>> >>>> >>> >>> Unlike PIDs, most of those should have a pretty simple method for >>> figuring out it's at balance. >> >> Things like output impedance, loop stability, line and load transient >> regulation sometimes matter. >> > >My understanding is that almost all those things are run well in the >very linear operating region these days. But I've not dealt too much >with load transients.
Voltage regulators have an annoying affection for oscillating, especially LDO types that have high open-loop output impedance, namely ones that drive the load from a collector or a drain. The oscillation waveform is usually a triangle, very nonlinear. Older data sheets, and many newer ones, only hint at stability issues. This was kind of fun: https://dl.dropboxusercontent.com/u/53724080/Circuits/LDO/TEM2_LDOs.jpg https://dl.dropboxusercontent.com/u/53724080/Circuits/LDO/TEM2_LDO_parts.JPG Those regs are only dropping tenths of a volt, so the mosfets are really controlled resistors. Loop dynamics varies with current. -- John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com
On Mon, 02 May 2016 17:57:32 -0700, Paul Rubin wrote:

> John Larkin <jjlarkin@highlandtechnology.com> writes: >> Sometimes the only practical way to design a temperature control loop >> is by breadboarding it; the thermal structure can be too fuzzy to even >> simulate. > > I wonder how close you can come by sticking temperature sensors all over > the place during development. Then apply heat in a single place and see > how the temperature map evolves over time; then move the heat source to > another place and repeat, etc. The idea is to get enough info to let > you simulate the system accurately using basic thermo equations.
If the question you want to answer is "now that I have it, how to I control it", then you can do swept-sine or step-input tests for system identification, and then design your controller from that. I prefer swept-sine measurements followed by design based on Bode plots. I like them because they're valid for any linear system, even ones that have distributed states, and because -- to an extent -- you can take nonlinearities into account as part of your control design. <http://wescottdesign.com/articles/FreqMeas/freq_meas.html> -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On Tue, 03 May 2016 17:23:24 -0500, Tim Wescott
<seemywebsite@myfooter.really> wrote:

>On Mon, 02 May 2016 17:57:32 -0700, Paul Rubin wrote: > >> John Larkin <jjlarkin@highlandtechnology.com> writes: >>> Sometimes the only practical way to design a temperature control loop >>> is by breadboarding it; the thermal structure can be too fuzzy to even >>> simulate. >> >> I wonder how close you can come by sticking temperature sensors all over >> the place during development. Then apply heat in a single place and see >> how the temperature map evolves over time; then move the heat source to >> another place and repeat, etc. The idea is to get enough info to let >> you simulate the system accurately using basic thermo equations. > >If the question you want to answer is "now that I have it, how to I >control it", then you can do swept-sine or step-input tests for system >identification, and then design your controller from that. > >I prefer swept-sine measurements followed by design based on Bode plots. >I like them because they're valid for any linear system, even ones that >have distributed states, and because -- to an extent -- you can take >nonlinearities into account as part of your control design. > ><http://wescottdesign.com/articles/FreqMeas/freq_meas.html>
A thermal system might have milliHertz responses, heater to sensor. I find it easier to measure the step response, which still might take many minutes to settle, and hack up an RC network model that simulates like the hardware. Diffusion is involved, so it might need a lot of RCs. The biggest nonlinearity in a closed-loop heater is railing the driver output at 0 and 100%. And there is a square-law heater response if you use a simple voltage drive. -- John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com
On Tue, 03 May 2016 17:07:28 -0700, John Larkin wrote:

> On Tue, 03 May 2016 17:23:24 -0500, Tim Wescott > <seemywebsite@myfooter.really> wrote: > >>On Mon, 02 May 2016 17:57:32 -0700, Paul Rubin wrote: >> >>> John Larkin <jjlarkin@highlandtechnology.com> writes: >>>> Sometimes the only practical way to design a temperature control loop >>>> is by breadboarding it; the thermal structure can be too fuzzy to >>>> even simulate. >>> >>> I wonder how close you can come by sticking temperature sensors all >>> over the place during development. Then apply heat in a single place >>> and see how the temperature map evolves over time; then move the heat >>> source to another place and repeat, etc. The idea is to get enough >>> info to let you simulate the system accurately using basic thermo >>> equations. >> >>If the question you want to answer is "now that I have it, how to I >>control it", then you can do swept-sine or step-input tests for system >>identification, and then design your controller from that. >> >>I prefer swept-sine measurements followed by design based on Bode plots. >>I like them because they're valid for any linear system, even ones that >>have distributed states, and because -- to an extent -- you can take >>nonlinearities into account as part of your control design. >> >><http://wescottdesign.com/articles/FreqMeas/freq_meas.html> > > > A thermal system might have milliHertz responses, heater to sensor. I > find it easier to measure the step response, which still might take many > minutes to settle, and hack up an RC network model that simulates like > the hardware. Diffusion is involved, so it might need a lot of RCs. > > The biggest nonlinearity in a closed-loop heater is railing the driver > output at 0 and 100%. And there is a square-law heater response if you > use a simple voltage drive.
Most swept-sine measurement systems (I have one that I compile in with any serious control code in my embedded stuff) will run a measurement unattended. Just leave a yellow card with "test in progress" on the thing and go have a nice lunch. There's formal methods for extracting parameters from a step response, but if your accuracy need isn't super-stringent then eyeballing it with RC networks isn't a bad way to go. Yes on the nonlinearity, although if it's not going to batter the power supply too much then a simple slow PWM to the heating element will take care of that right off, or use the pass transistor for the heating element (which is easy if you're talking about incubating eggs, but challenging if you're melting tungsten). -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
The 2026 Embedded Online Conference