![Microchip Technology AN908 Using Manual Download Page 17](http://html1.mh-extra.com/html/microchip-technology/an908/an908_using-manual_1785807017.webp)
2004 Microchip Technology Inc.
DS00908A-page 17
AN908
Adjusting the PID Gains
The P gain of a PID controller sets the overall system
response. When first tuning a controller, the I and D
gains should be set to zero. The P gain can then be
increased until the system responds well to set-point
changes without excessive overshoot or oscillations.
Using lower values of P gain will ‘loosely’ control the
system, while higher values will give ‘tighter’ control. At
this point, the system will probably not converge to the
set-point.
After a reasonable P gain is selected, the I gain can be
slowly increased to force the system error to zero. Only
a small amount of I gain is required in most systems.
Note that the effect of the I gain, if large enough, can
overcome the action of the P term, slow the overall con-
trol response and cause the system to oscillate around
the set-point. If oscillation occurs, reducing the I gain
and increasing the P gain will usually solve the
problem.
This application includes a term to limit integral windup,
which will occur if the integrated error saturates the out-
put parameter. Any further increase in the integrated
error will not effect the output. If allowed to accumulate,
when the error does decrease the accumulated error
will have to reduce (or unwind) to below the value that
caused the output to saturate. The Kc coefficient limits
this unwanted accumulation. For most situations, it can
be set equal to Ki.
All three controllers have a maximum value for the
output parameter. These values can be found in the
UserParms.h file and are currently set to avoid
saturation in the
SVGen()
routine.
CONTROL LOOP DEPENDENCIES
There are three PI control loops in this application that
are interdependent. The outer loop controls the motor
velocity. The two inner loops control the transformed
motor currents, I
d
and I
q
. As mentioned previously, the
I
d
loop is responsible for controlling flux and the I
q
value
is responsible for controlling the motor torque.
TORQUE MODE
When adjusting the coefficients for the three control
loops, it can be beneficial to separate the outer control
loop from the inner loops. The motor can be operated
in a torque mode by un-commenting the
#define
TORQUE_MODE
statement in the UserParms.h file. This
will bypass the outer velocity control loop and feed the
potentiometer demand value directly to the I
q
control
loop setpoint.
RECOMMENDED CONTROL LOOP TUNING
PROCEDURE
If the control loops require adjustment, it is helpful to
bypass the velocity control loop as described above. In
most situations, the PI coefficients for the I
d
and I
q
con-
trol loops should be set to equal values. Once the motor
has good torque response in the torque mode, the
velocity control loop can be enabled and adjusted.
Example Scope Plots
The following scope plots demonstrate the use of the
diagnostic outputs and proper tuning of the application
parameters.
A plot of the transformed quadrature phase current (I
q
)
vs. the motor mechanical velocity is shown in
Figure 14. Assuming the application is properly tuned,
the I
q
value is proportional to the motor torque. This
value can be found in the
ParkParm
data structure.
The motor mechanical velocity is in the
EncoderParm
data structure.
The plot shows an example of properly tuned control
loops. As you can see, there is little overshoot or ring-
ing in the bottom trace (motor velocity). Also, there is a
rapid response in the quadrature current (top trace),
followed by a decay with little overshoot or ringing as
the motor reaches the new speed.
FIGURE 14:
IQ VS. VELOCITY, 500 TO
1000 RPM STEP