0% found this document useful (0 votes)
48 views

Lab 4 and 5

This lab session introduces mathematical modeling of electrical systems using Simulink. The document discusses using Simulink to model physical systems for control system design and analysis. It describes how Simulink solves modeling equations and obtains system responses to different inputs. Block diagrams in Simulink represent mathematical models using blocks for basic operations connected by lines representing system variables. Common block types are discussed from libraries for mathematical, continuous, source, and sink functions. The lab aims to demonstrate modeling circuits using integrator, gain, summer and other blocks in Simulink.

Uploaded by

Meer Umar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Lab 4 and 5

This lab session introduces mathematical modeling of electrical systems using Simulink. The document discusses using Simulink to model physical systems for control system design and analysis. It describes how Simulink solves modeling equations and obtains system responses to different inputs. Block diagrams in Simulink represent mathematical models using blocks for basic operations connected by lines representing system variables. Common block types are discussed from libraries for mathematical, continuous, source, and sink functions. The lab aims to demonstrate modeling circuits using integrator, gain, summer and other blocks in Simulink.

Uploaded by

Meer Umar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Lab No 04 Instrumentation and Control (EL-305)

NED University of Engineering and Technology Department of Electronic Engineering

LAB SESSION 04
OBJECT: Mathematical modeling of Electrical System

Theory:

o e is applied Potential.
o i is the mesh current.
The differential equations for the given figure.
According to Mesh Analysis:
e(t)=V L +V C +V R
e(t)=LD i +
The state equations for the given figure.
This circuit contains two energy-storage elements,
Inductor and capacitor.

Let state variables are


X1= Vc the voltage across the capacitor and
X2= i the current in the inductor.

STATE EQUATION:

PROCEDURE:
1. create a MATLAB-function RLC.m
function dXdt=RLC(t,X)
e=60; % (V)
R=10; % (Ohm)
L=1; % (H)
C=10; % (F)
%dX/dt
dXdt(1,1)=(1/C)*X(2);
Lab No 04 Instrumentation and Control(EL-305)
NED University of Engineering and Technology Department of Electronic Engineering

dXdt(2,1)=(-1/L)*X(1)-(R/L)*X(2)+(1/L)*e;

2. Write an other M. file to call the function:

clear
close
Clc
X0=[0 0];
[t,X]=ode45('RLC',[0 500],X0);
subplot(2,1,1);
plot(t,X(:,1));
legend('Vc');
grid on;
title('Vc');
subplot(2,1,2);
plot(t,X(:,2),'r');
legend('i');
grid on;
title('i');

Graph:
 Time constant = RC = 10*10= 100 sec
For first time constant :
 Vc=63.2% * e = 0.632*60 =37.92 V
Lab No 04 Instrumentation and Control(EL-305)
NED University of Engineering and Technology Department of Electronic Engineering

OBSERVATIONS:
Parameter Behavior of system
Voltage
source(e)
Resistance(R)

Inductance(L)

Capacitance(C)

CONCLUSION:

EXERCISE:
Write the function and program of the following circuit diagram. Also explain the plots
of the respective state variables.
Criteria Poor (25%) Fair (50%) Good (75%) Excellent (100%)
Set up • Setup of equipment is not accurate • Setup of equipment is generally • Setup of equipment is generally • All equipment accurately placed
equipment • Help is required with several major workable with several details that accurate with 1 or 2 small details that • All necessary supplies on hand
and care details. need refinement need refinement • Very neat and organized
(20 points) • Many necessary supplies must be • Some necessary supplies must be • All necessary supplies on hand
found during lab (mid-lab) or after searched out after start of
start of experiment experiment
Following • Lacks the appropriate knowledge of • Demonstrates general knowledge of • Demonstrates good knowledge of the • Demonstrates very good knowledge
procedure the lab procedures lab procedures lab procedures of lab procedures
(30 points) • Often requires help from the • Requires help from teacher with • Will ask peers for help with problems • Gladly helps other students to follow
instructor to complete even basic some steps in procedures in lab procedures procedures
procedures • Works to follow each step before • Thoroughly and carefully follows
moving on to the next step each step before thoughtfully moving
on to the next step
Data • Measurements are incomplete, • Measurements are somewhat • Measurements are mostly accurate • Measurements are both accurate
collection inaccurate and imprecise inaccurate and very imprecise • Observations are generally complete and precise
(20 points) • Observations are incomplete or not • Observations are incomplete or • Work is organized • Observations are very thorough and
included recorded in a confusing way • Only 2 or 3 minor errors using may recognize possible errors in data
• Symbols, units and significant figures • There are 3 or more minor errors symbols, units and significant digits. collection
are not included using symbols, units and significant • Work is neat and organized
digits or 2 major errors • Includes appropriate symbols, units
and significant digits
Safety • Proper safety precautions are • Proper safety precautions are often • Proper safety precautions are • Proper safety precautions are
(10 points) consistently missed missed generally used consistently used
• Needs to be reminded often during • Needs to be reminded more than • May need to be reminded once • Consistently thinks ahead to ensure
the lab once during the lab during the lab safety
• Will often help other students to
conduct labs safely
Reporting • Many observations are not reported • Some significant observations are • Few relevant observations are missed • All relevant observations are
the results • Results are not discussed missed but report covers overall • Results are discussed reported and results are thoroughly
(20 objective of the lab session assessed
points) • Results are briefly discussed

Penalties 1. Late for more than 10 minutes without strong justification • -25 points of total score
2. Not wearing proper attire in the lab or wearing metallic jewelry which poses a safety hazard
3. Not obeying technician/demonstrator’s instructions
4. Eating/drinking in the lab
Lab No 05 Instrumentation and Control(EL-305)
NED University of Engineering and Technology Department of Electronic Engineering

LAB SESSION 05
OBJECT: Mathematical modeling of Electrical System by Simulink
THEORY:
To use graphical user interface diagrams to model the physical systems for the purpose of
design and analysis of control systems. We will learn how MATLAB/SIMULINK helps
in solving such models. This lab introduces powerful graphical user interface (GUI),
Simulink of MATLAB.
This software is used for solving the modeling equations and obtaining the response of a
system to different inputs. Both linear and nonlinear differential equations can be solved
numerically with high precision and speed, allowing system responses to be calculated
and displayed for many input functions.

A block diagram is an interconnection of blocks representing basic mathematical


operations in such a way that the overall diagram is equivalent to the system’s
mathematical model.
The lines interconnecting the blocks represent the variables describing the system
behavior. Block diagrams can represent modeling equations in both input-output and
state variable form.

SIMULINK
Simulink provides access to an extensive set of blocks that accomplish a wide range of
functions useful for the simulation and analysis of dynamic systems. The blocks are
grouped into libraries, by general classes of functions.
o Mathematical functions such as summers and gains are in the Math library.
o Integrators are in the Continuous library.
o Constants, common input functions, and clock can all be found in the Sources
library.
o Scope, To Workspace blocks can be found in the Sinks library.
o Simulink uses blocks to write a program.
o Blocks are arranged in various libraries according to their functions.
o Properties of the blocks and the values can be changed in the associated dialog
boxes.
Some of the blocks are given below.
SUM (Math library)
The sum block can be represented in two ways in Simulink, by a circle or by a rectangle.

GAIN (Math library)


A gain block is shown by a triangular symbol, with the gain expression written inside

INTEGRATOR (Continuous library)


Lab No 05 Instrumentation and Control(EL-305)
NED University of Engineering and Technology Department of Electronic Engineering

 The block for an integrator as shown below looks unusual. The quantity 1/s
comes from the Laplace transform expression for integration.

CONSTANTS (Source library)


 Constants are created by the Constant block .
 Double- clicking on the symbol opens a dialog box to establish the constant’s
value.
 It can be a number or an algebraic expression using constants whose values are
defined in the workspace .

STEP (Source library)


 A Simulink block is provided for a Step input, a signal that changes (usually from
zero) to a specified new, constant level at a specified time. These levels and time
can be specified through the dialog box, obtained by double-clicking on the Step
block.

SIGNAL GENERATOR (Source library)


 One source of repetitive signals in Simulink is called the Signal Generator.
 Double-clicking on the Signal Generator block opens a dialog box,where a sine
wave, a square wave, a ramp (saw tooth), or a random waveform can be chosen.
 In addition, the amplitude and frequency of the signal may be specified.
 The signals produced have a mean value of zero.
The repetition frequency can be given in Hertz (Hz).

SCOPE (Sinks library)


 The system response can be examined graphically, as the simulation runs, using
the Scope block in the sinks library .
 This name is derived from the electronic instrument, oscilloscope which performs
a similar function with electronic signals.
 Any of the variables in a Simulink diagram can be connected to the Scope block,
and when the simulation is started, that variable is displayed.
 It is possible to include several Scope blocks.
 Also it is possible to display several signals in the same scope block using a MUX
block in the signals & systems library.
Lab No 05 Instrumentation and Control(EL-305)
NED University of Engineering and Technology Department of Electronic Engineering

 The Scope normally chooses its scales automatically to best display the data.

CLOCK (Sources library)


 The clock produces the variable “time” that is associated with the integrators as
MATLAB calculates a numerical (digital) solution to a model of a continuous
system.
 The result is a string of sample values of each of the output variables.
 These samples are not necessarily at uniform time increments, so it is necessary to
have the variable “time” that contains the time corresponding to each sample
point.
 Then MATLAB can make plots versus “time.”
 The clock output could be given any arbitrary name; we use “t” in most of the
cases.

To Workspace (Sinks library)


 The To Workspace block is used to return the results of a simulation to the
MATLAB workspace, where they can be analyzed and/or plotted.
 Any variable in a Simulink diagram can be connected to a To Workspace block.
 In our exercises, all of the state variables and the input variables are usually
returned to the workspace.

In the Simulink diagram, the appearance of a block can be changed by changing the
foreground or background colors, or by drop shadow or other options available in the
format drop down menu. The available options can be reached in the Simulink window
by highlighting the block, then clicking the right mouse button. The Show Drop Shadow
option is on the format drop-down menu.

GENERAL INSTRUCTIONS FOR WRITING A SIMULINK PROGRAM


• To create a simulation in Simulink, follow the steps:
• Start MATLAB.
• Start Simulink.
• Open the libraries that contain the blocks you will need. These usually will
include the Sources, Sinks, Math and Continuous libraries, and possibly others.
• Open a new Simulink window.
• Drag the needed blocks from their library folders to that window. The Math
library, for example, contains the Gain and Sum blocks.
• Arrange these blocks in an orderly way corresponding to the equations to be
solved.
Lab No 05 Instrumentation and Control(EL-305)
NED University of Engineering and Technology Department of Electronic Engineering

• Interconnect the blocks by dragging the cursor from the output of one block to the
input of another block. Interconnecting branches can be made by right-clicking on
an existing branch.
• Double-click on any block having parameters that must be established, and set
these parameters. For example, the gain of all Gain blocks must be set. The
number and signs of the inputs to a Sum block must be established. The
parameters of any source blocks should also be set in this way.
• It is necessary to specify a stop time for the solution. This is done by clicking on
the Simulation > Parameters entry on the Simulink toolbar.
Mass-Spring System Model
Consider the Mass-Spring system used in the previous exercise as shown in the
figure.

Where;
 Fs(x) is the spring force.
 Ff(t) is the friction coefficient
 x(t) is the displacement
 Fa(t) is the applied force
The differential equation for the above Mass-Spring system can then be written as
follows

PROCEDURE:
Modeling of a second order system
 Construct a Simulink diagram to calculate the response of the Mass-Spring
system.
 The input force increases from 0 to 8 N at t = 1 s.
 The parameter values are M = 2 kg, K= 16 N/m, and B =4 N.s/m.
 Draw the free body diagram.
 Write the modeling equation from the free body diagram
 Solve the equations for the highest derivative of the output.
 Draw a block diagram to represent this equation.
 Draw the corresponding Simulink diagram.
 Use Step block to provide the input fa(t).
 In the Step block, set the initial and final values and the time at which the step
occurs.
 Use the “To Workspace” blocks for t, fa(t), x, and v in order to allow MATLAB
to plot the desired responses. Set the save format to array in block parameters.
 Select the duration of the simulation to be 10 seconds from the Simulation >
Parameters entry on the toolbar
Lab No 05 Instrumentation and Control(EL-305)
NED University of Engineering and Technology Department of Electronic Engineering
Simulink file

M-file for parameter values


Fa = 8; %N
M = 2; %kg
K = 16; %N/m
B = 4; : % Ns/m
Plotting the outputs in MATLAB:
sim('Lab5') % Has the same effect as clicking on Start on the toolbar.
subplot(2,1,1); plot(t,position); % Plots the initial run with B=4
hold on ; % Plots later results on the same axes as the first.
subplot(2,1,2); plot(t,Velocity); hold on
B = 30; % New value of B; other parameter values stay the same.
sim('Lab5') % Rerun the simulation with new B value. Plots new x on original axes.
subplot(2,1,1); plot(t,position); hold on
subplot(2,1,2); plot(t,Velocity); hold on
B =50;
sim('Lab5');
subplot(2,1,1); plot(t,position); xlabel('Time(t)'); ylabel('Position'); title('Mass Spring System');
legend('B=4','B=30','B=50'); grid on;
subplot(2,1,2); plot(t,Velocity); xlabel('Time(t)'); ylabel('Velocity'); title('Mass Spring System');
legend('B=4','B=30','B=50'); grid on;
EXERCISE:
1. Use SIMULINK to model the same systems which you have already done in the
previous Lab 3 and Lab 4.
2. Plot the same outputs and compare it with the previous plots.

CONCLUSION:
Criteria Poor (25%) Fair (50%) Good (75%) Excellent (100%)
Set up • Setup of equipment is not accurate • Setup of equipment is generally • Setup of equipment is generally • All equipment accurately placed
equipment • Help is required with several major workable with several details that accurate with 1 or 2 small details that • All necessary supplies on hand
and care details. need refinement need refinement • Very neat and organized
(20 points) • Many necessary supplies must be • Some necessary supplies must be • All necessary supplies on hand
found during lab (mid-lab) or after searched out after start of
start of experiment experiment
Following • Lacks the appropriate knowledge of • Demonstrates general knowledge of • Demonstrates good knowledge of the • Demonstrates very good knowledge
procedure the lab procedures lab procedures lab procedures of lab procedures
(30 points) • Often requires help from the • Requires help from teacher with • Will ask peers for help with problems • Gladly helps other students to follow
instructor to complete even basic some steps in procedures in lab procedures procedures
procedures • Works to follow each step before • Thoroughly and carefully follows
moving on to the next step each step before thoughtfully moving
on to the next step
Data • Measurements are incomplete, • Measurements are somewhat • Measurements are mostly accurate • Measurements are both accurate
collection inaccurate and imprecise inaccurate and very imprecise • Observations are generally complete and precise
(20 points) • Observations are incomplete or not • Observations are incomplete or • Work is organized • Observations are very thorough and
included recorded in a confusing way • Only 2 or 3 minor errors using may recognize possible errors in data
• Symbols, units and significant figures • There are 3 or more minor errors symbols, units and significant digits. collection
are not included using symbols, units and significant • Work is neat and organized
digits or 2 major errors • Includes appropriate symbols, units
and significant digits
Safety • Proper safety precautions are • Proper safety precautions are often • Proper safety precautions are • Proper safety precautions are
(10 points) consistently missed missed generally used consistently used
• Needs to be reminded often during • Needs to be reminded more than • May need to be reminded once • Consistently thinks ahead to ensure
the lab once during the lab during the lab safety
• Will often help other students to
conduct labs safely
Reporting • Many observations are not reported • Some significant observations are • Few relevant observations are missed • All relevant observations are
the results • Results are not discussed missed but report covers overall • Results are discussed reported and results are thoroughly
(20 objective of the lab session assessed
points) • Results are briefly discussed

Penalties 1. Late for more than 10 minutes without strong justification • -25 points of total score
2. Not wearing proper attire in the lab or wearing metallic jewelry which poses a safety hazard
3. Not obeying technician/demonstrator’s instructions
4. Eating/drinking in the lab

You might also like