Project 2 - Speed Control of a Direct Current (DC) motor
Project 2
In this project, a Simulink model for the DC motor will be first developed per the schematic shown in Figure 1.
Use the Proportional, Integral, and Derivative (PID) control design knowledge gained in the training to design, develop and test a controller to maintain a desired speed for the motor.
<!-- [if gte vml 1]>
Key Highlights:
- Mathematical modeling from the first principles
- Modeling an Electrical Engineering system
- Simulink based modeling
- Control law design and test
- Stability of a dynamic system
Deliverables:
- Matlab script to define modeling and control design parameters
- Simulink model to simulate and verify the design
Answer:
Code:
1. Motor parameters
Jm=0.01; %moment of inertia
Bm=0.1; %motor viscous friction
km=0.01; �ck emf constant
kt= 0.01; % Motor torque constant
Ra=1.0; %Armature resistance
La=0.5; %Armature inductance
2. motor design
subplot(3,2,1); plot(out.time,out.vs); grid; title('Supply Voltage');
subplot(3,2,2); plot(out.time, out.back_emf); grid; title('back emf');
subplot(3,2,3); plot(out.time, out.ai); grid; title('Armature Current');
subplot(3,2,4); plot(out.time, out.t); grid; title('Torque');
subplot(3,2,5); plot(out.time, out.w); grid; title('Speed');
3. PID Design
�ll parameters
run motor_parameters.m;
% PD Design
A= [-Bm/Jm kt/Jm; -km/La -Ra/La];
B= [0; 1/La];
%Pole placement design
fn=1;
wn=2*pi*fn;
zeta=0.5;
p1= -zeta*wn +wn*sqrt(zeta^2-1);
p2= -zeta*wn -wn*sqrt(zeta^2-1);
p=[p1;p2];
K=[A,B,P];
Design:
Step1:
Design of Motor:
<!-- [if gte vml 1]>
Step 2:
Design of DC Motor Dynamics:
<!-- [if gte vml 1]>
Step 3:
PID Design:
<!-- [if gte vml 1]>
Output Figure:
<!-- [if gte vml 1]>
Theory:
Modeling of DC motor:
Introduction to DC Motor
DC means “Direct Current”, and due to the pre-existing power distribution system, these motors could easily be controlled. The current flow in the wiring controls the speed of the motor. It has a direct relationship. A DC motor is a device or machine that converts DC power into mechanical energy. Its operation follows the principle that when a conductor carrying current is placed in a magnetic field, the conductor experiences a mechanical force. Fleming’s left-hand rule gives the direction of force.
Mathematical modelling from the first principle
Kirchhoff’s voltage law
Vf = Rf*If + If *d(if)/dt
Vs=Ra*Ia + La*d(Ia)/dt + Vb
The algebraic sum of all voltage around any closed loop in a circuit is equal to zero.
The relation between the Back EMF, angular velocity & Torque are related by
Vb =Km*d(theta)/dt. Vb= Back EMF; Km = Back EMF constant;
d(theta)/dt = angular velocity
T = Kt*Ia. T = torque; Kt = Torque constant
- The open loop transfer function for the motor with the speed(w) & Supply Voltage (Vs) can be derived as
w(s)/Vs(s) = Kt / [(J *La *s^2) + (J*Ra+b*La) *s+ (b*Ra+Kt*Km)]
A proportional integral & derivative (PID) controller design is to obtain the desired angular speed using the appropriate Supply voltage.
Vs = Supply Voltage b = motor viscous constant.
Ra = Armature Resistance; Ia = Armature Current; La = Armature Inductance
Vs -Vb = Ra*Ia + La*d(Ia)/dt ---------(1)
J*d^2(theta)/dt + b*d(theta)/dt = Kt*Ia -------(2)
Modelling an Electrical Engineering system using MATLAB code:
%This file contains the design parameters to model a DC Motor.
J = 0.01; %Moment of Inertia of the rotor in Kg-m^-2.
b = 0.1; %Motor Viscous friction Constant in N-m-s.
Km = 0.01; �ck EMF constant in v/rad/s.
Kt = 0.01; %Motor torque constant in N-m/amp.
Ra =1.0; % resistance of the armature circuit in Ohms.
La = 0.5; %Inductance of the armature circuit in Henries.
% Creating of state space Model
A = [-b/J Kt/J;-Km/La -Ra/La];
B = [0;1/La];
% Pole placement design and calculating of PID gains.
f = 1;
wn = 2*pi*f;
zeta = 0.5;
p1 = -zeta*wn+wn*sqrt(zeta^2-1);
p2 = -zeta*wn-wn*sqrt(zeta^2-1);
P = [p1;p2];
K = place (A, B,P);
Kp = K (1); %Proportional Gain
Kd = K (2); �rivative Gain
Ki = 20; %Integral Gain
Simulink:
we will assume that the input of the system is the voltage source (<!-- [if gte vml 1]>
The physical parameters for our example are:
(Jm) moment of inertia of the rotor 0.01 kg.m^2
(bm) motor viscous friction constant 0.1 N.m.s
(Ke) electromotive force constant 0.01 V/rad/sec
(Kt) motor torque constant 0.01 N.m/Amp
(R) Electric resistance 1 Ohm
(L) Electric inductance 0.5 H
In general, the torque generated by a DC motor is proportional to the armature current and the strength of the magnetic field. In this example we will assume that the magnetic field is constant and, therefore, that the motor torque is proportional to only the armature current <!-- [if gte vml 1]>
(1)<!-- [if gte vml 1]>
The back emf, <!-- [if gte vml 1]>
(2)<!-- [if gte vml 1]>
In SI units, the motor torque and back emf constants are equal, that is, <!-- [if gte vml 1]>
This system will be modeled by summing the torques acting on the rotor inertia and integrating the acceleration to give velocity. Also, Kirchoff's laws will be applied to the armature circuit. First, we will model the integrals of the rotational acceleration and of the rate of change of the armature current.
(3)<!-- [if gte vml 1]>
(4)<!-- [if gte vml 1]>
To build the simulation model, open Simulink and open a new model window. Then follow the steps listed below.
<!-- [if !supportLists]-->§ <!--[endif]-->Insert a Transfer Function block from the Simulink/Continuous library and draw lines to and from its input and output terminals.
<!-- [if !supportLists]-->§ <!--[endif]-->Label it "Armature" and the output line "Armature Current" as shown below. To add such a label, double-click in the empty space just below the line.
<!-- [if !supportLists]-->§ <!--[endif]-->Insert another Transfer Function block next to the previous one and draw lines to and from its input and output terminals.
<!-- [if !supportLists]-->§ <!--[endif]-->Label the input line "Torque", block as "Rotor Inertia and Friction" and the output line "Speed".
<!-- [if !supportLists]-->§ <!--[endif]-->Insert gain block and name it "Torque constant", connect it to the inpu and output terminals. Insert another gain block as shown in the below image.
<!-- [if !supportLists]-->§ <!--[endif]-->Connect a step input signal to the Sum block and output of sum block to the transfer function.
<!-- [if !supportLists]-->§ <!--[endif]-->Insert “To workspace” command to 5 output points as shown below and rename as required.
<!-- [if gte vml 1]>
In order to save all of these components except step signal and output command to workspace, as a single subsystem block, first select all of the blocks, then select Create Subsystem from Selection after right-clicking on the selected portion. Name the subsystem "DC_Motor_Dynamics" and then save the model.
<!-- [if gte vml 1]>
After creating the subsystem, insert Kp, Kd and Ki feedback signals to the circuit. Execute the model with different signal values and testing with different Ki values.
<!-- [if gte vml 1]>
Final Output Plot:
Plot at initial conditions:
<!-- [if gte vml 1]>
Plot at Ki value = 231
<!-- [if gte vml 1]>
Plot at ideal conditions with Ki = 100 and PID controllers
<!-- [if gte vml 1]>
Now For maintaining the stability of a dynamic system :
Output Results:
Case: 1 When maintaining a desired speed of the motor at 100:
<!-- [if gte vml 1]>
Case: 2 When maintaining a desired speed of the motor at 230v :
<!-- [if gte vml 1]>
<!-- [if !supportLists]-->· <!--[endif]-->Here by observing the above two graphs we change the desired speed as 100 in the case1 and 230 in the case 2
<!-- [if !supportLists]-->· <!--[endif]-->But here both the plots behaves same
<!-- [if !supportLists]-->· <!--[endif]-->So by this we can say that we maintained desired speed of a DC motor.
Conclusion:
The Simulink model for the DC motor as shown in Figure 1 uses the Proportional Integral and Derivative PID control design. Knowledge gained to design, develop and test a controller to maintain a desired speed for the motor.