Afghanistan
Albania
Algeria
Andorra
Anguilla
Antigua & Barbuda
Argentina
Armenia
Aruba
Australia
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belgium
Belize
Benin
Bermuda
Bhutan
Bolivia
Bonaire
Bosnia & Herzegovina
Botswana
Brazil
British Indian Ocean Ter
Brunei
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Canada
Canary Islands
Cape Verde
Cayman Islands
Central African Republic
Chad
Channel Islands
Chile
China
Christmas Island
Cocos Island
Colombia
Comoros
Congo
Cook Islands
Costa Rica
Cote D Ivoire
Croatia
Cuba
Curacao
Cyprus
Czech Republic
Denmark
Djibouti
Dominica
Dominican Republic
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Falkland Islands
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Ter
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guinea
Guyana
Haiti
Hawaii
Honduras
Hong Kong
Hungary
Iceland
India
Indonesia
Iran
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Japan
Jordan
Kazakhstan
Kenya
Kiribati
Korea North
Korea South
Kuwait
Kyrgyzstan
Laos
Latvia
Lebanon
Lesotho
Liberia
Libya
Liechtenstein
Lithuania
Luxembourg
Macau
Macedonia
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mexico
Midway Islands
Moldova
Monaco
Mongolia
Montserrat
Morocco
Mozambique
Myanmar
Nambia
Nauru
Nepal
Netherland Antilles
Netherlands (Holland, Europe)
Nevis
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
Norway
Oman
Pakistan
Palau Island
Palestine
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn Island
Poland
Portugal
Puerto Rico
Qatar
Republic of Montenegro
Reunion
Romania
Russia
Rwanda
Saipan
Samoa
Samoa American
San Marino
Sao Tome & Principe
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Singapore
Slovakia
Slovenia
Solomon Islands
Somalia
South Africa
Spain
Sri Lanka
St Barthelemy
St Eustatius
St Helena
St Kitts-Nevis
St Lucia
St Maarten
St Pierre & Miquelon
St Vincent & Grenadines
Sudan
Suriname
Swaziland
Sweden
Switzerland
Syria
Tahiti
Taiwan
Tajikistan
Tanzania
Thailand
Togo
Tokelau
Tonga
Trinidad & Tobago
Tunisia
Turkey
Turkmenistan
Turks & Caicos Is
Tuvalu
Uganda
Ukraine
United Arab Emirates
United Kingdom
United States of America
Uruguay
Uzbekistan
Vanuatu
Vatican City State
Venezuela
Vietnam
Virgin Islands (Brit)
Virgin Islands (USA)
Wake Island
Wallis & Futana Is
Yemen
Zaire
Zambia
Zimbabwe
Overview
5 Day training
1 day simulink
2 Days embedded Coder
etc
Tech support: (508) 647-7000 Option 2
Devin Parmenter
Kevin Parmenter
Maryland, Navy Airforce, Nasa, Boeing, Lockheed Martin, etc.
2004 LA Mathworks, trainer
Stanford: Controls, design, realtime systems
95-2003 in Silicon Valley
Finite Element software
Parameteric Tech- Software.
Lived in Mt. View 8 Years
Mechanical Engineer
Aerospace Industry
General Electric
FA-18 Gas Turbine
Blade analysis, etc.
Lot of ANSYS, NASTRAN
Ford Motor Company
Introduction
Over 4000 employees worldwide
2 million users in 180 countries
Used by over 5000 universities worldwide
Product overview
Matlab
Simulink - requires Matlab
Simulink has extensions
Code generation works for both.
File Structure/Computer Setup
Test with: C:\Users\marsr\Documents\MATLAB\USRAClass\coursefiles\slbe_o\chapter4\etc_PI
O Means "Aerospace"
SL means Simulink
What we can do with Simulink
Demo: f14 derives angle of attack based on 1D stick input.
Derive a quantity
Is graphically oriented
Design an algorithm
Signals are variables
Blocks are operations
Drive the variable through an algorithm
Wide variety of blocks
Lay out algorithm, usually left to right.
14
Angles are in radians
1d Model: stick input
Output: acceleration on pilot, angle of attack.
Inputs are physically impossible
Typical Design Process
Define REquirements
Specify Subsystems
Subsystem Design
Subsystem implementation
Subsystem integration and test
System-level integration and test
Integration test and calibration
Model is at the center of the design
Models
Design with Simulation
Implementation with automatic code gneration
Continuous test and verification
Executable Specifications from model
The Plan
Full course manual is provided
Skipping day 1: basic simulation
General Terms Dynamic systems
Continuous state dynamics
Discrete state dynamics
Outputs
First Principles modeling
Continuous Dynamics: mX''(t) + bx"()....
Specific example
Engine throttle
Negative feedback
Cable, Pedal, butterfly valve
Will Design closed-loop system
Pedal positon Sensor, engine control module, servomotor, plate sensor
See chapter guides for what chapter goes with what.
Chapter 4:Discrete System
Sample time will override processing.
Stairstep's real systems
Use them because computers are discrete
Sample time high enough then it equals analog
Presumes a real-time system if sample time is greater than 0
If sample time is 0 then run in continous mode.
If sample time is -1 then sample time is inherited from...input signal.
Most blocks will inherit sample time from proceding block.
Two time concepts
time step h
Time step is how often we are going to perform a simulation calculation (typically 0.2 sec timestep for a 10 second simulation)
sample time Ts
Ts is data update rate.
Should synchronize time step and sample time.
Can colorize model for timesteps.
Can have multiple rates.
Fast stample times will show up in red, then green, then blue.
Display-> Sample time -> Colors will color-code blocks for a table of rates.
Defining Discrete State Systems
Define discrete functions
Taking continuous time and discretizing it.
Unit delay block is the fundamental block for discrete systems. Gives us the z signal.
Unit Delay Block
Delays signal by 1 time unit
Gives us z
Converts time to previous update
Needs an initial conditon
Have to have a time rate and initial value.
Generates a table between x(k) and x(k-1)
Modeling Difference equations (continued)
Build block diagram from equation
Can't build directly. May have multiple delay blocks
4-step technique
Look at equations term-by-term. Determine how many terms are offset in time. Need a delay block for each.
Work from the middle of the model outward.
Create deplay blocks in the middle of the model, lablel their inputs and outputs.
Connect the signals based on the equation
Assign rates and initial conditions to blocks.
Callbacks
Becomes part of the model.
Executes on condition.
Callback: in Model Properties
To Re-initialzie, Hit Update model.
Can load other .m files to run. Enter by function name. Must be on path.
Discrete Transfer Function
Is a single block
Can absorb coefficients.
Shows TF on block pane.
Can absorb constant values.
Cannot represent non-linearities.
State Space Block
Can put A, B, C, D matricies in.
From breaking into a system of equations.
All discrete states are NOT direct feedthrough
Multirate Modeling
Have to buffer the data using rate transition block.
Currently using Zero-order hold algorithm for buffer.
Example: filter out sparkplug noise from throttle line.
Example is a low-pass filter
Every block system can run at a different time rate.
Turn on color and update diagram.
etc_PI_filter
Provides data integrity and determinism.
Non-Harmonic time step differences.
Need to address interactions with solver.
If integer multiplication isn't present then "non-harmonic"
Establishes "base rate" based on time steps available.
Automatically switches to variable-step solver.
Exercise on page G-17.
REmove rate limiter
Use procedure we saw on page 4-8.
Take equations from paper.
Has a subsystem called PID_controller
Open up x15_start
etc_PI model - cut and paste.
Add derivative control to system.
Modeling Continuous Time Systems
Physical boundaries
Contituous States
Plant model.
Continuous transfer functions
Modeling with Simulink
Rquires an ODE solver. Can't use discrete solver.
Integrator is the basic building block
State derivative equation
Input is x-dot,
Output is x
Procedure for modeling continous systems
Set up so highest-order derivative is on LHS
Determine how many integrators we will need to give us original signal.
Drop integrator blocks in and label them.
Review equation
Connect signals according to the equation
Integrators don't have an initial condition because they are continous.
Usually connects into a series of integrator blocks.
3-step Process for deriving a continous system model.
Step 1: Use a free-body diagram.
Step 2: Apply some 1st principles governing equation.
Puth highest-order derivative on LHS and move everything else to the RHS.
Step 3: Apply Mathworks methodology to resulting equation.
Create Simulink Diagram inputs and output nodes.
Count integrators and add enough integral blocks.
Label integrator blocks
Add in summation blocks
Add in gains into signals.
Enter initial conditions.
Identify the states in the model. They are always the output of the integrators.
Simulink keyboard shortcuts
Cntrl-I Inverts a block (turns in the other direction)
Sift key moves a block and breaks the signal.
Right-click and drag duplicates a block.
bdclose closes all simulink models.
cntrl-B build code.
Adding variables
Add matlab file name to init callback.
See page 5-10.
Configuration Parameters (Sprocket icon)
Data inport/export
Load from workspace
Set data in proper order in which the ports appear.
Use name of the variable, not abreviation on the port.
Check simulation time vs. time vector in imported data file.
Set initial conditions on integrators (states) to first points in data.
Scopes vs. Signal Viewer
Scopes take up modeling space.
Add a signal viewer instead
Right-click signal -> Create and Connect Simulink Viewer.
Viewer have tiny icon on signal.
Takes up less space, functions the same.
Exercise
Presume ideal wheel.
Strut has no mass.
Work in English units.
All units are sorted out.
G-25 Excersise
Vertically-oriented Free-body diagram.
landingGearStart
Developing Model Heiarchy
Affect the apperance and usability of a subsystem
Add a user interface using a mask or prompts
Create visual heiarchy
Chapter 7
Add block hiarchy to a Simulink model using Subsystems
Using Bus Signals
Example
C:\Users\marsr\Documents\MATLAB\USRAClass\coursefiles\slbe_o\chapter2
etc_plant_simple
Electronic throttle control system
Methodologies
There is a scripted way to change the model workspace.
Diagram -> Subsystem -> Create from selection
Selecting with or without labeled IO will act accordingly
There's a checkbox for "treat as atomic"in subsystem block parameters
Virtual vs. Atomic Subsystems
Atomic subsystems have heavy borders.
"Atomic": no longer divisible.
Superscripts are execution level/order
Non-virtual subsystems are subroutines.
Means on the diagram bundles look real, but aren't.
Atomic functions generate seperate functions in output code.
Atomic functions reduce interpreter overhead under code reuse.
Atomic become "direct feedthrough" which may cause algebraic loops.
Reducing signal congestion with busses.
Difference between a bus and a mux: not as much functionality.
Muxes are virtual bus.
Use bus creators and bus selectors
Use busses
Example: etc_no_bus
Bus selector can cross-wire signals in block properties
Bus gets stored as a data structure.
Only use MUX blocks to combine signals for scopes
Advanced bus programming
Bus creator can create a data object in code generation.
Use model explorer to add a bus data object to data workspace.
Bus editor allows to customize elements of bus object.
Select bus from workspace as type for bus creator
Can script it as an object in Matlab command window
Masking/Custom User Interface
Icons tab: add pictures
Down arrow displays the subsystem again.
Replaces subsystem diagram on double-click with a user interface.
Example: etc_mask2
Exmple: etc_mask1
To create: right-click subsystem -> mask -> create mask
Parameters: default values
Initialization: (callback)
Documentation:
Mask subsystem has local variables that override workspace.
Can create instance-specific values through mask default values.
All kinds of toys available to add to mask
Painting blocks
%disp(label)
Need to play around with mask generator.
%image(imread('throttle.png'))
Documenation
Is written in html.
Creates help display in help viewer.
Is a "cheat sheet" to fill in documentation.
Exercise G-39
In the init function loadAllParamValues.mat
Open up canned version of models and create subsystems.
Use fullModelStart
Pull models together using subsystems.
Copy/Paste subsystems
Open sensorChapter2, create subsystem.
Modeling Conditionally Executed Algroithims
Automantically get an extra port at the top.
Determine state
Determine when to execute
Execute based on a condition signal.
Not continuous
Not periodic
Determine output behavior.
Timeline shifts from continuous or discrete to triggered.
Automatically non-virtual
Can be enabled or triggered n number of times during the simulation.
Can add a conditional or triggered icon to a subsystem after it has been built.
Enabled Subsystems
Will not respond to condition signal being greater than zero.
Presumed to be enabled for more than one time steps at a time (at least two).
example: enabled
Can have 2 behaviors when disabled: reset and hold
Triggered
Can respond to a rising edge or falling edge triggers.
Assumed to be active for one time step at a time.
Can be found in the ports and subsystems library
Can preempt as a single threaded function call.
Rising/Falling edges must chage arithmetic sign (including from or to zero).
Example: trigger
Does not have to be discontinous (step function).
Untriggered behavior is also programable: sample and hold, reset, etc.
A subsystem can be both triggered and enabled simultaneously.
Third time concept...
Exersize
Add What was the altitude when the parachute deployed?
What was the velocity when the parachute deployed?
Use mars2Start
G-43
Mars Conditional Subsystem
Add: What was the time when the parachute deployed?
Design point: Deploy at 17,000 meters
Failsafe point: deploy at 6500 m
Want velocity< 503.8 m/sec
Creating Libraries
Define what a library is
Show you how it works
What links get created?
How to create a library
Simulink Library Browser-> Create Library
Looks just like a model window.
Can put components into the library that we want to access
Can use built-in Simulink components (Input/output time delay, integrator, addition blocks, etc.)
Can also add user-defined components such as subsystems
Can customize block properties to display in custom manners.
Save-as
Created Linkages using Libraries
Blocks used from libraries are linked.
Display-> show library links gives a little icon in lower left.
Icon means its linked back to the master copy in the library.
Can disable the link, or resolve the link.
Can break link. Then must delete and recopy to restore.
Can disable, modify instance, then PUSH copy to library. DANGEROUS.
How do links help?
Can go to mask-> subsystem and load image.
Changes will propogate from master copy if link exists.
Changes to master will not propogate to instances if links to libraries are broken.
Restoration recreates control modification.
Locking
Can lock libraries.
Not a permission system.
Deploying
Can add to Simulink Library browser
Can copy slblocks.m and edit it.
Refresh library
Combining Models into Diagrams
Model dependencies
Refrenced model mode
Considerations in referencing
References vs. subsystems
Use one Sumilink model as part of another model.
Model Workspaces
Workflow for making a model suitable for referencing
Accelerator Mode
May have to recompile to change parameters.
Have to make parameters tunable.
No access to source code
Pre-Compiling model to binary .mexw64
Used to speed up simulation.
Dynamically linked.
Corners on the reference block get colored in
The Model Block
Double Click and specify the model we want it to be
Looks like a subsystem
Block paramters are changable.
Runs as a seperate simulation
Under Ports and Subsystems
Is Generic until we specify the model.
Referenced model must have in and out ports or we can't communicate with it.
Advantages of referencing
Can test by reference in a test harness model.
Code reusability. Don't generate instances.
Don't have to copy/paste
Can work on models independantly simultaneously.
Test as a standalone component in a test harnes.
Essentially a function call.
Workflow
Cannot inherit signal properties across a model boundary.
Designate variables in the model explorer as reference inputs.
Solver time steps must be compatible (fixed vs. variable)
Referenced models must be on the Matlab search path
Design "Test Harness" as a seperate model.
Model needs locally typed I/O points
Must also specify fixed sample time.
Model Explorer
Declare as model reference input arguments and then MUST provide a value.
Only one configuration set can be active at a time.
Can copy/paste configuration sets
Asterix means unsaved changes in the model explorer.
Use the model explorer to dive all execution contexts.
Base workspace, Model workspace, Mask workspace
Don't have to recompile for new parameters if declared.
Dependency Viewer
Analysis-> Model dependencies -> Viewer
Exercise
Provided "Ref" models have been set up for referencing
Note: use models with "Ref" in the name.
Use Exercise G-45
Rebuild controller using referenced models instead
Use a callback to loadAllParamValues.mat