ClosedLoop PID algorithms in motion/motor control
Use Differential Feed Forward for Numerical Controls or Integrate Backward for Trajectory Control of Motion
First published here in April 2007, this timeless backtobasics tutorial by Ernst Dummermuth, one of several popular articles he wrote for us, generated a large number of page views on ControlDesign.com for years after we first posted it, and still draws attention today.
The basic function of closedloop control is to maintain a process characteristic (temperature, flow, pressure, speed, torque) at a desired value. The process can deviate from this desired set point (SP) value as a result of changing material, load requirements, interaction with other processes, and so on. The actual condition of the process characteristic measured is the process variable (PV). The deviation of the measured process variable from the desired set point is the error (E).
The formula for process error is thus: E = SP – PV
Once an error is determined, the function of the control loop is to output a control variable to the process to force the error E to zero. Figure 1 below shows a basic PID closed loop control.
FIGURE 1: YOUR BASIC PID
The classical loop control technique can include threemode control known as PID, which represents proportional, integral, and derivative. (Click image to enlarge.)
The classical control technique used to operate an analog control loop is known as a "threemode control." This control technique is based on the solution of an equation that can include one, two, or three terms, or modes, of control. Threemode control is known as PID, which represents proportional, integral, and derivative. This is the description of the mathematical operation performed in the terms of the equation.
SEE ALSO: You Think You've Got PID Troubles?
Functionally, proportional control action provides a control output component proportional to the value of the instantaneous error. Integral control action (also known as reset action) provides a control output component proportional to the summation of the error over a period of time. Derivative control action (also known as rate action) provides a control output component proportional to the rate of change of the error. These modes of control are used individually or in combination to provide the desired control action.
PID Equation
PID control action is represented by the equation:
Nowadays, computers and microprocessors are used to implement control functions. Thus the ideal PID equation is approximated by digital values and discrete time intervals. As such, the error E will be sampled at ∆t time intervals and a new control variable output V will be available every ∆t.
The PID equation also can be represented in a simplified form:
Cascade Loop Control
Cascade loop control is shown in Figure 2 below. Loop 1 is called the outer or primary loop; Loop 2 is called the inner or secondary loop. There might even be a ternary, innermost loop. The inner loop senses a change, and compensates for it before the outer loop is affected. This type of control is used to reduce the response time of the secondary loop when controlling a primary loop with large inertia.
FIGURE 2: CASCADE LOOP CONTROL
The inner loop senses change and compensates before the outer loop is affected to reduce the response time to a primary loop with large inertia. (Click image to enlarge.)
Because the inner loop(s) reduce the system’s response time, the sampling time ∆t for the inner loop(s) must be shorter, too. If the position loop of a motion/motor control is closed with a sampling rate of ∆t = 10 msec, then the velocity loop may be closed at ∆t = 1 msec, and the torque or acceleration loop at ∆t = 100 µsec. Finally, if pulsewidth modulation (PWM) is used to generate the output power signals, then the on/off times for the power switches should be calculated at ∆t = 10 µsec.
Figure 3 below illustrates a digital servo control. The control boxes perform PID algorithms. Only one or two of the three terms of the PID algorithm might be implemented. In 3, the outer Loop 1 might be a pure P control, Loop 2 a PI control, Loop 3 another P control, and Loop 4 is a P translation to switching times for the PWM. The process feedback(s) in Figure 3 are shown schematically as one line. If an incremental pulse encoder is used for feedback, it could provide velocity as well as position feedback. Torque feedback is obtained from the motor current. The acceleration loop and the PWM control are part of the drive circuit.
FIGURE 3: DIGITAL SERVO CONTROL
This concept illustrates inner loops with decreasing sampling rates. (Click image to enlarge.)
Figure 4 below shows a typical implementation of a motion control system. A new position command PC is computed and provided from an external source every ∆t = 10 msec. The difference between two successive position commands is the speed command fed forward into the velocity loop.
FIGURE 4: TYPICAL MOTION CONTROL IMPLEMENTATION
Cascade Loop Control with Position the primary command and Velocity VE feed forward. (Click image to enlarge.)
If KPV is selected properly, then the velocity feed forward provides most of the signal to the velocity loop (Loop 2) and the positionfollowing error E remains near zero for any velocity. Older numerical control systems didn’t use velocity feed forward.
In any case, such feed forward is optional for performance enhancement. In the end, the outermost loop must be satisfied.
For an actual implementation of a multiaxis motion control system, a personal computer can be used for the motion planning and position loop control of all axes at a 10 msec sampling rate. The velocity control loop may be implemented for one or two axes on a motion module using a microprocessor at a 1 msec sampling rate, and the torque, current and power control can be implemented in the drive, with a combination of a digital signal processor (DSP) at 100 µsec and 10 µsec, and some additional discrete circuits for the power switches.
An incremental digital encoder provides incremental position feedback IPF, pulses that are accumulated for the position feedback. These same encoder pulses also are accumulated for every ∆t = 1 msec, and represent the distance traveled per time—a digital tachometer.
The feedforward principle can be extended to the innermost loop as shown in Figure 5 below by providing an advanced acceleration offset AC. Note that all variables including acceleration are signed numbers. For distinction, a negative acceleration often is called a deceleration and appears here as (AC). A torque or current feedback for the inner loop already is provided by the drive. The AC signal, a torque command, is obtained as a derivative of VE.
ALSO READ: You think you’ve got PID troubles?
FIGURE 5: CASCADE LOOP WITH DERIVATIVES
Cascade Loop with Position the primary command and with Derivatives for Velocity VE and Acceleration AC. (Click image to enlarge.)
For generalpurpose motion control and trajectory control,it’s advantageous to make the acceleration AC the primary motion command as shown in Figure 6 below. Integration of the acceleration command AC produces the velocity command VE, and integration of VE produces the position command PC. If no torque feedforward AC is desired, then KPA = 0; everything else remains as shown. Drives and motors have torque limitations; keeping the AC value below those limits guarantees the motor and drive actually will follow the command closely.
FIGURE 6: CASCADE LOOP WITH ACCELERATION
Cascade Loop with Acceleration as Primary Motion Command, and with Integration for Velocity VE and Position PC. (Click image to enlarge.)
A typical move block might specify these parameters:
Position (Endpoint P3 in absolute form; go there from present position)
Velocity (maximum traverse velocity)
Acceleration (ramp up velocity at the beginning of the move)
Deceleration (slow down velocity at the end of the move)
Using the wellknown motion equations:
a = constant; accel/decel (1a)
v = a * t; or t = v / a (1b)
da = v * t; dd = v * t (1c )
da = distance to accel; dd = distance to decel
A motion planner prepares the move before execution:
The acceleration time can be computed using (1b). Then the distance da for the acceleration portion can be computed using (1c). The motion planner therefore stores P1 (start position P0 + da). Now computing from the endpoint backward, another time t can be found when deceleration must start (1b). With (1c) a deceleration distance dd is computed and the point P2 (Endpoint P3 – dd) is stored.
During execution beginning at P0, the acceleration value is applied to AC until P2. Then the acceleration is set to AC = 0 until P2. As soon as P2 has been passed, the deceleration value is applied to AC (here a negative value different from the acceleration). As a result the motion slows down into point P3. A corresponding graph of the move profile is shown in Figure 7 below.
FIGURE 7: MOVE PROFILE
Figure 6 is used as implementation of this profile with the proper ∆t time increments for integration. The order position loop monitors the momentary position and then simply provides the commands to switch the values in the AC register to the proper values. (Click image to enlarge.)
Note that Figure 6 is used as implementation of Figure 7 with the proper ∆t time increments for integration. The outer position loop monitors the momentary position and then simply provides the commands to switch the values in the AC register to the proper values: P0 (go, apply AC=accel), P1 (AC= 0), P2 (AC=decel) and P3 (AC=0). When P3 is reached the move block provides a “done” signal.
Read our article The NotSoOdd Couple, by Ernst Dummermuth. This article talks about how motor and its generator are bound together. One does not exist without the other. 
Join the discussion
We welcome your thoughtful comments.
All comments will display your user name.
Comments

<p>This is not "your basic PID controller" as the caption on figure 1 indicates. This is "your basic PID controller supplemented with constant feedforward control." See for example a more comprehensive PID survey such as the chapter by K.J. Astrom and T. Hagglund in the 1996 edition of the CRC Control Handbook.</p> <p>The basic idea of the feedforward control extension is a good one. If you know the VS value that must be applied to cause the plant to hold the desired PS setpoint level, and you use this as the feedforward signal, the integral term of the PID controller is no longer necessary to drive the system to the desired operating level. In fact, when the system stabilizes, the controller output (including the integral portion) goes to 0. Thus freed from the obligation to drive the system to reach the desired output level, the integral control can be better tuned for rejecting small output level disturbances.</p> <p>Drawbacks? The scheme isn't as easy as it sounds when the system is somewhat nonlinear, or when it must operate at various different setpoint levels. The combination of PID controller plus the feedforward control can sometimes increase the amount of transient overshoot. As is the case with any of the PID extensions, every added feature adds a certain amount of complication to the implementation and to the application. It is a better idea to start with the basic PID scheme, and build from there, even if the extensions are relatively good ones. </p>

<p>" It is a better idea to start with the basic PID scheme, and build from there, even if the extensions are relatively good ones." I agree that one should first get control of the system but as soon as possible the feed forwards should be adjusted until the error is minimized. If the velocity and acceleration feed forwards can be tuned well enough to provide the correct control output within 5% then the PID only needs to correct the last 5% which is must faster than if the PID must supply the whole control signal. After the feed forwards gains are optimized the PID gains can be revisited to correct for nonlinearities and changes in load.</p> <p>If you think about it the PID gains are the inverse of the system transfer function. If the feed forward gains are accurate enough the system model and PID gains can be computed. </p>
RSS feed for comments on this page  RSS feed for all comments