Top
Best
New

Posted by dhorthy 4 days ago

Proportional-Integral-Derivative (PID) controllers(en.wikipedia.org)
122 points | 62 comments
chrisb 2 days ago|
For a robotic BLDC motor velocity control application, I moved to using a linear ADRC (Active Disturbance Rejection Control) [0] controller. It is not much more complex to implement that a PID, but at least in my context it handles changing real-world environmental conditions with a correctness which I could not achieve with a PID however much I tried to tune it.

Still uses a PID for BLDC motor coil current control, as this control loop is much more predictable.

Currently using the proportional part only from a PID for position control, but this may change in the future.

[0] https://en.wikipedia.org/wiki/Active_disturbance_rejection_c... (although this isn't a very useful reference if you want the implementation maths!)

qsera 2 days ago|
I once tried to make a RC toy car so that it has proportional speed controls. I used some hall effect sensors to measure the speed at which the wheels are rotating and used it to compute the PWM signal that should be fed to the motor.

But the interference from the PWM signal appeared to mess with the speed sensor readouts that I couldn't make it work.

Can what you describe be used to solve it? If you would be kind enough to describe it, that would be great.

chrisb 2 days ago||
I use an MT6701 magnetic rotary sensor mounted on the motor shaft, running in AB[Z] mode. This is used to measure the angle of the motor, and generate the correct PWM signals for the three motor coils. My inner current-control loop runs at 15kHz, using a PI controller.
_kulang 3 days ago||
The fascination of programmer types with classical control and estimation topics is endlessly interesting as someone who studied control and estimation and hangs out here for interest in the programming. For me it was surprising to see that JEPA is a model predictive control algorithm it an almost literal sense; I guess I’m happy to have studied what I chose when I was 18.
fcatalan 3 days ago||
I signed up for one of the first MOOCs ever, about self driving cars by Sebastian Thrun, and of course PID was part of the curriculum.

I think that PID hits a certain sweet spot between cleverness, ease of implementation and practical utility that makes it catnip for the typical programmer's mind.

I liked it so much that when we had to implement it, I downloaded an open source driving simulator to see it work there instead of the simpler python environment we were using.

Animats 2 days ago|||
> I think that PID hits a certain sweet spot between cleverness, ease of implementation and practical utility that makes it catnip for the typical programmer's mind.

It's easy to implement, but hard to tune.

PID controllers can be built from analog pneumatic components, and often are.[1] This predates computer control. The I term is called "Reset" and the D term is called "Rate" in classical control.

[1] https://control.com/textbook/closed-loop-control/pneumatic-p...

airbreather 2 days ago||
Pretty easy to tune really - almost never use derivative, increase the proportional until oscillations occur then halve it, add a little integral, not so much it oscillates.
_kulang 3 days ago||||
It’s very intuitively appealing. We like it at my university for teaching first years how to build a line following robot. It’s one of the first times you can get students to really get that “ah” moment when they realise what they can do with code—it can affect the real world!
brcmthrowaway 3 days ago|||
Whatever happened to this guy?

Sounds like he made a bag with the first AI craze and retired.

YeGoblynQueenne 2 days ago|||
>> For me it was surprising to see that JEPA is a model predictive control algorithm it an almost literal sense; I guess I’m happy to have studied what I chose when I was 18.

It's sold as something completely different though that will revolutionize autonomous decision-making which it clearly isn't, it's just trying to re-invent the wheel but with neural nets this time around.

I'll confess I didn't understand what you meant with the part of your comment after the semi-colon.

nemoniac 3 days ago|||
This classic programming text book discusses computational analogs of the "signals" in signal-processing systems.

https://mitp-content-server.mit.edu/books/content/sectbyfn/b...

jrflo 3 days ago||
Yeah, kind of hilarious to me that this was posted here. I suppose if you’ve never encountered control systems at all before they are quite simple, elegant, and cool, but I’m surprised any technical person hasn’t come across them at some point.
_kulang 3 days ago|||
I think CS degrees are a bit light on classical theory in the modern day. In Australia CS degrees are what they say on the tin, but in America it seems almost as if CS degrees are anywhere from cybernetics to pure software development
stldev 2 days ago|||
Interesting generalization; that’s almost the opposite of my experience.

A common hiring anecdote we share with people outside tech is literally: “A CS degree doesn’t teach you how to code.”

For me, ~25 years ago in the UC system, it was all math/science/theory-oriented. Some C++/Java that was introduced to get you through all that theory. Learning how to code/actual software engineering comes with practical experience.

dcrazy 2 days ago||
My CS degree was a software engineering degree in a trench coat. I went back to give a guest lecture a decade later and the curriculum had changed to be more theory-focused.

(I am quite happy to have gotten the software engineering education.)

marcellus23 2 days ago|||
That hasn’t been my experience in the US, either personally or from talking to others who took CS degrees.

Keep in mind that plenty of people on HN and in the industry did not take CS degrees in college. We did learn about PIDs, if briefly.

dang 2 days ago||||
I wouldn't underestimate the value of introductory submissions! Every topic is familiar to some users, no topic is familiar to all users, and let's not forget that newcomers, who still have everything to learn, are particularly welcome.
BenjiWiebe 2 days ago||||
I've encountered control systems and PID controls, and I still find PID elegant and cool.
fragmede 3 days ago|||
https://xkcd.com/1053/
dredmorbius 2 days ago||
Also <https://xkcd.com/2501/>.
dvh 3 days ago||
I used it in metal detector (direct frequency measurement kind). It works really well. I (and you probably too) half assed pid controllers before you even know what it is. But it makes perfect sense. Proportional part reacts to the acute difference, derivative adjusts it when your controller is already going right direction to limit overshoot, and integral part improves cases when the difference is small but persist for long time. Learn them and use them, they're good tool.
londons_explore 3 days ago|
Almost always a good analysis will find a control strategy which performs better than PID...

But the benefit of PID is it is fairly easy to tune and works in a really wide range of situations.

laxisOp 2 days ago||
And it is most of the time not overkill
somat 2 days ago||
My personal exposure to the PID algorithm was my GPU fan. There is supposed to be some sort of internal fan curve to control it's speed but mine was not working, crashes everywhere. I Could still set the speed by hand. and while I was putting together a sort of hacky user space fan curve I had an epiphany. I Don't actually want a fan curve. I want to set an ideal temperature and have the computer figure out what fan speed is needed to maintain it. So I learned more about control logic than I was really prepared for and my user space fan speed script has a cute little PID controller to do just that. (technically for fan thermals you really only need a PD controller. No anticipatory preload needed. but who's counting)

I do sort of suspect a fan thermal control curve is a PID response curve written out in long hand but don't really have the math to prove it.

sz4kerto 2 days ago||
> I do sort of suspect a fan thermal control curve is a PID response curve written out in long hand but don't really have the math to prove it.

No, a fan response curve is kinda-sorta a P controller. It does not take into account 1) how quickly the temperature is rising or dropping (D) 2) the time passed since the system has drifted from the target temp (I).

RetroTechie 2 days ago|||
That might have been easier solved with eg. an adjustable voltage regulator (like good 'ol LM317?) with a temperature sensor in the feedback circuit.

No futzing with software needed.

Reminds me of Dave "EEVblog" Jones' in his "always give negative feedback" T-shirt.

(for those who don't know: it's a reference to opamps)

NooneAtAll3 2 days ago||
why not just set maximum speed and forget about it?
crote 2 days ago|||
Fan noise.

My computer sits next to my desk, so I want it to be as quiet as possible. This means the fan should run as the lowest speed which maintains a reasonable temperature, so at the very least there should be some kind of mapping between temperature and fan speed.

However, a rapidly-changing fan speed results in a more annoying sound than a slightly faster fan, and chip temperatures can ramp fast, so a simple linear mapping between temperature and fan speed isn't enough. To get a quiet fan in an environment where you are, say, loading the CPU to 100% for 100ms every second, the fan controller should be able to average out the heat production and let the fan run at a steady speed. After all, the cooler is a big chunk of metal, so its temperature will never ramp as fast as the core itself, so a rapid fan speed response is pointless.

cadamsdotcom 2 days ago|||
There are two types of nerd - one who optimized fan speeds and one who just lets ‘er rip for max compute ;)
boguscoder 3 days ago||
Honest question: are wiki links to any technical topic post worthy now?
nairboon 2 days ago||
At least for me, it's not about the wiki link. I'm here for the comments, the stories, anecdotes, related deep Diving links and general chit chat. If you view the link as "this is the control systems thread for today", all the upvoter make a lot more sense.
jitl 2 days ago||
yeah, this is the true gold of hacker news: learn about a new concept from the post, and then have knowledge multiplied by discussion across a range of experience levels from curious readers, to daily practitioners, and sometimes even p99.99 top experts in a field.
emil-lp 3 days ago|||
I think you can post more or less whatever you want.

Whether it gets upvoted depends on a lot of things.

For example, I will upvote this submission, but not your comment.

srean 3 days ago|||
Why the hell not ?

I still learn a lot from wikipedia. Maybe it's not useful for those who are experts in every thing. I am not one of them.

sph 2 days ago||
Sometimes even wiki links to non-technical, obscure articles.

Not that I am complaining, I come to this place to learn cool stuff, and there isn’t enough of it.

RossBencina 3 days ago||
Obligatory link to PID without a PhD: https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pd...
jitl 2 days ago||
comments like this are why i come to hacker news
kamranjon 3 days ago||
thank you!
ahartmetz 2 days ago||
I did a lab exercise (part of physics curriculum) with a PID controller once. It controlled a small electric motor with a small flywheel (i.e. not much inertia). We hand-tuned the parameters with potentiometers. The effect was quite impressive: the flywheel kept spinning at the same speed when we touched it, even with moderate force. It felt like there was a huge motor driving it because the RPM just wouldn't budge. It was still not hard to stop it completely (small motor after all), but it felt very stiff before that point.
zbentley 2 days ago||
Thanks to the advice of a colleague who had studied control theory, I once used PID controllers to manage autoscaling compute resources downstream of a lot of message queues. We used plenty of more typical autoscaling systems too, but for some workloads, PID controllers were ideal—when we had thousands of compute clusters across many queues, they minimized the state that needed to be stored between scaling system polls while effectively smoothing out the scale up/down rate to minimize resource waste and pointless whipsawing.
scary-size 1 day ago||
„How To Build a Thrust Vectored Model Rocket“ has a good section on this IIRC: https://www.youtube.com/watch?v=4cw9K9yuIyU
YuechenLi 1 day ago|
I think the more valuable topic to study is feedback control loop in general as a part of control theory: gain, stability/oscillation damping, overshoot, hysteresis/minimum commit, and noise filtering strategies (low pass, Kalman, etc). Those are just very useful general concepts applicable to any kind of long running systems.

The actual PID controllers ,however, are actually really finicky to tune, and hard to reason about directly. Good for simple linear systems, but it falls apart as real life systems tend to be complex and nonlinear.

More comments...