background image

III. Tuning the PID Filter

BACKGROUND

The transient response of a control system reveals important
information about the “quality” of control, and because a step
input is easy to generate and sufficiently drastic, the tran-
sient response of a control system is often characterized by
the response to a step input, the system step response.

In turn, the step response of a control system can be char-
acterized by three attributes: maximum overshoot, rise time,
and settling time. These step response attributes are defined
in what follows and detailed graphically in

Figure 16

.

1.

The maximum overshoot, Mp, is the maximum peak
value of the response curve measured from unity. The
amount of maximum overshoot directly indicates the
relative stability of the system.

2.

The rise time, t

r

, is the time required for the response to

rise from ten to ninety percent of the final value.

3.

The settling time, t

s

, is the time required for the response

to reach and stay within two percent of the final value.

A critically damped control system provides optimum perfor-
mance. The step response of a critically damped control
system exhibits the minimum possible rise time that main-
tains zero overshoot and zero ringing (damped oscillations).

Figure 17

illustrates the step response of a critically damped

control system.

INTRODUCTION

The

LM628

is

a

digital

PID

controller.

The

loop-compensation filter of a PID controller is usually tuned
experimentally, especially if the system dynamics are not
well known or defined.

The ultimate goal of tuning the PID filter is to critically damp
the motor control system

— provide optimum tracking and

settling time.

As shown in

Figure 7

the response of the PID filter is the

sum of three terms, a proportional term, an integral term, and
a derivative term. Five variables shape this response. These
five variables include the three gain coefficients (k

p

, k

i

, and

k

d

), the integration limit coefficient (i

l

), and the derivative

sampling coefficient (d

s

).

Tuning the filter equates to deter-

mining values for these variable coefficients, values that
critically damp the control system

.

Filter coefficients are best determined with a two-step experi-
mental approach. In the first step, the values of k

p

, k

i

, and k

d

(along with i

l

and d

s

) are systematically varied until reason-

ably good response characteristics are obtained. Manual
and visual methods are used to evaluate the effect of each
coefficient on system behavior. In the second step, an oscil-
loscope trace of the system step response provides detailed
information on system damping, and the filter coefficients,
determined in step one, are modified to critically damp the
system.

Note:

In step one, adjustments to filter coefficient values are inherently

coarse, while in step two, adjustments are inherently fine. Due to this
coarse/fine nature, steps one and two complement each other, and the
two-step approach is presented as the “best” tuning method. The PID
filter can be tuned with either step one or step two alone.

STEP ONE — MANUAL VISUAL METHOD

Introduction

In the first step, the values of k

p

, k

i

, and k

d

(along with i

l

and

d

s

) are systematically varied until reasonably good response

characteristics are obtained. Manual and visual methods are
used to evaluate the effect of each coefficient on system
behavior.

Note:

The next four numbered sections are ordered steps to tuning the PID
filter.

1. Prepare the System

The initialization section of the filter tuning program is ex-
ecuted to prepare the system for filter tuning. See

Table 11

.

This section initializes the system, presets the filter param-
eters (k

p

, k

i

, il = 0, k

d

= 2, d

s

= 1), and commands the control

loop to hold the shaft at the current position.

After executing the initialization section of the filter tuning
program, both desired and actual shaft positions equal zero;
the shaft should be stationary. Any displacement of the shaft
constitutes a position error, but with both k

p

and k

i

set to

zero, the control loop can not correct this error.

2. Determine the Derivative Gain Coefficient

The filter derivative term provides damping to eliminate os-
cillation and minimize overshoot and ringing, stabilize the
system. Damping is provided as a force proportional to the
rate of change of position error, and the constant of propor-
tionality is k

d

x d

s

. See

Figure 18

.

Coefficients k

d

and d

s

are determined with an iterative pro-

cess. Coefficient k

d

is systematically increased until the shaft

begins high frequency oscillations. Coefficient d

s

is then

increased by one. The entire process is repeated until d

s

reaches a value appropriate for the system.

01086017

FIGURE 16. Unit Step Response Curve Showing

Transient Response Attributes

01086018

FIGURE 17. Unit Step Response of a

Critically Damped System

AN-693

www.national.com

18

Содержание LM628

Страница 1: ...ence System Figure 15 is a detailed schematic of a closed loop motor control system All programs presented in this paper were developed using this system For application of the pro grams in other LM628 based systems changes in basic programming structure are not required but modification of filter coefficients and trajectory parameters may be required I Program Modules Breaking programs for the LM...

Страница 2: ... hardware reset block and a PORT 12 command Hardware Reset Block Immediately following power up a hardware reset must be executed Hardware reset is initiated by strobing RST pin 27 logic low for a minimum of eight LM628 clock periods The reset routine begins after RST is returned to logic high During the reset execution time 1 5 ms maximum the LM628 will ignore any commands or attempts to transfer...

Страница 3: ...t is eight bits This command initializes the DAC port for a 12 bit DAC It should not be issued in systems with an 8 bit DAC Busy bit Check Module Note 2 The 8 bit host I O port is a dual mode port it operates in command or data mode The logic level at PS pin 16 selects the mode Port c represents the LM628 command port commands are written to the command port and the Status Byte is read from the co...

Страница 4: ...1 5 ms c 06 PORT12 The RESET default size of the DAC port is eight bits This command initializes the DAC port for a 12 bit DAC It should not be issued in a system with an 8 bit DAC Busy bit Check Module c 1D RSTI This command resets only the interrupts indicated by zeros in bits one through six of the next data word It also resets bit fifteen of the Signals Register and pin 17 the host interrupt o...

Страница 5: ...r coeffi cients are written Each coefficient is written as a pair of data bytes a data word Because any combination of the four coefficients can be loaded within a single LFIL command sequence the number of data words following the filter control word can vary in the range from zero to four In the case of the example module the first byte of the filter control word 00 hex programs a derivative sam...

Страница 6: ...er Control Word Bit Position ds Selected Derivative Term Sampling Interval T d 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 1 Ts 0 0 0 0 0 0 0 1 2 2Ts 0 0 0 0 0 0 1 0 3 3Ts 0 0 0 0 0 0 1 1 4 4Ts 1 1 1 1 1 1 1 1 256 256Ts 01086010 FIGURE 8 Filter Control Word Bit Allocation AN 693 www national com 6 ...

Страница 7: ...variable number of data words The LTRJ command initiates loading trajectory parameters into input buffers The two data bytes written immediately after LTRJ com prise the trajectory control word The first byte programs with logical ones in respective bit positions the trajectory mode velocity or position velocity mode direction and stopping mode See Stop Module The second byte indi cates with logic...

Страница 8: ...ontrol word x1 hex selects motor off as the desired stopping mode This mode stops shaft motion by setting the motor drive signal to zero the appropriate offset binary code to apply zero drive to the motor Setting bit nine of the trajectory control word selects stop abruptly as the desired stopping mode This mode stops shaft motion at maximum deceleration by setting the target position equal to the...

Страница 9: ...r Programming Module c 1F LTRJ This command initiates loading the trajectory parameters input buffers Busy bit Check Module d d 00 00 HB LB These two bytes are the trajectory control word A 00 hex LB indicates no trajectory parameters will be loaded Busy bit Check Module c 01 STT STT must be issued to execute the desired trajectory Comments Execution of command STT results in execution of the de s...

Страница 10: ...te shaft revolution By definition two signals that are in quadrature are 90 out of phase When considered together channels A and B Figure 11 traverse four distinct digital states during each full cycle of either channel Each state transition represents one count of shaft motion The leading channel indicates the direction of shaft rotation Each line therefore represents one cycle of the output sign...

Страница 11: ...II Programs Continued 01086029 FIGURE 12 Calculations of Trajectory Parameters for Simple Absolute Position Move AN 693 www national com 11 ...

Страница 12: ...ationary and motion has not been stopped with a motor off stop module the current absolute position of the shaft is the target position If motion has been stopped with a motor off stop module or a position move has begun the absolute position that corresponds to the endpoint of the current trajectory is the target position Relative position is position measured relative to the current target posit...

Страница 13: ... LB indicates all three parameters will be loaded and both acceleration and velocity will be absolute values while position will be a relative value Busy bit Check Module d d 00 00 HB LB Acceleration is loaded in two data words These two bytes are the high data word In this case the acceleration is 17 counts sample2 Busy bit Check Module d d 00 11 HB LB acceleration data word low Busy bit Check Mo...

Страница 14: ... 0 rev sec2 until it reaches a maximum velocity of 4 0 rev sec After completing twenty forward direction revolutions including revolutions during acceleration the shaft will decelerate at 1 0 rev sec2 to a stop See Figure 14 Mask Interrupts An MSKI command sequence allows the user to determine which interrupt conditions result in host interrupts interrupt ing the host via the host interrupt output...

Страница 15: ...gram contains an absolute breakpoint set at 160 000 counts When this absolute position is reached the LM628 interrupts the host processor and the host executes a Smooth Stop Module Breakpoint positions for this example program are deter mined Load Trajectory Parameters This example program contains two LTRJ command se quences The trajectory control word of the first LTRJ com mand sequence 1828 hex...

Страница 16: ...ll be loaded and it will be a relative value Busy bit Check Module d d 00 02 HB LB Velocity is loaded in two data words These two bytes are the high data word In this case velocity is 2 0 rev s Because this is a relative value the current velocity will be increased by 2 0 rev s The resultant velocity will be 4 0 rev s Busy bit Check Module d 0C HB velocity data word low d 4A LB wait This wait repr...

Страница 17: ...II Programs Continued 01086004 Note All resistor values in Ω FIGURE 15 Reference System AN 693 www national com 17 ...

Страница 18: ...reason ably good response characteristics are obtained Manual and visual methods are used to evaluate the effect of each coefficient on system behavior In the second step an oscil loscope trace of the system step response provides detailed information on system damping and the filter coefficients determined in step one are modified to critically damp the system Note In step one adjustments to filt...

Страница 19: ...he shaft is turned the more sluggish it feels For the reference system the final values of kd and ds are 4000 and 4 respectively TABLE 11 Initialization Section Filter Tuning Program Port Bytes Command Comments c 00 RESET See Initialization Module Text wait The maximum time to complete RESET tasks is 1 5 ms c 06 PORT12 The RESET default size of the DAC port is eight bits This command initializes t...

Страница 20: ...too low the system is over damped and the shaft recovers too slowly If kp is too large the system is under damped and the shaft recovers too quickly This causes overshoot ringing and possibly oscillation The pro portional gain coefficient kp is increased to the largest value that does not cause excessive overshoot or ringing At this point the system is critically damped and therefore provides opti...

Страница 21: ...ogram provides the control loop with a repetitive small signal step input This is accomplished by repeatedly executing a small position move with high maximum velocity and high accel eration See Figure 19 and Table 12 01086022 FIGURE 19 Step Generation Section of Filter Tuning Program AN 693 www national com 21 ...

Страница 22: ...I This command resets only the interrupts indicated by zeros in bits one through six of the next data word It also resets bit fifteen of the Signals Register and the host interrupt pin pin 17 d xx HB don t care d 00 LB Zeros in bits one through six indicate all interrupts will be reset wait This wait block inserts a delay between repetitions of the step input The delay is application specific but ...

Страница 23: ...unts Note 10 The circuit of Figure 20 produces an inverted step response graph The oscilloscope input was inverted to produce a positive going more familiar step response graph Figure 21 represents the step response of an under damped control system this response exhibits excessive overshoot and long settling time The filter parameters used to gener ate this response were as follows kp 35 ki 5 kd ...

Страница 24: ...ed to cause the failure of the life support device or system or to affect its safety or effectiveness National Semiconductor Corporation Americas Email support nsc com National Semiconductor Europe Fax 49 0 180 530 85 86 Email europe support nsc com Deutsch Tel 49 0 69 9508 6208 English Tel 44 0 870 24 0 2171 Français Tel 33 0 1 41 91 8790 National Semiconductor Asia Pacific Customer Response Grou...

Отзывы: