Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If only the site explained wtf a PID controller was ...


This is probably not necessary here but I'll try anyway.

PID is a control loop algorithm: something which takes a desired value and an actual value from a sensor, and outputs something to some kind of actuator to try and get the actual value to match the desired value.

A simple example of a control loop algorithm is the "bang-bang" algorithm used by your thermostat. When it's too cold the furnace turns on, and when it's too hot the furnace turns off.

PID was discovered by observing boat helmspeople. It was observed that there are three major factors in their decision of how to turn the boat's wheel (the P, I, and D respectively).

First, they set the wheel to approximately where they think it needs to be to achieve the desired angle. That's the P, or proportional part.

Then they note the cumulative error over time, i.e. the distance away from the desired angle summed up over each moment that they are still waiting. As the cumulative error rises, they turn the wheel a bit further to compensate. This is the I, or integral term, which accommodates conditions where the controls are particularly dull, causing the proportional control to undershoot.

Finally they observe the rate at which they are approaching the desired angle and compensate negatively if they are approaching it more quickly than they expected. This is the D (derivative) term, which accommodates conditions where the controls are particularly sensitive and the proportional control overshoots.

PID just adds these three terms together with weights chosen for the specific application. Choosing those weights is the tuning process.


I made myself the work and created a very basic ClosedFeedbackLoop Example for java, for anyone that might want to try it out. It's old and has terrible documentation, but I also haven't touched it in quite some time. Either way, here it is:

https://github.com/RicardoMonteiroSimoes/ClosedLoopControlBl...

It contains several blocks,P,I,D,PID,PT1 and PT2, basically the ones that were teached to me


Thanks, I missed this explanation years ago when I studied industrial control systems! I truly appreciate it.

Though I wonder if that's me that got older and have better understanding of things that I now think I get it, or is it your explanation. Probably both.


In its defense...if you need to tune one, you probably know the acronym.

It's a common feedback control scheme for signal processing and engineering control more generally.

[0]https://en.m.wikipedia.org/wiki/PID_controller


You are right, but it would be nice to have a step-by-step explanation of how the tuning works. A black box is somewhat unsatisfying.

(And of course it doesn't need to explain what a Laplace transform is, as this is aimed at control engineers)


In the grandparent's defence, I thought it was about a cgroup controller: https://www.kernel.org/doc/Documentation/cgroup-v1/pids.txt.


Above the fold (and in the first five words of text) is a link to describe what a PID controller is.


> Above the fold

The entirety of the "fold" on my screen is an absurdly giant and seemingly irrelevant image, overlaid with the text "Tune your PID", "It has never been easier", and two buttons.

As I scroll down, the next thing my eyes catch is some mathematical nonsense, which tells me exactly nothing other than that this is a complex thing that is surely entirely over my head.

To people that know what a "PID controller" is, it's probably informative. I came in assuming that there was some sort of controller for OS program PIDs and was unable to grasp the context at all.


https://en.wikipedia.org/wiki/PID_controller#:~:text=A%20pro...

Heavily used for industrial automation, hackers here may know it from espresso machine hacking. (and I'm sure manyyyyy other uses)


Human beings are actually FASCINATING examples of PID controllers...especially as we learn.

I'm soon to become a dad for the first time and so my partner and I have become much more conscious and aware of babies around us and watching them learn things. It's really fun to apply control theory to that...

A friend has a young child who is learning to feed themselves. I was chatting with the friend while we drank beer and he helped the child eat dinner. using hands to pick up food (watermelon chunks) and bring it to mouth - very conservative and lossy PID-esque model of action, but you could watch small tuning improvements in real time. Then a spoon was introduced for sweet potatoes and the kid's PID controller clearly could not adapt to the change in mass in the system and we watched huge overshoots and control failures. Then it slowly improved...but isn't yet 'good'

then we tried to explain this to our partners (both reside in the 'S' in STEM)...


Can confirm. We use PIDs in espresso machines to control the temperature of the water used in brewing. Some machines have simple thermostats that over/under shoot ideal brewing temperature and a PID will help keep a consistent temperature or even let you override the temperature (if your machine runs too hot or too cold).


Do you have any insight on why PID controllers are used for this application? PID assumes a system with a continuous control input, but water boilers usually have an on/off switch. Is the input something like a PWM value?

My temperature controlled kettle does a way-more-than-optimal amount of switching when it's near the setpoint. That's consistent with using a PID controller into a PWM input.

Maybe there is a market opportunity for a water boiler that uses control techniques better suited to on/off inputs :)


A resistive electric heater can be PWM'ed to provide variable output. If you want to maintain a narrow temperature band, you can do that better by feeding the water temperature into your PID loop and have it control the PWM duty cycle, rather than to a simple on-off thermostat.


Yes! I use it to control both the amperage and temperature of a kiln.


3D printers use it to control bed and extruder temperatures.


Us Billies on the Hill use them in our stills.


For anybody interested in a simple introduction of PID control, I recommend watching Brian Douglas' videos https://www.youtube.com/playlist?list=PLUMWjy5jgHK20UW0yM22H...


BPS.space of 'model rocket version of Falcon Heavy' fame has a very good overview/introduction as part of a lecture to other model rocket builders: https://www.youtube.com/watch?v=4cw9K9yuIyU

It's a dynamic control loop.


A PID controller is a suspension system for data. And just like the shocks in your car or mountain bike, the components need to be tuned to make the ride smooth. PID controllers are used in ovens and thermostats and brushless motors and all kinds of things you probably already use.


The "Why" section, pretty much at the top of the website, has a link to the Wikipedia article.

It has been explained.


TL;DR over simple answer, it smooths the output by ramping up and down power supplied by predicting what will happen in the future based on history.

Eg: The water is about to boil so I am setting the burner to medium from max to keep it at just below a rolling boil.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: