Download as pdf or txt
Download as pdf or txt
You are on page 1of 66

Simulation Model

Requirements and
Modeling and simulation Control Electrical
Specifications

of multi-domain
physical systems Embedded Mechanic
Software al

PLC HIL

Shripad Chandrachood
Sr. Application Engineer
MathWorks – Natick, MA

© 2013 The MathWorks, Inc.1


Motivation

 Many real-world physical systems are multi-domain:


Combination of Electrical, Mechanical, Hydraulic etc.

 Successful controller development requires thorough


and accurate understanding of the physical system
2
Motivation

 Many real-world physical systems are multi-domain:


Combination of Electrical, Mechanical, Hydraulic etc.

 Successful controller development requires thorough


and accurate understanding of the physical system
3
Motivation

 Many real-world physical systems are multi-domain:


Combination of Electrical, Mechanical, Hydraulic etc.

Blades
Nacelle
Geartrain
Hub
Generator
Rotor
Speed

Tower Grid

 Successful controller development requires thorough


and accurate understanding of the physical system
4
Case Study: Wind Turbine Modeling

Pitch
Wind Lift, Drag
Blades

Nacelle
Hub Geartrain Generator

Rotor
Speed
Generator
Speed
Yaw

Tower Grid
5
Agenda

 System-level simulation of a wind turbine


 Benefits of the Model-Based Design process
 Modeling multi-domain physical systems using Simscape
 Overview of MathWorks physical modeling tools
 Testing system integration

6
Key Points Simulation Model
Requirements and
Specifications
Control Electrical

 Efficient design of wind turbines Embedded


Mechanical
requires a smooth, continuous Software

development process
PLC HIL

 The ability to easily adjust


Actuator System
the level of model fidelity Inputs
(Ideal) (Include)
enables earlier detection of Actuator System
integration issues (Realistic) (Ignore)

 Automatically documenting
tests can speed up design
iterations and provide necessary
proof of system performance
7
Traditional Development Process

Requirements and Specifications


Requirements are
unclear, incomplete,
and not integrated in
design process
Design and Implementation
Separate simulation
models are difficult
Embedded
Control Software Mechanical Electrical to integrate

Errors are found too


Integration and Test late in the process
using expensive
prototypes

8
Model-Based Design Process

Simulation Model
Requirements Save time by
and developing in a single
Specifications simulation environment
Control Electrical
Produce better designs
by continuously
Embedded comparing design and
Software Mechanical specification

PLC HIL Lower costs by using


HIL tests and fewer
hardware prototypes

9
Demo: Wind Turbine System-Level Simulation

10
Linking Specification and Design

Situation:

Simulation Model

Wind Turbine Req.


1. Control System

2. Electrical System Control Electrical

3. Mechanical System

Embedded
Software Mechanical

Problem: Matching design to


specification is difficult
Solution: Use Simulink
Verification and Validation
to link the design and specification
11
Detect System Integration Issues In Simulation

Model:

Mechanical Controls
Park
Hydraulic Supervisory
Logic Spin

Drag
Electrical Aero- Lift
dynamics
Wind

Problem: Test for system


integration issues before
building hardware prototypes
Actuator System
Inputs
Solution: Use the Simulink (Ideal) (Include)
environment to integrate the Actuator System
separate systems in simulation (Realistic) (Ignore)
12
Optimize System-Level Performance

Actuators

Sensors
u + s1 s2
System
y
s3

Controller Plant

 Simulating plant and controller in one environment


allows you to optimize system-level performance.
– Automate tuning process using optimization algorithms
– Accelerate process using parallel computing

13
Detect Integration Issues Earlier

Plant Plant
Specification Model

Actuators

Sensors
u + s1 s2
System
y
s3

Controller Plant

 Controls engineers and domain specialists can work


together to detect integration issues in simulation
– Convert plant models to C code for hardware-in-the-loop tests
– Distribute models to other internal users without extra licenses
– Distribute models to external users while protecting IP

14
Build Accurate Models Quickly

Plant
Multidomain
Fortran, C++ Plant
Specification Domain Knowledge Programming Effort Model
Mechanical
MATLAB, Simulink
Domain Knowledge Programming Effort
Hydraulic

Electronic Physical Modeling


Domain Programming
Power Systems Knowledge Effort

 Requires less domain knowledge and


programming effort than traditional methods
– Spend more time developing, less time modeling

15
MathWorks Physical Modeling Products

Simscape
Mechanical Hydraulic Electrical
SimPowerSystems

Thermal Pneumatic Magnetic

SimHydraulics
N S

Custom Domains via


Simscape Language

Multidomain physical systems


Electrical power systems Fluid power and control

SimElectronics
SimMechanics

SimDriveline

Multibody mechanics (3-D) Mechanical systems (1-D) Electromechanical and


electronic systems 16
MathWorks Physical Modeling Products

SimPowerSystems
SimElectronics
SimMechanics

SimHydraulics
SimDriveline

Simscape
Mechanical Hydraulic Electrical Thermal Pneumatic Magnetic

17
Case Study: Wind Turbine Modeling

Pitch
Wind Lift, Drag
Blades

Nacelle
Hub Geartrain Generator

Rotor
Speed
Generator
Speed
Yaw

Tower Grid
18
The Technology of Modern Wind Turbines

Wind turbines have mechanical and electrical components


and are enabled by power electronics
19
Model the Generator and Electrical Grid

Model:

Geartrain Grid

Transformer
Load

Problem: Model the generator and


electrical grid for the wind turbine
Solution: Use SimPowerSystems
built in components for induction,
synchronous generators, or wind
turbine modules 20
Model the Utility Grid

 Model localized power distribution grids that include synchronous and


asynchronous machines, transformers, transmission line dynamics and a
variety of specialized FACTS devices
 Use SimPowerSystems Discrete Simulation Type for detailed transient
analysis or switch to Phasor Simulation Type for steady state analysis

21
Model the Geartrain in SimDriveline

Model:
Hub Generator
Shaft Shaft

Helical
Helical
Gear
Gear
Planetary
Gear

Problem: Model the geartrain


of the wind turbine within the
Simulink environment to determine
the torque loads.
Solution: Use SimDriveline
to model the geartrain.
22
Model DC to DC Power Converters

 Construct, test and re-use multiple power electronic


converter topologies quickly and efficiently

Buck (step-down) Converter

Boost (step-up) Converter

Buck-Boost Converter

23
Model DC to DC Power Converters

 Balance model fidelity and simulation speed according


to your needs

SimPowerSystems
Piecewise linear systems solution
Multiphase bridges and pulse generators
Transient and harmonic analysis
Faster simulation

SimElectronics
Nonlinear simultaneous equations solution
Include temperature effects
SPICE level switching device models
Detailed simulation

24
Model DC to AC Power Inverters

 Build complex, multi-phase, multi-level inverter circuits using the Universal


Bridge from the SimPowerSystems library

 Use the built-in tools in SimPowerSystems to perform harmonic analysis


directly on your simulation model
 Use average voltage models or ideal switching algorithms for control
design and faster simulation

25
Mechanical Design: Import the Entire Design
Directly from a CAD Tool

SimMechanics Model
SolidWorks Model

The translator automatically generates the SimMechanics model using CAD information

26
Mechanical Design: Using SimMechanics Link
to Import from a CAD Tool
 Automatically create SimMechanics
models from a CAD assembly
– Converts mass and inertia
to rigid bodies
– Converts mate definitions to joints
– Creates STL files for use
with SimMechanics visualization
 Directly connects SolidWorks,
ProEngineer and Inventor
 Public API for other CAD tools
 Free download from
www.mathworks.com
– Requires MATLAB
27
Mechanical Design: Using SimMechanics Link
to Import from a CAD Tool
 SimMechanics Link can
import XML file to:
– Create a new model
– Add to existing model
– Update an existing model
– Replace a portion of an
existing model

 Engineering teams can


collaborate on the same
system without doing
redundant work

28
Model Blade Pitch
Linkage

Model:

Problem: Model the blade pitch


actuation linkage in the
Simulink environment
Solution: Use SimMechanics
to model the mechanical linkage
29
Flexible Bodies in SimMechanics

 Lumped parameter approach


– Chain of rigid elements connected by spring/dampers

Rigid Rigid Rigid Rigid Rigid


Body Body Body Body Body
FE
Software
 Finite Element Approach
– Export eigenmodes 1 2
Massless Reaction Reaction Massless
from FE program and Force
State-Space Force
Body Body
Model
import into Simulink
– Superimpose deflection Deflection
Deflection Deflection
due to flexibility Joint
Motion
Joint
onto rigid body motion
3 4
Rigid Body

30
Flexible Blades in SimMechanics

Model:

Problem: Model the blades as


flexible cantilevers in the
Simulink environment.
Massless
Solution: Use SimMechanics to State-Space Body

model the flexible body with two Model


Deflection
Joint
approaches (lumped parameter,
imported FEA modes). Rigid Body 31
Wind Turbine Control Systems

 Blade pitch control system


Pitch – Adjust pitch angle to regulate
rotational speed
Wind Lift, Drag
Blades  Supervisory control system
– Analyze operating conditions to
Nacelle determine state of turbine
Hub Geartrain Generator to enable/disable operation

Rotor
Speed
Generator
Speed
Yaw

Tower Grid
32
Controlling Rotor Speed Using the Pitch Angle

Model:

Pitch

Lift

Rotor
Speed

Problem: Control the pitch


angle so that the generator Desired Desired Angle Pitch Angle
shaft spins at nominal speed Rotor Speed Control
of Attack
+
Command

Solution: Use Simulink to -


Actual Inflow
determine the pitch angle by Rotor Speed Angle
controlling the angle of attack 33
Integrating Simscape with Simulink

Actuators

Sensors
s1 s2

u + s3
Physical
System
y
Controller Plant
(SL/SF) (Simscape)

34
34
Automatically Document Tests And Results

Situation:
Test

Design
Change Document

Evaluate
Results

Problem: Evaluate test results


quickly to make design changes
 Fail
PDF,
and document the results HTML,
Solution: Use Simulink Report
Pass
Doc,
Generator to automatically …
document tests and results 35
Automatically Generating C Code

Model:

P1 P2 Px
10 10 …
100 10 …
… … …

Problem: Minimize the simulation


time on a parameter sweep to Standalone
Executable
determine controller parameters.
Parameters 1
Solution: Use Simulink Coder to Parameters 2
create standalone executable. Parameters 3

Parameters 4 36
Test Controller Hardware and Performance of
Generated Control Code

Model: Wind Turbine


Wind Pitch
Speed Pitch Command
Test Pitch
Control
Vector Actuator
Algorithm
Pitch Angle
Rotor Speed

Pitch
Anemometer Command
Signal

Pitch
Angle

Problem: Test control algorithm Solution: Generate C code for


on actual controller hardware controller and plant to run
without using prototypes hardware-in-the-loop tests
37
HIL Test Setup
HIL System
Pitch command is
Anemometer communicated via CAN
measures wind speed to pitch actuators.
and provides input signal Pitch angle is sensed
to HIL system and sent back to
main controller via CAN.

Simulink Model

Bachmann electronic
M1 hardware controller
runs turbine model
in real time Model is configured for HIL tests,
converted to C code,
and downloaded to controller
38
Model-Based Design

Plant Modeling Control Design Testing

SimMechanics Simulink Control Design xPC Target


Simscape Control System Toolbox MATLAB Coder
SimElectronics Simulink Design Optimization Simulink Coder
SimPowerSystems Optimization Toolbox DSP System Toolbox
Simulink Design Optimization
Optimization Toolbox

39
Summary

 Optimize system performance


– Develop in a single environment
– No cosimulation

 Find problems before building


hardware using HIL

 Discover integration problems


using simulation
– No cosimulation

 Create accurate, reusable


plant models quickly and easily
40
More on Physical System Modeling…

41
Modeling Physical Systems
With MathWorks Products

Modeling Approaches

First Principles Modeling Data-Driven Modeling

Physical Networks Statistical Methods


Programming (Model Based System
(MATLAB, C) (Simscape and other
Physical Modeling Calibration Toolbox) Identification
(System Identification
Block Diagram products) Toolbox)
(Simulink)

Modeling Language Neural Networks


(Simscape language) (Neural Network
Toolbox)
Symbolic Methods Parameter Tuning
(Symbolic Math (Simulink Design Optimization)
Toolbox)

42
Modeling Approaches

First Principles Data-Driven

Programming

Block Diagram

Modeling Language

Symbolic Methods

 Purpose: Explore design or physical parameters


 Requirements:
– Physics of system are well-known
– System-level equations can be derived and implemented

43
Modeling Approaches

First Principles Data-Driven


Physical Networks
Programming

Block Diagram

Modeling Language

Symbolic Methods

 Purpose: Explore design or physical parameters


 Requirements:
– Physics of system are well-known
– Component-level models exist or can be created

44
Modeling Approaches

First Principles Data-Driven


Physical Networks Statistical Methods
Programming System
Identification
Measured
Block Diagram
Model
Modeling Language Neural Networks

Symbolic Methods

 Purpose: Model an existing design (real or virtual)


 Requirements:
– Relevant set of measured data is available
– Design and physical parameters will not be changed

45
Modeling Approaches

First Principles Data-Driven

k = ?
b = ?
Parameter Tuning

 Purpose: Ensuring parameter values are accurate


 Requirements:
– Relevant set of measured data is available
– Physically meaningful parameters can be automatically tuned

46
Modeling Approaches

First Principles Data-Driven


Physical Networks Statistical Methods
Programming (Model Based System
(MATLAB, C) (Simscape and other
Physical Modeling Calibration Toolbox) Identification
(System Identification
Block Diagram products) Toolbox)
(Simulink)

Modeling Language Neural Networks


(Simscape language) (Neural Network
Toolbox)
Symbolic Methods Parameter Tuning
(Symbolic Math Toolbox) (Simulink Design Optimization)

 Use the approach appropriate for your situation


 Each of these approaches can be leveraged
using MathWorks products

47
Simscape and Physical Modeling Products

Simscape
Mechanical Hydraulic Electrical
SimPowerSystems

Thermal Pneumatic Magnetic

SimHydraulics
N S

Custom Domains via


Simscape Language

Multidomain physical systems


Electrical power systems Fluid power and control

SimElectronics
SimMechanics

SimDriveline

Multibody mechanics (3-D) Mechanical systems (1-D) Electromechanical and


electronic systems 48
Quickly Build Intuitive Models Physical Modeling

Motor
Servoamplifier Hall Effect
Models that reflect system Sensor
DC Motor
Structure are easier to
understand,
modify, and reuse
Speed Controller

A B

T P T

Vehicle
Dynamics

Hydraulic Valve
Gears Diff
Engine

49
Quickly Build Intuitive Models Physical Modeling

Motor
Servoamplifier Hall Effect
Models that reflect system Sensor
DC Motor Best Practice
Structure are easier to
understand,
modify, and reuse
Speed Controller

A B

Aileron Mechanics
T P T

Hydraulic Valve

50
Electrical Systems in Equations

R DC Motor
dim
v  K e   imR wind  L wind
dt
L d
θ T  K t im  D  J
dt

Kt,Ke

J,b
i

51
Electrical Systems in Simscape

R DC Motor
dim
v  K e   imR wind  L wind
dt
L d
θ T  K t im  D  J
dt

Kt,Ke

J,b
i

 Simscape model advantages


– Easier to read than equations
– Quicker to create
– More intuitive – easier to explain to other engineers
52
Physical network approach (Simscape) vs.
Signal Flow approach (Simulink)

 Simulink Blocks are causal


– Transfer functions
– Input and output ports (signal flow)
– Graphically model system equations

τ,ω
 PhysMod “Blocks” are acausal
– Bi-directional energy flow
– Domain-specific physical ports
(electrical, hydraulic…)
– Graphically model system topology

53
Demo: Signal Flow vs. Network Approach
Electrical example: RC circuit

Simscape (Network) Model

Simulation Results:
i  v/r
Input Stimulus: dv
ic
dt

input output

1
p 
RC
Simulink (Block diagram) Model
54
Signal Flow vs. Network Approach
with hardware interactions

Simscape Network Model


Simulation Results:

Simulink Block Diagram Model

input output

Cascading two filters gives different results … Why?


55
Signal Flow vs. Network Approach
Modeling interactions

Simscape model System interactions


+ + vin  vout
 iin
iin iout R
vin vout

- - vout 
1
 iin  iout dt
C
Original Simulink model:

No interactions
No conservation

New Simulink model … … with interactions

56
Signal Flow vs. Network Approach
Summary

 Signal Flow (Simulink)


– No interaction between blocks unless explicitly specified
– The user must be aware the interactions exist and model the
effect
– System changes require model reformulation
 Network Approach (Simscape)
– System of equations automatically created and solved by
simulator
– Enforces conservation (KCL, Newton’s Law, etc…) at every
junction
– Topology changes easy to make, interactions occur
automatically

57
Simscape Pre-defined Domains

 Simscape generalizes conservation laws across physical domains


– i = 0 at every junction (where i is the through variable)
 Simscape pre-defined domains:

Port Type Across Variable Through Variable


Electrical Voltage Current
Hydraulic Pressure Flow rate
Mechanical Angular velocity Torque
(rotational)
Mechanical Translational velocity Force
(translational)
Pneumatic Pressure and temperature Mass flow rate and
heat flow
Thermal Temperature Heat flow
Magnetic MMF Flux

58
Simscape Language Example: DC Motor

 DC motor with inertia load


p1
Motor Equations:
dim
v  K e  im Rwind  Lwind
dt
d
shaft Tq   K t im  D  J
p2 dt

v = Terminal voltage Rwind = Winding resistance


Kt = Torque constant Lwind = Winding inductance
Ke = Back emf constant Tq = Output torque
 = Shaft speed D = Damping coefficient
im = Motor current J = Moment of inertia

59
Simscape Language Example: DC Motor

component dc_pm
nodes
p = foundation.electrical.electrical; % p:left
n = foundation.electrical.electrical; % n:left Physical
r = foundation.mechanical.rotational.rotational; % r:right
c = foundation.mechanical.rotational.rotational; % c:right Connections
end
parameters
Kt = {10 'N*m/A'}; % Torque constant
Ke = {10 'V/(rad/s)'}; % Back EMF Constant
Rwind = {1 'Ohm'}; % Winding Resistance Motor
Lwind = {1e-3 'H'};
J = {1 'kg*m^2'};
% Winding Inductance
% Motor Inertia
Parameters
B = {1 'N*m/(rad/s)'}; % Motor Damping
end
variables
theta = { 0, 'rad' }; % Angular Displacement
tq = { 0, 'N*m' };
w = { 0, 'rad/s' };
% Torque through variable
% Ang Vel across variable
Internal
i = { 0, 'A' }; % Current through variable Variables
v = { 0, 'V' }; % Voltage across variable
end
equation
w == theta.der;
v == Ke*w + i*Rwind + Lwind*i.der; % Motor Motor
end
tq == -Kt*i + B*w + J*w.der; % equations
Equations
end
60
Simscape Language Overview

 Provides first principles modeling at component level


 Enables control over model fidelity
– Add non-linear effects
– Include domain interactions (i.e. thermal effects)
– Supports conditional statements
 Leverage the foundation library source code as starting
point

61
61
Benefits of Network Modeling Approach

 Network analysis techniques used to solve system


 Burden on simulator not the user to formulate system
equations
 Fidelity of system model is determined by component
equations
 Network representation easy for non-experts to follow
and understand

62
62
Multi-Domain System in Simscape

6
7

4
1. Voltage is applied to motor
2. Motor generates torque to spin pump
3. Pump supplies pressure to the
8 hydraulic valve
3 4. Actuator is used to open/close the
2
valve and direct fluid flow
1 5. Hydraulic cylinder moves left or right
depending on valve position
6. Mechanical load provides opposing
force to cylinder
7. Motion sensor feeds position back to
controller
8. Control unit provides set point
9. Position control is achieved
10. No system equations derived!
63
63
Multi-Domain System in Simscape

6
7
9

4
1. Voltage is applied to motor
2. Motor generates torque to spin pump
3. Pump supplies pressure to the
8 hydraulic valve
3 4. Actuator is used to open/close the
2
valve and direct fluid flow
1 5. Hydraulic cylinder moves left or right
depending on valve position
6. Mechanical load provides opposing
force to cylinder
7. Motion sensor feeds position back to
controller
8. Control unit provides set point
9. Position control is achieved
10. No system equations derived!
64
64
Summary

 Optimize system performance


– Develop in a single environment
– No cosimulation

 Find problems before building


hardware using HIL

 Discover integration problems


using simulation
– No cosimulation

 Create accurate, reusable


plant models quickly and easily
65
Q&A

66

You might also like