Basic Programming for Matlab-Control Systems-Lab Mannual, Exercises of Control Systems Analysis

This is lab manual for Control Systems course provided by Dr. Anjum Khalil at Quaid-i-Azam University. It includes: Analyzing, Behavior, Order, System, Theory, State, Space, Simulating, Frequency, Response, Robot

Typology: Exercises

2011/2012

Uploaded on 07/11/2012

hamzi
hamzi 🇵🇰

4.8

(6)

3 documents

1 / 40

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Control Systems Lab
Course Code: EE3811
LAB # 1:
BASIC PROGRAMMING FOR MATLAB
Nameofstudent:…………………………………………………………………..
RollNo:…..………………………………………………………………………..
DateofLAB:………………………………………………………………………
Reportsubmittedon:….……………………………………………….…………..
Section:….……………………………………………….………………………..

Marksobtained:…………………………

Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download Basic Programming for Matlab-Control Systems-Lab Mannual and more Exercises Control Systems Analysis in PDF only on Docsity!

Control Systems Lab

Course Code: EE

LAB # 1:

BASIC PROGRAMMING FOR MATLAB

Name of student: …………………………………………………………………..

Roll No: …..………………………………………………………………………..

Date of LAB: ………………………………………………………………………

Report submitted on: ….……………………………………………….…………..

Section: ….……………………………………………….………………………..

Marks obtained: …………………………

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

LAB # 1

FOR MATLAB COURSE WORK

Question no 1. A Linear System

a) A network structure of the form shown below is employed in a Neural Network architecture of ADALINE (Adaptive Linear Combiner).

w U

w2 Y U

w U

As shown, inputs from three different sensors are applied to the weights of the network and after being multiplied by the corresponding weights the inputs are summed together to produce the corresponding output Y. The system is described by the following set of linear equations Y=w1 U1 + w2U2 + w3*U Where the data set is as shown in the table below

U1 U2 U3 Y 2 3 4 6 1 2 3 8 5 6 4 9

Define a data matrix using the data given above and form a simple set of linear equations of the form

U*w=Y

Where U, w and Y are matrices.

b) Solve the set of linear equations by employing the inverse of U and using the Cramer Rule to find out the solution set for w (weights of the net).

w

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

TEAM X

Over No

Runs in this over

Total score

Run average

Wickets in this over

Total no of wickets

Run rate required to win 1 2 3 4 5 6 7 8 9

This table should be returned in the form of a MATRIX for team A and B both. Of course the last column in the table would hold true only for team playing second.

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Mohammad Ali Jinnah University, Islamabad

Control Systems Lab

Course Code: EE

LAB # 2

Introduction to Control Systems and MATLAB

Name of student: …………………………………………………………………..

Roll No: …..………………………………………………………………………..

Date of LAB: ………………………………………………………………………

Report submitted on: ….……………………………………………….…………..

Section: ….……………………………………………….………………………..

Marks obtained: …………………………

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Introduction to Simulink:

SIMULINK is a program for simulating dynamic systems. As an extension to MATLAB, SIMULINK adds many features specific to dynamic systems while retaining all of MATLAB’s general-purpose functionality. SIMULINK has two phases of use: model definition and model analysis. A typical session starts by either defining a model or retrieving a previously defined model, and then proceeds to analysis of that model. These two steps are often performed iteratively until the model achieves the desired behavior. To facilitate model definition, SIMULINK adds a new class of windows called block diagram windows. In these windows, models are created and edited principally by mouse driven commands. Part of mastering SIMULINK is to become familiar with the manipulation of model components within these windows. After you define a model, you can analyze it either by choosing options from the SIMULINK menus or by entering commands in MATLAB’s command window.

Constructing a Simple Model:

At the MATLAB prompt type >>simulink. This command displays a new window containing icons for the subsystem blocks that make up the standard library. These subsystems can be opened (by double-clicking) to produce the windows containing the prototype blocks to be copied into your models. Click on File and New, and then move the window to a comfortable position.

Open Sources, Sinks, Continuous, and Connections by double-clicking on the icon with the left mouse button. Move the windows to a comfortable position. Blocks can be copied from one window to another by dragging them from the original location to the new location by holding down the left mouse button. Assemble the following diagram in your working window. [e.g. Step Input -> Sources; Sum ->Math operations, Transfer Fcn -> Continuous; Scope -> Sinks ]

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

The above two figures shows Simulation 1 and Simulation 2 for the same system.

Simulation 1: The system which is usually represented by ‘G’ is shown as Integrator. Input to this system is a step function. In response to this input, the integrator’s output will be a Ramp. Another block, Gain, is attached in between the input and system. This gain will affect the output. Higher the value of this gain, more rapid will be the slope.

Simulation 2:

An advantage associated with this system is that it has faster response. As can be seen from the graph that the output is achieved in a less time due to faster response.

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Inverted Pendulum:

An inverted pendulum is a physical device consisting in a cylindrical bar (usually of aluminum) free to oscillate around a fixed pivot. The pivot is mounted on a carriage, which in its turn can move on a horizontal direction. The carriage is driven by a motor, which can exert on it a variable force. The bar would naturally tend to fall down from the top vertical position, which is a position of equilibrium. The goal of the LAB position. This is possible by exerting a force on the carriage through the motor, which tends to contrast the 'free' pendulum dynamics. The correct force has to be calculated measuring the instant values of the horizontal position and the pendulum angle.

Why it is used? The inverted pendulum is a traditional example (neither difficult nor

trivial) of a controlled system. Thus it is used in simulations and performance of different controllers (e.g. PID controllers, state space controllers, fuzzy controllers....).

Command To Open Inverted Pendulum In MATLAB:

On the Matlab Command Window, write “penddemo”.

An inverted pendulum is a physical device consisting in a bar (usually of aluminum) free to oscillate around a fixed pivot. The pivot is mounted on a carriage, which in its turn can move on a horizontal direction. The tor, which can exert on it a variable force. The bar would naturally tend to fall down from the top vertical position, which is a position of LAB is to stabilize the pendulum (bar) on the top vertical

s possible by exerting a force on the carriage through the motor, which tends to contrast the 'free' pendulum dynamics. The correct force has to be calculated measuring the instant values of the horizontal position and the pendulum angle.

The inverted pendulum is a traditional example (neither difficult nor trivial) of a controlled system. Thus it is used in simulations and LABs to show the performance of different controllers (e.g. PID controllers, state space controllers, fuzzy

Command To Open Inverted Pendulum In MATLAB:

On the Matlab Command Window, write “penddemo”.

An inverted pendulum is a physical device consisting in a bar (usually of aluminum) free to oscillate around a fixed pivot. The pivot is mounted on a carriage, which in its turn can move on a horizontal direction. The tor, which can exert on it a variable force. The bar would naturally tend to fall down from the top vertical position, which is a position of unsteady is to stabilize the pendulum (bar) on the top vertical

s possible by exerting a force on the carriage through the motor, which tends to contrast the 'free' pendulum dynamics. The correct force has to be calculated measuring the instant values of the horizontal position and the pendulum angle.

The inverted pendulum is a traditional example (neither difficult nor s to show the performance of different controllers (e.g. PID controllers, state space controllers, fuzzy

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Understanding Simulation:

  1. Open the ‘Lab1’ simulation.
  2. Identify different blocks.
  3. Identify the basic feedback block diagram from figure 1 as given below.

Sum^ Controller^ System

  1. Double click on the inverted pendulum subsystem and identify the different blocks in it.
  2. Comment about each block you have identified in step 4.
  3. Double click on the Controller block and identify different blocks present there, commenting about each one.
  4. Now start simulation by pressing the play button located in the toolbar.
  5. An output window will appear showing the inverted pendulum, positioned with respect to the slider given underneath.
  6. Change the position of the slider to answer these questions: o Does the triangle move when the position of the slider is changed?

o Is there any difference between the triangle and the pendulum?

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

  1. What is the value of error in the steady state?
  2. Note down the value of ‘K’ in the controller block.
  3. Stop simulation now.
  4. Change the values of ‘K’ and ‘Ki’ in the controller block to zero.
  5. Again start the simulation and note the changes you see.
  6. Do you see some error, what is the value of error now?
  7. Now give different values of the ‘K’ and ‘Ki’, and make a table of it, listing the corresponding steady-state error.

K Ki Steady-State Error

  1. Explain how you felt when you performed the LAB explained in control system in human body?

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Mohammad Ali Jinnah University, Islamabad

Control Systems Lab.

Course Code: EE 3813

LAB # 3

Modeling in Simulink using some basic examples

Name of student: …………………………………………………………………..

Roll No: …..………………………………………………………………………..

Date of LAB: ………………………………………………………………………

Report submitted on: ….……………………………………………….…………..

Section: ….……………………………………………….………………………..

Marks obtained: …………………………

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Objectives:

  1. Simulating a Cruise Control Model in Simulink.
  2. Modeling in Simulink.
  3. Exercise: Suspension Model.

Cruise Control Model:

Following is the equation of motion for an automobile.

v & +

Using this differential equation, we can find the transfer function of this cruise control.

U s

V s

( )

( )

Now implement this transfer function using simulink and analyze its output. Use the values of m = 1580 kg , and b = 26 N.sec/m period of time. Its output will be quite similar to a car whose driver accelerates it for instance and then leaves the car to decelerate at its own speed. Also make use of the differential equation to make a second model of the same system using simulink. Compare the output of both the systems now. It should be same.

LAB # 3

Simulating a Cruise Control Model in Simulink.

Exercise: Suspension Model.

Following is the equation of motion for an automobile.

m

u v m

b

Using this differential equation, we can find the transfer function of this cruise control.

m

b

m s +

1

Now implement this transfer function using simulink and analyze its output. Use the b = 26 N.sec/m. Remember to give the input for a small period of time. Its output will be quite similar to a car whose driver accelerates it for instance and then leaves the car to decelerate at its own speed. Also make use of the differential equation to make a second model of the same system using simulink. Compare the output of both the systems now. It should be same.

Following is the equation of motion for an automobile.

Using this differential equation, we can find the transfer function of this cruise control.

Now implement this transfer function using simulink and analyze its output. Use the

. Remember to give the input for a small period of time. Its output will be quite similar to a car whose driver accelerates it for an

Also make use of the differential equation to make a second model of the same system using simulink. Compare the output of both the systems now. It should be same.

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Location of Different Important Blocks:

  • Simulink > Continuous > Integrator.
  • Simulink > Continuous > Transfer Function.
  • Simulink > Continuous > Differentiator.
  • Simulink > Math Operations > Absolute.
  • Simulink > Math Operations > Gain.
  • Simulink > Math Operations > Slider Gain.
  • Simulink > Math Operations > Sum.
  • Simulink > Signal Routing > Demultiplexer.
  • Simulink > Signal Routing > Multiplexer.
  • Simulink > Sinks > Display.
  • Simulink > Sinks > Scope.
  • Simulink > Sources > Clock.
  • Simulink > Sources > Pulse Generator.
  • Simulink > Sources > Ramp.
  • Simulink > Sources > Signal Generator.
  • Simulink > Sources > Signal Builder.
  • Simulink > Sources > Sine Wave.
  • Simulink > Sources > Step Signal.

Control System Lab. Mohammad Ali Jinnah University, Islamabad.

Modeling a Toy train system:

Following are the differential equations one cart.

M x x

M

k

x F k

& &

2 2

1

Which can be re-arranged as:

2

2 2

1

2 1

s k
s F s

M s X X

M s X

Relating both the equations, use simulink to draw the desired mathematical model. Input to the system is ‘r’ and output should be ‘y’, to fulfill the transfer function given as:

Use the following values:

M 1 =10 kg M 2 =5 kg g=9.8 m/sec^2 μ =0.002 N.m/sec

k=

Exercise

Modeling a Toy train system:

Following are the differential equations for the toy train moving in one direction with

x x M x

x x M x

g

k g

&

&

1 2 2 2

1 2 1 1

μ

μ

1 2 2 2

1 2 1 1

s s gs s
k s s gs

X X M X

X X M X

Relating both the equations, use simulink to draw the desired mathematical model. system is ‘r’ and output should be ‘y’, to fulfill the transfer function given as:

for the toy train moving in one direction with

( s )

Relating both the equations, use simulink to draw the desired mathematical model. system is ‘r’ and output should be ‘y’, to fulfill the transfer function given as: