Spinning Brushless Motors with Simulink

30
Spinning Brushless Motors with Simulink Nukul Sehgal Vamshi Kumbham

Transcript of Spinning Brushless Motors with Simulink

Page 1: Spinning Brushless Motors with Simulink

Spinning Brushless Motors with SimulinkNukul Sehgal

Vamshi Kumbham

Page 2: Spinning Brushless Motors with Simulink

We will spin a brushless motor using Simulink and Model-Based

Design

2

Page 3: Spinning Brushless Motors with Simulink

Brushless motors are everywhere

3

Page 4: Spinning Brushless Motors with Simulink

Developing embedded motor control software has its challenges

Page 5: Spinning Brushless Motors with Simulink

Developing embedded motor control software has its challenges

▪ Design work needed to be started before

motor hardware was available and needed

extensive testing to comply with standards

▪ Team needed to rapidly implement control

software on embedded processor once more

hardware became available

▪ Complex algorithms running at high sample

rates were difficult to implement in short

amount of time

Page 6: Spinning Brushless Motors with Simulink

Why Simulink for motor control?

6

Customers routinely

report 50% faster

time to market

▪ Verify control algorithm with desktop

simulation

▪ Generate compact and fast code from models

▪ Minimize development time using reference

examples

Page 7: Spinning Brushless Motors with Simulink

Motor Control Blockset simplifies the workflow

▪ Control blocks optimized for code

generation

▪ Sensor decoders and observers

▪ Motor parameter estimation

▪ Controller autotuning

▪ Reference examples

7

Page 8: Spinning Brushless Motors with Simulink

Brushless motors require complex algorithms – field-oriented

control

8

Speed

Controller

Current

Reference

Generator

Current

Controller

Space

Vector

Generator

Power

Inverter

Voltage

Supply

PMSMPark, Clarke Transforms

Sensor

decoders or

observers

Control algorithm

Physical system

𝑖𝑎

𝑖𝑏

𝑖𝑑

𝑖𝑞

𝜔𝑟𝑒𝑓 𝑇𝑟𝑒𝑓

𝜔

𝑣𝐷𝐶

𝜃𝑒

𝑖𝑑_𝑟𝑒𝑓

𝑖𝑞_𝑟𝑒𝑓

𝑣𝑑_𝑟𝑒𝑓

𝑣𝑞_𝑟𝑒𝑓

𝑣𝛼_𝑟𝑒𝑓

𝑣𝛽_𝑟𝑒𝑓

d,q

a,b

Inverse Park Transform

d,q

α,β

𝑑𝑢𝑡𝑦𝑐𝑦𝑐𝑙𝑒𝑠

Page 9: Spinning Brushless Motors with Simulink

Workflow for implementing field-oriented control

Calibrate

Sensors

Estimate

Motor Parameters

Model

Motor & Inverter

Design

Control Algorithm

Deploy &

Validate

Page 10: Spinning Brushless Motors with Simulink

We will use Texas Instruments motor control kit

10

Teknic 2310P

surface-mount PMSM

TMS320F28379D

MCU

DRV8305 3-phase

inverter

Page 11: Spinning Brushless Motors with Simulink

Sensor calibration

▪ Calibrate ADC offsets

11

Page 12: Spinning Brushless Motors with Simulink

Sensor calibration

▪ Calibrate ADC offsets

▪ Calibrate position sensor

offset

13

Page 13: Spinning Brushless Motors with Simulink

Parameter estimation

▪ Instrumented tests running

on the target

▪ Host model to start and

control parameter estimation

14

Page 14: Spinning Brushless Motors with Simulink

Bonus: you can use other techniques to parameterize motor models

15

From datasheet From ANSYS Maxwell,

JMAG, Motor-CAD FEA tools

From dyno data

Simscape Electrical Simscape Electrical Powertrain Blockset

Page 15: Spinning Brushless Motors with Simulink

Modeling motor and inverter

▪ Use linear lumped-parameter

motor model

▪ Model inverter as an

average-value inverter or

model switching with

Simscape Electrical

16

Page 16: Spinning Brushless Motors with Simulink

Bonus: you can model at needed level of fidelity

17

Motor Control Blockset

Simscape Electrical

Simscape Electrical Simscape Electrical

Page 17: Spinning Brushless Motors with Simulink

Control algorithm design

▪ Model field-oriented control

algorithm

▪ Model sensor decoders or

sensorless observers

▪ Tune loop gains

▪ Verify in closed-loop

simulation

18

Page 18: Spinning Brushless Motors with Simulink

Control algorithm design

▪ Model field-oriented control

algorithm

▪ Model sensor decoders or

sensorless observers

▪ Tune loop gains

▪ Verify in closed-loop

simulation

19

Control System Toolbox

Page 19: Spinning Brushless Motors with Simulink

Bonus: you can use several techniques to tune loop gains

21

Empirical Computation FOC Autotuner Classic Control Theory

Motor Control Blockset Motor Control Blockset and

Simulink Control Design

Simulink Control Design

Page 20: Spinning Brushless Motors with Simulink

Control algorithm design

▪ Model field-oriented control

algorithm

▪ Model sensor decoders or

sensorless observers

▪ Tune loop gains

▪ Verify in closed-loop

simulation

22

Page 21: Spinning Brushless Motors with Simulink

Deployment

▪ Target any processor with

ANSI C code

▪ Use provided example to

partition the model into

algorithmic and

hardware-specific parts

▪ Generate algorithmic

code for integration into

embedded application

23

Algorithmic Code

Page 22: Spinning Brushless Motors with Simulink

Deployment

▪ Generate code (floating and

fixed-point)

▪ Use host model to control and

debug

▪ Validate on hardware

24

Page 23: Spinning Brushless Motors with Simulink

MathWorks Training Services:Exploit the full potential of MathWorks products

Load tests Run test Results

Control

System

Design

Simulation Based Testing

Production Code Generation

Page 24: Spinning Brushless Motors with Simulink

You can verify and profile code using Processor-In-the-Loop testing

26

Page 25: Spinning Brushless Motors with Simulink

Bonus: you can target FPGAs as well

27

HDL Code Generation

Page 26: Spinning Brushless Motors with Simulink

Workflow for implementing field-oriented control

Calibrate

Sensors

Estimate

Motor Parameters

Model

Motor & Inverter

Design

Control Algorithm

Deploy &

Validate

Page 27: Spinning Brushless Motors with Simulink

Challenge

Develop control software to maximize the efficiency

and performance of a permanent magnet

synchronous motor

Solution

Use MathWorks tools for Model-Based Design to

model, simulate, and implement the control system

on a target processor

Results

▪ Development time cut in half

▪ Design reviews simplified

▪ Target verification and deployment accelerated

“MathWorks tools enabled us to verify the quality of our design at

multiple stages of development, and to produce a high-quality

component within a short time frame.”

- Markus Schertler, ATB Technologies

Link to user story

ATB Technologies permanent magnet

synchronous motor.

ATB Technologies cuts electric motor controller development time

by 50% using code generation for TI’s C2000 MCU

Page 28: Spinning Brushless Motors with Simulink

Use Model-Based Design for your next motor control project!

30

▪ Verify control algorithm with desktop

simulation

▪ Generate compact and fast code from models

▪ Minimize development time using reference

examples, built-in algorithmic blocks,

automated parameter estimation, and gain-

tuning

Page 29: Spinning Brushless Motors with Simulink

Learn More

▪ Visit mathworks.com/products/motor-control

and mathworks.com/solutions/power-

electronics-control

▪ Get power electronics control design trial

package with necessary tools for desktop

modeling, simulation, control design, and

production code generation of your next

motor control project

Page 30: Spinning Brushless Motors with Simulink

As a follow up, in which area would you like to talk to us?

▪ Buy/Try the product

▪ Speak with our technical expert

▪ Training (Paid)

▪ Consulting (Paid)

▪ I am not ready for any of the above

32