Top Banner
Research Methodology Part III: Modeling and Simulation Dr. Tarek A. Tutunji Mechatronics Engineering Department Philadelphia University - Jordan
119

Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

May 20, 2018

Download

Documents

lecong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Research Methodology Part III:

Modeling and Simulation Dr. Tarek A. Tutunji

Mechatronics Engineering Department

Philadelphia University - Jordan

Page 2: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Outline

• Math Models

• Simulation

• MATLAB General

• MATLAB Tool Boxes and Applications

• MATLAB Simulink

Dr.

Tar

ek A

. Tu

tun

ji

2

Page 3: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

What is a System? • A system can be considered as a mathematical transformation

of inputs into outputs.

• A system should have clear boundaries

• A system can be a connection of subsystems and/or components. An RLC circuit is a system where the resistor, the capacitor, the inductor, and the source are the components

Page 4: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Mathematical Models

Dr.

Tar

ek A

. Tu

tun

ji

4

Page 5: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Math Models

• Math modeling is the process of representing the behavior of a real system by a collection of mathematical equations.

• Many different models can be associated with the same system depending on the desired level of approximation.

• Models are cause-and-effect structures—they accept external information and process it according to the equations to produce one or more outputs.

• Parameter is a fixed-value unit of information

• Signal is a changing-unit of information

Page 6: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Math Models

Dr.

Tar

ek A

. Tu

tun

ji

6

Math Models Obtained using

Theoretical Based on physical principles

Experimental Based on measurements

Page 7: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Modeling vs. Experimental Validation

[Ref.] Craig and Stolfi

Page 8: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Modeling Cycle

Page 9: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Model Categories

• Static vs. dynamic

• Linear vs. nonlinear

• Time-invariant vs. time-variant

• SISO vs. MIMO

• Continuous vs. discrete

• Deterministic vs. stochastic

Page 10: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Static vs. Dynamic

• Models can be static or dynamic

• Static models produce no motion, fluid flow, or any other

changes.

• Example: Battery connected to resistor

• Dynamic models have energy transfer which results in power flow. This causes motion, or other phenomena that change in time.

• Example: Battery connected to resistor, inductor, and capacitor

Dr.

Tar

ek A

. Tu

tun

ji

10

v = 𝒊𝑹

idtC

1

dt

diLRiv

Page 11: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Linear vs. Nonlinear

• Linear models follow the superposition principle

• The summation outputs from individual inputs will be equal to the output of the combined inputs

• Most systems are nonlinear in nature, but linear models can be used to approximate the nonlinear models at certain point.

Dr.

Tar

ek A

. Tu

tun

ji

11

Page 12: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Linear vs. Nonlinear Models

• Linear Systems • Nonlinear Systems

Page 13: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Nonlinear Model: Motion of Aircraft

Page 14: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Nonlinear Models: 4-Bar Mechanism

Dr.

Tar

ek A

. Tu

tun

ji

14

𝑇 = 𝐴∅ 2 +1

2

𝑑𝐴

𝑑∅2∅ 22 +

1

2𝑘𝛾4 ∅2 − ∅2(0) + 𝐶𝛾4

2∅ 2

𝐴(∅ 2) = 𝑚𝑖 𝛼2 + 𝛽2 + 𝐽𝑖𝛾𝑖

2

4

𝑖=2

where

Page 15: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Linearization using Taylor Series

sin 𝑥 = sin 0 + cos 0 𝑥 − 0 = 𝑥

Linearization is done at a particular point. For example, linearizing the nonlinear function, sin at x=0, using the first two terms becomes

Page 16: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Time-invariant vs. Time-variant

• The model parameters do not change in time-invariant models

• The model parameters change in time-variant models

• Example: Mass in rockets vary with time as the fuel is consumed.

Dr.

Tar

ek A

. Tu

tun

ji

16 If the system parameters change with time, the system is time varying.

Page 17: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Time-invariant vs. variant

• Time-invariant

F(t) = ma(t) – g

Where m is the mass, a is the acceleration, and g is the gravity

• Time-variant

F = m(t) a(t) – g

Here, the mass varies with time. Therefore the model is time-varying

Dr.

Tar

ek A

. Tu

tun

ji

17

Page 18: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Linear Time-Invariant (LTI)

• LTI models are of great use in representing systems in many engineering applications.

• The appeal is its simplicity and mathematical structure.

• Although most actual systems are nonlinear and time varying

• Linear models are used to approximate around an operating point the nonlinear behavior

• Time-invariant models are used to approximate in short segments the system’s time-varying behavior.

Page 19: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

LTI Models: Block Diagrams Manipulation

Page 20: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SISO vs. MIMO

• Single-Input Single-Output (SIS0) models are somewhat easy to use. Transfer functions can be used to relate input to output.

• Multiple-Input Multiple-Output (MIMO) models involve combinations of inputs and outputs and are difficult to represent using transfer functions. MIMO models use State-Space equations D

r. T

arek

A. T

utu

nji

20

Page 21: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

System States

• Transfer functions

• Concentrates on the input-output relationship only.

• Relates output-input to one-output only SISO

• It hides the details of the inner workings.

• State-Space Models

• States are introduced to get better insight into the systems’ behavior. These states are a collection of variables that summarize the present and past of a system

• Models can be used for MIMO models

Page 22: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Block Diagram State Example

Page 23: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Differential Equations • A system can be represented by the differential equations

• x –state variable, u – input, y – output

• f and h are functions

• For LTI systems, the differential equations become

• A is called the dynamics (or system) matrix

• B is called the control (or input-gain) matrix

• C is called the sensor (or output-gain) matrix

• D is called the direct term.

Page 24: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Example: Spring-Mass with Damping

State-Space representation for SISO models

u (force) is the input q (displacement) is the output

u

Page 25: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MIMO Systems for DC Motor

Dr.

Tar

ek A

. Tu

tun

ji

25

Page 26: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SISO vs. MIMO Systems

Dr.

Tar

ek A

. Tu

tun

ji

26

Transfer Function U(t) Y(t)

Page 27: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Continuous vs. discrete

• Continuous models have continuous-time as the dependent variable and therefore inputs-outputs take all possible values in a range

• Discrete models have discrete-time as the dependent variable and therefore inputs-outputs take on values at specified times only in a range

Dr.

Tar

ek A

. Tu

tun

ji

27

Page 28: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Continuous vs. discrete-time

Page 29: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Continuous vs. discrete

• Continuous Models

• Differential equations

• Integration

• Laplace transforms

• Discrete Models

• Difference equations

• Summation

• Z-transforms

Page 30: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Calculus Review

• Differentiation

• Difference

• Integration

• Summation

Page 31: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Laplace vs. Z-transform

• Laplace transforms are used to transform models from the continuous-time domain to the frequency domain

Dr.

Tar

ek A

. Tu

tun

ji

31

• Z transforms are used to transform discrete-time models to the frequency domain.

Page 32: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Deterministic vs. Stochastic

• Deterministic models are uniquely described by mathematical equations. Therefore, all past, present, and future values of the outputs are known precisely

• Stochastic models cannot be described mathematically with a high degree of accuracy. These models are based on the theory of probability

Page 33: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulation

Dr.

Tar

ek A

. Tu

tun

ji

33

Page 34: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulation

• Simulation is the process of running, solving, and acquiring the results of a model using a computer.

• Simulation process can be divided into three sections:

• Initialization

• Iteration

• Termination

Page 35: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulation Advantages over Experiments • It is cheaper to model systems than to build real systems

• Some system states cannot be measured in the real system

• Virtual experiments are repeatable

• Simulated models are controllable

• Simulated models are monitorable

Page 36: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Real-Time Simulation

[Ref.] Prof. Rolf Isermann

Page 37: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB

• Math modeling with MATLAB

• MATLAB products

• MATLAB: Basics and general view

• Tool boxes and applications

• Control Design Application

• System Identification Application

• Neural Network Application

• Fuzzy Logic Application

• Simulink

• Simscape

• SimElectronics

Dr.

Tar

ek A

. Tu

tun

ji

37

Page 38: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

38

Page 39: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

39

Page 40: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

40

Page 41: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

41

Reference: Mathworks 2011

Page 42: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

42

Reference: Mathworks 2011

Page 43: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

43

Reference: Mathworks 2011

Page 44: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB Product Family

• MATLAB

• Math, Statistics, and Optimization

• Symbolic Math Toolbox • Partial Differential Equation Toolbox • Statistics Toolbox • Curve Fitting Toolbox • Optimization Toolbox • Global Optimization Toolbox • Neural Network Toolbox • Model-Based Calibration Toolbox

• Parallel Computing

• Parallel Computing Toolbox

• MATLAB Distributed Computing Server

• Control System Design and Analysis

• Control System Toolbox • System Identification Toolbox • Fuzzy Logic Toolbox • Robust Control Toolbox • Model Predictive Control Toolbox • Aerospace Toolbox

44

Page 45: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB Product Family • Signal Processing and Communications

• Signal Processing Toolbox • DSP System Toolbox • Communications System Toolbox • Wavelet Toolbox • RF Toolbox • Phased Array System Toolbox • LTE System Toolbox

• Test and Measurement

• Data Acquisition Toolbox • Instrument Control Toolbox • Image Acquisition Toolbox • OPC Toolbox • Vehicle Network Toolbox

• Image Processing and Computer Vision

• Image Processing Toolbox • Computer Vision System Toolbox • Image Acquisition Toolbox • Mapping Toolbox

• Computational Finance

• Financial Toolbox • Econometrics Toolbox • Datafeed Toolbox • Database Toolbox • Spreadsheet Link EX (for Microsoft Excel) • Financial Instruments Toolbox • Trading Toolbox

45

Page 46: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB Product Family

• Computational Biology

• Bioinformatics Toolbox

• SimBiology

• Application Deployment

• MATLAB Compiler • MATLAB Builder NE (for Microsoft .NET

Framework) • MATLAB Builder JA (for Java language) • MATLAB Builder EX (for Microsoft Excel) • Spreadsheet Link EX (for Microsoft Excel) • MATLAB Production Server

• Code Generation and Verification

• MATLAB Coder • C/C++ • HDL Coder • HDL Verifier • Filter Design HDL Coder • Fixed-Point Designer

• Database Connectivity and Reporting

• Database Toolbox

• MATLAB Report Generator

46

Page 47: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: Desktop

Dr.

Tar

ek A

. Tu

tun

ji

47

Page 48: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: Matrix Operations

Dr.

Tar

ek A

. Tu

tun

ji

48

Page 49: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: Plotting

Dr.

Tar

ek A

. Tu

tun

ji

49

Page 50: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: LTI Models

Dr.

Tar

ek A

. Tu

tun

ji

50

LTI Models and Transfer Functions

Connecting Block Diagrams

[Ref] Kevin Craig

Page 51: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: LTI model analysis

Dr.

Tar

ek A

. Tu

tun

ji

51

Analysis Plots

System Response

[Ref] Kevin Craig

Page 52: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Example

Dr.

Tar

ek A

. Tu

tun

ji

52

[Ref] Kevin Craig

Page 53: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Example

Dr.

Tar

ek A

. Tu

tun

ji

53

[Ref] Kevin Craig

Page 54: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: m-files

Dr.

Tar

ek A

. Tu

tun

ji

54

Page 55: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: m-files

Dr.

Tar

ek A

. Tu

tun

ji

55

Page 56: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: m-file commands

Dr.

Tar

ek A

. Tu

tun

ji

56

Page 57: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: m-file commands

Dr.

Tar

ek A

. Tu

tun

ji

57

Page 58: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

MATLAB: m-file commands

Dr.

Tar

ek A

. Tu

tun

ji

58

Page 59: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

M-File Example function [X,FX,DFX]= RMtst(x)

% Finds minimum of a function

% f(x) = 2(x-3)^2+4

% using an algorithm

% by updating the variable x

% in direction opposite to derivative

% X, FX, and DFX are the vectors

% composed of x, f(x), and f'(x) at

% each iteration

X=[]; FX=[]; DFX=[]

for i=1:12

% Evaluation the function

fx=2*(x-3)^2+4;

% Evalaute the derivative

dfx = 4*(x-3);

% update the variable

x=x-0.1*dfx;

% Save values in vectors

X=[X x];

FX = [FX fx];

DFX = [DFX dfx];

end

Dr.

Tar

ek A

. Tu

tun

ji

59

Page 60: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

M-File Example

Dr.

Tar

ek A

. Tu

tun

ji

60

x

f(x)

iteration

0 2 4 6 8 10 121

1.5

2

2.5

3

0 2 4 6 8 10 120

5

10

15

20

25

Page 61: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Control Design Application

Dr.

Tar

ek A

. Tu

tun

ji

61

Page 62: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Design and Analyze Control Systems • Control System Toolbox provides industry-standard algorithms and

applications for systematically analyzing, designing, and tuning linear control systems.

• Systems can be specified as a transfer function, state-space, zero-pole-gain or frequency-response model.

• Functions, such as step response plot and Bode plot, let you visualize system behavior in time domain and frequency domain.

• You can tune compensator parameters using automatic PID controller tuning and other interactive and automated techniques.

• You can validate your design by verifying rise time, overshoot, settling time, gain and phase margins, and other requirements.

Dr.

Tar

ek A

. Tu

tun

ji

62

Page 63: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Key Features

• Series, parallel, feedback, and general block-diagram connection of linear models

• Root locus, Bode diagrams, LQR, LQG, and other classical and state-space control system design techniques

• Model representation conversion, continuous-time model discretization, and low-order approximation of high-order systems

Dr.

Tar

ek A

. Tu

tun

ji

63

Page 64: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

64

Page 65: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Demos

>> demo toolbox control

Dr.

Tar

ek A

. Tu

tun

ji

65

Page 66: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

DC Motor Control Example

>> R = 2.0; L = 0.5; Km = 0.1; Kb = 0.1; Kf = 0.2; J = 0.02;

>> tf1 = tf(Km,[L R]);

>> tf2 = tf(1,[J Kf]);

>> tf3 =series(tf1,tf2); % assume Td = 0

>> DCsys = feedback(tf3,Kb);

Dr.

Tar

ek A

. Tu

tun

ji

66

Page 67: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Toolbox has Two Windows

Dr.

Tar

ek A

. Tu

tun

ji

67

Page 68: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Control and Estimation Tools Manager

Dr.

Tar

ek A

. Tu

tun

ji

68

Page 69: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Controller Architecture

Dr.

Tar

ek A

. Tu

tun

ji

69

Page 70: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Import Models

Dr.

Tar

ek A

. Tu

tun

ji

70

Page 71: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Analysis Plots

Dr.

Tar

ek A

. Tu

tun

ji

71

Page 72: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Closed and Open Loop Responses

Dr.

Tar

ek A

. Tu

tun

ji

72

Step Response

Time (seconds)

Am

plit

ude

0 0.5 1 1.5 2 2.50

0.05

0.1

0.15

0.2

0.25

Page 73: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Automated Tuning

Dr.

Tar

ek A

. Tu

tun

ji

73

Page 74: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

DC Motor Response with Controller

Dr.

Tar

ek A

. Tu

tun

ji

74

Step Response

Time (seconds)

Am

plit

ude

0 0.2 0.4 0.6 0.8 1 1.20

0.2

0.4

0.6

0.8

1

1.2

1.4

Page 75: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SISO Design Task

Dr.

Tar

ek A

. Tu

tun

ji

75

Page 76: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Output and Controller Signals

Dr.

Tar

ek A

. Tu

tun

ji

76

Step Response

Time (seconds)

Am

plit

ude

0 0.2 0.4 0.6 0.8 1 1.20

0.5

1

1.5

Step Response

Time (seconds)

Am

plit

ude

0 0.2 0.4 0.6 0.8 1 1.20

5

10

Page 77: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

System Identification Application

Dr.

Tar

ek A

. Tu

tun

ji

77

Page 78: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Creates Dynamic Models from Measurements • System Identification Toolbox provides MATLAB functions, Simulink blocks, and

an applications for constructing mathematical models of dynamic systems from measured input-output data.

• Time-domain and frequency-domain input-output data to identify continuous-

time and discrete-time transfer functions, process models, and state-space models.

• The toolbox also provides algorithms for embedded online parameter

estimation.

• The toolbox provides identification techniques such as maximum likelihood, prediction-error minimization and subspace system identification.

• Nonlinear system dynamics can be estimated using Hammerstein-Wiener models and nonlinear ARX models with wavelet network, tree-partition, and sigmoid network nonlinearities.

• The toolbox performs grey-box system identification for estimating parameters

of a user-defined model.

Dr.

Tar

ek A

. Tu

tun

ji

78

Page 79: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Key Features

• Transfer function, process model, and state-space model identification using time-domain and frequency-domain response data

• Autoregressive (ARX, ARMAX), Box-Jenkins, and Output-Error model estimation

using maximum likelihood, prediction-error minimization (PEM), and subspace system identification techniques

• Online model parameter estimation • Time-series modeling (AR, ARMA) and forecasting • Identification of nonlinear ARX models and Hammerstein-Wiener models with

input-output nonlinearities such as saturation and dead zone • Linear and nonlinear grey-box system identification for estimation of user-

defined models • Delay estimation, filtering, resampling, and reconstruction of missing data

Dr.

Tar

ek A

. Tu

tun

ji

79

Page 80: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

80

Page 81: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Demo Examples

Dr.

Tar

ek A

. Tu

tun

ji

81

Page 82: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Demo Examples

Dr.

Tar

ek A

. Tu

tun

ji

82

Page 83: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SI Example

>> load dryer2

This loads

• input (u2 – heating power)

• output (y2 – temperature of air flow)

Dr.

Tar

ek A

. Tu

tun

ji

83

Page 84: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SI Example

Dr.

Tar

ek A

. Tu

tun

ji

84

Page 85: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SI Example

Dr.

Tar

ek A

. Tu

tun

ji

85

Page 86: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SI Example

Dr.

Tar

ek A

. Tu

tun

ji

86

Page 87: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SI Example

Dr.

Tar

ek A

. Tu

tun

ji

87

Page 88: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SI Example

Dr.

Tar

ek A

. Tu

tun

ji

88

Page 89: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Fuzzy Logic Application

Dr.

Tar

ek A

. Tu

tun

ji

89

Page 90: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Design and Simulate Fuzzy Control Systems • Fuzzy Logic Toolbox provides MATLAB functions, graphical

tools, and a Simulink block for analyzing, designing, and simulating systems based on fuzzy logic.

• The product guides you through the steps of designing fuzzy inference systems. Functions are provided for many common methods, including fuzzy clustering and adaptive neurofuzzy learning.

• The toolbox lets you model complex system behaviors using simple logic rules and then implement these rules in a fuzzy inference system.

Dr.

Tar

ek A

. Tu

tun

ji

90

Page 91: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Key Features

• Specialized GUIs for building fuzzy inference systems and viewing and analyzing results

• Membership functions for creating fuzzy inference systems • Support for AND, OR, and NOT logic in user-defined rules • Standard Mamdani and Sugeno-type fuzzy inference systems • Automated membership function shaping through neuroadaptive

and fuzzy clustering learning techniques • Ability to embed a fuzzy inference system in a Simulink model • Ability to generate embeddable C code or stand-alone executable

fuzzy inference engines

Dr.

Tar

ek A

. Tu

tun

ji

91

Page 92: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

92

Page 93: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Example

Dr.

Tar

ek A

. Tu

tun

ji

93

Page 94: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

FIS Editor

Dr.

Tar

ek A

. Tu

tun

ji

94

Page 95: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Fuzzy Inputs and Outputs

Dr.

Tar

ek A

. Tu

tun

ji

95

Page 96: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Rule Editor

Dr.

Tar

ek A

. Tu

tun

ji

96

Page 97: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Export to Workspace

Dr.

Tar

ek A

. Tu

tun

ji

97

Page 98: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulink Model

Dr.

Tar

ek A

. Tu

tun

ji

98

Page 99: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulink Results

Dr.

Tar

ek A

. Tu

tun

ji

99

Page 100: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Neural Network Application

Dr.

Tar

ek A

. Tu

tun

ji

100

Page 101: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Create, Train, and Simulate Neural Networks • Neural Network Toolbox provides functions and applications

for modeling complex nonlinear systems that are not easily modeled with a closed-form equation

• Neural Network Toolbox supports supervised learning with feedforward, radial basis, and dynamic networks. It also supports unsupervised learning with self-organizing maps and competitive layers

• You can design, train, visualize, and simulate neural networks. You can use Neural Network Toolbox for applications such as data fitting, pattern recognition, clustering, time-series prediction, and dynamic system modeling and control

Dr.

Tar

ek A

. Tu

tun

ji

101

Page 102: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Neural Net Time Series

Dr.

Tar

ek A

. Tu

tun

ji

102

Page 103: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

103

Page 104: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

System Identification

Dr.

Tar

ek A

. Tu

tun

ji

104

Page 105: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Predictive Control

Dr.

Tar

ek A

. Tu

tun

ji

105

Find u’ to minimize the following function:

Ref: Martin Hagan

Page 106: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Example: CSTR >> predcstr

Dr.

Tar

ek A

. Tu

tun

ji

106

Page 107: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulink Product Family

• Simulink • Physical Modeling

• Simscape • SimMechanics • SimDriveline • SimHydraulics • SimRF • SimElectronics • SimPowerSystems

• Event-Based Modeling

• Stateflow

• SimEvents

• Control System Design and Analysis

• Simulink Control Design

• Simulink Design Optimization

• Aerospace Blockset

107

Page 108: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulink Product Family

• Signal Processing and Communications

• DSP System Toolbox • Communications System Toolbox • SimRF • Computer Vision System Toolbox

• Real-Time Simulation and Testing

• Simulink Real-Time

• Real-Time Windows Target

• Code Generation

• Simulink Coder • Embedded Coder • HDL Coder • Simulink PLC Coder • Fixed-Point Designer • DO Qualification Kit (for DO-178) • IEC Certification Kit (for ISO 26262 and IEC

61508)

• Verification, Validation, and Test

• Simulink Verification and Validation • Simulink Design Verifier • SystemTest • Simulink Code Inspector • HDL Verifier • Polyspace Bug Finder • Polyspace Code Prover

108

Page 109: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulink

Dr.

Tar

ek A

. Tu

tun

ji

109

Page 110: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulink Library Browser

Dr.

Tar

ek A

. Tu

tun

ji

110

Page 111: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simulink: Simple Examples

Dr.

Tar

ek A

. Tu

tun

ji

111

Page 112: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Simscape

Dr.

Tar

ek A

. Tu

tun

ji

112

Page 113: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Model and simulate multidomain physical systems • Simscape provides an environment for modeling and simulating

physical systems spanning mechanical, electrical, and hydraulic • It provides fundamental building blocks from these domains that

you can assemble into models of physical components, such as electric motors, inverting op-amps, hydraulic valves, and ratchet mechanisms.

• Simscape models can be used to develop control systems and test

system-level performance. • You can parameterize your models using MATLAB variables and

expressions, and design control systems for your physical system in Simulink®. To deploy your models to other simulation environments, including hardware-in-the-loop (HIL) system

• Simscape supports C-code generation.

Dr.

Tar

ek A

. Tu

tun

ji

113

Page 114: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

114

Page 115: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

SimElectronics

Dr.

Tar

ek A

. Tu

tun

ji

115

Page 116: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Model and Simulate Electronic and Mechatronic Systems • SimElectronics provides component libraries for modeling and

simulating electronic and mechatronic systems

• The libraries include models of semiconductors, motors, drives, sensors, and actuators

• SimElectronics models can be used to develop control algorithms in electronic and mechatronic systems, including vehicle body electronics and aircraft servomechanisms

Dr.

Tar

ek A

. Tu

tun

ji

116

Page 117: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Dr.

Tar

ek A

. Tu

tun

ji

117

Page 118: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Conclusion

• Math modeling is an integral part of research • Math models can be divide into: Static vs. dynamic, linear vs. nonlinear,

time-invariant vs. time-variant, SISO vs. MIMO, and continuous vs. discrete

• Simulation of math models show the response of the models and therefore help in the analysis of their behavior

• MATLAB is a very power software tool for modeling and simulation • MATLAB has many associated toolboxes. The most commonly-used for

mechatronics are: Control design, system identification, neural networks, and fuzzy logic

• Simulink has many additional packages. The most useful for

mechatronics are: Simscape and SimElecronics

Dr.

Tar

ek A

. Tu

tun

ji

118

Page 119: Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology Part III: Modeling and Simulation ... •Parameter is a fixed-value unit of information

Reference

• Mathworks user guides

• Mathworks presentations for MATLAB 2011

• Kevin Craig “MATLAB for Mechatronics”,Rensselaer Polytech Univ. 2000

• Rolf Isermann “Mechatronics Design Approach” Chapter 2 in Mechatronics Handbook edited by Bishop.

• Golnaraghi and Kao “Automatic Control Systems”. Theoretical Foundation: Modeling of Dynamic Systems (Ch4) 2010

• Astrom and Murray. “Feedback Systems: An Introduction to Scientists and Engineers”. System Models (Ch2) 2009