PI Section From DMC MATH - v13.1
PI Section From DMC MATH - v13.1
Description This module implements a simple 32-bit digital PI controller with anti-windup
correction.
Ref
Out
PI
Fdb MACRO
C Interface
Object Definition
typedef struct {
Ref // Input: reference set-point
Fbk // Input: feedback
Out // Output: controller output
Kp // Parameter: proportional loop gain
Ki // Parameter: integral gain
Umax // Parameter: upper saturation limit
Umin // Parameter: lower saturation limit
up // Data: proportional term
ui // Data: integral term
v1 // Data: pre-saturated controller output
i1 // Data: integrator storage: ui(k-1)
w1 // Data: saturation record: [u (k-1) - v(k-1)]
} PI;
PI
The module definition is created as a data type. This makes it convenient to instance an interface
to the PI module. To create multiple instances of the module simply declare variables of type PI.
PI_DEFAULTS
Structure symbolic constant to initialize PI module. This provides the initial values to the terminal
variables as well as method pointers.
Module Usage
Instantiation
The following example instances two PI objects
PI pi1, pi2;
Initialization
To Instance pre-initialized objects
PI pi1 = PI_DEFAULTS;
PI pi2 = PI_DEFAULTS;
Example
The following pseudo code provides the information about the module usage.
main()
{
Technical Background
The PI_cntl module implements a basic summing junction and P+I control law with the following features:
Programmable output saturation
Independent reference weighting on proportional path
Anti-windup integrator reset
The PI controller is a sub-set of the PID controller. All input, output and internal data is in I8Q24 fixed-
point format. A block diagram of the internal controller structure is shown below.
up
Umax
Kp Ki Umin
+ + ui + +
r(k) u(k)
- + Output
Reference
(Ref) (Out)
i1
z-1 v1
=?
y(k)
Feedback w1
(Fbk)
a) Proportional path
The proportional path is a direct connection between the error term and a summing junction with the
integral path. The error term is:
b) Integral path
The integral path consists of a discrete integrator which is pre-multiplied by a term derived from the output
module. The term w1 is either zero or one, and provides a means to disable the integrator path when
output saturation occurs. This prevents the integral term from “winding up” and improves the response
time on recovery from saturation. The integrator law used is based on a backwards approximation.
c) Output path
The output path contains a summing block to sum the proportional and integral controller terms. The
result is then saturated according to user programmable upper and lower limits to give the controller
output.
The pre-and post-saturated terms are compared to determine whether saturation has occurred, and if so,
a zero or one result is produced which is used to disable the integral path (see above). The output path
law is defined as follows.
v1 (k ) u p (k ) ui (k ) ................................................................................... (3)
0 :v1 (k ) u (k )
w1 (k ) .............................................................................. (5)
1 :v1 (k ) u (k )
Default values for the controller coefficients are defined in the macro header file which apply unity gain
through the proportional path, and disable both integral and derivative paths. A suggested general
technique for tuning the controller is now described.
Step 1. Ensure integral is set to zero and proportional gain set to one.
Step 2. Gradually adjust proportional gain variable (Kp) while observing the step response to achieve
optimum rise time and overshoot compromise.
Step 3. If necessary, gradually increase integral gain (Ki) to optimize the return of the steady state output
to nominal. The controller will be very sensitive to this term and may become unstable so be sure to start
with a very small number. Integral gain will result in an increase in overshoot and oscillation, so it may be
necessary to slightly decrease the Kp term again to find the best balance. Note that if the integral gain is
used then set to zero, a small residual term may persist in ui.