Hacker News new | ask | show | jobs
by roland35 2223 days ago
PID loops are simple and effective control solutions and are relatively easy to incorporate into embedded controllers as well. Generally I have left out the integration step because it can easily cause instabilities, even with a wind-up preventer.

When things get more complicated like with flight controllers or advanced motor drives PID is not recommended. Another problem I've seen is people gloss over tuning a PID controller properly too.

4 comments

>Generally I have left out the integration step because it can easily cause instabilities, even with a wind-up preventer.

Funny, in automotive we always left out the derivative component not the integral which IMHO is the most useful component of the controller.

Yeah I've usually heard that the derivative component is what gets left out, never heard of leaving out the integral
Yea, I built a ball beam balancing device that torqued the beam using electromagnets (instead of the standard 2nd order system with a motor in the center and fast response). The electromagnets can not 'instantly' change the angle of the beams, and the ball's dynamics lead to overall instability as it rolls around and accelerates faster than the system can respond.. Without a derivative term it would have been impossible to control the system. That being said, the project was deliberately contrived in a way where the effects of the P,I,D terms were observable.
If you have a system without natural dampening and can't tolerate overshoot or oscillation you'd use a bit of D to slow things down.
It does depend on the system you're controlling, often there's a natural integral in there and so you effectively 'shift' everything down one (P acts more like I, D acts like P, and I is a double-integral). Like how PD is fine for the quadcopter control until wind is added to the simulation.
Definitely.

The main price of an integrator is 90 degrees of phase lag; this will harm the stability of many systems but as long as it's kept at a low bandwidth it's usually fine.

The main price of derivative gain is high frequency noise amplification, and so a well designed PID will have a limited bandwidth for the D term as well. For many systems, especially those that are already damped or don't need the extra phase margin, it's not needed or not worth the noise cost.

A quick intuition for this is: d/dx(e^(iwx)) = iw*e^(iwx)... that is, differentiation amplifies higher frequencies more than lower ones.
Right, an integral is a low-pass filter with infinite gain at DC and a derivative is a high-pass filter with gain of 0 (negative infinity dB) at DC; they both have 90 degrees of phase shift.
In high school we nearly always left out the I term because we didn't mathematically verify our controllers, couldn't risk breaking the systems we were controlling with windup, and cared more about smooth and predictable motion than accuracy.
Why did you guys drop the derivative part? I've always found that pretty useful.
> Another problem I've seen is people gloss over tuning a PID controller properly too.

This, a million times. My senior design project in college was building a quadcopter from scratch (including the control software)[1].

We basically built a test harness out of two poles with strings attached to the quadcopter so once we lifted it off, we could just test different PID parameters until it was stable. I think we eventually built an app to vary them in flight, which was definitely a terrible idea, and we crashed many, many quadcopters this way.

I think the answer is basically "build a simulated quadcopter with the same parameters as yours and test parameters in the simulation", but that probably would have been an equivalent senior project... IIRC, this is basically what you have to do for state-variable feedback, so it's much, much more effort than simply do what we did (especially when the cost of failure is low).

The control loop code is actually fairly straightforward [2], it was mapping what exactly the PID controller was controlling to the real world application (turning motors on and off).

[1]: https://github.com/Rose-Hulman-ROBO4xx/1314-BeagleBone-Quadc... [2]: https://github.com/Rose-Hulman-ROBO4xx/1314-BeagleBone-Quadc...

I'm a PID newbie and am wondering if it's the right way to go for a hobby project. My control variable (heat input) and process variable (volume of vapor output) have a fairly laggy and non-linear relationship due to changing mass and composition of working fluid and phase change. Proportional just kind of runs out of steam (har har) near the set point presumably b/c of the non-linearity, and that plus lag really messes with the integral tuning (i basically need two different values for when pv is under or over the setpoint).

Should i keep tinkering or try something different (maybe multiple loops or something?) What's next after PID?

Also this is an ambient pressure system with multiple safety precautions to ensure it stays that way.

PID is popular because it has only three tunable parameters, and you can kind of just turn the knobs until it works. :-)

For a more systematic design, construct a simple mathematical model of your plant. If nothing else, this will allow you to run faster-than-realtime simulations to experiment with parameters. (Thermal time constants are typically annoyingly slow to fiddle with in real time.)

Simulink is an ideal tool for this, but you can just as well use Python or C++. One way to do it is to structure your model as a differential equation and then use a solver to integrate it.

There are several typical lines of attack. Write the plant either as a transfer function and then think about poles and zeros. Write it as coupled first-order linear differential equations and think about state space.

"Feedback systems: An intro for scientists and engineers" by Åstrom and Murray is a popular introductory text. "Feedback control of dynamic systems" by Franklin and Powell is a superb, slightly more advanced college textbook. (The current edition is wildly expensive but older editions are just as good and nearly free.) I also like "Control System Design: An Intro to State-Space Methods" by Friedland (an inexpensive paperback published by Dover).

This is awesome and has got a few ideas flowing already (and a few terms to google). Not only are the simulations faster, i can mess around with them whenever i feel like it. Setting up the 'real deal' is a weekend affair. Fidelity of any simulation i put together will be very questionable for a while but at least it can help me understand how the parameters affect the response.

I really appreciate it! Thanks!

I had to do PID in firmware for some electro-mechanical system that was continuously self-calibrating and ended up only using P and I parts. No derivative.