ECE 5570 - Lab 2 PID Control of A Brush DC Motor Objectives

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

ECE 5570 - Lab 2

PID Control of a Brush DC Motor


Objectives
The objective of this lab is to experiment with a proportional -integral derivative (PID) control law for the positioning of a brush DC motor.
Integral control is found useful to achieve zero-steady state errors in the
presence of constant load disturbances. To avoid overshoot in the
responses, simple modifications are applied to the control law. Controller
parameters are selected by trial and error and by a procedure based on the
principle of the symmetric optimum.

1.

Introduction

Assuming voltage control of the motor, a PID control law is given by


v " k P (! ref # ! ) $ k I % (! ref # ! ) dt $ k D

d
(! ref # ! )
dt

(1)

where v is the voltage applied to the motor, !ref is the desired position of the motor, ! is the
actual position of the motor, and k P , kI , and k D are the proportional, integral, and derivative
gain parameters, respectively. Heuristically, one finds that, for increasing values of the
parameters, k P accelerates the speed of the response and k D improves the damping, while kI
guarantees the return of the steady-state error to zero. However, the response of the closed-loop
system depends on all three parameters in a complex manner, making manual tuning difficult.
Several modifications are brought to this control law in practice. The derivative action is
usually only applied to ! , so that large control values do not result from step changes in the
reference input. Sometimes, the proportional term is also modified in order to avoid the presence
of a low-frequency zero in the transfer function. To that effect, the contribution from the
reference signal is reduced through a factor k F < 1, and the control law becomes
d
(2)
v " k P (k F! ref # ! ) $ k I % (! ref # ! ) dt # k D (! )
dt
An important practical problem is also that of integrator wind-up. For large steps of the
reference input, the response of the system exhibits an overshoot, even if no overshoot is
observed for small steps. This problem occurs because the control input reaches a limit and the
behavior of the system ceases to be linear. The integrator state then becomes large, leading to a
peaking of the response. Several fixes exist for the problem. For example, the integration may
be stopped when an input limit is reached or when the tracking error is large.
The performance of the PID control law can be evaluated using step inputs and various
performance criteria. For example, the rise time is the time it takes for the output to rise from
10% to 90% of its final value. The percent overshoot is the amount by which the response

overshoots its steady-state value. The settling time is the time it takes for the output to settle
within 2% of its final value. The steady-state error is the difference between the steady-state
value and the reference input.

2.

Experiments

Equipment needed:
You will need:
& brush DC motor,
& dual power amplifier,
& cable rack, and
& small brush DC motor (to serve as a load).
& You will also need a metal frame to mount the motors on,
and a box with screws and a screwdriver.
& dSpace kit which includes an encoder cable and I/O
breakout box.

2.1

Preliminary testing

Following steps similar to those followed in Lab 1, test the operation of the system including
amplifier, motors and encoder. Then, attach the smaller DC motor to the bigger one with a shaft
coupler. Connect the small DC motor to the second amplifier through DACH2, and test its
operation the same as the larger motor. Important note: power is applied through the red and
black banana plugs. The yellow and green banana plugs are outputs from a tachometer and
should not be used.

2.2

PID control - Manual tuning

The experiment ECE5570_lab2 applies the PID control law (1) to the motor. It is assumed that
the bigger DC motor, with the encoder, is connected to DACH 1. The program generates a step
of voltage of 6V on DACH 2 from time t = 1.5 to time t = 3 seconds. The torque generated by
the smaller DC motor simulates the effect of a change of load.
By trial and error, find the set of control parameters ( k P , k I , k D ) that gives the best step
response you can find (consider the performance criteria listed above). Apply a reference input
of 30 degrees. You will find that adjusting the three parameters is a tricky problem because of
their dependencies. One approach consists in first setting k I = 0 and finding the best possible
values of k P and k D . Usually, the response improves when k D increases, but there is a value
beyond which vibrations arise because of the discretization. For k P , there is usually an optimum
value beyond which the response becomes poorly damped. Once the first steps are
completed, k I may be raised in order to improve the steady-state error. Usually, the integral
action leads to a deterioration of the transient response and a trade-off has to be reached. The
proportional and derivative parameters may also have to be re-adjusted once k I is raised.

In your experiments, you are likely to observe the following phenomena:


&

&
&

2.3

Without a load, fast responses can be achieved with a PD control law ( kI = 0). The
responses also remain good for large steps. However, a significant steady-state error
appears under load disturbances;
With the integral action, the steady-state error goes to zero, but there is a tendency for the
control law (1) to overshoot, sometimes with a sluggish return to the steady-state value.
With sufficiently large steps of reference input (e.g., 300 degrees), the response
overshoots more than it does for small steps (even in percentage).

Working with dSPACE software Design

The programs used by the dSPACE board to implement experiments are created using C/C++
code and a compiler/linker provided with the system. For each of the labs the code for an
experiment is available in coursename_labX.c and driver.c where coursename is something like
ECE5570 and X is the lab number (ie..ECE5570_lab2.c ).
All of the control algorithms and the main loop are found in the coursename _labsX.c file,
which will be referred to as the lab code. Any code that supports the hardware interface to the
system is found in driver.c file, which will be called the driver code.
Looking at the lab code it can be broken down in to three sections. The first section contains
global variables that are used for connection to the buttons, plot windows and displays in the
layout window. The next section is the main( ) function which is processed when the board is
loaded. Last is a function called user_isr( ), this function contains the logic and equations that
implement the control laws for the experiments.
For an embedded system, like dSPACE, most of the code that does the work is not located
in the main( ) function. The main includes initializations for the system that sets up the
framework of hardware interrupts or ISRs. An ISR is a signal that tells the system that data is
ready to be sent/received or that a certain function should be performed.
In the case of the lab experiments, a built-in timer provides an ISR every 2 msec to perform
the operations of getting the current position for the incremental encoder (INC1) and setting the
output values of DACH1 and DACH2. The function isr_srt( ) in the driver code performs the
commands to read and write the encoder and ADC respectively. isr_srt( ) also runs the function
from the lab code user_isr( ) which performs the control processing. The system then sits and
waits for the next ISR.
The lab code and driver code must be compiled/linked to be used by the system.
This requires a Command prompt window. A shortcut to Command prompt is provided in the
directory with the lab experiments. From the command prompt the program down1104.exe can
be used to compile/link and load the program for the system. The syntax for this command is:
> Down1104 filename1.c fileaname2.c
All the .c files created to implement the experiment software must be listed as arguments to
down1104.exe.
In turn, this application is used to generate a .ppc file that contains the machine code used on
the board. Because of how the experiments are set up the first filename argument should be

coursename_labX.c followed by driver.c. With a valid execution of down1104.exe the board


should be loaded and ready to perform experiments.

2.4

Symmetric optimum and feed-forward modification

In the second part of the lab, replace the control law (1) by (2). The control law can be found in
the user_isr( ) function of the file ECE5570_lab2.c along with all the variable that will be need
to implement the control law of (2). You will determine the gain parameters by using the
principle of the symmetric optimum. Because the principle applies to PI control laws, the PID
parameters will be determined in two steps:
& First, the largest possible value of k D will be determined experimentally;
& then, the parameters k P and kI will be determined using the principle of the symmetric
& optimum for the resulting transfer function.
The response of the motor from the voltage to the velocity can be approximately modeled by a
first-order transfer function k / ' s $ a ( .For the motors in the lab, k ! 1000 and a ! 100. A good
value of k D for the motors in the lab is around 0.2. When such a velocity feedback is applied,

the transfer function becomes k / s ' s $ a $ kk D ( . From the voltage to the position, the transfer
function is then
P(s) "

k
with a) " a $ kk D
s ' s $ a) (

(3)

This transfer function is of the type for which the symmetric optimum parameters were derived
in Homework 2. The resulting parameters k P and kI were related to the parameters k and a)
through the relationships
a)
kP " ,
(4)
3k

kI "

' a)(

27k

(5)

Using the tuning procedure and the modified control law (2):
&
&
&
&
&

Find values for k P , kI , k D , and k F , and fine-tune these values experimentally to


optimize the performance for a 30 degree step;
Modify the control law so that performance remains acceptable for a large step (e.g.,300
degrees). Specifically, stop the integration when the maximum voltage is reached.
Plot the response for the large step.
Plot the response for a 30 degree step and for a period of time not exceeding 200ms.
Calculate the values of the rise time, percent overshoot, settling time, and steady-state
error with/without load.

3.

Report at a Glance

Be sure to include:
&
&
&
&
&
&
&
&

Plot of the response using the PD controller, with values of the PD gains.
Plot of the response using the PID controller, with values of the PID gains.
Plot of the response using the PID controller for a large step of reference input.
Plot of the (best) response using the modified PID controller for a long move.
Values of the PIDF gains given by the theory and eventually selected. C-code of the
modified control law.
Plot of the response using the modified PID controller, showing the detail of the transient
response.
Values of the rise time, settling time, percent overshoot, and steady-state error.
Comments.

You might also like