You are on page 1of 20

University of Sana’a Analog Control System

MT311
Faculty of Engineering

Mechatronics Department

Lab2:
System Modeling
Eng Mohamed Doba

16 – 04 - 2018
Quiz-1
 1- Solve the differential equation of the system using Matlab and plot its solution ?

 𝑑𝑥 2
=𝑏 ∗ 𝑥 − 𝑝 ∗ 𝑥 b=1, P=0.5, x0=3
𝑑𝑡
 2- Animation of 3d graph ?
Function: Z = sin(sqrt(X.^2+Y.^2))
System Modeling
 System modeling using mathematical equations:
- System modeling using Differential equations. (Script)
- System modeling using Block diagrams. (Simulink)
- System modeling using Transfer function. (Script + Simulink)
 System modeling using Simscape library in Matlab (Simulink)
 System modeling using Experimental methods
System Modeling Using Mathematical Equations
(Example: Dc Motor)
Types of Dc Motors

 Permanent magnet.
 Electro magnet:
 Separately excited.
 Self excited:
- Shunt Dc motor.
- Series Dc motor.
- Compound Dc motor.
Dc Motors Modeling – Basic Equations
DC Motor Modeling - (If : Constant)
Dc Motor Modeling - (If : Constant)

Magnetic flux of the field circuit is constant.

 Basic Governing Laws:


- Newton's 2nd law.
- Kirchhoff's voltage law.
- The torque generated by a DC motor is proportional to the armature current and the
strength of the magnetic field.

- The back EMF of the motor is proportional to the angular velocity of the shaft by a
constant factor Ke.
Dc Motor Modeling - (If : Constant):
 Equations describing the behavior
of the DC motor.
 Output Variable.
Dc Motor Modeling - (If : Constant)

 Example:
Using Matlab, solve the differential equation of the Dc motor? (i.e: current of the motor
with respect to time)
(v = 5 volts)
Dc Motor Modeling - (If : Constant)

 Example:
Using Matlab, solve the differential equation of the Dc motor? (i.e: current of the motor
with respect to time)
(v = 5 volts)

Solution:

function di = dc_dia(t, i) span_t = [0 10];


vin = 5; i0 = 0;
R = 1; [t, i ] = ode23(@dc_dia, span_t , i0);
L = 0.5; plot(t, i)
K = 0.01;
b = 0.1;

di = (vin-R*i-K*(K*i/b))/L;
end
More in Solving Differential Equations in Matlab

Solve a single differential equation


 Numerically solve differential equations, including higher order equations, by converting
equations to MATLAB® functions that ode45 can solve.

 Define this second-order differential equation.

syms y(t)
eqn = diff(y, 2) == (1-y^2)*diff(y) - y

 Convert eqn to a system of first-order differential equations by using odeToVectorField


from Symbolic Math Toolbox

V = odeToVectorField(eqn)
More in Solving Differential Equations in Matlab

 V is symbolic, but ode45 does not accept symbolic input. Therefore, convert V to a
MATLAB function by using matlabFunction. Specify the input variables as t and Y by
using the 'Vars' name-value pair argument.

M = matlabFunction(V,'Vars',{'t','Y'})

 Solve the system defined by M using ode45 for 0 ≤ t ≤ 20. Use the initial conditions y(0) =
2 and y'(0) = 0.

tspan = [0 20];
y0 = [2 0];
[tspan,sol] = ode45(M,tspan,y0);
plot(tspan,sol)
More in Solving Differential Equations in Matlab

Solve a System of Differential Equations


 Solve this system of linear first-order differential equations.

syms u(t) v(t)


ode1 = diff(u) == 3*u + 4*v;
ode2 = diff(v) == -4*u + 3*v;
odes = [ode1; ode2]

V = odeToVectorField(odes)
M = matlabFunction(V,'Vars',{'t','Y'})
tspan = [-5 5];
y0 = [1 0];
[tspan,sol] = ode45(M,tspan,y0);
plot(tspan,sol)
Dc Motor Modeling - (If : Constant)

 Example:
Using Matlab, solve the differential equation of the Dc motor? (i.e: current of the motor
with respect to time)
(v = 5 volts)
vin = 5;R = 1;L = 0.5;
Solution:
K = 0.01;b = 0.1;j = 0.01;

syms w(t) i(t)

ode1 = diff(w) == (K*i - b*w)/j;


ode2 = diff(i) == (vin- R*i - K*w)/L;

odes = [ode1;ode2]

V = odeToVectorField(odes)
M = matlabFunction(V,'Vars',{'t','Y'})
tspan = [0 5];
y0 = [0 0];
[tspan,sol] = ode45(M,tspan,y0);
plot(tspan,sol)
DC Motor Modeling - (Series Dc motor)
DC Motor Modeling - (Series Dc motor)

 Example:
Find the mathematical equations that describe the series dc motor and solve the
differential equations in Matlab?

Rs+Ra = 0.1
Vt = 5
K=k1=kf=0.1
Next lab:

Requirement from the students:


 Quiz to test your understanding for this lab

Subjects in the next lab:


 System modeling using Block diagrams
References:

 https://www.mathworks.com/help/index.html
 http://ctms.engin.umich.edu/CTMS/index.php
Any Questions ?!

By: Mohamed Doba


fb.com/mnb.doba

You might also like