advanced ac motor control s/w development › ... › automotive › files › kr-expo-2012 ›...

31
1 © 2012 The MathWorks, Inc. Advanced AC Motor Control S/W Development Sang-Ho Yoon Senior Application Engineer The MathWorks

Upload: others

Post on 28-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

1 © 2012 The MathWorks, Inc.

Advanced AC Motor Control S/W

Development

Sang-Ho Yoon

Senior Application Engineer

The MathWorks

Page 2: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

2

Agenda

Develop ECUs with Model-Based Design

Generate Application Code for Prototyping

Generate Algorithm Code for Production

Case Study: Brushless Motor Control Application

Questions

Page 3: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

3

ECU Development Process with Model-Based Design

System Requirements

System Design

Software Design

Coding

Software

Integration

Hardware/Software

Integration

System Integration

and Tuning

Sim

RP

RP (Embedded) SIL

PIL

HIL

Sim: Simulation

RP: Rapid Prototyping

PCG: Production Code Generation

SIL: Software-in-the-Loop Testing

PIL: Processor-in-the-Loop Testing

HIL: Hardware-in-the-Loop Testing PCG

Design

with

Simulation

Executable

Specifications

Continuous

Test and

Verification

Automatic

Code Generation

Models

Page 4: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

4

Simulation with Simulink

Simulink Embedded algorithm Model of physical system

Simulating plant and controller in one environment

allows engineers to optimize system-level

performance.

Controls engineers and domain specialists can work

together to detect integration issues in simulation.

Page 5: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

5

Rapid Prototyping

Generate, deploy, and tune code for a component (algorithm or controller)

on a real-time simulator connected to system hardware

Simulink Embedded algorithm Model of physical system

Physical system

Harness

Code

Generation

Rapid prototyping hardware

(real-time simulator)

Tuning and

logging

Host

Page 6: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

6

Rapid Prototyping on Embedded Processors

Run the generated code in real time, tune parameters, and monitor real-

time data on the same processor you plan to use in mass production, or a

close equivalent to it.

Simulink Embedded algorithm Model of physical system

Physical system

Harness

Code

Generation

Embedded microprocessor

Tuning and

logging

Host

Page 7: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

7

Processor-in-the-Loop Testing

Use processor-in-the-loop PIL to evaluate the behavior of a candidate

algorithm on the target processor.

Simulink Embedded algorithm Model of physical system

Code

Generation

Embedded microprocessor

Host

IDE

Lin

k

PIL Testing on

Embedded Hardware

Page 8: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

8

Hardware-in-the-Loop Testing

Final test before integration using simulated plant executing in real time.

Simulink

Embedded algorithm Model of physical system

Real-time simulator

Harness

Code

Generation

Embedded microprocessor

Host

Code

Generation

Page 9: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

9

Agenda

Develop ECUs with Model-Based Design

Generate Application Code for Prototyping

Generate Algorithm Code for Production

Case Study: Brushless Motor Control Application

Questions

Page 10: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

10

xPC Target Focusing Areas

System Requirements

System Design

Software Design

Coding

Software

Integration

Hardware/Software

Integration

System Integration

and Tuning

Sim

RP

RP (Embedded) SIL

PIL

HIL

PCG

Design

with

Simulation

Executable

Specifications

Continuous

Test and

Verification

Automatic

Code Generation

Models

Sim: Simulation

RP: Rapid Prototyping

PCG: Production Code Generation

SIL: Software-in-the-Loop Testing

PIL: Processor-in-the-Loop Testing

HIL: Hardware-in-the-Loop Testing

Page 11: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

11

Host computer

with MATLAB

xPC Target Turnkey

computer

Ethernet or RS 232

1

2

3

An environment that allows the real-time execution of Simulink

models on a separate xPC Target Kernel compatible PC.

Simulink

Coder

What is xPC Target?

Page 12: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

12

Host Computer

with MATLAB

xPC Target Turnkey

Computer

Ethernet or RS 232

An Environment that provides interactive access between the

real-time application and the host computer

Allows live parameter tuning, control from the original Simulink

model and offline analysis support in MATLAB.

Host computer

with MATLAB

xPC Target Turnkey

computer

Ethernet or RS 232

What is xPC Target?

Page 13: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

13

Host computer

with MATLAB

xPC Target Turnkey

computer

Ethernet or RS 232

3

An Environment that provides interactive access between the

real-time application and the host computer

Allows live parameter tuning, control from the original Simulink

model and offline analysis support in MATLAB.

1

2

4

2

What is xPC Target?

Page 14: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

14

xPC Target Turnkey PC

Host computer

with MATLAB

xPC Target Turnkey

computer

Ethernet or RS 232

An Environment that provides numerous I/O device driver blocks

Blocks are easily configurable within the Simulink model and

communicate with actual hardware in real-time.

What is xPC Target?

Page 15: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

15

xPC Target

Turnkey computer

An Environment that provides numerous I/O device driver blocks

Blocks are easily configurable within the Simulink model and

communicate with actual hardware in real-time.

What is xPC Target?

Page 16: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

16

Mobile Real-Time Target Machine

Performance : – 2GHz Dual Core Intel processor

– 2GB RAM, 100GB HD

– Gigabit Ethernet

Expandable : 5 PCI Slots

Digital and Analog I/O, CAN, Serial, etc

FPGA Expansion Card :

– High-speed PWM and Quadrature generation and decoding

– High-frequency control loops

– Programmable with Mathworks HDL Coder

Page 17: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

17

xPC Target Turnkey

Target Hardware partnership with Speedgoat

Hardware customized to fit your performance and I/O needs

Saves you time and hassle of acquiring, installing, configuring, and testing

Commercial Version : http://www.mathworks.com/products/xpctarget/supported-hardware

Academia Version : http://www.mathworks.com/academia/xpctarget-turnkey

Page 18: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

18

Agenda

Develop ECUs with Model-Based Design

Generate Application Code for Prototyping

Generate Algorithm Code for Production

Case Study: Brushless Motor Control Application

Questions

Page 19: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

19

Considerations for Embedded S/W

Development

Page 20: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

20

Simulink Coder

Generates code for use in simulation and

prototyping applications

Comes with Generic Real-Time (GRT) based

targets

Embedded Coder

Generates efficient code that can be

customized to look like hand code for

production

Comes with Embedded Real-Time (ERT)

based targets

Code Generation Products:

Simulink Coder and Embedded Coder

Page 21: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

21

Agenda

Develop ECUs with Model-Based Design

Generate Application Code for Prototyping

Generate Algorithm Code for Production

Case Study: Brushless Motor Control Application

Questions

Page 22: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

22

Brushed DC vs. AC Motor Control

Brushed DC Motor Control : Mechanical Commutation

Brushless DC Motor: Electrical Commutation

Software

Battery

Embedded

Controller Inverter

Page 23: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

23

Example PMSM Controller

Controller Algorithm Attributes:

• Outer Loop Velocity Controller @100Hz

• Inner Loop Current Controller @25kHz

• Coordinate transforms (ABC to/from dq)

• Multiple PI Controllers

Controller Outputs:

Three PWM Duty Cycles

Rotor Phase Currents

(AC Waveforms)

Page 24: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

24

Simulating plant and controller in one environment

allows engineers to optimize system-level performance.

Controls engineers and domain specialists can work

together to detect integration issues in simulation.

Inverter

and

Motor

Optimize Performance with Simulation

PMSM

Control Algorithm

Plant

+ u y

Controller

Page 25: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

25

Rapid Prototyping

Real Time Simulator

Motor

Hardware

System Model

Rapid Prototyping

Code

Generation

Controller

C Code

Motor

Model

Controller

Model

Page 26: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

26

Hardware High-Level Block Diagram

xPC Target Turnkey

Mobile Machine

Power

Electronics

PMSM

Motor

Encoder

Simulink Host Real-Time Target Application

Hardware

Page 27: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

27

Embedded System

Embedded Software

Motor

Hardware

System Model

Embedded Code Generation

Code

Generation

Controller

C Code

Motor

Model

Controller

Model

Page 28: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

28

Embedded Software Project

Integrating Generated Controller Code

with an Embedded Software Project

Execute at 25kHz

{

Controller

Command

ADC PWM

Encoder

Page 29: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

29

Embedded Software Project

Integrating Generated Controller Code

with an Embedded Software Project

Main()

{

Commands_Init

PWM_Init

ADC_Init

Encoder_Init

Controller_Init

while(1) {

}

}

ADC_InterruptServiceRountine_25kHz()

{

Commands_Read

ADC_Read

Encoder_Read

Controller_Step

PWM_Write

}

Page 30: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

30

Assessing behavior and execution time using

Processor-In-the-Loop (PIL)

Simulink

Embedded

Processor

Seria

l / TC

PIP

Serial / T

CP

IP

PIL Implementation

Code

Generation

Test

Signals Verifications

Controller

Model

Controller

C Code

Page 31: Advanced AC Motor Control S/W Development › ... › automotive › files › kr-expo-2012 › trac… · Advanced AC Motor Control S/W Development ... Brushless Motor Control Application

31 © 2012 The MathWorks, Inc.

Questions?