MAE106 Laboratory Exercises
Lab # 5
PD Control of DC motor position
University of California, Irvine
Department of Mechanical and Aerospace Engineering
Understand how to implement and tune a PD controller to control the position of a DC
Explore the frequency response of the PD controller by testing how it responds to
sinusoidal inputs of different frequencies.
Parts & equipment
1 Seeeduino board
1 Motor driver
1 DC motor with encoder
Introduction to PD Control
The most common controller used by engineering designers to control the movement of a
motorized part is the PD (proportional-derivative) controller (sometimes an integral control
term is added to create a PID controller, but we will not explore I control in this lab). In this
lab you will implement a PD position controller. Such controllers are also used in robot
arms, radars, numerically controlled milling machines, manufacturing systems, and control
surfaces on aerospace vehicles. The PD control law is:
𝜏 = −𝐾 𝑝𝜃 − 𝜃 𝑑 − 𝐾 𝑑𝜃 − 𝜃 𝑑
𝜃𝑑 desired motor angular position 𝜏 desired motor torque
𝜃̇ desired motor angular velocity 𝐾𝑝 proportional gain
𝜃𝑑 actual motor angular position 𝐾 derivative gain
𝜃 actual motor angular velocity
Note that the controller has two terms – one proportional to the position error (the “P” part),
and one proportional to the derivative of position (i.e. velocity, the “D” part). Thus, it is
called a “PD” controller. The implementation of this controller for a DC motor with inertia,
J, is shown in Figure 2. Figure 1. Block diagram that you will implement to make the PD controller for the motor. J
is the inertia of the motor shaft.
To understand how the actual system behaves we need to first understand its dynamics.
First, let's look at the dynamical equation that describes how θ evolves with time when the
controller is attached to the motor.
Dynamics of the motor and shaft:
𝜏 = 𝐽𝜃 ̈
Dynamics of the controller system:
𝜏 = 𝐽𝜃 = −𝐾 (𝜃 𝑝 𝜃 ) − 𝑑 (𝜃 − 𝑑 )̇ 𝑑
Re-writing to make input-output clear:
𝑱𝜽 + 𝑲 𝜽 + 𝑲 𝜽 = 𝑲 𝜽 + 𝑲 𝜽
𝒅 𝒑 𝒅 𝒅 𝒑 𝒅
This differential equation has similar dynamics to a mass-spring-damper system with
Force as the input and Position as the output. That is, it follows the same equations of
motion. This allows us to use our intuition about mass-spring-damper systems when
designing and tuning a PD controller.
Recall that the differential equation of motion for a mass-spring-damper system is given
𝑚𝑥̈ + 𝐵𝑥̇ + 𝐾𝑥 = 𝐹
and thus using the analogy to the PD controller we have that:
mass-spring-damper system PD controller
m mass J motor inertia
B damper 𝐾𝑑 derivative control term
K spring 𝐾𝑝 proportional control term
F input force 𝜏 desired motor torqueIn a mechanical system, if you wanted the system to respond more quickly, you would
increase the natural frequency (ω ) ny picking a stiffer spring (higher K). Which variable
would you change in your differential equation for the PD system to make your system
respond more quickly (i.e. increase its natural frequency)?
Note: there is a limit to how big you can make this variable because of the time delays in
this sampled data system.
By adding the derivative gain (K ) do control the position of the motor we must now take
into account the concept of damping when designing and implementing the controller.
With damping in the controller we can have four types of behaviors:
Undamped (i.e. zero damping): The system oscillates at its natural frequency.
These oscillations are a function of the controller's gain, Kp.
Underdamped: The system will move to its desired position and oscillate about this
position with is oscillations gradually decreasing to zero.
Critically damped: The system will move to its desired position as quickly as
possible without oscillating.
Overdamped: The system will move asymptotically towards its desired position
without oscillating, but at a slower rate than the critically damped case.
Suppose you didn’t want your motor to oscillate too much. This is an important issue! You
usually want your motor to go to a desired value quickly and accurately without oscillating.
You will have to change the derivative gain K untid you get the system to be critically
damped.Yellow Pin 2
White Pin 3
O.SVEINI Dual VNH25P 30
12V power supply
Yellow Pin 2 White Pin 3 01 01IN. OTINr OICS OGND Pololu MDO3A O.SVEINI Dual VNH25P 30 OVIN I O2PWM O2IN. O2INs Blue 5V Green GND 12V power supply fritzingPart I: Step response of the actual system
Construct the Arduino circuit in Figure 2. Download the code for this lab from the website
and run it on the Arduino. As in previous labs, when you open the Serial Monitor (or when
you press the 'reset' button on the Arduino), the code will re-initialize, then run a step
response and send time, position, and desired position of the motor to the monitor for the
duration of the response. You can copy and paste this into