mbd model based design - march 2009

40
MBD – Model Based Design

Upload: qkhanh

Post on 06-Apr-2015

134 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: MBD Model Based Design - March 2009

MBD – Model Based Design

Page 2: MBD Model Based Design - March 2009

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

Page 3: MBD Model Based Design - March 2009

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

Page 4: MBD Model Based Design - March 2009

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

Page 5: MBD Model Based Design - March 2009

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

Page 6: MBD Model Based Design - March 2009

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

Page 7: MBD Model Based Design - March 2009

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

Page 8: MBD Model Based Design - March 2009

Control Systems with MATLAB, Simulink, and TI C2000™ DSPs

Page 9: MBD Model Based Design - March 2009

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®

Page 10: MBD Model Based Design - March 2009

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+

-

Page 11: MBD Model Based Design - March 2009

MATLAB, Simulink, and TI C2000™ DSPs

Page 12: MBD Model Based Design - March 2009

A PMSM System - Design and Tunethrough Simulation

• Design Fixed-Point Controller• Specify Motor (Plant) Dynamics

Page 13: MBD Model Based Design - March 2009

Specify Tests and Visualize Results

Page 14: MBD Model Based Design - March 2009

Algorithm Specifications and Reuse

Design with Simulation

Generate Code for Rapid Prototyping

Generate Code for Production

Page 15: MBD Model Based Design - March 2009

Target Optimized Blocks (C28x)

• Blocks which call optimized TI routines in generated code and simulate with bit-true accuracy.

Page 16: MBD Model Based Design - March 2009

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

Page 17: MBD Model Based Design - March 2009

Schedulers and Device Drivers (C280x,

C281x and C2833x)

Page 18: MBD Model Based Design - March 2009

Rapid Prototyping - Asynchronous Scheduler and Device Drivers: Synchronizing ADC and PWM for F2808

Page 19: MBD Model Based Design - March 2009

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

Page 20: MBD Model Based Design - March 2009

Target-Host Communications:Host Side Blocks

Page 21: MBD Model Based Design - March 2009

STEP 3 - Code Verification using Processor-In-the-Loop Testing (PIL)

Simulink Test Bench

TestSignals

CCS Test Bench

VerificationsAlgorithm

Linkfor CCS

AlgorithmCode

PILInterface

Page 22: MBD Model Based Design - March 2009

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/

Page 23: MBD Model Based Design - March 2009

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

Page 24: MBD Model Based Design - March 2009

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

Page 25: MBD Model Based Design - March 2009

Generate code residing in Flash memory

Page 26: MBD Model Based Design - March 2009

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

Page 27: MBD Model Based Design - March 2009

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

Page 28: MBD Model Based Design - March 2009

Summary and Next Steps

Page 29: MBD Model Based Design - March 2009

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

Page 30: MBD Model Based Design - March 2009

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

Page 31: MBD Model Based Design - March 2009

From Models to Hardware –Design and Implementation of a Permanent Magnet Synchronous Motor Controller

PMSMF2808

Knob

eZdsp

PowerSupply

Page 32: MBD Model Based Design - March 2009

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]

Page 33: MBD Model Based Design - March 2009

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)

Page 34: MBD Model Based Design - March 2009

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

Page 35: MBD Model Based Design - March 2009

Documentation

search result

Demo search result

Demo

description

Page 36: MBD Model Based Design - March 2009

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

Page 37: MBD Model Based Design - March 2009

Appendix A:

Leverage TI’s Optimized Libraries

in your Simulink Design and C2000

Implementation

Page 38: MBD Model Based Design - March 2009

Target Optimized Blocks (C28x)

• Simulink Blocks that call optimized TI routines in generated code and simulate with bit-true accuracy.

Page 39: MBD Model Based Design - March 2009

Schedulers and Device Drivers (C280x and C281x)

Page 40: MBD Model Based Design - March 2009

Target-Host Communications:Host Side Blocks