Closed Loop Control of PMSM Motor: Field Oriented Control Using Hall Sensors
Closed Loop Control of PMSM Motor: Field Oriented Control Using Hall Sensors
Master of Science
Supervisor
Tomas Uno Jonsson
ISY, Linköping University
Examiner
Lars Eriksson
ISY, Linköping University
Linköping University i
Abstract
Fossil-fuel vehicles are one of the main causes of CO2 emissions nowadays. As we are moving toward
cleaner environment electrification of vehicles are becoming more and more popular. With the environ-
ment in mind, the recent improvement in battery technology and electronics has drawn a lot of attention
to Brushless DC or BLDC motors. Due to their high torque output and robust design, BLDC motors
are a popular choice as the main propulsion unit in electric vehicles. Permanent magnet synchronous
motor, PMSM, is also a brushless dc motor with minor changes in design. So the word BLDC and
PMSM is used interchangeably. In this thesis, two motor control algorithms were investigated. 6-Step
control and Field oriented control or FOC. A three-phase inverter allows these motors to be driven by
a battery. But when battery voltage goes down the speed of the motor also goes down. This thesis
investigates a method to maintain the same speed at lower dc voltage. Also running of other motors
than the control system was designed for. The control system performs well in simulation for two of
the motor tested with the FOC algorithm. Simulation results show that the control system can track
speed and current references with minimum error. Speed controller and current controllers control each
parameter independently to control the motor. Low battery simulations provide useful data that shows
how the field weakening technique makes it possible to achieve higher speed at low dc voltages.
ii
Sammanfattning
Fossildrivna fordon är en av de främsta orsakerna till koldioxidutsläpp i dag. I och med att vi går
mot en renare miljö blir elektrifieringen av fordon allt mer populär. Med miljön i åtanke har den
senaste tidens förbättring av batteriteknik och elektronik dragit mycket uppmärksamhet till Brushless
DC- eller BLDC-motorer som ska användas som huvudframdrivningsenhet. På grund av dess höga
vridmomentutgång och robusta design så är BLDC-motorer mer populära. En permanent magnetisk
synkronmotor, PMSM, är också en borstlös dc-motor med mindre förändringar i designen. Så orden
BLDC och PMSM används omväxlande. I denna avhandling undersöktes två motoriska styralgoritmer. 6-
stegskontroll och fältorienterad kontroll eller FOC. En trefas växelriktare gör att dessa motorer kan drivas
av ett batteri. Men när batterispänningen går ner går motorns hastighet också ner. Denna avhandling
undersöker en metod för att bibehålla samma hastighet vid lägre likspänning, men även drift av andra
motorer än vad styrsystemet var konstruerat för. Styrsystemet fungerar bra i simulering för två av de
motorer som testas med FOC-algoritmen. Simuleringsresultat visar att styrsystemet kan spåra hastighet
och aktuella referenser med minimalt fel. Hastighetsregulator och aktuella styrenheter kontrollerar varje
parameter individuellt för att styra motorn. Simuleringar med lågt batteri ger användbara data som
visar hur fältförsvagningstekniken gör det möjligt att uppnå högre hastighet vid låg likströmsspänning.
iii
Acknowledgements
I would like to sincerely thank my supervisor, Tomas Uno Jonsson for his help and feedback during the
project.
Finally, I would like to thank my opponent for the thesis, Vinod Diwakara.
iv
Contents
Abstract ii
Sammanfattning iii
Acknowledgements iv
List of Tables ix
1 Introduction 1
1.1 Problem definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Thesis outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Theory 3
2.1 Electric motor fundamentals and control systems . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 Brushed DC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.2 Brushless motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.2.1 PMSM types and motor inductances . . . . . . . . . . . . . . . . . . . . . 5
2.1.3 Motor pole pairs, mechanical and electrical properties . . . . . . . . . . . . . . . . 5
2.1.4 Control hardware and commutation . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.5 Rotor position sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 6 Step control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.1 Problem with 6 step control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Field oriented control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.1 Mathematical model of PMSM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.1.1 Motor model in abc frame . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.1.2 abc to αβ transformation (Clarke Transformation) . . . . . . . . . . . . . 10
2.3.1.3 Motor model in αβ frame . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.1.4 αβ to dq transformation (Park Transformation) . . . . . . . . . . . . . . 11
2.3.1.5 Motor model in dq frame . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.1.6 Electromagnetic torque . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.2 Field Oriented Control implementation . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.3 Stator voltage decoupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.4 Speed and angle feedback from motor . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3.4.1 Speed calculation from Hall sensor . . . . . . . . . . . . . . . . . . . . . . 14
2.3.4.2 Angle estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.5 PWM techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.5.1 Sinusoidal PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
v
2.3.5.2 Space vector PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.6 Startup issues with FOC and rotor alignment . . . . . . . . . . . . . . . . . . . . 19
2.4 PI controller tuning and motor parameter dependency . . . . . . . . . . . . . . . . . . . . 20
2.5 Battery low voltage and field weakening . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3 Simulation 22
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.2 Simulation Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3 Speed and current controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3.1 Speed control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3.2 Current control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4 Speed and Angle simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4.1 Speed estimation using hall sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4.2 Angle estimation simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.5 Low battery voltage operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.6 Running different motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4 Discussion 34
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.3 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5 Conclusion 36
5.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.2 Future works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
References 37
A Motor Specifications 40
Linköping University vi
List of Figures
vii
3.14 Vd and Vq voltage outputs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.15 Space vector generation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.16 Phase currents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.17 RPM calculation using 1 and 3 hall sensors and actual RPM. . . . . . . . . . . . . . . . . 30
3.18 Estimated angle from calculated speed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.19 Boel motor speed control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.20 Motor speed and output torque of the Boel motor. . . . . . . . . . . . . . . . . . . . . . . 32
3.21 Current control performance of the Boel motor. . . . . . . . . . . . . . . . . . . . . . . . . 33
3.22 Phase currents for the given reference speed. . . . . . . . . . . . . . . . . . . . . . . . . . 33
ix
CHAPTER 1
Introduction
The rapid growth of electric vehicles in recent years has drawn lots of attention in using Permanent mag-
net synchronous motors (PMSM) as the main drive motor. Being lightweight and compact compared to
diesel or petrol engines it is much cheaper. PMSM has no moving part other than the rotor that makes
them robust and suitable for long-term use in industrial and home applications. Right now PMSMs are
used where any motor is required from HVAC, cooling fan, electric scooter, and electric bikes the list
goes on [1–13].
PMSM can be controlled with or without sensor feedback from the motor. With sensors, the control
system is easy to develop but costly and adds more failure points to the whole system. Sensorless control
on the other hand is more robust and also more complex. In this thesis, hall sensors are used by the
control system to calculate motor speed and electric angle.
There are many ways to control a PMSM, for example, 6 step control, field-oriented control, and field
weakening control. Field-oriented control is the main interest for this thesis but 6 step control is also
investigated as it has much easier implementation.
1. What happens when the battery voltage goes low? and how the control system will handle low
battery voltage to keep steady RPM?
2. Is it possible to run a different motor without the need for a change in the control algorithm?
1
1.2 Thesis outline
In chapter 2, the theory of motor and control systems is discussed. Motor mathematical models, the
transformation between different models, and estimation methods are discussed in this chapter.
Chapter 3 is for the simulation result. All the method discussed in the theory chapter is simulated and
presented in this chapter.
Chapter 4 is for discussion based on the simulation. Simulation results provide answers asked in the first
chapter.
Linköping University 2
CHAPTER 2
Theory
F
B
N
3
these are also known as DC motor and this process of passing currents through different coils’ is called
commutation. DC motors’ have very high starting torque this allows diverse use of these motors. But
there are losses in the brush. As the brush is in contact with moving metal it wears off and requires
constant maintenance. Also, the brush generates heat and spark which prohibits the use of these motors
in a gas-related application.
As the rotor is moving in a magnetic field, a current is induced through the coils and generates volt-
age in phase with the rotor position in relation to the stator magnets. This voltage is known as Back
electromotive force or simply Back EMF. At higher speeds, back emf can be very high and physically
damage the motor and other connected components.
The most commonly used brushless motors are Brushless DC (BLDC) motor and the Permanent magnet
synchronous (PMSM) motor.
Both BLDC and PMSM motors are similar in configuration. They both have permanent magnets as
rotors are usually made of neodymium magnets.
What makes them different is their back emf. Due to stator winding construction BLDC motor produces
trapezoidal back emf and PMSM produces sinusoidal voltage shown in figure 2.2.
10 10
Va Va
Vb Vb
5 Vc 5 Vc
Voltage (V)
Voltage (V)
0 0
-5 -5
-10 -10
0 0.05 0.1 0 0.05 0.1
Time (sec) Time (sec)
(a) BLDC. (b) PMSM.
Linköping University 4
2.1.2.1 PMSM types and motor inductances
Depending on the rotor design, PMSMs can be of several types. Merrill’s rotor, interior magnet, surface
magnet, inset, and symmetrical buried to name a few [14]. Among all other types two most commonly
used PMSMs are Interior PMSM and Surface mounted PMSM. Shown in figure 2.3. Due to the difference
in magnetic path interior PMSM has different d-axis inductance and q-axis inductance [15] . In surface-
mounted magnets, both paths have same inductance path, shown in figure 2.4a. So Ld = Lq . Figure
2.4a shows Ld and Lq inductances. Figure 2.4b shows high and low inductance paths for Lq and Ld . So
for IPMSM Ld 6= Lq .
SPMSM IPMSM
Linköping University 5
motor’s mechanical speed, angle, and electric speed and angle.
The physical speed of the rotor is mechanical speed. and the rotor’s physical angular velocity is the
mechanical angle of the rotor. But electrical parameters are required by the controller to calculate and
estimate different parameters and maintain the stability of the whole control algorithm.
The following equations show the relation between mechanical and electrical parameters.
ωe = pp × ωm (2.1)
θe = pp × θm (2.2)
Here,
ωe = Electrical speed of the motor in Rad/s
ωm = Mechanical speed of the motor in Rad/s
θe = Rotor electrical angle in Rad
θm = Rotor mechanical angle in Rad
pp = Motor pole pair
3 phase inverter is used to connect motor terminals to either high or low DC voltage shown in figure 2.5.
To run the motor different gate pulse is used from a high-speed microcontroller to turn on or off each
MOSFET. Speed of the motor is controlled by using pulse-width modulated(PWM) gate pulse. PWM
techniques are discussed in later sections of this thesis.
g1 g3 g5
12 V B
C
g2 g4 g6
Linköping University 6
Figure 2.6: Hall sensor position.
Hall emf
a b c a b c
0 0 0 0 0 0
0 0 1 0 -1 +1
0 1 0 -1 +1 0
0 1 1 -1 0 +1
1 0 0 +1 0 -1
1 0 1 +1 -1 0
1 1 0 0 +1 -1
1 1 1 0 0 0
Linköping University 7
2.2.1 Problem with 6 step control
The table 2.1 shows that the motor coils are energized between high and low voltages. This high voltage
switching creates torque ripple. This is unwanted as ripple can cause vibration, unwanted noise, and
unsmooth operation. Another problem is only 2 phases are active at a time, which reduces possible
output power. To avoid these problems sinusoidal voltage is applied to the gates of the inverter so that
the motor runs smoothly without any torque ripple.
10 -3
Torque
20
15
Torque (Nm)
10
-5
0 0.2 0.4 0.6 0.8 1
Time (sec)
Through field-oriented control, it is possible to apply sinusoidal voltage at the motor. To control the
motor with a microcontroller, a simplified mathematical model is required which is discussed in the next
section.
Figure 2.8: Rotor and stator magnetic field orientation for maximum torque generation.
Linköping University 8
Stator magnetic field can be represented by its vector components. One component is aligned to the
rotor magnetic field called the direct axis,d, and the other one is perpendicular to the rotor magnetic field
called quadrature axis,q which is shown in figure 2.9. Stator magnetic field can be aligned perpendicular
to rotor magnetic field by setting d axis to 0 and adjusting q axis.
The Control system is designed to turn on or off specific MOSFET of the inverter in figure 2.5 so that
necessary voltage is applied to the motor to keep correct stator magnetic field orientation. The Control
system needs feedback from the motor to know if it is running properly eg. correct speed and protection
from overvoltage or over current and also to detect stall.
Were,
vabc = Phase voltages
Rs = Stator coil resistance
iabc = Phase currents
Ψsabc = Stator flux
and, Ψsabc is given by [18]
Ψsa ia Ψra
Ψsb = Lss ib + Ψrb (2.4)
Ψsc ic Ψrc
Were,
Linköping University 9
Figure 2.10: 3-phase equivalent model of PMSM.
xa = A cos(ωt + ϕ) (2.7)
xb = A cos(ωt + ϕ − 2π/3) (2.8)
xc = A cos(ωt + ϕ + 2π/3) (2.9)
Linköping University 10
Figure 2.11: abc to αβ transformation.
Linköping University 11
Figure 2.12: αβ to dq transformation.
Here,
iq = Current in q axis
id = Current in d axis
Lq = q Axis inductance
Linköping University 12
Ld = d Axis inductance
pp = Number of pole pairs
J = Inertia moment
fv = Viscous friction coefficient
Tl = Load torque
Starting from the current measurement, phase currents are measured from the motor terminal, shown
in figure 2.13. Then Clarke and Park transformation is applied to generate id and iq currents. Which
is then compared with the reference, to generate the error. The error signal is then amplified by the
PI controllers. The decoupling block simultaneously calculates vdd and vqd to control d-axis and q-axis
voltage independently of their d and q axis currents. These voltages are added with the PI controllers’
output to generate vd and vq voltages. Inverse Carke transform then followed by Inverse Park transform
generates abc voltages that are required by PWM generator to generate Space vector modulated signals.
Which is then fed to the inverter that generates 3 phase voltage for the motor.
vq
Speed ref PI(s) PI(s) a
iq_ref
vqd Inv Clarke SVPWM 3 Phase Inverter
iq &
b
vd Park
PI(s)
id_ref vdd c
id
Decoupling
ia
Angle
Hall
Hall Decoder Sensors PMSM
Speed
The decoupling block solves the following equations to generate vdd and vqd .
Linköping University 13
vqd = Rs iq + ωe .Ld .id + λωe (2.24)
1 Revolution
To measure the high time of the hall sensor an interrupt generator is used that produces a tick with
known time interval, Tq . Then, when the hall signal transitions from 0 → 1, a counter is incremented
with each tick, Tq . When the next falling edge of hall signal is detected the counter value is stored and
reset for the next cycle, which is shown in figure 2.15. Multiplying the counter value with tick interval,
Tq will give hall sensor high time,Th .
Linköping University 14
1
Hall_input
0.8
0.6
0.4
0.2
50
Counter
40
30
20
10
From the following equations, f can be calculated. For this project, Tq = 10 µS.
Th = Tq × Nc (2.26)
T = 2 × Th (2.27)
1
f= (2.28)
T
Estimating speed from one hall sensor means speed is updated at every hall change or 180◦ . Which can
be a problem during startup or when the motor is ran at a slower speed. To avoid this problem all of
the hall sensors are used. With the same algorithm mentioned above except the counter is reset at every
hall change from all sensors. So reset pulse is generated from simple edge detection for all sensors and
counter is reset at every pulse from the edge detector. In this way the algorithm gives 6 times better
resolution for speed update.
Here, ωe is electrical speed of the rotor in Rad/s, and θe is the electrical angle of the rotor in Radians.
As the angle keeps increasing, it needs to be reset to align with phase A back emf. This is done through
correct edge of hall pulses. So the integrator is reset with correct hall edge to start the calculation again.
Linköping University 15
1
h_a
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7
Time (seconds)
1
h_b
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7
Time (seconds)
1
h_c
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7
Time (seconds)
1
Edge_abc
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7
Time (seconds)
1
Fundamental freq
0.8 Triangle
Amplitude
0.6
0.4
0.2
0
0 0.05 0.1 0.15 0.2 0.25
Time (Seconds)
1
SPWM
0.8
Amplitude
0.6
0.4
0.2
0
0 0.05 0.1 0.15 0.2 0.25
Time (Seconds)
voltage from a DC source. For example, speed control of a motor by changing battery voltage.
The modulator produces output 1 or 0 by comparing the amplitudes of a reference signal to a high-
frequency triangular wave. If reference amplitude is greater than carrier then output is high else output
is low. Figure 2.17 shows the comparison and PWM signal generation.
This ’high’ time is also called the duty cycle and expressed in percentage. As it shows the percentage
of DC voltage seen by the load. Dividing duty cycle by 100 gives modulation index. Which is another
representation of the ratio between applied DC voltage to the load and total DC voltage. so for modu-
lation index ma , 0 ≤ ma ≤ 1. In case of ma > 1, it is called over modulation.
For example, if a DC source is 24V and duty cycle is 30% or ma = 0.3 that is the switch stays 30% of
Linköping University 16
the time on and 70% of the off then the voltage seen by a load will be,
30
= 24 ×
100
= 7.2 V
Similarly for 90% duty cycle, ma = 0.9, and output voltage is,
90
= 24 ×
100
= 21.6 V
If a sinusoidal voltage is used as the reference then modulated PWM signal changes according to the
frequency of the sinusoidal voltage shown in figure 2.19. Using a low pass filter sinusoidal voltage can
be reproduced from the PWM signal. As the motor coils are huge inductors they act as low pass filters.
This way AC voltage is applied from a DC source. This is why this modulator is also called an inverter
and for 3 phase system, it is called 3 phase inverter.
1
Fundamental freq
Triangle
0.8
0.6
0.4
0.2
0
0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8
Time (seconds)
1
SPWM
0.8
0.6
0.4
0.2
0
0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8
Time (seconds)
Linköping University 17
1
Fundamental freq
0.8 Triangle
Amplitude
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (Seconds)
1
SPWM
0.8
Amplitude
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (Seconds)
Space Vector g1 g3 g5
U1 1 0 0
U2 1 1 0
U3 0 1 0
U4 0 1 1
U5 0 0 1
U6 1 0 1
Linköping University 18
1
3rd Harmonic
Fundamental freq
0.5
Amplitude
0
-0.5
-1
0 0.5 1 1.5
Time (sec)
SVPWM
0.5
Amplitude
-0.5
0 0.5 1 1.5
Time (sec)
a
b
0.5 c
Amplitude
-0.5
0 0.5 1 1.5
Time (sec)
This thesis deals with the start-up condition by changing the initial angle. At start-up, the FOC algorithm
has no idea of the angle of the rotor. So a small voltage is provided to vd , strengthening the magnetic
field of the rotor causing the rotor to align with the known stator magnetic field. This also provides
a small initial rotation, enough for the decoupling block to calculate vd and vq voltages which in turn
provides the necessary voltage to the motor. Figure 2.24 shows the initial angle and RPM change during
start-up.
At start-up, the control system performs the following actions,
Linköping University 19
1
Fundamental freq
0.8 Triangle
Amplitude
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (Seconds)
1
SVPWM
0.8
Amplitude
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (Seconds)
20
Rpm_matlab
0
-20
RPM
-40
-60
-80
1.5 Angle_matlab
Angle (Rad)
0.5
Linköping University 20
the following equations. Matlab script in appendix B shows the calculation used in simulation.
wm = Rs /Ld (2.31)
wc = 5 ∗ wm (2.32)
Kic = wc2 ∗ Ld (2.33)
Kpc = wc ∗ Ld (2.34)
ws = wc /10 (2.35)
Kis = ws2 ∗J (2.36)
Kps = ws ∗ J (2.37)
So in the case of a new motor, these parameters need to be updated manually before running the motor.
This process can be automated if motor parameter identification is included in the control system. Similar
process is discussed in [28].
One of the methods to maintain high RPM is to weaken the magnetic field of the permanent magnets.
d-axis current is aligned with rotor magnetic field which was discussed in 2.3. Permanent magnets have
fairly constant magnetic flux [29]. Until now d-axis reference was set to zero to achieve maximum torque.
But applying currents to the d-axis can weaken or strengthen the rotor magnetic field. Applying a nega-
tive current to the d axis will weaken the flux. There are other methods of field weakening control [30–34].
The equation 2.19 also shows that vq is dominant at a high load, negative id allows lower vq for the same
rotor speed.
Setting negative id reference will allow the controller to apply appropriate voltage by the inverter. But
too much negative current reference may exceed the current limits for the inverter or the motor.
Linköping University 21
CHAPTER 3
Simulation
3.1 Introduction
Computer simulation of any model is the ideal way of understanding the behavior and overall perfor-
mance. Deploying and running a new control algorithm of a motor to an existing system can be dangerous
in real life.
To avoid damage to the motor or any other component both Six step control and Field oriented control
were simulated in Simulink. The simulation contains a PMSM motor model, that has parameters speci-
fied in table A.1.
Different parameter values were tested by applying different conditions and some of the values were
tweaked to achieve maximum performance. The control system was designed using the Linix motor [35],
provided by NXP and then tested on Boel motor [14] to check the performance and verify questions
asked in Chapter 1.
FOC controller block consists of the control algorithm, shown in figure 3.2. Hall decoder reads hall
signals and performs calculations to provide angle and speed measurement discussed in section 2.3.4.
Decoupling block executes equations mentioned in section 2.3.3 and outputs calculated vd and vq . A
detailed view of this block is shown in figure 3.5.
The speed control block compares the current speed and measured speed from the Hall decoder block
and produces the reference q-axis current for the input speed. Detailed views are shown in figure 3.7.
Current measurement block measures phase currents using ADC then performs Clarke and Park trans-
form to produce d and q axis currents shown in figure 3.3. The difference between speed control blocks
output and Current measurement blocks output is the d and q axis error signals.
The current controller takes these error signals as input and PI controllers output d and q axis voltage
based on Kp and Ki gains calculated from motor variables. These outputs are then added with decou-
pling blocks output to produce d and q axis voltage by the Inverter to generate space vectors and space
22
vector PWM.The inverter control block, detailed view in figure 3.4, shows the generation of space vector
by the inverse Park and Clarke transform to produce Uref from d and q axis voltage discussed as in
section 2.3.5.2.
Rotor align block performs initial rotor alignment discussed in section 2.3.6 to align rotor to a predefined
angle by applying a voltage at d axis shown in the figure. Initialization block provides a signal to sync
this initialization and disable all other blocks as necessary.
FOC Controller
Speed input
ADC
Hall out In
U_ref
Discrete Hall Sensor
5e-06 s.
U_ref
Uref Tm
+ T_in
A A
12 V m
B B
-
C C
PMSM
3 Phase Inverter
vd_d
Angle
Init_ctrl
Angle [Te] Speed input
Speed
[init] Init_ctrl
1 Speed_reference Speed_ctrl_out iq_err
iq_ref iq_err
vd vd_in vd_out vd
Speed_estimated
RPM
[iq] [init] Init_ctrl u_ref 1
Speed Control U_ref
Phase Current
Speed_in
a α α
1 Clarke d 2
Transform
Current b β β id
Park
Transform
sin sinθ
Sine e
2 θ Cosine q 1
e
LUT cosθ
Angle cos e
iq
Linköping University 23
1 d
a A
vd
α α
2 q
vq
Inverse Inverse B U_ref 1
Park Clarke b
u_ref
sin sinθ
e
Sine
3 θ Cosine β β
e
LUT
Angle c C
cos cosθ
e
Sine-Cosine Lookup Inverse Park Transform Inverse Clarke Transform Space Vector Generator
id_mes 1
did vd R s id Lq
= − + .ωe.iq
dt Ld Ld Ld 1
iq_mes 2 vd_d
did
vd = R sid + Ld − ωe.Lq.iq [we]
dt
Speed_in 3 [we]
rpm2rad/s
2
iq_mes_copy
diq vq Rs.iq Ld ωe
= − − .ωe.id − λ id_mes_copy
dt Lq Lq Lq Lq 1
2
di vq_d
vq = Rsiq + L q q + ωe.Ld .id + λωe
dt [we]
1
vd_in >= 1
vd_out
3
Init_ctrl
2
vq_in >= 2
vq_out
Linköping University 24
id_err 3 5
vd_d
P
PI(z) 1
I vd
2
Init_ctrl
pi_d
iq_err 1 4
vq_d
P
PI(z) 2
I vq
pi_q
Speed controller receives speed feedback from hall sensor decoder and outputs necessary voltage command
for Current controllers. The current controllers constantly monitor motor phase currents and based on
the speed controller’s output, provide voltage command to the Space vector modulator. The decoupling
block’s output is added with the current controller’s output to control d and q axis voltage independently.
Speed_reference 2
int_ctrl 1 >=
3 P
Speed_estimated PI(z) 1
I Speed_ctrl_out
pi_s
Linköping University 25
2000 Motor RPM
Speed_ref
1000
500
0 1 2 3 4 5
Time (Seconds)
Figure 3.9: Speed tracking by the controller without load.
Speed (RPM)
400
200
0 Motor RPM
0.04
Torque (Nm)
0.02
0 Torque
2
Current (A)
0 Ia
Ib
Ic
-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (Seconds)
Linköping University 26
3.3.2 Current control
Figure 3.13 shows the transformation results of phase currents. d and q axis currents are transformed
using Clarke and park transformation. Figure 3.14 shows the output vd and vq which is calculated from
decoupling block and current measurement block. Inverter control block produces necessary space vector
signal as output is shown in figure 3.15. Figure 3.16 shows phase currents for the same time.
1
q_measured
iq_ref
0.5
Current (A)
-0.5
-1
0 1 2 3 4 5
Time (Seconds)
Figure 3.11: q-axis current control
d_measured
0.3 id_ref
Current (A)
0.2
0.1
-0.1
0 1 2 3 4 5
Time (Seconds)
Figure 3.12: d-axis current control
Figure 3.11 and 3.12 shows current tracking for the same simulation on figure 3.9. Differences at the
beginning of the simulation is from rotor alignment. After initial rotor alignment idref is zero. Measured
d-axis current also measures the same value. Changes in speed reference require higher or lower iq
current. Figure 3.11 and 3.12 shows reference currents are well tracked by the current controllers.
Linköping University 27
q_measured
2
Current (A)
1.5
0.5
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (Seconds)
d_measured
0.3
Current (A)
0.2
0.1
-0.1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (Seconds)
Vq and Vd output
vq
1.5
Voltage (V)
0.5
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (Seconds)
0 vd
Voltage (V)
-0.5
-1
-1.5
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (Seconds)
Linköping University 28
U_ref_a
0.2 U_ref_b
U_ref_c
0.1
Voltage (V) 0
-0.1
-0.2
-0.3
0.4 0.45 0.5 0.55
Time (Seconds)
Figure 3.15: Space vector generation.
1.5
Ia
1 Ib
Ic
0.5
Current (A)
-0.5
-1
-1.5
0.4 0.5 0.6 0.7
Time (Seconds)
Figure 3.16: Phase currents
Figure 3.10 also shows that the current controllers control phase currents according to the load or input
speed. When a torque was applied externally at 1.5 sec, more current was applied to the motor to sustain
500 RPM by the controller. Figure 3.14 also shows higher vq voltage.
Linköping University 29
3.4 Speed and Angle simulation
3.4.1 Speed estimation using hall sensors
500 Rpm_h_abc
Rpm_h_a
400 Rpm_actual
Speed (RPM)
300
200
100
Figure 3.17 shows speed calculation results from one hall sensor and 3 hall sensors. Using 3 hall sensors
provides better speed resolution as mentioned in section 2.3.4.1.
1500 Rpm_estimated
1000
RPM
500
0
0.35 0.4 0.45 0.5 0.55 0.6
Time (seconds)
Angle (Radians)
6 Angle_actual
Angle_estimated
4
0
0.35 0.4 0.45 0.5 0.55 0.6
Time (seconds)
Figure 3.18 shows that as soon as the motor speeds up, the estimated gets closer to the actual angle. So
at higher speeds, the estimation error will be almost zero.
Linköping University 30
3.5 Low battery voltage operation
Section 2.5 discusses techniques to maintain high RPM at lower battery voltage. To simulate low volt-
age operation the motor was run at various DC voltage levels simulating different battery charge levels.
Measured parameters are listed in table 3.1.
DC voltage is measured from the battery terminal. id_ref is the applied id reference for different cases.
id and iq are dq currents, measured at output Current measurement block shown in figure 3.3. vd and
vq are the controller output voltage to the inverter, measured at the current controllers’ output, shown
in figure 3.7. For motor phase currents, only phase A current is shown in the table as the rest of the
phases are the same. The mod index is the modulation index calculated by the following equation,
q
vd2 + vq2
ma = (3.1)
DC
2
The table shows that applied negative d-axis current increases RPM. This can be used partly to alleviate
speed loss during low battery voltage. idref can be reduced as long as phase currents do not exceed the
hardware limit. Here rated maximum phase current is 100 A.
The first case can be considered where without any field weakening the motor produces 3500 RPM at
250V. This speed was maintained throughout the voltage drop cases. Even at 180 V, the motor can
produce 3500 RPM with a higher phase current. The calculated modulation index also shows 15%
overmodulation with slight roundoff errors. This is true for the space vector modulation technique.
Linköping University 31
3.6 Running different motor
The Boel motor in appendix A.1 was run with 200 VDC, without making any change in the control
system. Figure 3.19 shows speed control performance and figure 3.20 shows the output motor torque.
1000
500
0
0 2 4 6 8 10 12
Time (Seconds)
Figure 3.19: Boel motor speed control.
2000
Motor RPM
Speed_ref
Speed (RPM)
1500
1000
500
0
0 2 4 6 8 10 12
Time (Seconds)
Torque
2
Torque (Nm)
-1
-2
0 2 4 6 8 10 12
Time (Seconds)
Figure 3.20: Motor speed and output torque of the Boel motor.
Linköping University 32
10
d_measured 4 q_measured
8 id_ref iq_ref
6 2
Current (A)
Current (A)
4
0
2
0 -2
-2
0 5 10 0 5 10
Time (Seconds) Time (Seconds)
(a) d-axis current control. (b) q-axis current control.
10
Ia
Ib
Ic
5
Current (A)
-5
0 2 4 6 8 10 12
Time (Seconds)
Figure 3.22: Phase currents for the given reference speed.
Figure 3.22 shows phase currents at no load operation for the given speed reference. Figure 3.21b and
3.21a shows current control performance with new control gains. This proves that it is possible to run a
separate motor with this control system with new current and speed control gains as long as the motor
specifications are known.
Linköping University 33
CHAPTER 4
Discussion
4.1 Introduction
This chapter contains a discussion between the questions asked in chapter 1 theories provided in chapter
2 and results from the simulation chapter.
4.2 Results
The primary goal of this thesis was to run a PMSM and investigate the situation for low battery voltage
and maintain RPM and run a different motor with minimum or no change in the control algorithm.
Speed tracking simulations in Figures 3.9, 3.10, 3.19 and 3.20 show that the control system can run a
PMSM with minimum overshoot while input speed reference changes. Speed control is stable and fast.
As the speed is estimated from the hall sensors speed calculation error minimizes with higher speed.
Angel estimation error is multiplied by the speed estimation. So minimum speed error means low angle
estimation error.
Table 3.1 shows the performance during low battery voltage operation. RPM values at lower idref show
that it is possible to maintain a high RPM at low battery voltage. The theory section 2.5 discussed that
field weakening will allow higher motor speed at lower dc voltage levels with higher phase current. But
this high speed comes at the cost of torque. Since the battery has less power at lower voltages, the motor
can not produce the same power, in other words, maintain high speed and high torque at the same time.
So when battery voltage drops controller applies low idref to increase the speed at lower torque output.
This can be observed at phase current too. With lower idref , phase current increases to maintain higher
speeds. Also in section 2.3.5.2, it was mentioned that Space vector modulation allows 15% more use of
DC voltage. Maximum speed is achieved when the motor is run at maximum DC voltage. So in the case
of space vector modulation, if modulation index ma = 1.15 then the motor will run at maximum speed.
Modulation index results and RPM values in the table prove this. There are some roundoff errors, which
caused ma > 1.15.
For the second motor, only gains of current and speed controller were changed. So the second question
asked in chapter 1 is yes, the control system can run any motor as long as the specifications are known
and have fixed d and q axis inductances.
34
4.3 Methods
Field-oriented control is not a new control algorithm and all the IEEE papers and books used in this
thesis work show the same equations for implementation. But improvement the possibilities of the algo-
rithm are endless. Few estimation techniques were used in this thesis work with better estimation the
control algorithm will perform better and become robust. In [24] speed estimation was done by using
one hall sensor but in this thesis use if three hall sensor technique shows better performance.
Currently, negative speed is not taken into account. So the motor can only run in one direction. Direc-
tion identification requires detecting predefined hall patterns, which is kept as future work.
There are motors available that have variable d and q axis inductances. This control system can not run
these types of motors yet. Future improvements are necessary to run these motors.
Hardware implementation raises safety concerns. At the time of implementation in an embedded system,
the control system might need modification or tweaking based on performance. So this model despite
having good simulation performance is not yet ready to be implemented in hardware.
Linköping University 35
CHAPTER 5
Conclusion
5.1 Conclusion
The thesis intended to implement closed-loop field-oriented control with hall sensor feedback for speed
and angle estimation and study the case for low battery voltage and the use of different motors. The
theory chapter provides theories and mathematical analysis for the control algorithm. The simulation
results show that positive outcomes for the research questions asked in chapter one.
• Improving the control algorithm to run motors that have d and q axis inductance matrix.
• Making the control system automatic. So that it can measure motor variables by running a self-test
algorithm.
36
References
[1] C.-I. Nicola, M. Nicola, A. Vintilă, and D. Sacerdoţianu, “Identification and sensorless control of
pmsm using foc strategy and implementation in embedded system,” in 2019 International Conference
on Electromechanical and Energy Systems (SIELMEN), pp. 1–6, 2019.
[2] L. Qu, L. Qu, and W. Qiao, “A linear active disturbance rejection controller-based sensorless control
scheme for pmsm drives,” in 2019 IEEE Energy Conversion Congress and Exposition (ECCE),
pp. 792–797, 2019.
[3] L. Yu, C. Wang, H. Shi, R. Xin, and L. Wang, “Simulation of pmsm field-oriented control based on
svpwm,” in 2017 29th Chinese Control And Decision Conference (CCDC), pp. 7407–7411, 2017.
[4] F. Jin, W. Qian, H. Bai, D. Lu, and B. Cheng, “Using one fpga to control two high-switching-
frequency pmsm drive systems through a novel time-division multiplexing method,” in 2018 IEEE
Applied Power Electronics Conference and Exposition (APEC), pp. 998–1002, 2018.
[5] M. Caruso, A. Di Tommaso, R. Miceli, C. Nevoloso, G. Vassallo, and G. Vitamia, “Foc with resolver
implementation for pmsm drives by using a low cost atmel sam3x8e microcontroller,” in 2020 Fif-
teenth International Conference on Ecological Vehicles and Renewable Energies (EVER), pp. 1–8,
2020.
[6] A. O. di Tommaso, R. Miceli, G. R. Galluzzo, and M. Trapanese, “Efficiency control for permanent
magnet synchronous generators,” in 2006 IEEE International Conference on Industrial Technology,
pp. 2079–2084, 2006.
[10] C. Cavallaro, A. Di Tommaso, R. Miceli, A. Raciti, G. Ricco Galluzzo, and M. Trapanese, “Anal-
ysis a dsp implementation and experimental validation of a loss minimization algorithm applied to
permanent magnet synchronous motor drives,” in IECON’03. 29th Annual Conference of the IEEE
Industrial Electronics Society (IEEE Cat. No.03CH37468), vol. 1, pp. 312–317 vol.1, 2003.
37
[11] G. Schettino, C. Buccella, M. Caruso, C. Cecati, V. Castiglia, R. Miceli, and F. Viola, “Overview
and experimental analysis of mc spwm techniques for single-phase five level cascaded h-bridge fpga
controller-based,” in IECON 2016 - 42nd Annual Conference of the IEEE Industrial Electronics
Society, pp. 4529–4534, 2016.
[12] M.-F. Tsai and H.-C. Chen, “Design and implementation of a cpld-based svpwm asic for variable-
speed control of ac motor drives,” in 4th IEEE International Conference on Power Electronics and
Drive Systems. IEEE PEDS 2001 - Indonesia. Proceedings (Cat. No.01TH8594), vol. 1, pp. 322–328
vol.1, 2001.
[13] M. T. Kassa and D. Changqing, “Design optimazation and simulation of pmsm based on maxwell and
twinbuilder for evs,” in 2021 8th International Conference on Electrical and Electronics Engineering
(ICEEE), pp. 99–103, 2021.
[14] A. Kronberg, “Salient pole motor inverter design: with implementation of space vector modulation,”
2012.
[15] M. Johansson, “Evaluation of sensor solutions & motor speed control methods for bldcm/pmsm in
aerospace applications,” 2017.
[16] X. Gao, “Bldc motor control with hall sensors based on frdm-ke02z,” 2013.
[17] D. Daniel, “Pmsm and foc theory.” https://community.nxp.com/t5/
NXP-Model-Based-Design-Tools/Module-2-PMSM-and-FOC-Theory/m-p/761926.
[18] G. Alain and J. De Leon-Morales, Sensorless AC Motor Control: Robust Advanced Design Tech-
niques and Applications. SPRINGER, May 2005.
[19] Fadili, Abdelmounime El Magri, Fouad Giri, and Abderrahim El , Control Models for Synchronous
Machines, ch. 3, pp. 41–56. John Wiley & Sons, Ltd, 2013.
[20] Wikipedia contributors, “Alpha–beta transformation — Wikipedia, the free encyclopedia,” 2021.
[Online; accessed 14-March-2021].
[21] I. WESTIN, “Sensorless control of a pmsm,” 2016.
[22] Mathworks, “Permanent magnet synchronous machine.” https://se.mathworks.com/help/
physmod/sps/powersys/ref/permanentmagnetsynchronousmachine.html.
[23] F. Semiconductor, “Sensorless pmsm vector control with a sliding mode observer for compressors
using mc56f8013,” 2008.
[24] D. Daniel, “Motor control class: Lecture 10 - speed estimator.” https://community.nxp.com/t5/
NXP-Model-Based-Design-Tools/Motor-Control-Class-Lecture-10-Speed-Estimator/m-p/
681518.
[25] Mathworks, “Space vector modulation (svm) for motor control.” https://se.mathworks.com/
solutions/power-electronics-control/space-vector-modulation.html.
[26] L. Zhen, “Sinusoidal control of bldcm with hall sensors based on frdm-ke04z and tower board,” 2014.
[27] L. Harnefors and H. Nee, “Control of variable speed drives applied signal processing and control,”
Mälardalen University, Västeras, Sweden, 2002.
[28] Mathworks, “Estimate pmsm parameters using recommended hardware.” https://se.mathworks.
com/help/mcb/gs/estimate-pmsm-parameters-using-recommended-hardware.html.
[29] T. Deng, Z. Su, J. Li, P. Tang, X. Chen, and P. Liu, “Advanced angle field weakening control
strategy of permanent magnet synchronous motor,” IEEE Transactions on Vehicular Technology,
vol. 68, no. 4, pp. 3424–3435, 2019.
Linköping University 38
[30] R. U. Lenke, R. W. De Doncker, M.-S. Kwak, T.-S. Kwon, and S.-K. Sul, “Field weakening control of
interior permanent magnet machine using improved current interpolation technique,” in 2006 37th
IEEE Power Electronics Specialists Conference, pp. 1–5, 2006.
[31] D. Stojan, D. Drevensek, Z. Plantic, B. Grcar, and G. Stumberger, “Novel field-weakening con-
trol scheme for permanent-magnet synchronous machines based on voltage angle control,” IEEE
Transactions on Industry Applications, vol. 48, no. 6, pp. 2390–2401, 2012.
[32] Z. Lei, W. Xuhui, Z. Feng, K. Liang, and Z. Baocang, “Deep field-weakening control of pmsms for
both motion and generation operation,” in 2011 International Conference on Electrical Machines
and Systems, pp. 1–5, 2011.
[33] C.-T. Pan and J.-H. Liaw, “A robust field-weakening control strategy for surface-mounted
permanent-magnet motor drives,” IEEE Transactions on Energy Conversion, vol. 20, no. 4, pp. 701–
709, 2005.
[34] L. Harnefors, K. Pietilainen, and L. Gertmar, “Torque-maximizing field-weakening control: design,
analysis, and parameter selection,” IEEE Transactions on Industrial Electronics, vol. 48, no. 1,
pp. 161–168, 2001.
[35] F. Semiconductor, “Bldc sensorless reference design using mc56f8006,” 2009.
Linköping University 39
APPENDIX A
Motor Specifications
In this project, Linix 45ZWN24-40 [35] and Boel motor [14] were simulated.
40
APPENDIX B
1 clc
2 clear
3
4 % Motor Parameters for Linix / NXP motor
5
6 pp = 2; % Pole pair
7 Rs = 0.56; % Stator resistance [ Ohm ]
8 Ld = 0.000375; % Direct axis inductance [ H ]
9 Lq = 0.000435; % Quadrature axis inductance [ H ]
10 Ke = 0.0135281; % Back - EMF constant [ V . Sec / rad ]
11 J = 0.12 e -4; % Drive inertia [ kg . m2 ]
12 lambda = sqrt (2/3) * Ke / pp ; % Flux linkage
13
14 % PI gain Calculation
15 wm = Rs / Ld ;
16 wc = 5* wm ;
17 ws = wc / 10;
18
19 % Speed controller gain
20 Ki_s = ws ^2 * J ; % Integral gain
21 Kp_s = ws * J ; % Proportional gain
22
23 % Current controller gain
24 Ki = wc ^2 * Ld ;
25 Kp = wc * Ld ;
26
27 % Simulation Parameters
28 Ts = 5e -6; % Sample time
29
30 % Speed calculation
31 int_b = 0.01 e -3; % Interrupt Base
32
33 disp ( ' Motor parameters initialized ! ')
41
www.liu.se