accélérer l’électrification

62
1 © 2017 The MathWorks, Inc. © 2021 The MathWorks, Inc. Développement d’un FOC pour PMSM Accélérer l’électrification

Upload: others

Post on 13-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Accélérer l’électrification

1© 2017 The MathWorks, Inc.© 2021 The MathWorks, Inc.

Développement d’un FOC pour PMSMAccélérer l’électrification

Page 2: Accélérer l’électrification

2

Page 3: Accélérer l’électrification

3

More Complex Algorithms

▪ Increasing motor control

algorithm complexity

– Field-Oriented Control (FOC)

– Field-weakening control

– Sensorless

– Space vector PWM

▪ Increasing need to run these

algorithms faster

– Wide bandgap semiconductors

– Increasing popularity of motor

types such as switched

reluctance motors

Page 4: Accélérer l’électrification

4

Model-Based Design

Page 5: Accélérer l’électrification

5

Why Simulink for motor control?

▪ Verify control algorithm with desktop simulation

▪ Generate compact and fast code from models

▪ Minimize development time using reference examples

Page 6: Accélérer l’électrification

6

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

Page 7: Accélérer l’électrification

7

Agenda

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

▪ Plant modeling

– Sensors Calibration

– Motor Parameters Estimation

– Motor and Inverter Model

▪ Algorithm design with simulation

– Field-Oriented control

– Autotuning control gain

– Verifying controller

▪ Software deployment

– Code generation

Page 8: Accélérer l’électrification

8

Texas Instruments Motor Control Kit

Page 9: Accélérer l’électrification

9

▪ Plant modeling

– Sensors Calibration

– Motor Parameters Estimation

– Motor and Inverter Model

▪ Algorithm design with simulation

– Field-Oriented control

– Autotuning control gain

– Verifying controller

▪ Software deployment

– Code generation

Agenda

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

Page 10: Accélérer l’électrification

10

Agenda

▪ Plant modeling

– Sensors Calibration

– Motor Parameters Estimation

– Motor and Inverter Model

▪ Algorithm design with simulation

– Field-Oriented control

– Autotuning control gain

– Verifying controller

▪ Software deployment

– Rapid control prototyping

– Code generation

– Hardware-In-The-Loop (HIL) test

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

Page 11: Accélérer l’électrification

11

Sensor Calibration

▪ ADC offsets

▪ Position Sensor Offset

Page 12: Accélérer l’électrification

12

ADC Offsets

1

2

.hex

Page 13: Accélérer l’électrification

13

ADC Offsets

Page 14: Accélérer l’électrification

14

ADC Offsets

Page 15: Accélérer l’électrification

15

ADC Offsets

Page 16: Accélérer l’électrification

16

Position Sensor Offset

Page 17: Accélérer l’électrification

17

▪ Plant modeling

– Sensors Calibration

– Motor Parameters Estimation

– Motor and Inverter Model

▪ Algorithm design with simulation

– Field-Oriented control

– Autotuning control gain

– Verifying controller

▪ Software deployment

– Rapid control prototyping

– Code generation

– Hardware-In-The-Loop (HIL) test

Agenda

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

Page 18: Accélérer l’électrification

18

Motor Parameters Estimation

Two types of parameter estimation methods:

Page 19: Accélérer l’électrification

19

Motor Parameters Estimation - Instrumented Test

Page 20: Accélérer l’électrification

20

Parameter Estimation Using Operation Data

Problem: Simulation data does not match measured data because the parameters are incorrect

Solution: Use to automatically tune model parameters

Page 21: Accélérer l’électrification

21

Page 22: Accélérer l’électrification

22

▪ Plant modeling

– Sensors Calibration

– Motor Parameters Estimation

– Motor and Inverter Model

▪ Algorithm design with simulation

– Field-Oriented control

– Autotuning control gain

– Verifying controller

▪ Software deployment

– Rapid control prototyping

– Code generation

– Hardware-In-The-Loop (HIL) test

Agenda

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

Page 23: Accélérer l’électrification

23

Motor and Inverter Modeling

▪ Use linear lumped-parameter model shipped with

Page 24: Accélérer l’électrification

24

Model Fidelity

Page 25: Accélérer l’électrification

26

Simscape Products

▪ Simscape platform

– Foundation libraries in many domains

– Language for defining custom blocks

▪ Extension of MATLAB

– Simulation engine and custom diagnostics

▪ Simscape add-on libraries

– Extend foundation domains with

components, effects, parameterizations

– Multibody simulation

– Editing Mode permits use of add-ons

with Simscape license only

– Models can be converted to C code

Page 26: Accélérer l’électrification

27

Trade Off - Balance Model Fidelity vs Simulation Speed

Page 27: Accélérer l’électrification

▪ Plant modeling

– Sensors Calibration

– Motor Parameters Estimation

– Motor and Inverter Model

▪ Algorithm design with simulation

– Field-Oriented control

– Autotuning control gain

– Verifying controller

▪ Software deployment

– Code generation

Agenda

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

Page 28: Accélérer l’électrification

Modeling Field-Oriented Control (FOC)

Clarke transform (abc →αβ)

Park transform (αβ → dq)

Measured current (A,B,C)

in time domain

Current control (d, q)

Page 29: Accélérer l’électrification

𝑑𝑢𝑡𝑦𝑐𝑦𝑐𝑙𝑒𝑠

Modeling Field-Oriented Control (FOC)

𝑖𝑎

𝑖𝑏

𝑖𝑑

𝑖𝑞

𝜔𝑟𝑒𝑓𝑇𝑟𝑒𝑓

𝜔

𝑣𝐷𝐶

𝜃𝑒

𝑖𝑑_𝑟𝑒𝑓

𝑖𝑞_𝑟𝑒𝑓

𝑣𝑑_𝑟𝑒𝑓

𝑣𝑞_𝑟𝑒𝑓

𝑣𝛼_𝑟𝑒𝑓

𝑣𝛽_𝑟𝑒𝑓α β

α β

Page 30: Accélérer l’électrification

Modeling Field-Oriented Control (FOC)

Page 31: Accélérer l’électrification

Autotuning controller gains

Page 32: Accélérer l’électrification

Autotuning controller gains

▪ Algorithm details:

– Injects a few superimposed sine waves,

while maintaining closed-loop operation

– Collects plant input-output data

– Estimates frequency response in real-time

– Tunes PID parameters to satisfy desired

bandwidth and phase margin

Plant

Closed-Loop

PID Autotuner

PID

Controller

test signal

outputref

tuned gains

▪ Initial stable PID controller is required

▪ Option to deploy autotuning to embedded processor using Simulink Coder™

Requires Simulink Control Design™

Page 33: Accélérer l’électrification

Autotuning controller gains

Autotuning

Motor speed is close to the nominal value while tuning

Page 34: Accélérer l’électrification

Autotuning controller gains

Page 35: Accélérer l’électrification

Autotuning controller gains

Page 36: Accélérer l’électrification

Verifying Controller

Simulation models are primary meant

to support V&V activities

Page 37: Accélérer l’électrification

Verifying Controller

Functional Testing

Textual

Requirements

Executable

Specification

Model used for

production code

generation

Generated

C/C++ code

Object

code

ModellingCompilation

and Linking

Code

Generation

▪ Does design meet requirements

▪ Confirm correct design behavior

▪ Verify no unintended behavior

Page 38: Accélérer l’électrification

Verifying Controller

Author test-cases that are derived from requirements

– Use test harness to isolate component under test

– Test Sequence to create complex test scenarios

Manage tests, execution, results

– Re-use tests for regression

– Automate in Continuous Integration

systems such as Jenkins

Page 39: Accélérer l’électrification

Dynamic Testing Static Analysis

Verifying Controller

Interactive testing

Reactive Testing

Coverage Analysis

Code Testing

Edit-time checks

(Dead Logic Detection)

(Test Case Generation)

Requirement Proving

Code proving

Page 40: Accélérer l’électrification

Agenda

CALIBRATE SENSORS

ESTIMATE MOTOR PARAMETERS

MODEL MOTOR & INVERTER

DESIGN FOC ALGORITHM

TUNE CONTROLLER GAINS

GENERATE CODE

VALIDATE ON HARDWARE

VERIFY IN DESKTOP SIMULATION

▪ Plant modeling

– Sensors Calibration

– Motor Parameters Estimation

– Motor and Inverter Model

▪ Algorithm design with simulation

– Field-Oriented control

– Autotuning control gain

– Verifying controller

▪ Software deployment

– Code generation

Page 41: Accélérer l’électrification

CoreSoftware

Algorithms and Logic

A B C

M

I NPUT

BLUE G REEN RED

PO W ER

RGBSplit-4BLACK BOX

V RCS

InputDrivers

OutputDrivers

SpecialDeviceDrivers

CommDrivers

Scheduler/Operating SystemAnd Support Utilities

CommunicationInterfaces

Sensors

Actuators

SpecialInterfaces

ASAP2

CCP

Most

Development

is on Core

Software

Algorithms

Simple Embedded Software Architecture

Page 42: Accélérer l’électrification

Embedded Software Project

Integrating Generated Controller Code with an Embedded

Software Project

Execute at 20kHz

{

Controller

Command

ADC PWM

Encoder

Model Hand

Page 43: Accélérer l’électrification

Embedded Software Project Pseudo-Code

Integrate Generated Controller Code with Your Hand-Coded

Software Project

interruptServiceRountine()

{

readAdcCountFromDriver();

readEncoderCountFromDriver();

controller();

writePwmCountToDriver();

}

main()

{

adcInit();

encoderInit();

pwmInit();

controllerInit();

while(1) {

}

}

Model Hand

Page 44: Accélérer l’électrification

Embedded Coder Hardware Support Packages

Hardware Support Packages: https://www.mathworks.com/hardware-support/home.html

Page 45: Accélérer l’électrification

MathWorks TI C2000 Support Package for Embedded Coder

Scheduling the generated code:

▪ Periodic tasks

▪ Idle tasks

▪ Interrupts (Hardware, Software)

▪ Advanced concepts:

– Pre-emptive rate-monotonic scheduler

– Base rate interrupt replacement

– Peripheral triggers (launch A/D

conversion from PWM)

– Running on the CLA

– Loading in Flash, running in RAM

– Using DMA

Supported devices:

▪ F2802x/3x/5x/6x/07x/004x

▪ F2833x/32x/37xS/37xD/38xS/38xD

▪ Fixed-point F280x/1x

F28379D LaunchPad

Page 46: Accélérer l’électrification

Supported TI C2000 drivers

▪ ADC, AIO, Comparator,

▪ GPIO, eQEP, ePWM, eCAP,

▪ eCAN, I2C, SCI, SPI, LIN

▪ Watchdog, DMA

▪ Motor control position sensing

– Optical encoder (using eQEP)

– Hall sensors (using eCAP)

– Sensorless (using SMO)

Page 47: Accélérer l’électrification

Prepare the Model for Code Generation Using Supported TI C2000

Drivers Blocks

Page 48: Accélérer l’électrification

Prepare the Model for Code Generation Using Supported TI C2000

Drivers Blocks

Page 49: Accélérer l’électrification

Deployment on the Target

▪ Generate code (floating

and fixed-point)

▪ Use host model to

control and debug

▪ Validate on hardware

Page 50: Accélérer l’électrification

Fixed-Point conversion

▪ Run the tool on the

system to convert

▪ Chose your conversion

method

Page 51: Accélérer l’électrification

Fixed-Point conversion

▪ Prepare the environment

▪ Configure your options

▪ Accept or modify the

datatype proposition

Page 52: Accélérer l’électrification

Fixed-Point conversion

▪ Run again with your

new datatype

▪ Compare

automatically with

floating point results

Page 53: Accélérer l’électrification

Deployment on the Target

▪ Generate code (floating

and fixed-point)

▪ Use host model to

control and debug

▪ Validate on hardware

Page 54: Accélérer l’électrification

Software-In-the-Loop (SIL) Testing

Test Vectors

Desktop Simulation(on PC)

Results

Model

Object Code Execution (on PC)

Results

Generated Code

Object File

CodeGenerator

PCCompiler

== ?

Compare

▪ Show equivalence, model to code

▪ Assess code execution time

▪ Collect code coverage

Page 55: Accélérer l’électrification

Software-In-the-Loop Test with Model Reference

Page 56: Accélérer l’électrification

Processor-In-the-Loop (PIL) Testing

Test Vectors

Desktop Simulation(on PC)

Results

Model

Object Code Execution (on target)

Results

Generated Code

Object File

CodeGenerator

CrossCompiler

== ?

Compare

▪ Verify numerical equivalence

▪ Assess target execution time

▪ Collect on target code coverage

Page 57: Accélérer l’électrification

System & Test Model

Serial link

Processor-In-the-Loop (PIL) TestingVerify Production Controller with Processor-in-the-loop

1 0 0 1 0 0

1 1 1 0 1 0

0 0 0 1 1 1

0 1 1 0 0 1

Algorithm

Open hardware

Or Evaluation boards

Or Production Board

Page 58: Accélérer l’électrification

Verify and Profile Code Using Processor-In-the-Loop(PIL) Testing

Page 59: Accélérer l’électrification

Deployment on the Target

▪ Generate code (floating

and fixed-point)

▪ Use host model to

control and debug

▪ Validate on hardware

Page 60: Accélérer l’électrification

Code Generation and Real-Time Testing in Model-Based Design

Code generation

Rapid Control Prototyping

DesktopSimulation

HIL testing

Validation

Page 61: Accélérer l’électrification

Key Takeaways

▪ Model-based design for motor control enables you to make 50% faster time

to market.

– Various fidelity modeling of motor and inverter using Simscape Electrical

– Autotuning PI controller gains using optimization algorithm

▪ Motor Control Toolbox, a new product in R2020a, enables you to minimize

development time using reference examples

– Sensor calibration, built-in algorithmic blocks, automated parameter estimation, and

gain-tuning

▪ Generate, deploy and validate production code

Page 62: Accélérer l’électrification

Q&A