© All Rights Reserved

25 views

© All Rights Reserved

- control engineering test one.pdf
- Class 24-26 PID Controllers and Robust Design
- Process Modeling, Identificaion and Control
- Optimisation of Settling Time for PID Position Control in Mobile Satellite Dish
- DC Modeling
- Control Systems--The Last Basic Course, Pt II
- Robust Control System Design(2004).pdf
- System Dynamics
- 05275897
- RTAR - Control Loop Perf Measurement 2-02-09
- 10 IJAEST Vol No.4 Issue No.1 Stability Enhancement of DC Motor Using IMC Tuned PID Controller 092 096
- s71500 Pid Control Function Manual EnUS en-US
- Control 1
- Mit Improved Filter Design in Internal Model Control
- Control Systems
- ELE 4201 Control Systems Laboratory_ 2
- 0041
- Simulink_Basics_Tutorial.pdf
- CS-II (Module 1)
- Steady State Errors

You are on page 1of 39

Matlab and Simulink

for Control

for Control

Automatica I (Laboratorio) Automatica I (Laboratorio)

2/78

Matlab and Simulink

Matlab and Simulink

CACSD CACSD

3/78

Matlab and Simulink for Control

Matlab and Simulink for Control

Matlab introduction

Simulink introduction

Control Issues Recall

Matlab design Example

Simulink design Example

Part I

Introduction

4 / 78

Introduction What is Matlab and Simulink?

What is Matlab

5 / 78

Introduction What is Matlab and Simulink?

What are Matlab components?

Development Environment

Graphics

6 / 78

Introduction What is Matlab and Simulink?

What is Simulink?

systems

7 / 78

Introduction What is Matlab and Simulink?

How Simulink Works?

1. Create a block diagram (model)

2. Simulate the system represented by a block diagram

8 / 78

Introduction Matlab&Simulink Getting Started

Matlab Environment

9 / 78

Introduction Matlab&Simulink Getting Started

The Matlab Language

D urers Matrix

1 A=[16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1 ] ;

2 sum(A) %ans = 34 34 34 34

3 sum(A ) %ans = 34 34 34 34

4 sum( di ag (A) ) %ans = 34

Operators

1 100: 7: 50 % 100 93 86 79 72 65 58 51

2 sum(A( 1 : 4 , 4 ) ) % ans = 34

10 / 78

Introduction Matlab&Simulink Getting Started

The Matlab API

You can call Matlab routines from C/FORTRAN programs and vice

versa

11 / 78

Introduction Matlab&Simulink Getting Started

Simulink Environment

12 / 78

Introduction Matlab&Simulink Getting Started

Starting Simulink

Just type in Matlab

1 s i mul i nk

13 / 78

Part II

Matlab Background

14 / 78

Matlab Background Transfer Functions and Laplace Transforms

Laplace Transform

Denition

The Laplace Transform is an integral transform perhaps second only to the

Fourier transform in its utility in solving physical problems. The Laplace

transform is dened by:

L[f (t)] (s)

0

f (t)e

st

dt

Source: [1, Abramowitz and Stegun 1972]

15 / 78

Matlab Background Transfer Functions and Laplace Transforms

Laplace Transform

Several Laplace Transforms and properties

f L[f (t)] (s) range

1

1

s

s > 0

t

1

s

2

s > 0

t

n n!

s

n+1

n Z > 0

e

at 1

sa

s > a

L

t

f

(n)

(t)

(s) = s

n

L

t

[f (t)]

s

n1

f (0) s

n2

f

(0) . . . f

(n1)

(0) (1)

This property can be used to transform dierential equations into algebraic

ones. This is called Heaviside calculus

16 / 78

Matlab Background Transfer Functions and Laplace Transforms

Heaviside Calculus Example

Let us apply the Laplace transform to the following equation:

f

(t) + a

1

f

(t) + a

0

f (t) = 0

which should give us:

s

2

L

t

[f (t)] (s) sf (0) f

(0)

+

+a

1

{sL

t

[f (t)] (s) f (0)} +

+a

0

L

t

[f (t)] (s) = 0

which can be rearranged to:

L

t

[f (t)] (s) =

sf (0) + f

(0) + a

1

f (0)

s

2

+ a

1

s + a

0

17 / 78

Matlab Background Transfer Functions and Laplace Transforms

Transfer Functions

Laplace transform of the system modelling equations (2) & (3)

System modelling equations

F = m v + bv (2)

y = v (3)

Laplace Transform:

F(s) = msV(s) + bV(s)

Y(s) = V(s)

18 / 78

Matlab Background Transfer Functions and Laplace Transforms

Transfer Functions cntd.

equation (5)

Transfer Function

Laplace Transform:

F(s) = msV(s) + bV(s) (4)

Y(s) = V(s) (5)

Transfer Function:

Y(s)

F(s)

=

1

ms + b

(6)

19 / 78

Matlab Background Matlab Functions

Matlab Functions Transfer Function I

What is tf?

Species a SISO transfer function for model h(s) = n(s)/d(s)

1 h = t f (num, den )

What are num & den?

row vectors listing the coecients of the polynomials n(s) and d(s)

ordered in descending powers of s

Source: Matlab Help

20 / 78

Matlab Background Matlab Functions

Matlab Functions Transfer Function II

tf Example

T(s) =

2s3

s+1

h=tf([2 -3], [1 1])

T(s) =

2s+1

4s

2

+s+1

h=tf([2 1], [4 1 1])

21 / 78

Matlab Background Matlab Functions

Matlab Functions Feedback I

Matlab code

1 s y s = f eedback ( f or war d , backward ) ;

Source: [2, Angermann et al. 2004]

22 / 78

Matlab Background Matlab Functions

Matlab Functions Feedback II

transfer function

Example

Forward =

1

sT

i

(7)

Backward = V (8)

T(s) =

C(s)

R(s)

=

1

sT

i

1 + V

1

sT

i

23 / 78

Matlab Background Matlab Functions

Matlab Functions Step Response

syst em=t f ( [ 2 1 ] , [ 4 1 1 ] ) ;

t =0: 0. 1: 50;

s t e p (100 syst em )

a x i s ( [ 0 30 60 180] )

24 / 78

Matlab Background Steady-State Error

Steady-State Error Denition

Figure 1: Unity Feedback System

Steady-State Error

The dierence between the input and output of a system in the limit as

time goes to innity

25 / 78

Matlab Background Steady-State Error

Steady-State Error

Steady-State Error

e() = lim

s0

sR(s)

1 + G(s)

(10)

e() = lim

s0

sR(s) |1 T(s)| (11)

26 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Feedback controller How does it work I?

Figure 2: System controller

derivative of e

integral of e

27 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Feedback controller How does it work II?

K

p

(proportional gain) times the magnitude of the error +

K

i

(integral gain) times the integral of the error +

K

d

(derivative gain) times the derivative of the error

Controllers Output

u = K

p

e + K

i

edt + K

d

de

dt

Controllers Transfer Function

K

p

+

K

i

s

+ K

d

s =

K

d

s

2

+ K

p

s + K

i

s

28 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Characteristics of PID Controllers

Proportional Controller K

p

Integral Controller K

i

Derivative Controller K

d

reduces overshoot

29 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Example Problem

Figure 3: Mass spring and damper problem

Modelling Equation

m x + b x + kx = F (12)

30 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Example Problem

Laplace & Transfer Functions

m x + b x + kx = F

ms

2

X(s) + bsX(s) + kX(s) = F(s) (13)

X(s)

F(s)

=

1

ms

2

+ bs + k

(14)

31 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Matlab System Response

Assumptions

Let: m = 1[kg], b = 10[Ns/m], k = 20[N/m]

Matlab code

1 %{ Set up v a r i a b l e s %}

2 m=1; b=10; k=20;

3 %{ Ca l c u l a t e r e s pons e%}

4 num=1;

5 den=[m, b , k ] ;

6 pl a nt=t f (num, den ) ;

7 s t e p ( pl a nt )

32 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Matlab System Response

Figure 4: Amplitude Displacement

33 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Problems

34 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Controllers Characteristics

Type Rise time Overshoot Settling time S-S Error

K

p

decrease increase small change decrease

K

i

decrease increase increase eliminate

K

d

small change decrease decrease small change

These correlations may not be exactly accurate, because K

p

, K

i

, and K

d

are dependent on each other. In fact, changing one of these variables can

change the eect of the other two.

35 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Controller

P Transfer Function

X(s)

F(s)

=

K

p

s

2

+ bs + (k + K

p

)

Matlab code

1 %{ Set up p r o p o r t i o n a l gai n%}

2 Kp=300;

3 %{ Ca l c u l a t e c o n t r o l l e r %}

4 s y s c t l =f eedback (Kp pl ant , 1 ) ;

5 %{ Pl ot r e s u l t s %}

6 t =0: 0. 01: 2;

7 s t e p ( s y s c t l , t )

36 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Controller Plot

Figure 5: Improved rise time & steady-state error

37 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Derivative Controller

PD Transfer Function

X(s)

F(s)

=

K

d

s + K

p

s

2

+ (b + K

d

)s + (k + K

p

)

Matlab code

1 %{ Set up p r o p o r t i o n a l and d e r i v a t i v e gai n%}

2 Kp=300; Kd=10;

3 %{ Ca l c u l a t e c o n t r o l l e r %}

4 c ont r=t f ( [ Kd , Kp ] , 1 ) ;

5 s y s c t l =f eedback ( c ont r pl ant , 1 ) ;

6 %{ Pl ot r e s u l t s %}

7 t =0: 0. 01: 2;

8 s t e p ( s y s c t l , t )

38 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Derivative Controller Plot

Figure 6: Reduced over-shoot and settling time

39 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Integral Controller

PI Transfer Function

X(s)

F(s)

=

K

p

s + K

i

s

3

+ bs

2

+ (k + K

p

)s + K

i

Matlab code

1 %{ Set up p r o p o r t i o n a l and i n t e g r a l gai n%}

2 Kp=30; Ki =70;

3 %{ Ca l c u l a t e c o n t r o l l e r %}

4 c ont r=t f ( [ Kp , Ki ] , [ 1 , 0 ] ) ;

5 s y s c t l =f eedback ( c ont r pl ant , 1 ) ;

6 %{ Pl ot r e s u l t s %}

7 t =0: 0. 01: 2;

8 s t e p ( s y s c t l , t )

40 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Integral Controller Plot

Figure 7: Eliminated steady-state error, decreased over-shoot

41 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Integral Derivative Controller

PID Transfer Function

X(s)

F(s)

=

K

d

s

2

+ K

p

s + K

i

s

3

+ (b + K

d

)s

2

+ (k + K

p

)s + K

i

Matlab code

1 %{ Set up p r o p o r t i o n a l and i n t e g r a l gai n%}

2 Kp=350; Ki =300; Kd=50;

3 %{ Ca l c u l a t e c o n t r o l l e r %}

4 c ont r=t f ( [ Kd , Kp , Ki ] , [ 1 , 0 ] ) ;

5 s y s c t l =f eedback ( c ont r pl ant , 1 ) ;

6 %{ Pl ot r e s u l t s %}

7 t =0: 0. 01: 2;

8 s t e p ( s y s c t l , t )

42 / 78

Matlab Background Proportional, Integral and Derivative Controllers

Proportional Integral Derivative Controller Plot

Figure 8: Eliminated steady-state error, decreased over-shoot

43 / 78

Part III

Matlab Cruise Control System

44 / 78

Matlab Cruise Control System Design Criteria

How does Cruise Control for Poor work?

Figure 9: Forces taking part in cars movement

Based on Carnegie Mellon University Library Control Tutorials for Matlab and Simulink

45 / 78

Matlab Cruise Control System Design Criteria

Building the Model

Using Newtons law we derive

F = m v + bv (15)

y = v (16)

Where: m = 1200[kg], b = 50[

Ns

m

], F = 500[N]

46 / 78

Matlab Cruise Control System Design Criteria

Design Criteria

max

= 10[m/s] = 36[km/h]

max

within 6[s]

2% of a steady-state error

47 / 78

Matlab Cruise Control System Matlab Representation

Transfer Function

System Equations:

F = m v + bv

y = v

Laplace Transform:

F(s) = msV(s) + bV(s) (17)

Y(s) = V(s) (18)

Transfer Function:

Y(s)

F(s)

=

1

ms + b

(19)

48 / 78

Matlab Cruise Control System Matlab Representation

Matlab Representation

Matlab code

1 m=1200;

2 b=50;

3 num=[ 1] ;

4 den=[m, b ] ;

5 c r u i s e=t f (num, den ) ;

6 s t e p = (500 c r u i s e ) ;

49 / 78

Matlab Cruise Control System Matlab Representation

Results

Figure 10: Car velocity diagram mind the design criteria

50 / 78

Matlab Cruise Control System Matlab Representation

Design criteria revisited

51 / 78

Matlab Cruise Control System PID Controller

Feedback controller

Figure 11: System controller

52 / 78

Matlab Cruise Control System PID Controller

Decreasing the rise time

Proportional Controller

Y(s)

R(s)

=

K

p

ms + (b + K

p

)

(20)

Matlab code

1 Kp=100; m=1200; b=50;

2 num=[ 1] ; den=[m, b ] ;

3 c r u i s e=t f (num, den ) ;

4 s y s c t l =f eedback (Kp c r u i s e , 1 ) ;

5 t =0: 0. 1: 20;

6 s t e p (10 s y s c l , t )

7 axi s ( [ 0 20 0 10] )

53 / 78

Matlab Cruise Control System PID Controller

Under- and Overcontrol

Figure 12: K

p

= 100 Figure 13: K

p

= 10000

54 / 78

Matlab Cruise Control System PID Controller

Making Rise Time Reasonable

Proportional Integral Controller

Y(s)

R(s)

=

K

p

s + K

i

ms

2

+ (b + K

p

)s + K

i

(21)

Matlab code

1 Kp=800; Ki =40; m=1200; b=50;

2 num=[ 1] ; den=[m, b ] ;

3 c r u i s e=t f (num, den ) ;

4 c ont r=t f ( [ Kp Ki ] , [ 1 0 ] )

5 s y s c t l =f eedback ( c ont r c r u i s e , 1 ) ;

6 t =0: 0. 1: 20;

7 s t e p (10 s y s c l , t )

8 axi s ( [ 0 20 0 10] )

55 / 78

Matlab Cruise Control System PID Controller

Results

Figure 14: Car velocity diagram meeting the design criteria

56 / 78

Part IV

Simulink Cruise Control System

57 / 78

Simulink Cruise Control System Building the Model

How does Cruise Control for Poor work?

Figure 15: Forces taking part in cars movement

Based on Carnegie Mellon University Library Control Tutorials for Matlab and Simulink

58 / 78

Simulink Cruise Control System Building the Model

Physical Description

Forces acting on the mass

F = m

dv

dt

+ bv (22)

Where: m=1200[kg], b=50[

Nsec

m

], F=500[N]

59 / 78

Simulink Cruise Control System Building the Model

Physical Description cntd.

Integral of acceleration

a =

dv

dt

dv

dt

= v (23)

60 / 78

Simulink Cruise Control System Building the Model

Building the Model in Simulink

Figure 16: Integrator block from Continuous block library

61 / 78

Simulink Cruise Control System Building the Model

Building the Model in Simulink

Obtaining acceleration

Acceleration

a =

dv

dt

=

F bv

m

(24)

62 / 78

Simulink Cruise Control System Building the Model

Building the Model in Simulink

Figure 17: Gain block from Math operators block library

63 / 78

Simulink Cruise Control System Building the Model

Elements used in Simulink Model

64 / 78

Simulink Cruise Control System Building the Model

Complete Model

65 / 78

Simulink Cruise Control System Building the Model

Mapping Physical Equation to Simulink Model

66 / 78

Simulink Cruise Control System Simulating the Model

Setting up the Variables

F=500[N]

...and set up variables in Matlab

1 m=1200;

2 b=50;

67 / 78

Simulink Cruise Control System Simulating the Model

Running Simulation

Choose SimulationStart

68 / 78

Simulink Cruise Control System Simulating the Model

Extracting Model into Matlab

Replace the Step and Scope Blocks with In and Out Connection

Blocks

69 / 78

Simulink Cruise Control System Simulating the Model

Verifying Extracted Model

Matlab code

1 [ A, B, C, D]=l i nmod ( cc2mt l b ) ;

2 [ num, den]= s s 2 t f (A, B, C, D) ;

3 s t e p (500 t f (num, den ) ) ;

70 / 78

Simulink Cruise Control System Simulating the Model

Matlab vs Simulink

Figure 18: Matlab

Figure 19: Simulink

71 / 78

Simulink Cruise Control System Implementing the PI Control

The open-loop system

K

p

= 800

K

i

= 40

72 / 78

Simulink Cruise Control System Implementing the PI Control

Subsystem

Figure 20: Subsystem Block and its Contents

73 / 78

Simulink Cruise Control System Implementing the PI Control

PI Controller I

Figure 21: Step: nal value=10, time=0

74 / 78

Simulink Cruise Control System Implementing the PI Control

PI Controller II

Figure 22: We use Transfer Fcn block from Continuous-Time Linear Systems

Library

75 / 78

Simulink Cruise Control System Implementing the PI Control

Results

76 / 78

References

References

Course basic references Course basic references

77/78

Textbooks

Textbooks

Digital Control of Dynamic Systems (3rd Edition)

by Gene F. Franklin, J. David Powell, Michael L.

Workman Publisher: Prentice Hall; 3 edition

(December 29, 1997) ISBN: 0201820544

Lecture slides

Computer Lab Exercises

78/78

- control engineering test one.pdfUploaded byMayanja Mugizi Mhamud
- Class 24-26 PID Controllers and Robust DesignUploaded byapi-26676616
- Process Modeling, Identificaion and ControlUploaded byluisagarcia366
- Optimisation of Settling Time for PID Position Control in Mobile Satellite DishUploaded byJournal of Telecommunications
- DC ModelingUploaded bydivinelight
- Control Systems--The Last Basic Course, Pt IIUploaded byabhineet sharma
- Robust Control System Design(2004).pdfUploaded bybaloochyb
- System DynamicsUploaded byr16
- 05275897Uploaded byanuj1166
- RTAR - Control Loop Perf Measurement 2-02-09Uploaded byDarkmatter Darkmatterr
- 10 IJAEST Vol No.4 Issue No.1 Stability Enhancement of DC Motor Using IMC Tuned PID Controller 092 096Uploaded byiserp
- s71500 Pid Control Function Manual EnUS en-USUploaded byTonheca Rockk
- Control 1Uploaded byJoel Parr
- Mit Improved Filter Design in Internal Model ControlUploaded byDiego Quimbert
- Control SystemsUploaded bymathematyx
- ELE 4201 Control Systems Laboratory_ 2Uploaded byKhandai Seenanan
- 0041Uploaded byShamsMohd
- Simulink_Basics_Tutorial.pdfUploaded byVinod Wankar
- CS-II (Module 1)Uploaded byioppoi poi
- Steady State ErrorsUploaded byMuhmmad Farrukh Ali
- OnderaUploaded bySubhasish Mahapatra
- Suppliment 1Uploaded byMelissa Smith
- Tuning of PID Matlab.pdfUploaded byKrešimir Džoić
- AIP JournalUploaded bySanjiv Cr
- AUV_PIDUploaded byLe Anh Tuan
- 4 Digital Control-Advanced Controllers_Autotuning.pdfUploaded byetmatsuda
- International Journal of Applied Control,Electrical and Electronics Engineering(IJACEEE)Uploaded byijwest
- APPLICATION OF OPTIMAL-TUNING PID CONTROL TO INDUSTRIAL HYDRAULIC SYSTEMSUploaded bySeyed Ali Tabatabaee
- Panagopoulos Et Al-2000-International Journal of Robust and Nonlinear ControlUploaded bySoumyadeep Bose
- Pid IntroductionUploaded byHilmy Pramuditya Fhansuri

- TapeOp March 2011 Sample_issueUploaded bycoffeecup44
- 1 Best Practices in Key Account ManagementUploaded bysribalaji85
- Onion Sites torwebUploaded byDonHuaflex
- Semi Automatic Stair Climbing Wheel ChairUploaded byInternational Journal of Innovative Science and Research Technology
- BACTERIAL CONCRETE - A SOLUTION TO CRACK FORMATIONUploaded byIJIRAE- International Journal of Innovative Research in Advanced Engineering
- mpact20overview203rd20Uploaded byapi-235813398
- DV 270 Droplet SeparatorUploaded byJas Indo
- Steven W. Anderson ResumeUploaded bySteven W. Anderson
- Analysis of Transmission Tower With Different ConfigurationUploaded byPankaj Taneja
- Oracle Sales Cloud eBookUploaded byDSunte Wilson
- Tabella Codici Evento e DiagnosticaUploaded byjorgedavidgonzalez
- FoilographyPrintmakingUploaded bycetakasyraf
- Wireless Local Loop (WLL)Uploaded byXee Roblox
- PG BulletinUploaded byPawan Kumar Meena
- Design and Control of an LCL Filter Based Three Phase Active Rectifier (1)Uploaded byTravis Gray
- kiosk.rtfUploaded byjcsk8
- Contoh Dokumen CalculationUploaded byTriana Rosma Fikriyati Dina
- Mcp Logo Guidelines June 2013Uploaded byLolan
- 3_Line Follower Robotic Doc _orgUploaded bySaidarao Pulipati
- Proj_Eval-1Uploaded byShaveta Sandhu
- GATE 1992.pdfUploaded byVammsy Manikanta Sai
- Generator Commissioning Procedure .pdfUploaded bykvrao44
- Beech Kit Catalog April 2009Uploaded byGerardo Altuna
- Prestressing MethodUploaded byMeghanaagarwal9
- Call Center Metrics and Useful TerminologyUploaded byvrkrishnan138624
- FullText.pdfUploaded byMate Šušnjar
- 5s Introduction(1)Uploaded byKavitha Ramalingam
- Skoda Rapid LeafletUploaded bymsreddy116
- 05 Process PlanningUploaded byCADTDD
- Book of Abstract MSCEIS 2015Uploaded byAnonymous EQCHo5