Tracked Vehicle Dynamics Modeling and Simulation Methodology ...
Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology...
Transcript of Research Methodology Part III: Modeling and Simulation. Modeling and... · Research Methodology...
Research Methodology Part III:
Modeling and Simulation Dr. Tarek A. Tutunji
Mechatronics Engineering Department
Philadelphia University - Jordan
Outline
• Math Models
• Simulation
• MATLAB General
• MATLAB Tool Boxes and Applications
• MATLAB Simulink
Dr.
Tar
ek A
. Tu
tun
ji
2
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
Mathematical Models
Dr.
Tar
ek A
. Tu
tun
ji
4
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
Math Models
Dr.
Tar
ek A
. Tu
tun
ji
6
Math Models Obtained using
Theoretical Based on physical principles
Experimental Based on measurements
Modeling vs. Experimental Validation
[Ref.] Craig and Stolfi
Modeling Cycle
Model Categories
• Static vs. dynamic
• Linear vs. nonlinear
• Time-invariant vs. time-variant
• SISO vs. MIMO
• Continuous vs. discrete
• Deterministic vs. stochastic
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
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
Linear vs. Nonlinear Models
• Linear Systems • Nonlinear Systems
Nonlinear Model: Motion of Aircraft
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
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
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.
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
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.
LTI Models: Block Diagrams Manipulation
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
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
Block Diagram State Example
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.
Example: Spring-Mass with Damping
State-Space representation for SISO models
u (force) is the input q (displacement) is the output
u
MIMO Systems for DC Motor
Dr.
Tar
ek A
. Tu
tun
ji
25
SISO vs. MIMO Systems
Dr.
Tar
ek A
. Tu
tun
ji
26
Transfer Function U(t) Y(t)
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
Continuous vs. discrete-time
Continuous vs. discrete
• Continuous Models
• Differential equations
• Integration
• Laplace transforms
• Discrete Models
• Difference equations
• Summation
• Z-transforms
Calculus Review
• Differentiation
• Difference
• Integration
• Summation
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.
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
Simulation
Dr.
Tar
ek A
. Tu
tun
ji
33
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
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
Real-Time Simulation
[Ref.] Prof. Rolf Isermann
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
Dr.
Tar
ek A
. Tu
tun
ji
38
Dr.
Tar
ek A
. Tu
tun
ji
39
Dr.
Tar
ek A
. Tu
tun
ji
40
Dr.
Tar
ek A
. Tu
tun
ji
41
Reference: Mathworks 2011
Dr.
Tar
ek A
. Tu
tun
ji
42
Reference: Mathworks 2011
Dr.
Tar
ek A
. Tu
tun
ji
43
Reference: Mathworks 2011
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
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
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
MATLAB: Desktop
Dr.
Tar
ek A
. Tu
tun
ji
47
MATLAB: Matrix Operations
Dr.
Tar
ek A
. Tu
tun
ji
48
MATLAB: Plotting
Dr.
Tar
ek A
. Tu
tun
ji
49
MATLAB: LTI Models
Dr.
Tar
ek A
. Tu
tun
ji
50
LTI Models and Transfer Functions
Connecting Block Diagrams
[Ref] Kevin Craig
MATLAB: LTI model analysis
Dr.
Tar
ek A
. Tu
tun
ji
51
Analysis Plots
System Response
[Ref] Kevin Craig
Example
Dr.
Tar
ek A
. Tu
tun
ji
52
[Ref] Kevin Craig
Example
Dr.
Tar
ek A
. Tu
tun
ji
53
[Ref] Kevin Craig
MATLAB: m-files
Dr.
Tar
ek A
. Tu
tun
ji
54
MATLAB: m-files
Dr.
Tar
ek A
. Tu
tun
ji
55
MATLAB: m-file commands
Dr.
Tar
ek A
. Tu
tun
ji
56
MATLAB: m-file commands
Dr.
Tar
ek A
. Tu
tun
ji
57
MATLAB: m-file commands
Dr.
Tar
ek A
. Tu
tun
ji
58
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
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
Control Design Application
Dr.
Tar
ek A
. Tu
tun
ji
61
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
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
Dr.
Tar
ek A
. Tu
tun
ji
64
Demos
>> demo toolbox control
Dr.
Tar
ek A
. Tu
tun
ji
65
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
Toolbox has Two Windows
Dr.
Tar
ek A
. Tu
tun
ji
67
Control and Estimation Tools Manager
Dr.
Tar
ek A
. Tu
tun
ji
68
Controller Architecture
Dr.
Tar
ek A
. Tu
tun
ji
69
Import Models
Dr.
Tar
ek A
. Tu
tun
ji
70
Analysis Plots
Dr.
Tar
ek A
. Tu
tun
ji
71
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
Automated Tuning
Dr.
Tar
ek A
. Tu
tun
ji
73
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
SISO Design Task
Dr.
Tar
ek A
. Tu
tun
ji
75
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
System Identification Application
Dr.
Tar
ek A
. Tu
tun
ji
77
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
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
Dr.
Tar
ek A
. Tu
tun
ji
80
Demo Examples
Dr.
Tar
ek A
. Tu
tun
ji
81
Demo Examples
Dr.
Tar
ek A
. Tu
tun
ji
82
SI Example
>> load dryer2
This loads
• input (u2 – heating power)
• output (y2 – temperature of air flow)
Dr.
Tar
ek A
. Tu
tun
ji
83
SI Example
Dr.
Tar
ek A
. Tu
tun
ji
84
SI Example
Dr.
Tar
ek A
. Tu
tun
ji
85
SI Example
Dr.
Tar
ek A
. Tu
tun
ji
86
SI Example
Dr.
Tar
ek A
. Tu
tun
ji
87
SI Example
Dr.
Tar
ek A
. Tu
tun
ji
88
Fuzzy Logic Application
Dr.
Tar
ek A
. Tu
tun
ji
89
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
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
Dr.
Tar
ek A
. Tu
tun
ji
92
Example
Dr.
Tar
ek A
. Tu
tun
ji
93
FIS Editor
Dr.
Tar
ek A
. Tu
tun
ji
94
Fuzzy Inputs and Outputs
Dr.
Tar
ek A
. Tu
tun
ji
95
Rule Editor
Dr.
Tar
ek A
. Tu
tun
ji
96
Export to Workspace
Dr.
Tar
ek A
. Tu
tun
ji
97
Simulink Model
Dr.
Tar
ek A
. Tu
tun
ji
98
Simulink Results
Dr.
Tar
ek A
. Tu
tun
ji
99
Neural Network Application
Dr.
Tar
ek A
. Tu
tun
ji
100
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
Neural Net Time Series
Dr.
Tar
ek A
. Tu
tun
ji
102
Dr.
Tar
ek A
. Tu
tun
ji
103
System Identification
Dr.
Tar
ek A
. Tu
tun
ji
104
Predictive Control
Dr.
Tar
ek A
. Tu
tun
ji
105
Find u’ to minimize the following function:
Ref: Martin Hagan
Example: CSTR >> predcstr
Dr.
Tar
ek A
. Tu
tun
ji
106
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
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
Simulink
Dr.
Tar
ek A
. Tu
tun
ji
109
Simulink Library Browser
Dr.
Tar
ek A
. Tu
tun
ji
110
Simulink: Simple Examples
Dr.
Tar
ek A
. Tu
tun
ji
111
Simscape
Dr.
Tar
ek A
. Tu
tun
ji
112
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
Dr.
Tar
ek A
. Tu
tun
ji
114
SimElectronics
Dr.
Tar
ek A
. Tu
tun
ji
115
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
Dr.
Tar
ek A
. Tu
tun
ji
117
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
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