mbd model based design - march 2009
TRANSCRIPT
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
Implementation
Test and Verification
Algorithms
C, C++
MCU DSP
VHDL, Verilog
Automatic code generation- Reduces time, effort- Enables code reuse- Minimizes coding errors
System Behavior models
Environment models
Executable models- Unambiguous,
“one truth”- Links to textual
requirements
Physical
Components models
Environment models
Algorithms
Simulation- Reduces need for
physical prototypes- Enables systematic
“what-if” analysis
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
• Link for Code Composer Studio• Real Time Workshop Embedded Coder• Target for TI C2000
Compile
& Link
C/ASM
Code
Texas InstrumentsCode Composer Studio™
Environment
Down
load
Debug
TI C2000
DSP
MathWorks
Modeling Environment
MATLAB® Simulink® Stateflow®
STEP 1 - Simulate controller and electro-mechanical plant
models to verify specification and optimize system
performance.
Electrical
Mechanical
Device
Actuators SensorsPlantu y
System
PerformanceController PerformanceController+
-
MATLAB, Simulink, and TI C2000™ DSPs
A PMSM System - Design and Tunethrough Simulation
• Design Fixed-Point Controller• Specify Motor (Plant) Dynamics
Specify Tests and Visualize Results
Algorithm Specifications and Reuse
Design with Simulation
Generate Code for Rapid Prototyping
Generate Code for Production
Target Optimized Blocks (C28x)
• Blocks which call optimized TI routines in generated code and simulate with bit-true accuracy.
Code
STEP 2 - Rapid Prototyping - “Target Support Package TC2™” for testing in a real environment
Models
Target for
TI C2000
Real-Time
Workshop
Embedded
Coder
AlgorithmSpecification
Processor Specifications
Scheduler and Device Specific Drivers
AlgorithmImplementation
Schedulers and Device Drivers (C280x,
C281x and C2833x)
Rapid Prototyping - Asynchronous Scheduler and Device Drivers: Synchronizing ADC and PWM for F2808
Target – Host Communicationsfor Tuning and Monitoring
• Target Side Model
• Generated Code runs on DSP
Host Side Model
Model executes on PC
Monitor or tune low-rate data
Write to channelRead from channel
CAN, SCI, RTDX
Target-Host Communications:Host Side Blocks
STEP 3 - Code Verification using Processor-In-the-Loop Testing (PIL)
Simulink Test Bench
TestSignals
CCS Test Bench
VerificationsAlgorithm
Linkfor CCS
AlgorithmCode
PILInterface
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
Code – Flash(Standalone)
STEP 4- Production Code Generation Method 1:Generate Standalone Code
Models
Target for
TI C2000
Real-Time
Workshop
Embedded
Coder
AlgorithmSpecification
Processor Specifications
Scheduler and Device Specific Drivers
AlgorithmImplementation
Generate code residing in Flash memory
Code – Flash(Standalone)
Production Code Generation: Method 2Algorithm Export for Integration with your Drivers and Scheduler
Models
Real-Time
Workshop
Embedded
Coder
AlgorithmSpecification
Processor Specifications
Scheduler and Device Specific Drivers
AlgorithmImplementation
Integrate test harness
STEP 5 - Verify and Validate
Designmodel
Executetest
cases
Automaticallygenerate
code
Coverage
Report
Software-in-the-loop
TargetCode
Processor-in-the-loop
Target processor
with design
Test harness model
Hardware-in-the-loop
Target ECU
Requirements
Summary and Next Steps
Model-Based Design Benefits
Model-Based Design
• Executable specification
• Design with simulation
• Implementation through code
generation
• Continuous test and
verification
Innovation• Rapid design iterations• “What-if” studies• Unique features and differentiators
Quality • Reduce design errors• Minimize hand coding errors• 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
Processor specific codeTarget Function Libraries and Legacy Code Tool
Production Code DeploymentGenerate code for deployment to Flash
Execution speed from FlashAbility to assign data and functions to be copied from Flash to RAM
Verification of Code Execution Processor-in-the-Loop testing
Asynchronous SchedulingCapture and act upon hardware and software interrupts
From Models to Hardware –Design and Implementation of a Permanent Magnet Synchronous Motor Controller
PMSMF2808
Knob
eZdsp
PowerSupply
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 [email protected]
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 search result
Demo
description
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