7
\$\begingroup\$

I'm currently designing an equivalent of the mass-spring-dashpot system, and during the design phase I realized I don't fully understand how PID controllers physically work.

Below is an image, the top half of which is the physical setup. There's a mass hooked up to a spring and dashpot. There is some magical position sensor that outputs the position of the mass (ignore how it does this), and there is a motor attached to the mass so we can apply a force to it. The position sensor feeds into a computer, and the computer controls what force the motor produces.

The bottom half is what I imagine the control loop looks like. We have some set point for the mass, and the offset (error) is fed into the PID controller, which outputs a current which is fed to the motor, which outputs a force which acts on the mass, which thus changes the position.

My question is that the input to the PID controller is a position (namely x_set - x_actual), but its output is mysteriously a current. How is this possible? The PID controller computes integrals and derivatives of position, which in no way is relevant to amperage.

Am I missing a component in my control loop - is there something in between the controller and the motor? Or perhaps between the sum block and the controller?

Any help is greatly appreciated. ^^

\$\endgroup\$
3
  • 1
    \$\begingroup\$ You're outputting a control signal that will get the mass to the desired position in minimal time and overshoot. The control signal is a rate of change of position. What else should it output? A position? It would just be reporting the x_set the whole time and you don't even need a PID for that. \$\endgroup\$
    – Samuel
    Commented Feb 19, 2016 at 20:01
  • \$\begingroup\$ The motor produces a torque (which is the rotational counterpart of a linear force) and the motor developed torque is proportional to current. The motor current is determined by the difference between required mass position and actual mass position. There are several changes of physical units in the system: displacement to voltage; voltage to current; current to torque,... Some of these are performed by identifiable components (e.g. potentiometer = displacement transducer) and some are inherent in the device (e.g. torque, acceleration, velocity, displacement all co-exist on the motor shaft) \$\endgroup\$
    – Chu
    Commented Feb 19, 2016 at 23:07
  • \$\begingroup\$ Correct me if I'm wrong: what you are basically asking is how to convert between the computed signal value from the PID to the actual output signal which is in current? \$\endgroup\$ Commented Mar 21, 2021 at 9:57

4 Answers 4

7
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Essentially, what you're saying is that my position sensor takes in an input of position x and outputs some number, let's say z. In addition, as a human I want my set point to be the position x_set, but in actuality I should be feeding the number z_set into my control loop. So, the input to my PID controller is (z_set - z), which is likely to be a current or voltage or whatever. Did I get that correct? \$\endgroup\$
    – anonymouse
    Commented Feb 19, 2016 at 20:08
  • \$\begingroup\$ Yes. You want your set position to be z. However the PID loop doesn't know anything about positions, only (in your case) numbers. So you put a number that represents z as the set point into the PID controller. \$\endgroup\$
    – Neil_UK
    Commented Feb 19, 2016 at 20:47
3
\$\begingroup\$

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) $$

\$\endgroup\$
1
\$\begingroup\$

To translate the position to a current, you probably need a gain, i.e. k1 A/meters, it depends on the electrical characteristics of the position sensor.

\$\endgroup\$
0
\$\begingroup\$

Adding my 2 cents' worth, the input to the PID controller is not the position, but the position converted into a current or a voltage.

To express in words the salient points to help in answering the question, what the other respondents have explained using mathematics:

Essentially the electronic PID controller 'sees' at the input for the desired mass position Set Point a voltage or a current. At the other input for the feedback sensor monitoring the position of the mass, the PID controller 'sees' a current or a voltage converted by the feedback sensor.

The mass position feedback sensor is not explicitly shown in the provided diagram, so one may assume it's the unity feedback line going from the output of the System Dynamics' block to the negative input of the summing junction.

The unity negative feedback is to signify that when the user's desired Set Point matches the mass position, the feedback signal from the position sensor has the same magnitude but opposite sign, to the Set Point signal.

The electronic PID controller then electronically subtracts the user's desired mass position converted current or voltage value, from the actual measured mass position by the feedback sensor's converted current or voltage value.

The difference between the user's desired converted current or voltage value and the feedback sensor's converted current or voltage value may be referred to as the Control Error or CE for short.

If the CE is zero, the PID controller does not output any current or voltage; i.e. the PID controller's output is zero because the mass position is at the user's desired set point.

If the CE is not zero, either a positive or negative value, the PID controller will output either a negative or positive voltage current or voltage to adjust the mass' position to match the user's desired set point. The negative or positive current or voltage drives an electric motor to adjust the mass position. When the mass position is shifted to the user's desired set point position, the CE is zero and the PID outputs zero current or voltage, to stop the mass from moving.

The electric motor converts the electrical current or voltage provided by the PID controller, into a mechanical Force or Torque (twisting Force) to move the position of the mass.

The negative current or voltage output of the PID controller may be arranged so that the electric motor will turn, say anti-clockwise, resulting in the mass moving to the left (or down depending on your point of view), and the positive current or voltage output of the PID controller may be arranged so that the electric motor will turn clockwise, resulting in the mass moving to the right (or up). The convention for left or right, or up or down, is adopted depending on how the mechanics of the plant is configured.

Disclaimer: Please correct any misinterpretations I may have made in the text above; I would appreciate constructive criticism.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.