Sei sulla pagina 1di 40

MBD – Model Based Design

Agenda
• Model Based Design w/ MATLAB and Simulink
– Overcome today’s design challenges

• Motor Control Systems Design; a PMSM example


– 5 Steps to design and implement your system
• Design with simulation
• Rapid Prototyping
• Verify your code
• Generate production code
• Validate and verify your system

• Summary and Next Step


Core MathWorks Products

The leading environment for


technical computing

– Numeric computation
– Data analysis and visualization
– The industry-standard,
high-level programming language
for algorithm development
– Toolboxes for signal and image processing,
statistics, optimization, symbolic math, and
other areas
– Foundation of the
MathWorks product family
Core MathWorks Products

The leading environment for modeling,


simulating, and implementing
communications systems and semiconductors
– Foundation for Model-Based Design
– Digital, analog, and mixed-signal systems, with
floating- and fixed-point support
– Algorithm development, system-level design,
implementation, and test and verification
– Optimized code generation for FPGAs and DSPs
– Blocksets for signal processing, communications,
video and image processing, and RF
– Open architecture with links to third-party modeling
tools, IDEs, and test systems
From Traditional Embedded System Development to Model-Based
Design

Requirements and
Specifications
Design
Environment models

Environment models
System Behavior models
Physical
Components models Implementation
Executable models
- Unambiguous, Algorithms
“one truth”
- Links to textual Algorithms
Test and
requirements Simulation
- Reduces need for
Verification
physical prototypes
- Enables systematic
“what-if” analysis
C, C++ VHDL, Verilog

MCU DSP

Automatic code
generation
- Reduces time, effort
- Enables code reuse
- Minimizes coding errors
Today’s Design Challenges
• Increasing complexity
– Standardization
– Security

• Intensified Competition
– Time-to-market pressure
– Cut product costs
– Preserve product quality

• Design team integration


– Analog/Mixed-Signal, digital hardware, DSP/control software
MathWorks Key Industries

• Aerospace and Defense


• Automotive
• Biotech and Pharmaceutical
• Chemical/Petrochemical
• Communications
• Education
• Electronics
• Industrial Automation and Machinery
• Financial Services
• Power and Energy
• Semiconductor
Control Systems with MATLAB, Simulink,
and TI C2000™ DSPs
MATLAB, Simulink, and TI C2000™ DSPs
MathWorks
Modeling Environment

MATLAB® Simulink® Stateflow®

• Link for Code Composer Studio


• Real Time Workshop Embedded Coder
• Target for TI C2000

C/ASM
Code Compile
& Link Down
load TI C2000
Texas Instruments
Code Composer Studio™ DSP
Environment Debug
STEP 1 - Simulate controller and electro-mechanical plant
models to verify specification and optimize system
performance.

Controller Performance System


Performance
A
ct S
ua Electrical en
to so
+
-
Controller rs
Mechanical
Device
rs
u Plant
y
MATLAB, Simulink, and TI C2000™ DSPs
A PMSM System - Design and Tune
through Simulation

• Specify Motor (Plant) Dynamics


• Design Fixed-Point Controller
Specify Tests and Visualize Results
Algorithm Specifications and Reuse

Design with Simulation

Generate Code for


Production

Generate Code for Rapid Prototyping


Target Optimized Blocks (C28x)

• Blocks which call optimized TI routines in generated code and


simulate with bit-true accuracy.
STEP 2 - Rapid Prototyping - “Target Support
Package TC2™” for testing in a real environment

Models
Algorithm Processor
Specification Specifications

Real-Time
Workshop Target for
Embedded TI C2000
Code Coder

Algorithm
Implementation

Scheduler and Device Specific Drivers


Schedulers and Device Drivers (C280x,
C281x and C2833x)
Rapid Prototyping - Asynchronous Scheduler and
Device Drivers: Synchronizing ADC and PWM for F2808
Target – Host Communications
for Tuning and Monitoring
• Target Side Model Host Side Model
• Generated Code runs on DSP Model executes on PC
Monitor or tune low-rate data

CAN, SCI, RTDX

Read from channel


Write to channel
Target-Host Communications:
Host Side Blocks
STEP 3 - Code Verification using
Processor-In-the-Loop Testing (PIL)
Simulink Test Bench

Test Algorithm
Verifications
Signals

PIL
Interface

Link
for CCS
CCS Test Bench
Algorithm
Code
Why Verify the Generated Code?
Some sources of unexpected differences between PC simulation
and target executed code

• Target C compiler optimization settings


e.g. “Register (-o0)” versus “File (-o3)” in CCS

• Code generation optimization settings


e.g. “Ignore integer downcasts in folded expressions” removes some intermediate
castings which may affect mathematical results

• Integration of custom code


e.g. The developer has configured the code generator to include calls to their own
optimized processor-specific functions in the generated code

• Defects in hardware, compiler, linker, or code generator


e.g. see MathWorks Web Bug Reports http://www.mathworks.com/support/bugreports/
Processor-In-the-Loop Testing

• PIL is a technique to evaluate how well a candidate algorithm


operates on the target processor selected for the application.

• Code is generated from the Simulink specification, downloaded to the


target processor (or simulator), and then executed in step-by-step co-
simulation with Simulink.

• This approach enables testing of the same object code that will be
used in production.

• PIL can be used to catch some differences between PC simulation


and target executed code
STEP 4- Production Code Generation Method 1:
Generate Standalone Code

Models
Algorithm Processor
Specification Specifications

Real-Time
Workshop Target for
Embedded TI C2000
Code – Flash Coder
(Standalone)

Algorithm
Implementation

Scheduler and Device Specific Drivers


Generate code residing in Flash
memory
Production Code Generation: Method 2
Algorithm Export for Integration
with your Drivers and Scheduler

Models
Algorithm Processor
Specification Specifications

Real-Time
Workshop
Embedded
Code – Flash Coder
(Standalone)

Algorithm
Implementation

Scheduler and Device Specific Drivers


STEP 5 - Verify and Validate
Requirements

Design Test harness


Coverage
model Report model

Integrate test harness with design

Automatically Target processor


Target ECU Execute
generate test
code Target cases
Code

Processor-in-the-loop
Hardware-in-the-loop
Software-in-the-loop
Summary and Next Steps
Model-Based Design Benefits
Model-Based Design Innovation
• Executable specification • Rapid design iterations
• “What-if” studies
• Design with simulation • Unique features and differentiators
• Implementation through code
generation Quality
• Reduce design errors
• Continuous test and • Minimize hand coding errors
verification • Improve communication internally and
externally

Cost
• Reduce expensive physical prototypes
• Reduce re-work
• Reduce testing

Time-to-market
• Get it right the first time
Addressing Embedded Programming
Challenges

Challenge Response
Target Function Libraries and
Processor specific code
Legacy Code Tool
Generate code for deployment to
Production Code Deployment
Flash
Ability to assign data and functions
Execution speed from Flash
to be copied from Flash to RAM
Verification of Code Execution Processor-in-the-Loop testing
Capture and act upon hardware
Asynchronous Scheduling
and software interrupts
From Models to Hardware –
Design and Implementation of a Permanent Magnet
Synchronous Motor Controller

F2808
PMSM
eZdsp

Knob

Power
Supply
Summary and Next Steps

Some of the MathWorks Products Featured Today:


– MATLAB, Simulink, Real-Time Workshop Embedded Coder
– Embedded IDE Link CC (for use with Code Composer Studio)
– Target Support Package TC2 (for use with TI C2000)

Next Steps
1. Get more information
– www.mathworks.com/applications/controldesign/
– Watch a free webinar: www.mathworks.com/webinars
2. Contact your MathWorks Sales rep
– Arrange a customer visit with MathWorks’ engineers to help your
company safe money and time to market

Thank You !
antonin.ancelle@mathworks.com
Tutorial (1) - Installation
• Install Matab/Simulink – R2009A with adhoc
toolbox
• Install Code Composer Studio – CCS 3.3
• Install emulator drivers (check emulator supplier
web site)

• Setup the TMS320F28335 eZDSK


– Connect the eZDSK to the host
– Supply the eZDSK
– Configure CCS for the TMS320F28335 eZDSK
(NB: you do not need to launch CCS)
Tutorial (2) – Demo
• Launch Matlab from the icon on desktop

• Select Demo from Matlab/start menu

• Type F28335\ in the navigator help to review all possible demos, all
using Target Support Package TC2
– Asynchronous Scheduling
– Using the I2C Bus to Access a Connected EEPROM
– SPI-Based Control of PWM Duty Cycle
– HIL Verification of IIR Filter via SCI
– ADC-PWM Synchronization via ADC Interrupt
– Permanent Magnet Synchronous Motor Field-Oriented Control
– CAN-Based Control of PWM Duty Cycle
– Real-Time Data Exchange via RTDX
– CAN Calibration Protocol and External Mode
– Motor Control
Documentation
search result

Demo
description
Demo search result
Tutorial (3) – Model selection
• "ADC-PWM Subsystem“ Demo:
– consists of an ADC driving the duty cycle input port of the PWM.
– PWM is configured to trigger ADC start of conversion (SOC).
• Select one of the available models
– Spectrum Digital F2812 eZdsp c2812adcpwmasynctest.mdl
– Spectrum Digital F2808 eZdsp c2808adcpwmasynctest.mdl
– Spectrum Digital F28335 eZdsp c28335adcpwmasynctest.mdl
Appendix A:

Leverage TI’s Optimized Libraries


in your Simulink Design and C2000
Implementation
Target Optimized Blocks (C28x)
• Simulink Blocks that call optimized TI routines in generated
code and simulate with bit-true accuracy.
Schedulers and Device Drivers
(C280x and C281x)
Target-Host Communications:
Host Side Blocks

Potrebbero piacerti anche