Control Systems
PROJECT REPORT
Project Title:
Speed Control of DC Motor Using PID Controller
Submitted By:
o Nismat Abid FA21-BEE-073
o Ali Saad FA21-BEE-075
o Nabila Niazi FA21-BEE-082
Submitted To:
Sir Saad Hassan
Date:
17 May 2024
Department of Electrical & Computer Engineering
COMSATS University Islamabad, Wah Campus
PID Controller:
PID (Proportional-Integral-Derivative) control is a commonly used technique for controlling the
speed of DC motors. It is widely applied in various industries and automation systems where
precise speed control is required.
Principles of PID Control: PID control utilizes three components: proportional, integral, and
derivative. Each component contributes to the control signal based on the error between the desired
speed (setpoint) and the actual speed (feedback) of the DC motor.
1. Proportional Control (P): The proportional term produces an output signal proportional
to the current error. It contributes to the control effort in direct proportion to the difference
between the setpoint and the current speed. Proportional control alone can lead to steady-
state errors, as it does not consider the system's past behavior.
2. Integral Control (I): The integral term sums up the past errors over time and produces an
output signal proportional to the integral of the error. It helps eliminate steady-state errors
and provides a corrective action for sustained deviations from the setpoint.
3. Derivative Control (D): The derivative term considers the rate of change of the error. It
produces an output signal proportional to the rate of change and helps anticipate future
errors. Derivative control is beneficial in dampening the system's response, reducing
overshoot, and improving stability.
DC Motor:
A DC motor is any of a class of rotary electrical motors that converts direct current electrical
energy into mechanical energy. It is used for a wide variety of industrial, commercial and
residential operations.
Parameters Value
Armature inductance (Henry) La = 0.1215H
Armature resistance (ohm) Ra = 11.2Ω
Rotor inertia (kg m2 ) Jm = 0.002953Nms/rad
Armature Voltage (Volt) Va(t) = 240V
Viscous friction coefficient (Nms/rad) Bm = 0.002953Nms/rad
Motor Torque constant (Nm/A) Km = 1.28Nm/A
Back emf constant (V s/rad) Kb = 1.28Vs/rad
Speed W = 1500rpm
Tuning of PID controller:
Ziegler-Nichols tuning method: The Ziegler-Nichols Act is a PID amendment law that seeks to
produce fair values for the three parameters of obtaining a PID:
Kp - is the advantage of the control system
Ti - is the integration time of the controller
Td - is the time from the controller
Given the two parameters for measuring the measured response obtained from the ratings:
Tu time of oscillation frequency at the intensity level
The margin gain loop stability
Effects of increasing the PID controller parameters.
Parameter Rise time Overshoot Setting time Steady-state Stability
error
Kp Decrease Increase Small change Decrease Degrade
Ki Decrease Increase Increase Eliminate Degrade
Kd Minor change Decrease Decrease No effect in Improve
theory if Kd small
Simulation:
MATLAB Code:
% Motor parameters
Ra = 11.2;
L = 0.1215;
Km = 1.28;
Kb = 1.28;
Jm = 0.002953;
B =0.002953;
Kt =0.1;
Tl =0.1;
K =1;
omega=1500;
% Step 2: Define the transfer function
den1 = [1, ((Km*Kb)+(Ra*B)+(Kt*Km*K))/(Ra*Jm)];
num1 = (Kt*Km*K)/(Ra*Jm)*omega;
T = tf(num1, den1);
% Step 3: Create PID controller
Kp = 1.0; % Proportional gain
Ki = 0.5; % Integral gain
Kd = 0.2; % Derivative gain
controller = pid(Kp, Ki, Kd);
% Step 4: Connect PID controller to the transfer function
system = feedback(controller * T, 1);
% Step 5: Set desired speed reference
desired_speed = 100;
% Step 6: Simulate the control loop
t = 0:0.01:10; % Time vector
[y, ~] = step(desired_speed * system, t);
% Plot the results
plot(t, y)
xlabel('Time')
ylabel('Speed')
title('PID Speed Control of DC Motor')
Output:
Temperature Control
Proportional Control:
The proportional term of the PID controller generates a control signal proportional to
the error. The control signal is calculated as Kp * Error, where Kp is the proportional
gain. The proportional term contributes to the immediate response of the system to the
error.
Integral Control:
The integral term of the PID controller integrates the error over time to eliminate
steady-state errors. It is calculated as Ki * Integral(Error), where Ki is the integral gain.
The integral term helps to handle persistent errors and contributes to the long-term
response of the system.
Derivative Control:
The derivative term of the PID controller considers the rate of change of the error. It
helps dampen the response and reduce overshoot and oscillations. The control signal
from the derivative term is calculated as Kd * Derivative(Error), where Kd is the
derivative gain. The derivative term contributes to the responsiveness of the system to
changes in the error.
By continuously adjusting the control signal based on the error, the PID controller can regulate the
system to reach and maintain the desired temperature setpoint. The proportional, integral, and
derivative terms work together to balance the response speed, stability, and steady-state accuracy
of the temperature control system.
MATLAB Code:
% Transfer Function Parameters
K = 1; % Gain
tau = 2; % Time constant
num = K; % Numerator coefficients
den = [tau 1]; % Denominator coefficients
% Control Loop Parameters
dt = 0.1; % Time step
endTime = 10; % Total simulation time
% Create Transfer Function
sys = tf(num, den);
% Define different combinations of PID controller gains
kp_values = [1, 2, 3, 1, 2, 3];
ki_values = [0.5,1, 1.2, 2.3, 0.6, 1];
kd_values = [0.2, 0.4, 0.6, 2, 0.3, 5];
figure;
% Loop through different combinations and plot the step response
for i = 1:6
% PID Controller Parameters
Kp = kp_values(i);
Ki = ki_values(i);
Kd = kd_values(i);
% Create PID Controller
pidController = pid(Kp, Ki, Kd);
% Connect PID Controller to the Transfer Function
sys_with_pid = feedback(pidController * sys, 1);
% Simulate Step Response
t = 0:dt:endTime; % Time span
subplot(2, 3, i);
step(sys_with_pid, t);
title(sprintf('Kp=%.2f, Ki=%.2f, Kd=%.2f', Kp, Ki, Kd));
end
suptitle('Step Response of Temperature System with Different PID Controller Gains');
Output: