KEMBAR78
Design and Implementation of Motor Control Algorithms | PDF | Electric Motor | Power Inverter
0% found this document useful (0 votes)
76 views144 pages

Design and Implementation of Motor Control Algorithms

The document discusses the design and implementation of motor control algorithms, focusing on various industry applications and the challenges faced in electric drives. It highlights the use of MathWorks tools for model-based design to enhance efficiency and reduce development time for permanent magnet synchronous motors. Additionally, it covers motor modeling techniques and the importance of tuning control algorithms for optimal performance.

Uploaded by

raj_kumart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views144 pages

Design and Implementation of Motor Control Algorithms

The document discusses the design and implementation of motor control algorithms, focusing on various industry applications and the challenges faced in electric drives. It highlights the use of MathWorks tools for model-based design to enhance efficiency and reduce development time for permanent magnet synchronous motors. Additionally, it covers motor modeling techniques and the importance of tuning control algorithms for optimal performance.

Uploaded by

raj_kumart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 144

Design and implementation of Motor Control

Algorithms

By Ramanuja Jagannathan
Sr. Application Engineer
2024-03-22

© 2024 The MathWorks, Inc.


1
The Increasing Complex World of Motor Control
Industry Applications

Auto HEV/EV powertrain, power steering,


wiper motors

IAM Variable speed drives for automation,


industrial robotics,
elevators/escalators, HVAC, fans, and
pumps
Aerodef/ Variable speed motors for propulsion,
Ship electric motors used to replace
hydraulics in fuel metering valves,
speed brakes, flap controls
Rail Propulsion/traction
Med Pumps, therapeutics, surgical tools
Devices

Consume direct drive washing machines; battery-


r powered contractor, home, and garden
tools
2
Control Challenges in Electric Drives

▪ Operating safe and efficient (minimizing power losses) over a wide speed range

▪ Maintaining proper torque for systems with a broad dynamic range while keeping low-
computational complexity of the control algorithm

▪ Need reduced models to tackle slower simulations

▪ Estimating the speed and position in sensorless drives

▪ Tuning the controller to obtain fast transient response

▪ Accounting for hardware and real-time constraints

3
ATB Technologies Cuts Electric Motor Controller Development Time
by 50% Using Code Generation for TI’s C2000 MCU
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 ATB Technologies permanent magnet synchronous
motor.

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


▪ Development time cut in half at multiple stages of development, and to produce a high-quality
▪ Design reviews simplified component within a short time frame.”
▪ Target verification and deployment accelerated - Markus Schertler, ATB Technologies

Link to user story 4


Motor control design tasks

Motor Modeling Inverter + Modulation Modeling

Power Supply

vq vα Gate
Iq reference +- PI-controller pulses

Inverse SVPWM
Park Generator
vd vβ
0 +- PI-controller

iq ia
ib
id Clarke/Park ic

Motor

FOC Control Design Hardware Deployment


5
Experiment Results

Animation Credits: Prof M Riaz, University of Minnesota


6 6
http://people.ece.umn.edu/users/riaz/index.htm
How does a PMSM work?

11
PMSM Fields
𝑖𝑎

𝜓𝑎
S N

12
𝜓𝑏
PMSM Fields
𝑖𝑏

𝜓𝑎
S N

13
𝜓𝑏
PMSM Fields
𝑖𝑐

𝜓𝑎
S N

𝜓𝑐

14
𝜓𝑏
PMSM Fields

𝜓𝑚
𝜓𝑎
S N

𝜓𝑐

15
𝜓𝑏
PMSM – Rotating 𝜓𝑝
𝑖𝑎 , 𝑖𝑏 , 𝑖𝑐
Magnetic Field

𝜓𝑚
𝜓𝑎
S N

𝜓𝑐

16
PMSM Dynamic Model

𝑑𝜓𝑎
𝑉𝐴 𝑅𝑠 0 0 𝑖𝑎 𝑑𝑡
𝑑𝜓𝑏
▪ 𝑉𝐵 = 0 𝑅𝑠 0 𝑖𝑏 +
𝑑𝑡
𝑉𝐶 0 0 𝑅𝑠 𝑖𝑐 𝑑𝜓𝑐
𝑑𝑡
𝜓𝑎 𝐿𝑎𝑎 𝐿𝑎𝑏 𝐿𝑎𝑐 𝑖𝑎 𝜓𝑎𝑚
▪ 𝜓𝑏 = 𝐿𝑏𝑎 𝐿𝑏𝑏 𝐿𝑏𝑐 𝑖𝑏 + 𝜓𝑏𝑚
𝜓𝑐 𝐿𝑐𝑎 𝐿𝑐𝑏 𝐿𝑐𝑐 𝑖𝑐 𝜓𝑐𝑚
𝜓𝑚 𝐶𝑜𝑠(𝜃𝑒 )
𝜓𝑎𝑚 2𝜋
▪ 𝜓
𝜓𝑏𝑚 = 𝑚 𝐶𝑜𝑠(𝜃𝑒 − )
3
𝜓𝑐𝑚 2𝜋
𝜓𝑚 𝐶𝑜𝑠(𝜃𝑒 + )
3

17 17
https://www.mathworks.com/help/sps/ref/pmsm.html
PMSM Dynamic Model

▪ 𝜃𝑒 = 𝑁𝜃𝑟 + 𝑟𝑜𝑡𝑜𝑟 𝑜𝑓𝑓𝑠𝑒𝑡


▪ 𝐿𝑎𝑎 = 𝐿𝑠 + 𝐿𝑚 𝐶𝑜𝑠(2𝜃𝑒 )
2𝜋
▪ 𝐿𝑏𝑏 = 𝐿𝑠 + 𝐿𝑚 𝐶𝑜𝑠 2(𝜃𝑒 − )
3
2𝜋
▪ 𝐿𝑐𝑐 = 𝐿𝑠 + 𝐿𝑚 𝐶𝑜𝑠 2(𝜃𝑒 + )
3
𝜋
▪ 𝐿𝑎𝑏 = 𝐿𝑏𝑎 = −𝑀𝑠 − 𝐿𝑚 𝐶𝑜𝑠 2 𝜃𝑒 +
6
𝜋 2𝜋
▪ 𝐿𝑏𝑐 = 𝐿𝑐𝑏 = −𝑀𝑠 − 𝐿𝑚 𝐶𝑜𝑠 2 𝜃𝑒 + −
6 3
𝜋 2𝜋
▪ 𝐿𝑐𝑎 = 𝐿𝑎𝑐 = −𝑀𝑠 − 𝐿𝑚 𝐶𝑜𝑠 2 𝜃𝑒 + +
6 3

18 18
https://www.mathworks.com/help/sps/ref/pmsm.html
Mathematical
Transforms

Clarke’s Transformations
𝑓𝛼 1 −1/2 −1/2 𝑓𝑎
2
𝑓𝛽 = ∗ 0 3/2 − 3/2 ∗ 𝑓𝑏
3
𝑓0 1/2 1/2 1/2 𝑓𝑐

Park’s Transformations
𝑓𝑑 cos 𝜃 sin 𝜃 0 𝑓𝛼
𝑓𝑞 = − sin 𝜃 cos 𝜃 0 ∗ 𝑓𝛽
𝑓0 0 0 1 𝑓0

19
PMSM Dynamic Model

𝑑𝜓𝑑
▪ 𝑉𝑑 = 𝐼𝑑 𝑅𝑠 − 𝜔𝑒 𝜓𝑞 +
𝜓𝑄 𝑑𝑡
𝑑𝜓𝑞
▪ 𝑉𝑞 = 𝐼𝑞 𝑅𝑠 + 𝜔𝑒 𝜓𝑑 +
𝜓𝑝 𝑑𝑡
𝛽

▪ 𝜓𝑑 = 𝐿𝑑 𝐼𝑑 + 𝜓𝑚
N
S

S N ▪ 𝜓𝑞 = 𝐿𝑞 𝐼𝑞
𝜓𝐷
𝜓𝑚

3
▪ 𝑇𝑒 = 𝑁 𝐼𝑞 (𝜓𝑚 + 𝐼𝑑 𝐿𝑑 ) − 𝐼𝑑 𝐼𝑞 𝐿𝑑
2
𝑑𝜔𝑟
IPMSM has a higher q-axis inductance
▪ Te – TL = 𝐽 + 𝑏𝜔𝑟
𝑑𝑡
than its d-axis inductance

https://www.mathworks.com/help/sps/ref/pmsm.html 20
PMSM Dynamic Model

3
▪ 𝐿𝑑 = 𝐿𝑠 + 𝑀𝑠 + 𝐿𝑚
𝜓𝑄 2
3
▪ 𝐿𝑞 = 𝐿𝑠 + 𝑀𝑠 − 𝐿𝑚
𝜓𝑝 2
𝛽 ▪ 𝐿0 = 𝐿𝑠 − 2𝑀𝑠
N
S

S N
𝜓𝐷 ▪ 𝑘𝑒 = 𝑁𝜓𝑚 [in V/Krpm]
𝜓𝑚
▪ 𝑒𝑝ℎ = 𝑘𝑒 𝜔
▪ 𝑘𝑡 = 𝑁𝜓𝑚 [in Nm/A]
3
▪ 𝑇 = 𝑘𝑡 𝐼𝑝𝑘 (𝑖𝑓𝐿𝑑 = 𝐿𝑞 )
2
IPMSM has a higher q-axis inductance
than its d-axis inductance

https://www.mathworks.com/help/sps/ref/pmsm.html 21
How to model your Permanent magnet synchronous motor?

22
Motor Modeling Fidelity

Thermal Dependency Nonlinear Flux vs. iabc,


Steady-State Linear Lumped
Rotor angle, Saturation
Torque-Speed Curves

23
Importing motor efficiency map to Simscape

Motor efficiency data from


a Motor Desing tool

24
Modeling Motor Electrical Parameters

Modeling Option Parameters


Lumped Model Data [𝜓𝑚 /𝐾𝑇 /𝐾𝑣 ], [𝐿𝑑 , 𝐿𝑞 , 𝐿0 || 𝐿𝑠 , 𝐿𝑚 , 𝑀𝑠 ], 𝑅𝑠 , P

2-D Partial derivative data [constant mutual 𝑑𝜓(𝑖,𝜃) 𝑑𝜓(𝑖,𝜃)


, 𝑑𝜃 , 𝑅𝑠 , 𝑀𝑠
inductance] 𝑑𝑖

2-D Partial derivative data [sinusoidal back emf] 𝐿𝑑 𝑖𝑑 , 𝑖𝑞 , 𝐿𝑞 𝑖𝑑 , 𝑖𝑞 , 𝜓 𝑖𝑑 , 𝑖𝑞 , 𝑅𝑠 , 𝐿0 , P

3-D Partial derivative data 𝑑𝜓𝐴 (𝑖𝑑 ,𝑖𝑞 ,𝜃) 𝑑𝜓𝐴 (𝑖𝑑 ,𝑖𝑞 ,𝜃) 𝑑𝜓𝐴 (𝑖𝑑 ,𝑖𝑞 ,𝜃)
, , , T(𝑖𝑑 , 𝑖𝑞 , 𝜃) , 𝑅𝑠
(Use ee_calculateFluxPartialDerivatives) 𝑑𝑖𝐴 𝑑𝑖𝐵 𝑑𝑖𝐶

4-D Partial derivative data 𝑑𝜓𝐴 (𝑖𝐴 ,𝑖𝐵 ,𝑖𝐶 ,𝜃) 𝑑𝜓𝐴 (𝑖𝐴 ,𝑖𝐵 ,𝑖𝐶 ,𝜃) 𝑑𝜓𝐴 (𝑖𝐴 ,𝑖𝐵 ,𝑖𝐶 ,𝜃)
, , , T(𝑖𝐴 , 𝑖𝐵 , 𝑖𝐶 , 𝜃) , 𝑅𝑠
𝑑𝑖𝐴 𝑑𝑖𝐵 𝑑𝑖𝐶

3-D Flux Linkage Data 𝜓𝑑 (𝑖𝑑 , 𝑖𝑞 , 𝜃), 𝜓𝑞 (𝑖𝑑 , 𝑖𝑞 , 𝜃), T(𝑖𝑑 , 𝑖𝑞 , 𝜃) , 𝑅𝑠 , P


𝜓𝑑 (𝐼𝑠 , 𝛽, 𝜃), 𝜓𝑞 (𝐼𝑠 , 𝛽, 𝜃), T(𝐼𝑠 , 𝛽, 𝜃) , 𝑅𝑠 , P
𝜓𝐴 (𝑖𝑑 , 𝑖𝑞 , 𝜃), T(𝑖𝑑 , 𝑖𝑞 , 𝜃) , 𝑅𝑠 , P
𝜓𝐴 (𝐼𝑠 , 𝛽, 𝜃), T(𝐼𝑠 , 𝛽, 𝜃) , 𝑅𝑠 , P [includes higher harmonic]
https://www.mathworks.com/help/sps/ref/femparameterizedpmsm.html 25
Demo - Import Efficiency Map Data from Motor-CAD

>>openExample('simscapeelectrical/EfficiencyMapFromMotorCADExample')
26
Demo - Generate ROM of PMSM Motor Drive Subsystem

>>openExample('simscapeelectrical/GenerateROMOfMotorDriveSubsysExample')
27
How to parametrize PMSM?

28
Motor Parameter Estimation

• Lumped motor parametes – Rs, Ld, Lq, Ke, J, F

• If we don’t have the motor datasheet, how to get


these parameters?

• If we have motor datasheet, how to validate the


datasheet? Flash parameter estimation
algorithm to uC

PC Microcontroller
(Simulink) (TI C2000)

(No-load) 29
Motor parametrization from Dyno test

▪ Connect Motor to
dyno
▪ Perform design of
experiments

30
Use Motor Design tools Flux vs current and rotor position data

31
FEM Tool Look-up Tables

• Input:
• Current vector amplitude,
• Current vector angle (advance
angle, b),
• Rotor position (q)

• Output:
• Total flux
• Inductance
• Torque
• Iron Losses

32
Demo - Import IPMSM Flux Linkage Data from Motor-CAD

>>openExample('simscapeelectrical/IPMSMFluxFromMotorCADExample')
33
34
35
36
How to model PMSM losses and faults?

37
Modeling Iron Losses

Modeling Option Model


𝑎ℎ 𝑎𝐽 2 𝑎𝑒𝑥 1.5
Iron Losses (open and 𝑃𝑜𝑐 𝑉𝑚𝑟𝑚𝑠 = 𝑉𝑚 + 𝑉 𝑚 + 𝑉𝑚
𝑘 𝑟𝑚𝑠 𝑘 2 𝑟𝑚𝑠 𝑘 1.5 𝑟𝑚𝑠
short circuit method) 𝑏 𝑏 𝑏𝑒𝑥 ∗
𝑃𝑠𝑐 𝑉 ∗ 𝑑𝑟𝑚𝑠 = 𝑘ℎ 𝑉 ∗ 𝑑𝑟𝑚𝑠 +𝑘 𝐽2 𝑉 ∗ 𝑑𝑟𝑚𝑠 2 +𝑘 1.5 𝑉 𝑑𝑟𝑚𝑠 1.5
Steinmetz 𝑃𝑟𝑜𝑡𝑜𝑟 𝑓 = 𝑘ℎ𝑟 𝐼𝑝 , 𝛽 𝑓+𝑘𝐽𝑟 𝐼𝑝 , 𝛽 𝑓 2 +𝑘𝑒𝑟 𝐼𝑝 , 𝛽 𝑓 1.5
Parametrization 𝑃𝑠𝑡𝑎𝑡𝑜𝑟 𝑓 = 𝑘ℎ𝑠 𝐼𝑝 , 𝛽 𝑓+𝑘𝐽𝑠 𝐼𝑝 , 𝛽 𝑓 2 +𝑘𝑒𝑠 𝐼𝑝 , 𝛽 𝑓 1.5
𝑃𝑙𝑜𝑠𝑠,𝑟𝑜𝑡𝑜𝑟 𝑓 = 𝑘ℎ𝑟 𝐼𝑑 , 𝐼𝑞 𝑓+𝑘𝐽𝑟 𝐼𝑑 , 𝐼𝑞 𝑓 2 +𝑘𝑒𝑟 𝐼𝑑 , 𝐼𝑞 𝑓 1.5
𝑃𝑙𝑜𝑠𝑠,𝑠𝑡𝑎𝑡𝑜𝑟 𝑓 = 𝑘ℎ𝑠 𝐼𝑑 , 𝐼𝑞 𝑓+𝑘𝐽𝑠 𝐼𝑑 , 𝐼𝑞 𝑓 2 +𝑘𝑒𝑠 𝐼𝑑 , 𝐼𝑞 𝑓 1.5
𝑃𝑟 𝑖𝑑 , 𝑖𝑞 , 𝑤 , 𝑃𝑠 (𝑖𝑑 , 𝑖𝑞 , 𝑤)
𝑃𝑟 𝑖𝑠 , 𝛽, 𝑤 , 𝑃𝑠 (𝑖𝑠 , 𝛽, 𝑤)

• The iron losses model assumes sinusoidal currents.

• Modelling motor losses help in designing outer loop operating point control to minimize losses

38
Modeling Thermal Dissipation and Dependence Model

• 𝑖 2 𝑅 𝑙𝑜𝑠𝑠𝑒𝑠, 𝑒𝑑𝑑𝑦 𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑎𝑛𝑑 ℎ𝑦𝑠𝑡𝑒𝑟𝑒𝑠𝑖𝑠 𝑙𝑜𝑠𝑠𝑒𝑠

• Thermal mass both for stator and rotor

• % of main flux and cross-tooth flux path iron


losses through rotor and winding

𝑅 = 𝑅0 (1 + 𝛼 𝑇 − 𝑇0 )

∆𝐵
S N 𝐵 Permanent magnet flux temperature coefficient
∆𝑇

39
Motor Thermal Circuit
Thermal interaction between components with heat input data

40
Motor with Thermal Model

41
Faulted PMSM Modelling

42
Demo – Thermal model and faultable PMSM

>>openExample('simscapeelectrical/PMSMWithTh >>openExample('simscapeelectrical/FaultedPMS
ermalExample') MExample')

43
Demo – Generate a Simulink Reduced-Order Thermal Model from
Motor-CAD Thermal Model

https://in.mathworks.com/matlabcentral/fileexchange/120598-import-a-motor-cad-thermal-model-into-simulink-
and-simscape 44
What modulation technique works for my motor?

45
PMSM: Inverter and Modulation Technique

▪ Voltage source inverter (VSI) is


used to commutate current in the
motor

▪ Physical system a
b Vdc
– Fixed inverter topology c
– Select semiconductor device
– Current sensing strategy

▪ Modulation logic
– Continuous modulation
– Discontinuous modulation
46
Semiconductors modeling fidelity
Drain-Source Voltage vs. Drain Current for Semiconductor Models
Linear Switch Threshold-Based Surface Potential

Input and Reverse Transfer Capacitance vs. Gate-Source Voltage in Semiconductor Models

No Dynamics Constant Capacitance Surface Potential

47
Semiconductors modeling fidelity
Drain-Source Voltage vs. Drain Current for MOSFET Models

Fixed Temperatures Self-Heating Varying Temperature

48
Parametrizing from datasheet
IGBT Module

49
Parametrizing from datasheet
IGBT Module

50
Parametrizing from datasheet
IGBT Module

51
Parametrizing from datasheet
IGBT Module

52
>> graphImporter 53
Inverter and Modulation Technique

▪ PWM Generation (converter control)


– Generate a modulation waveform for each phase using a continuous or discontinuous
method
– Generate converter pulses

Continuous PWM modulation Discontinuous PWM modulation


waveform waveform 54
Inverter and Modulation Technique

Sinusoidal pulse width modulation Space vector pulse width modulation

Modulation Wave

Carrier Wave

𝑉𝑑𝑐_𝑏𝑢𝑠 𝑉𝑑𝑐_𝑏𝑢𝑠
𝑉𝑙𝑛−𝑝𝑘 ≤ 𝑉𝑙𝑛−𝑝𝑘 ≤
2 3
55
Space vector hexagon – Corresponding switching states

56
Space Vector Modulation

57
Demo - Determine Power Losses and THD for PWM Methods

>> openExample('mcb/DeterminePowerLossesTHDForPWMModulationMethodsExample') 58
59
Current measurement sensors

▪ Current sensors are


either shunt type or inline
sensor based.

60
Configure your model to balance model fidelity and simulation speed

Verification of control, Design PWM techniques to Verification of control, Loss estimation and Thermal
Control algorithm design LUTs for reference deal with ripples and Control algorithm design
Effect of switching, Analysis
current generation acoustics,
Observer verification

*Typically used for 61


Demo - Model Switching Dynamics in Inverter Using Simscape
Electrical

>> openExample('mcb/SimscapeElectricalExample')
62
63
64
What control strategies work for PMSM?

65
Motor control design

V/F control Six-step Field-oriented Direct torque


Field-weakening
commutation for control control
control
BLDC with Hall
sensor

66
VbyF control
▪ Open-loop control (also known as
scalar control or Volts/Hz control)

▪ Simple technique that does not


need any feedback from the
motor.

67
VbyF Controller Block
Specify
▪ Rated Speed and Voltage
▪ Pole pairs
▪ Boost or Min Voltage
▪ Initial Ramp up Time
▪ Reference Speed

68
69
I-F Controller

• The I-F control algorithm provides good


control over torque during motor startup.

• The control algorithm starts the motor


without any current overshoots

• Also provides a smooth I-F control to closed-


loop control transition.

70
I-F Controller

71
Demo - Sensorless Field-Oriented Control of PMSM Using I-F
Control-Based Startup

>>openExample('mcb/SensorlessFOCOfPMSMUsingIFBasedStartupExample') 72
73
Direct Torque Control

▪ Torque and Flux are given as command to controller

▪ Torque is controlled in the stationary frame

▪ Torque changes rapidly by applying the appropriate space vector voltage

▪ Stator flux is referenced control technique

▪ Senorless

74
Control Algorithm Design
Direct Torque Control

𝑉2 (010) 𝑉3 (011)

Flux Torque Voltage


Vector
Increase Increase V3
𝑉6 (110) Increase Decrease V5
𝑉1 (001) Decrease Increase V2
Decrease Decrease V4

𝑉4 (100) 𝑉5 (101)
75
Control Algorithm Design
Direct Torque Control

76
Demo - Direct Torque Control of PMSM Using Quadrature Encoder
or Sensorless Flux Observer

>>openExample('mcb/DirectTorqueControlOfPMSMQuadratureEncoderFluxObserverExample')
77
Field-Oriented Control
𝜓𝑄

𝜓𝑝
𝛽

NN
S
S N

S
𝜓𝐷
𝜓𝑚

rotor flux In SPMSM, controlling rotor field


d-axis current ⏊ to Stator field produces
(high speed field weakening)
maximum torque
q-axis current Torque control

79
Field-Oriented Control

FOC Algorithm

• Measure rotor angular position and phase currents

• Compute the desired stator field vector based on measured rotor angular
position

• Control 3-phase currents by modulating phase voltages to achieve the


desired stator field vector

80
Control Algorithm Design
Field-oriented control architecture

𝐼𝑑,𝑟𝑒𝑓 𝑉𝑑 𝑉𝛼
𝜔𝑟𝑒𝑓 𝑇𝑟𝑒𝑓 Current PI Contr. 1 d,q
Speed SVPWM 𝑑𝑢𝑡𝑦
Controller
Reference 𝐼𝑞,𝑟𝑒𝑓 𝑉𝑞 𝑉𝛽 Generator 𝑐𝑦𝑐𝑙𝑒𝑠
Three-Phase
Generator PI Contr. 2 α,β Inverter
𝜔

𝐼𝑑 𝐼𝑎
d,q 𝐼𝑏
𝐼𝑞
a,b,c 𝐼𝑐
Park, Clarke Transforms

Current control
𝜃𝑒
Sensor
Speed feedback Speed
decoders/ Motor
Calculation
Observers

Speed control Physical sys

81
Field-Oriented Control - Signals Diagram

max max 1
5V
0 0 0.5

0
min min 0
0 t 0 t 0 t 0 PWM_a_HS t
vαα vaa DCaa PWM_a_LS
vbb DCbb Gate PWM_b_HS
Inverse Park vββ Inverse Clarke SVPWM PWM_b_LS
vcc DCcc Driver
PWM_c_HS
PWM_c_LS
pi

Rotor position
0
0 t

θ processing
max
(sensor-based or
senserless)
vqq vdd
min
0 t
idd iαα iaa a
‘dq’ ibb Electric b
Park Clarke Inverter
Control iqq iββ icc Motor c

max max max max

0 0 0

min min min min


0 t 0 t 0 t 0 t

82
Demo - Generate Motor Control Models for Selected Algorithm and
Hardware

>>openExample('mcb/GenerateMotorControlModelsForSelectedAlgoAndHardwareExample') 83
84
How field weakening works?

85
What is Field-Weakening Control?
To achieve high-speed high-performance torque control

86
What is Field-Weakening Control?
- PMSM motor model

Electrical Model
dd (1)
Vd = R s id + -  e L qiq
dt

dq
Vq = R s iq + +  e Ld id +  epm (2)
dt
• Vq is the q-axis voltage
Back-EMF voltage

d = L d id + pm (3) •
Vd is the d-axis voltage
Iq is the q-axis current
• Id is the d-axis current
q = L qiq (4)
• Rs is the stator phase winding resistance
• λpm is the permanent magnet flux linkage
Mechanical Model • λq the q-axis flux linkage
3p • λd is the d-axis flux linkage
Tem = 2 (pm iq+( Ld - Lq) iq id) (5) • Tem is the electromechanical torque
produced by PMSM 87
Flux-Weakening and Torque Control Tables

Vdc
Vdc λ𝑚𝑎𝑥 Id
ω 2D-LuT Id ÷ 2D-LuT
Inputs: ω Inputs:
Tcmd - Speed Iq - λ𝑚𝑎𝑥 Iq
Tcmd
- Torque - Torque

Speed-Based LuTs Maximum-Flux-Based LuTs

88
PMSM Constraint Curve

• 𝑖𝑑 2 + 𝑖𝑞 2 ≤ 𝐼𝑠,𝑚𝑎𝑥 2 𝑇3 𝑇2
𝑖𝑞 𝑇1
• 𝑢𝑑 2 + 𝑢𝑞 2 ≤ 𝑈𝑠,𝑚𝑎𝑥 2
• 𝜔1 < 𝜔2 < 𝜔3
3
• 𝑇𝑒 = 2 𝑁 𝐼𝑞 𝜓𝑚 + (𝐿𝑑 − 𝐿𝑑 )𝐼𝑑 𝐼𝑞
• 𝑇1 < 𝑇2 < 𝑇3

𝜔3
𝜔4 𝑖𝑑

𝜔2

𝜔1

89
PMSM Constraint Curve

𝑑𝑇 𝑇3 𝑇2
=0 𝑖𝑞 𝑇1
𝑑𝛽

𝜔4 𝑖𝑑
𝜔3

𝜔2

𝜔1

90
PMSM Constraint Curve

𝑇3 𝑇2
𝑖𝑞 𝑇1

𝜔4 𝑖𝑑
𝜔3

𝜔2

𝜔1

91
PMSM Constraint Curve

𝑇3 𝑇2
𝑖𝑞 𝑇1

MTPV
𝜔4 𝑖𝑑
𝜔3

𝜔2

𝜔1

92
PMSM Constraint Curve

Field Weakening Strategy: 𝑇3 𝑇2


• CVCP 𝑖𝑞 𝑇1
• CCCP
• VCLMT
• Lookup-Table

MTPV
𝜔4 𝑖𝑑
𝜔3

𝜔2

𝜔1

93
VCLMT

94
Demo – PMSM Constraint Curves, Applications and Drive
Characteristics

>>openExample('mcb/PMSMConstraint >>openExample('mcb/PMSMDriveChara
CurvesAndTheirApplicationExample') cteristicsAndConstraintCurvesExample')
95
PMSM Constraint Curves

▪ Live-script file
– For lumped-parameter based plotting

– Displays interactively
▪ MTPA curve (Maximum Torque per Ampere)

▪ MTPV curve (Maximum Torque per Voltage)

▪ Voltage limit curve

▪ Current limit curve

▪ Drive Characteristics

Figure : Dependency of curves and characteristics on parameters changes


Ref: https://www.mathworks.com/help/mcb/ug/pmsm-characteristics-constraint-curves.html 96
Demo - Field-Weakening Control (with MTPA) of Nonlinear PMSM
Using Lookup Table

>>openExample('mcb/FWCWithMTPAOfNonLinearPMSMUsingLUTExample')
98
Optimizing PMSM Control

Iq ref

-Id ref Id ref

-Iq ref

Ref: https://www.mathworks.com/help/mcb/gs/field-weakening-control-mtpa-pmsm.html
https://www.mathworks.com/help/mcb/gs/fwc-with-mtpa-of-non-linear-pmsm-using-lut.html#d124e21255 99
Demo - Plot Constraint Curves and Drive Characteristics for PMSM
and SynRM Directly from Block Parameters Dialog Box

100
Demo - Improve Motor Efficiency with Optimized Control
Parameters

>>openExample('simscape_shared/ImproveMotorEfficiencyWithOptimizedControlParametersExample') 101
102
103
How are control gains tuned?

104
Control Algorithm Design
Tune loop gains
Empirical computation
Simulink Control Design
• Automatically tune SISO and MIMO control system
using FRE or motor linear model
• PID autotuner – automatically tune PID gains in
simulation and real-time.

FOC Autotuner
Optimization Technique • Automatically and sequentially tune multiple PID
• Automatically and sequentially tune multiple PID control loops in FOC application
control loops in FOC application - Direct-axis (d-axis) current loop
- Direct-axis (d-axis) current loop - Quadrature-axis (q-axis) current loop
- Quadrature-axis (q-axis) current loop - Speed loop
- Speed loop • Enable specifying control bandwidth and phase margin
• Enable specifying control bandwidth and phase margin • Capable in Simulation and Real-time
• Capable in Simulation and Real-time

105
FOC Autotuner perturbs the output and computes the control gain

Id Speed
perturbations perturbations

Iq
Closed-loop
perturbations
response Closed-loop
before response
tuning after tuning

106
Online Frequency Estimation injects perturbation in the output of
the controller

107
Demo- Tune PI Controllers Using Field Oriented Control Autotuner

>>openExample('mcb/FOCAutotunerExample')
108
109
Demo- Frequency Response Estimation of PMSM Using Field-
Oriented Control

>>openExample('mcb/FrequencyResponseEstimationOfPMSMFocQepExample')
110
How to measure position of the rotor position?

111
Control Algorithm Design
Field-oriented control architecture

𝐼𝑑,𝑟𝑒𝑓 𝑉𝑑 𝑉𝛼
𝜔𝑟𝑒𝑓 𝑇𝑟𝑒𝑓 Current PI Contr. 1 d,q
Speed SVPWM 𝑑𝑢𝑡𝑦
Controller
Reference 𝐼𝑞,𝑟𝑒𝑓 𝑉𝑞 𝑉𝛽 Generator 𝑐𝑦𝑐𝑙𝑒𝑠
Three-Phase
Generator PI Contr. 2 α,β Inverter
𝜔

𝐼𝑑 𝐼𝑎
d,q 𝐼𝑏
𝐼𝑞
a,b,c 𝐼𝑐
Park, Clarke Transforms

Current control
𝜃𝑒
Sensor
Speed feedback Speed
decoders/ Motor
Calculation
Observers

Speed control Physical sys

112
Position Sensors

▪ Position and speed sensors are


required for estimating the
present mechanical status of the
system.
– Quadrature Encoders
– Hall sensors Quadrature Encoder
– Resolvers

Resolver Sensor Hall Sensor


113
Position sensors calibration

Quadrature encoder Calibrate Hall sensor Resolver with


calibration Identify Hall sensor Square-pulse carrier
sequence frequency

114
Demo - Field-Oriented Control of PMSM Using Hall Sensor

>>openExample('mcb/FocHallExample')
115
Demo - Field-Oriented Control of PMSM Using Quadrature
Encoder

>>openExample('mcb/FOCQepExample')
116
Speed Sensing and Estimation with Motor Control Blockset

Hall effect

Sensor Quadrature
Decoders encoder
Speed & Position
measurement

Resolver

Flux

Sliding mode
Sensorless
observers Pulsating high
frequency

Extended EMF
117
Demo - Estimate Initial Rotor Position Using Pulsating High-
Frequency and Dual-Pulse Methods

>>openExample('mcb/IPMSMInitPosEstExample')
118
Demo - Sensorless Field-Oriented Control of PMSM

>>openExample('mcb/SensorlessFocFOSMOExample')
119
120
How deployed motor control algorithm works?

121
Model architecture with layers to assist porting algorithm between
different hardware

Hardware Driver Application


Application
Drivers Abstraction Abstraction
122
Model architecture with layers to assist porting algorithm between
different hardware
Hardware Hardware Application Application
Driver Abstraction Abstraction Layer
Layer Layer Layer

Convert ADC Convert Amp to


Read ADC
count to Amp Per-unit

Convert Application for


Read Position
Position to Sin motor control
sensor
Cos

Convert duty to Convert duty to Convert duty to


register value register value per-unit

123
Control flow in Motor Control Blockset examples

https://www.mathworks.com/help/mcb/gs/program-control-flow-of-mcb-examples.html 124
Include TI C2000 Driver Blocks

Simulink Embedded Run on


CCS Project C2000
Model Coder

C2000
Blockset
Introduced
in R2023a
125
Configuring peripheral interfaces – PWM

SET

CLEAR CLEAR

ZERO
CMPA PRD

CMPB

126
Configuring peripheral interfaces – PWM

127
Configuring peripheral interfaces – Current sensor

128
Configuring peripheral interfaces – Current sensor

129
Configuring peripheral interfaces – Speed sensor

130
Configuring peripheral interfaces – Speed sensor

131
Configuring peripheral interfaces – Speed sensor

132
Configuring peripheral interfaces – Speed sensor

133
Configuring peripheral interfaces – Communication Serial

134
Configuring peripheral interfaces – Communication Serial

135
Configuring peripheral interfaces – Communication CAN

136
Configuring peripheral interfaces – Communication CAN

137
Signal Scaling using per unit System

• Creates a scalable control algorithm that can be used across many


systems.
𝑄𝑡𝑦 𝑖𝑛 𝑆𝐼 𝑢𝑛𝑖𝑡𝑠
• 𝑃𝑈𝑠𝑦𝑠𝑡𝑒𝑚 . 𝑄𝑡𝑦 =
𝑏𝑎𝑠𝑒 𝑣𝑎𝑙𝑢𝑒

𝑉𝑏𝑎𝑠𝑒 𝑖𝑛𝑣𝑒𝑟𝑡𝑒𝑟.𝑉𝑑𝑐
𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝑉𝑏𝑎𝑠𝑒 = , SVPWM
3
𝑖𝑛𝑣𝑒𝑟𝑡𝑒𝑟.𝑉𝑑𝑐
𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝑉𝑏𝑎𝑠𝑒 = , SPWM
2

𝐼𝑏𝑎𝑠𝑒 𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝐼𝑏𝑎𝑠𝑒 = 𝑖𝑛𝑣𝑒𝑟𝑡𝑒𝑟. 𝐼𝑠𝑒𝑛𝑠𝑒𝑀𝑎𝑥


𝑁𝑏𝑎𝑠𝑒 Rated speed
𝑇𝑏𝑎𝑠𝑒 3
𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝑇𝑏𝑎𝑠𝑒 = ∗ 𝑝𝑚𝑠𝑚. 𝑝 ∗ 𝑝𝑚𝑠𝑚. 𝐹𝑙𝑢𝑥𝑃𝑀 ∗ 𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝐼𝑏𝑎𝑠𝑒
2

𝑃𝑏𝑎𝑠𝑒 3
𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝑇𝑏𝑎𝑠𝑒 = ∗ 𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝑉𝑏𝑎𝑠𝑒 ∗ 𝑃𝑈𝑆𝑦𝑠𝑡𝑒𝑚 . 𝐼𝑏𝑎𝑠𝑒
2 138
Demo - Field-Oriented Control of PMSM Using Quadrature
Encoder

>>openExample('mcb/FOCQepExample')
139
Demo - Integrate MCU Scheduling and Peripherals in Motor Control
Application

>>openExample('shared_mcb_soc_c2b/IntegrateMCUSchedulingAndPeripheralsInMotorControlExample')
140
Demo - Partition Motor Control for Multiprocessor MCUs

>>openExample('shared_mcb_soc_c2b/PartitionMotorControlForMultiprocessorMCUsExample')
141
Test FOC Algorithm in Real-Time

• Interactively test FOC algorithms with “External Mode” and

Simulink Dashboard Library Blocks

• Eliminate need for maintaining calibration & measurement

files during early prototyping phase

• Make design iterations short and efficient by eliminating

undesired handover between tools and departments

142
Hardware Setup

Development Computer Target Computer Device Under Test


PWMs
Inverter Enable,
Fault Clear

Ethernet

Phase Currents
Quadrature Encoder
Faults

• MATLAB • Multicore CPU • 3-Phase Inverter


• Simulink • IO397 • 3-Phase PMSM
• Simscape • PWMs • 24V DC Power Supply
• ADCs (phase currents)
• Simulink Real-Time • DACs • Quadrature Encoder
• Code Generation Tools • Quadrature Decoder
• GPIOs (enInverter, FltClr)

143
Hardware-in-the-Loop Simulation of Power Converter
Linearized Inverter used to
deploy to FPGA I/O module
Target Computer via Simcape HDL Workflow
Development with FPGA I/O Module
Computer
Model sample time = 500 nanoseconds (2 MHz)

Device Under Test


Xilinx Kintex®-7 FPGA QEP
Output voltage
Floating-point DAC - Current
support

PWM Capture - 200 MHz PWM signal


• 5 nanosecond resolution

100 kHz
144
Demo - Field-Oriented Control (FOC) of PMSM Using Hardware-In-
The-Loop (HIL) Simulation

>>openExample('mcb/FieldOrientedControlOfPMSMUsingHardwareInTheLoopHILExample')
145
Motor Control Blockset – Supported Lib and Examples

Calibrate Sensors Estimate Motor Model Motor & Define Control Tune Loop Gains Deploy & Validate
parameters Inverter Architecture
Using HSP Hand-written
driver coder

Optical encoder Empirical


Avg plant model V/F Six-step
FOC Autotuner
Instrumented test for
param estimation

Resolver Physical plant model FOC DTC

PID Tuner SysTune

Model-predictive Reinforcement
Hall Sensor Using FEM data from 3rd control learning
party tools

Supported off-the-shelf motor control hardware kit

Microchip NXP STM Infineon Trenz FPGA Speedgoat


TI
Rapid prototyping kit
Embedded Processors SoC (FPGA)

146
Motor Control Workflow :- From Modeling to Deployment

Datasheet

Parameterize Plant Define Code


Control gain Deploy &
motor modeling control
tuning generation o Validate
architecture

*Run
Sensor
Parameter
calibration
Estimation

Motor & Inverter modeling Control algorithm implementation Codegen, deployment & validation

* Motor setup needed for Parameter Estimation 147


Motor control design tasks

Motor Modeling Inverter + Modulation Modeling

Power Supply

vq vα Gate
Iq reference +- PI-controller pulses

Inverse SVPWM
Park Generator
vd vβ
0 +- PI-controller

iq ia
ib
id Clarke/Park ic

Motor

FOC Control Design Hardware Deployment


148
Control Challenges in Electric Drives

▪ Operating safe and efficient (minimizing power losses) over a wide speed range

▪ Maintaining proper torque for systems with a broad dynamic range while keeping low-
computational complexity of the control algorithm

▪ Need reduced models to tackle slower simulations

▪ Estimating the speed and position in sensorless drives

▪ Tuning the controller to obtain fast transient response

▪ Accounting for hardware and real-time constraints

149
Thank you

▪ E-mail:
rjaganna@mathworks.com

▪ LinkedIn:
www.linkedin.com/in/jrvinayak

150

You might also like