Share this

What is PID? A visual explanation and detailed instructions on PID tuning.

2026-04-06 07:22:35 · · #1

(a) First, let's thoroughly understand what PID is.

What is PID?

PID stands for "Proportional, Integral, and Derivative," and it's a very common control algorithm. In engineering practice, the most widely used regulator control law is proportional, integral, and derivative control, abbreviated as PID control or PID regulation. It has become one of the main technologies in industrial control due to its simple structure, good stability, reliable operation, and convenient adjustment.

Algorithms are not edible.

PID has a history of 107 years.

It's not something sacred; everyone has surely seen practical applications of PID.

For example, quadcopters, self-balancing scooters... and cruise control in cars, temperature controllers in 3D printers...

In situations where a physical quantity needs to be kept stable (such as maintaining balance, stabilizing temperature, speed, etc.), PID controllers come in very handy.

So here's the question:

For example, I want to control an electric kettle to keep the temperature of a pot of water at 50℃.

Why use calculus theory for such a simple task?

You must be thinking:

This is so easy! Just let it heat up when the temperature is below 50 degrees Celsius and turn off the power when the temperature is above 50 degrees Celsius, right? A few lines of code can be written in minutes with an Arduino.

Yes, that's true—if the requirements aren't high, you can certainly do it that way. But! If you put it another way, you'll see where the problem lies:

What if the object I'm controlling is a car?

If you wanted your car to stay at 50 km/h without moving, would you still dare to do that?

Imagine that the car's cruise control computer detects a speed of 45 km/h at a certain moment. It immediately commands the engine: Accelerate!

As a result, the engine suddenly went to 100% full throttle, and with a whoosh, the car accelerated rapidly to 60km/h.

Then the computer issued another command: Brake!

As a result, *squeak...waa ...

Therefore, in most situations, using "on/off signals" to control a physical quantity is rather simplistic and crude. Sometimes, it's impossible to maintain stability because microcontrollers and sensors are not infinitely fast; data acquisition and control require time.

Moreover, the controlled object has inertia. For example, if you unplug a heater, its "residual heat" (i.e., thermal inertia) may cause the water temperature to continue to rise for a short while.

At this point, an 'algorithm' is needed:

It can bring the physical quantities that need to be controlled to the vicinity of the target.

It can "predict" the trend of this quantity's change.

It can also eliminate static errors caused by factors such as heat dissipation and resistance.

...

So, mathematicians at the time invented this enduring algorithm—the PID.

As you should already know, P, I, and D are three different control functions, which can be used individually (P, I, D), in pairs (PI, PD), or all three together (PID).

What are the differences between these three functions? Please be patient, let me explain.

Let's start by discussing the three most basic parameters of a PID controller: kP, kI, and kD.

kP

P stands for proportion. Its function is the most obvious, and its principle is the simplest. Let's talk about this first:

The quantities that need to be controlled, such as water temperature, have both a current value and a target value that we expect.

When the difference between the two is not significant, let the heater heat it "gently".

If the temperature drops significantly for some reason, let the heater heat it up a little more.

If the current temperature is much lower than the target temperature, run the heater at full capacity to heat the water to near the target temperature as quickly as possible.

This is the function of P. Compared with the switching control method, isn't it much more "gentle and refined"?

In actual programming, you can establish a linear function relationship between the deviation (target minus current) and the "adjustment strength" of the regulating device to achieve the most basic "proportional" control.

The larger the value of kP, the more aggressive the regulatory effect; the smaller the value of kP, the more conservative the regulatory effect.

If you are building a self-balancing scooter, with the help of P, you will find that the scooter will shake violently around the balance angle and be difficult to stabilize.

If you've reached this point—congratulations! You're just one step away from success!

kD

The role of D is easier to understand, so let's talk about D first and I last.

We just learned about the role of P. You might notice that P alone doesn't seem to be enough to make the balance scooter stand up, and the water temperature control is also inconsistent. It seems that the whole system is not very stable and is always "shaking".

Imagine a spring in your mind: it's currently in its equilibrium position. Pull it slightly, then release it. It will then oscillate. Because the resistance is very small, it might oscillate for a long time before returning to its equilibrium position.

Imagine if you submerged the system shown in the diagram above in water and pulled it: in this case, it would take much less time to return to its equilibrium position.

We need a control mechanism to bring the "rate of change" of the controlled physical quantity toward zero, similar to the effect of "damping".

This is because the control effect of P becomes smaller when the target is closer. The closer to the target, the gentler the effect of P. Many internal or external factors cause the control variable to fluctuate within a small range.

The function of D is to make the velocity of the physical quantity approach 0. Whenever the quantity has velocity, D will exert force in the opposite direction to try to stop the change.

The larger the kD parameter, the stronger the braking force in the opposite direction of the velocity.

If it's a balance bike, with both P and D controls, and the parameters are adjusted properly, it should be able to stand up! Hooray!

Wait a minute, there seems to be one more member in the PID trio. It looks like PD can keep physical quantities stable, so what's the point of I?

Because we overlooked an important situation:

kI

Let's take hot water as an example again. Suppose someone takes our heating device to a very cold place and starts boiling water. It needs to be heated to 50℃.

Under the influence of P, the water temperature slowly rises. Until it reaches 45℃, he discovers something unfortunate: the weather is too cold, and the rate at which the water dissipates heat is equal to the rate at which P controls the heating.

What should we do?

Brother P thought to himself: I'm already very close to my goal; all I need to do is heat it up a little.

Brother D thought: Heating and heat dissipation are equal, and the temperature does not fluctuate, so it seems that I don't need to adjust anything.

As a result, the water temperature remains forever at 45℃, never reaching 50℃.

As human beings, we know from common sense that we should increase the heating power. But how much should we increase it by?

The method devised by our predecessors was truly ingenious.

An integral quantity is set. As long as the deviation exists, the deviation is continuously integrated (accumulated) and reflected in the adjustment force.

In this way, even if the difference between 45℃ and 50℃ is not significant, this integral will continue to increase over time as long as the target temperature has not been reached. The system will gradually realize: the target temperature has not been reached, it's time to increase the power!

Once the target temperature is reached, assuming no temperature fluctuations, the integral value will remain unchanged. At this point, the heating power still equals the heat dissipation power. However, the temperature remains a stable 50℃.

The larger the value of kI, the larger the coefficient multiplied during integration, and the more obvious the integration effect.

Therefore, the role of I is to reduce the error under static conditions and make the controlled physical quantity as close as possible to the target value.

Another issue when using it is that an integral limit needs to be set. This is to prevent the integral from accumulating too much at the beginning of heating, making it difficult to control.

(ii) Let’s take a look at how to adjust the PID.

(PID parameter tuning tips)

To find the optimal parameters, check them in ascending order: first the proportional gain, then the integral gain, and finally the derivative gain. If the curve oscillates frequently, the proportional gain needs to be enlarged.

The curve floats around a large bend; turning the proportional dial smaller results in a slow curve deviation and recovery. Decreasing the integral time lengthens the curve's oscillation period; further increasing the integral time increases the curve's oscillation frequency. First, reduce the derivative to reduce momentum and slow oscillation. The derivative time should be increased. The ideal curve has two waves: a high first wave and a low second wave (4:1 ratio). Observe, adjust, and analyze extensively; the adjustment quality will not be low.

To accelerate the reaction, increase P and decrease I.

To slow down the reaction, decrease P and increase I.

If the proportion is too large, it will cause systemic oscillations.

If the integral is too large, it will cause the system to become sluggish.

Disclaimer: This article is a reprint. If there are any copyright issues, please contact us promptly for deletion (QQ: 2737591964). We apologize for any inconvenience.

Read next

CATDOLL 123CM Sasha TPE

Height: 123cm Weight: 23kg Shoulder Width: 32cm Bust/Waist/Hip: 61/54/70cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22