design and implementation of motor control systems with

39
Design and Implementation of Motor Control Systems with MATLAB, Simulink, and TI C2000DSPs Jing Wu Applications Engineer A Model-Based Design Approach

Upload: others

Post on 23-Feb-2022

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Design and Implementation of Motor Control Systems with

Design and Implementation ofMotor Control Systems with MATLAB,

Simulink, and TI C2000™ DSPs

Jing WuApplications Engineer

A Model-Based Design Approach

Page 2: Design and Implementation of Motor Control Systems with

DEMO - From Models to Hardware –Design and Implementation of a Permanent Magnet

Synchronous Motor Controller

PMSMF2808

Knob

eZdsp

PowerSupply

Page 3: Design and Implementation of Motor Control Systems with

Agenda

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

• Motor Control Systems Design; a PMSM example– 4 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 4: Design and Implementation of Motor Control Systems with

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 5: Design and Implementation of Motor Control Systems with

Requirements andSpecifications

Design

Implementation

Test andVerification

From Traditional Embedded SystemDevelopment to Model-Based Design

AlgorithmsAlgorithms

C, C++C, C++

MCUMCU DSPDSP

VHDL, VerilogVHDL, Verilog

Automatic codegeneration- Reduces time, effort- Enables code reuse- Minimizes coding errors

Gen

erat

e

Gen

erat

e Generate

Generate

System Behavior modelsSystem Behavior models

Environment modelsEnvironment models

Executable models- Unambiguous,“one truth”

- Links to textualrequirements

PhysicalComponents models

PhysicalComponents models

Environment modelsEnvironment models

AlgorithmsAlgorithms

Simulation- Reduces need for

physical prototypes- Enables systematic“what-if”analysis

Page 6: Design and Implementation of Motor Control Systems with

Requirements andSpecifications

Design

Implementation

Model Based Design Workflow

PhysicalComponents models

PhysicalComponents models

Environment modelsEnvironment models

AlgorithmsAlgorithms

Simulation- Reduces need for

physical prototypes- Enables systematic“what-if”analysis

C, C++C, C++

MCUMCU DSPDSP FPGAFPGA ASICASIC

VHDL, VerilogVHDL, Verilog

Automatic codegeneration- Reduces time, effort- Enables code reuse- Minimizes coding errors

Generate

Generate

Gen

erat

e

Gen

erat

e

AlgorithmsAlgorithms

System Behavior modelsSystem Behavior models

Environment modelsEnvironment models

Executable models- Unambiguous,“one truth”

- Links to textualrequirements

Test andVerification

MCU DSP

EmbeddedSoftware

DigitalElectronics

C, C++ VHDL, Verilog

Implement

Integration

Design

Physical Components

Environment

Algorithms

Gen

erat

e Generate

Page 7: Design and Implementation of Motor Control Systems with

TestEnvironments

ContinuousV&V

Requirements

Model Based Design Workflow

MCU DSP

EmbeddedSoftware

DigitalElectronics

C, C++ VHDL, Verilog

Implement

Integration

Design

Physical Components

Environment

Algorithms

Gen

erat

e Generate

Page 8: Design and Implementation of Motor Control Systems with

Model-Based Designwith MATLAB and Simulink

Page 9: Design and Implementation of Motor Control Systems with

*Languages*Applications

Software

Data

Hardware

Analysis Visualization

Deployment

Reporting &Documentation

MATLAB:Technicalcomputingenvironment

MATLAB Product FamilyThe Platform for Model-Based Design

Page 10: Design and Implementation of Motor Control Systems with

MATLAB Products

Simulink:Graphical,modeling andsimulationenvironment

Multi Domain Modeling

Embedded Systems

Hardware in the loop

Rapid Prototyping

Simulink for Model-Based Design

Page 11: Design and Implementation of Motor Control Systems with

Trace Between Code and Specification

Page 12: Design and Implementation of Motor Control Systems with

Complex Timing and Concurrency

•Complex timing–Feedback–Asynchronous edge triggered

blocks–Multi-rate digital with arbitrary

sample rates

•Concurrency–True expression of

parallelism– Important for whole system or

hardware sub-system design

Page 13: Design and Implementation of Motor Control Systems with

Who is Using Model-Based Design and CodeGeneration and for What Type of Application

•Big companies as well as startups–Toyota–BAE– Intacton, Duhyney…

•General applications as well as safety criticalapplications–Control, audio, video, medical, process–DO178B, Autosar, ABS systems…

Page 14: Design and Implementation of Motor Control Systems with

Toyota Uses MathWorks™ Tools to Increase Quality, ReduceCosts, and Speed Time to Market of New Vehicles

ChallengeTo speed up design, increase quality, and reduce R&Dcosts by finding an alternative to traditional design methods

SolutionUse MathWorks tools for control design to prototype,model, test, and refine control strategies in an integrateddesign environment

ResultsDeliver a better product to market faster — and at

a lower costReduced time to embedded code Forge a pathway to innovation

“MATLAB®, Simulink®, and

Stateflow®… have become the

de facto standard at Toyota for

simulation, data processing, and

controls design. It would be

impossible to list all of the

applications for these tools at

Toyota.”Akira Ohata

Toyota

“MATLAB®, Simulink®, and

Stateflow®… have become the

de facto standard at Toyota for

simulation, data processing, and

controls design. It would be

impossible to list all of the

applications for these tools at

Toyota.”Akira Ohata

Toyota

Page 15: Design and Implementation of Motor Control Systems with

Safety-CriticalCertification

Honeywell, FAA Software Tools Forum, May 2004

http://www.mathworks.com/company/newsletters/aero_digest/aug04/Honeywells.pdf

More than one million lines of automatically generated flight codecertified to DO-178B within past year

Page 16: Design and Implementation of Motor Control Systems with

Successful Deployments ofModel-Based Design

Caterpillar– Engine and Machine Control

DaimlerChrysler– Cruise Control, Trucks– Body Control, Cars

Delphi– Climate Control

General Motors– Powertrain ECU Software

Jaguar– Body Controls

Motorola– Seats, Battery, and Chassis Controls

Siemens– Chassis Controls for Commercial Vehicles

Toyota– Powertrain ECU Software

Visteon– Powertrain Controls and Audio Systems

Boeing– Radar, Imaging and Controls

Honeywell– DO178B Safety Critical Systems

Lockheed Martin– Flight Controls, Joint Strike Fighter

NASA Hyper-X– Achieved SEI CMM Level 5 with MBD

Northrop Grumman– UAV and Radar Systems

RealTek– Audio system CODECs

Sandia– FPGA-based Radar Systems

For a full list of user stories, seehttp://www.mathworks.com/company/user_stories

Page 17: Design and Implementation of Motor Control Systems with

Motor Control Systems withMATLAB, Simulink, and TI

C2000™ DSPs

Page 18: Design and Implementation of Motor Control Systems with

•Link for Code Composer Studio•Embedded C-code generation•Target for TI C2000

MATLAB, Simulink, and TI C2000™ DSPs

Compile& Link

C/ASMCode

Texas InstrumentsCode Composer Studio™

Environment

Download

Debug

TI C2000DSP

MathWorksModeling Environment

MATLAB® Simulink® Stateflow®

Page 19: Design and Implementation of Motor Control Systems with

4 Steps of Design

1. Design with simulation

2. Rapid Prototyping

3. Verify your code

4. Generate production code

Page 20: Design and Implementation of Motor Control Systems with

STEP 1 - Simulate controller andelectro-mechanical plant models toverify specification and optimize systemperformance.

ElectricalMechanical

DeviceActuators

Sensors

Plantu y

SystemPerformance

Controller Performance

Controller+

-

Page 21: Design and Implementation of Motor Control Systems with

A PMSM System - Design and Tunethrough Simulation

• Design Fixed-PointController

• Specify Motor (Plant) Dynamics

Page 22: Design and Implementation of Motor Control Systems with

Specify Tests and Visualize Results

Page 23: Design and Implementation of Motor Control Systems with

Algorithm Specifications and Reuse

Design with Simulation

Generate Code for Rapid Prototyping

Generate Code forProduction

Page 24: Design and Implementation of Motor Control Systems with

Code

STEP 2 - Rapid Prototyping - “TargetSupport Package TC2™”for testing in a realenvironment

Models

Target forTI C2000

EmbeddedC-code

Generation

AlgorithmSpecification

ProcessorSpecifications

Scheduler and Device Specific Drivers

AlgorithmImplementation

Page 25: Design and Implementation of Motor Control Systems with

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

Page 26: Design and Implementation of Motor Control Systems with

Target –Host Communicationsfor Tuning and Monitoring

Target Side ModelGenerated Code runs on DSP

Host Side ModelModel executes on PC

Monitor or tune low-rate data

Write to channelRead from channel

CAN, SCI, RTDX

Page 27: Design and Implementation of Motor Control Systems with

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

Simulink Test Bench

TestSignals

CCS Test Bench

VerificationsAlgorithm

Linkfor CCS

AlgorithmCode

PILInterface

Page 28: Design and Implementation of Motor Control Systems with

Need for Code Verification

•Target C compiler optimization settings

•Code generation optimization settings

•Integration of custom code

•Defects in hardware, compiler, linker, or codegenerator

Page 29: Design and Implementation of Motor Control Systems with

Code –Flash(Standalone)

STEP 4 - Production Code GenerationMethod 1:Generate Standalone Code

Models

Target forTI C2000

EmbeddedC-code

Generation

AlgorithmSpecification

ProcessorSpecifications

Scheduler and Device Specific Drivers

AlgorithmImplementation

Page 30: Design and Implementation of Motor Control Systems with

Code –Flash(Standalone)

Production Code Generation: Method 2Algorithm Export for Integrationwith your Drivers and Scheduler

Models

EmbeddedC-code

Generation

AlgorithmSpecification

ProcessorSpecifications

Scheduler and Device Specific Drivers

AlgorithmImplementation

Page 31: Design and Implementation of Motor Control Systems with

Integrate test harness

Verify and Validate

Designmodel

Executetest

cases

Automaticallygenerate

code

CoverageReport

Software-in-the-loop

TargetCode

Processor-in-the-loop

Target processor

with design

Test harnessmodel

Hardware-in-the-loop

Target ECU

Requirements

Page 32: Design and Implementation of Motor Control Systems with

Summary and Next Steps

Page 33: Design and Implementation of Motor Control Systems with

Addressing EmbeddedProgramming Challenges

Capture and act upon hardware andsoftware interruptsAsynchronous Scheduling

Processor-in-the-Loop testingVerification of Code Execution

Ability to assign data and functions to becopied from Flash to RAMExecution speed from Flash

Generate code for deployment to FlashProduction Code Deployment

TFL and Legacy Code ToolProcessor specific code

ResponseChallenge

Page 34: Design and Implementation of Motor Control Systems with

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

MCU DSP

EmbeddedSoftware

DigitalElectronics

C, C++ VHDL,Verilog

ImplementI

Design

PhysicalComponents

Environment

Algorithms

Gen

erat

eGenerate

Page 35: Design and Implementation of Motor Control Systems with

Production Code Deployment

Example applications of production deploymentinclude:– Engine and transmission control– Hybrid electric vehicle battery control– Commercial aircraft fly-by-wire system, certified to Level A DO178B

Page 36: Design and Implementation of Motor Control Systems with

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 Steps1. 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 save money and time to market

Thank You !

Page 37: Design and Implementation of Motor Control Systems with

From Models to Hardware –Design and Implementation of a Permanent

Magnet Synchronous Motor Controller

PMSMF2808

Knob

eZdsp

PowerSupply

Page 38: Design and Implementation of Motor Control Systems with

Data-Driven ModelingFirst Principles Modeling

NeuralNetworkToolbox

SimscapeSimMechanicsSimDriveline

SimHydraulicsSimPowerSystems

SystemIdentification

Toolbox

SimulinkParameterEstimation

Simulink

Tools for Modeling Dynamic Systems

Modeling Approaches

Modeling Dynamic Systems in Simulink

Page 39: Design and Implementation of Motor Control Systems with

Thank You!