Misconceptions about PID Controllers

The input to the PID controller is not a position. The input to the position sensor is a position.

The input to the PID controller is a signal that represents a position.

It could be a voltage, or a current, or a digital number. The exact form of the signal doesn't matter, because all it has to do is represent to the controller what the position is.

If it's an analogue signal, the set point will typically be set by a potentiometer or DAC, to put a reference analogue signal representing the desired position into an analogue subtractor.

If it's a digital signal, the set point will be a number representing the desired position into a digital subtractor.

The controller will have means to integrate and differentiate the signal, weight the direct (P for proportional), integrated (I) and differentiated (D) signals (hence PID), add them together, and output them.

If it's an analogue signal, it might drive the motor directly, or via an amplifier. A digital signal could be converted via a DAC to drive a conventional motor, or may stay digital all the way into an ESC to drive a stepper or brushless motor.


Neil has a perfect answer for you, but this confusion comes up again and again, so it wouldn't hurt to emphasize the relationship between mathematics, models and reality.

In reality, you will have physical units, in your case the item that you wish to control, the environment it lives in, and also sensors, actuators (motors) and a control apparatus (usually an electronic circuit or a micro-controller) which you add in order to control your item.

In order to understand the behavior of your resulting system, as well as make good design choices we have to turn to modelling the systems that are in play. This is a process of approximation, where we ignore details that we think is non-essential to the system behavior yet retain the overall behavior of the system.

For instance, your system dynamic equation is based on Newton's Laws, but obviously you might add things like friction and aerodynamics, variations based on heat, compression of the mechanical parts, etc. Your actuators are probably designed to be fairly linear around their operating point, but they can also be modeled as non-linear equations. Even your controller part is most likely a simplification -- for instance, no electrical circuit is 100% accurate, nor operates instantaneously -- and you haven't modeled that. But that is okay, it probably won't change the efficiency of your control by much.

A model is a fictional (mathematical) construct that we use to understand the behavior of the system. Though fictional, it is enormously useful because we are able to reason about the system. Your PID diagram above is a graphical representation of the following equations: $$ \begin{aligned} i(t) = C(x_\text{set}(t) - x(t), t;\; k_P, k_I, k_D), &\;\text{model of PID controller} \\ F(t) = M(i(t), t), &\;\text{model of motor} \\ mx''(t) + cx'(t) + kx(t) = F(t), &\;\text{model of system} \end{aligned} $$ These make more or less sense to me. I would perhaps model the sensor, taking the position \$x\$ into a measured value \$x_\text{measured}\$. A typical addition is to add $$ x_\text{measured}(t) = x(t) + \epsilon(t), $$ where \$\epsilon\$ is a Gaussian noise function, in order to model measurement inaccuracies.

The fact that you use the current \$i\$ as an output from your controller tells me what type of output you intend.

With this model, you can now do neat things like simulate it on a computer. This might indicate what your PID constants should be. You can calculate the frequency response curves, in order to find out if the system resonates at certain frequencies.

Finally, notice that just about everything in control depends on time. This is often then just omitted, and we also use the notation: $$ \dot{x} = x'(t) = \frac{dx}{dt}(t) $$