Degree project in
FPGA Based Sensorless Control of a Permanent Magnet Synchronous Motor
ALI EL HAFNI
Stockholm, Sweden 2012
XR-EE-E2C 2012:021 Electrical Engineering Master of Science
Elektris he Antriebssysteme & Leistungselektronik
Te hnis he Universität Mün hen
Professor Dr.-Ing. Ralph Kennel
Master Thesis
FPGA Based Sensorless Control of a
Permanent Magnet Syn hronous Motor
! #"$%&(') !* #$+ !&, $%-/.#"01$%/23&4!
56/*781') #* 9;:< =>!'!*?);@A;*B') #*! $+
C DD?):8*! !*E! GFIHJ'<&-/. 5K)L"$E"$9; MN&O$P7.&
Q 2R*B L"TS"$+U')2/"$%:G
Elektris he Antriebssysteme & Leistungselektronik
Te hnis he Universität Mün hen
Professor Dr.-Ing. Ralph Kennel
Ar isstraÿe21, 80333 Mün hen
Tel.: 089/28928358 Fax:089/28928336 email: eatei.tum.de
Ali El Hafni
FPGA Based Sensorless Control of a
Permanent Magnet Syn hronous Motor
Magnet Syn hronous Motor
Lehrstuhl für
Elektris he Antriebssysteme & Leistungselektronik
der Te hnis hen UniversitätMün hen
Professor Dr.-Ing. Ralph Kennel
Submitted for the Degree of Master of S ien e, M.S .,
in Ele tri alPowerEngineering Engineering
Ali El Hafni
Born01.11.1986 inSaida, Lebanon
Supervision : Ms . Zhixun Ma
Beginning : 15.04.2012
End : 15.10.2012
Date of Presentation : 23.10.2012
To Prof. Dr. Ing. Ralph Kennel, thank you for giving me the opportunity to
ondu t this proje t inone of the best universities in Europe. The experien ethat
I obtained during the lastsix monthis unforgettable.
To my supervisor Zhixun Ma, without your support and guidan e all the way,
thisproje twouldhavenotbeena hievable. Thankyouforbeingagreatsupervisor
and supporter, I have gained a lot of experien e working with you, in and outside
the s ope of the proje t. I hope I have been up to your expe tations. I wish you
su ess and lu k inyour resear h and life.
To my supervisor inKTH MatsLeksel, thank youfor being a greatmentorand
supervisor throughoutmy studiesinSto kholm, and givingme the han etotravel
abroadto work onthe proje t.
FinallyIwouldliketothankmyfriendsandfamily,andeveryone whosupported
mein this proje t.
Ali M. El Hafni
Elektris he Antriebssysteme & Leistungselektronik
Te hnis he Universität Mün hen
Professor Dr.-Ing. Ralph Kennel
Ar isstraÿe21, 80333 Mün hen
Tel.: 089/28928358 Fax:089/28928336 email: eatei.tum.de
MASTERTHESIS MA0019
Name of Student: ElHafni, Ali
S hanzenba hstrasse 8
81371,Mün hen
Interest of Study: Ele tri Power Engineering
Titleof Thesis : FPGA BasedSensorless Controlof a Permanent Magnet
Syn hronous Motor
Supervisor : Ms . Zhixun Ma
ProblemStatement
1. Study onsensorless ontrol of permanentmagnet syn hronous motors
2. Design and Simulationof anExtended KalmanFilterfor sensorless ontrol
3. FPGA Implementationof Extended Kalman Filterand high frequen y inje -
tion
Prof. Dr.-Ing. Ralph Kennel
The work inthis thesis is based onresear h arriedout atthe Institute for Ele tri-
alDrive Systems and Power Ele troni s, Te hnis he Universität Mün hen (TUM)
supervised by Ms . Zhixun Ma. It is all my own work unless referen ed to the
ontraryin the text.
Field Oriented Control (FOC) has proven to be a high performan e and robust
ontrol strategy for ele tri al drives. However the states of the ma hine, namely
speed and/or position, have to be measured in this ontrol strategy. Sin e the
useofen odersde reases therobustnessof thesystemand in reases ost,in reasing
interesthasbeenfo usedonsensorless ontrols hemes. This ontrolstrategyaimsto
eliminatetheen oder, andestimatethespeedand/orpositionofthema hinebased
only on the urrents and voltages measurements. In this thesis, sensorless ontrol
of a permanent magnet syn hronous ma hine (PMSM) is studied. Ttwo methods
are introdu ed inthis work. The ExtendedKalman Filterfor the high speed range
and the High Frequen y inje tion method for low speed range. In addition, these
methods are implemented using an FPGA instead of a DSP solution. Simulations
and experimental results are presented. The two methods prove to be ee tive in
their respe tive speed ranges, and provide a basis for hybrid full speed sensroless
ontroller.
Fältvektorbaseradreglering(FieldOriented Control, FOC) har visatsigvara en ef-
fektiv o h robustkontrollstrategiför elektriskadrivsystem. Do k behöver mannor-
maltsetthatillgångtillhastigheto h/ellerpositionvidanvändningavdennametod.
Meneftersomanvändandetavrotationsgivareminskarrobusthetenhossystemeto h
ökarkostnaden har intressetför givarlös regleringökat. Vid givarlösreglering elim-
ineras rotationsgivaren o h hastigheten o h/eller positionen uppskattas baserat på
ström-o hspänningsmätningar. Idettaexamensarbeteundersökssensorlöskontroll
aven permanentmagnetiseradsynkronmaskin(PMSM). Tvåmetoderharstuderats.
Dels har det utökade Kalmanltret för den övre hastighetsområdet studerats o h
dels har en metod baserad på högfrekvensinjektionför det lägre hastighetsområdet
studerats. Metodernaharimplementeratsiett FGPA-baseratsystemiställetförett
system med DSP. Simuleringaro hexperimentellaresultat presenteras irapporten.
De två metoderna visar sig vara eektiva inom sina respektive hastighetsområden
o hutgörenutgångspunktförettsensorlösthybridkontrollsystemförhelahastighet-
sområdet.
A knowledgement vii
Problem Statement ix
De laration xi
Abstra t xiii
1 Introdu tion 1
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Thesis Outline. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Ba kground 5 2.1 Introdu tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Review of Sensorless Control Te hniques . . . . . . . . . . . . . . . . 5
2.2.1 Fundamental Ex itationMethods . . . . . . . . . . . . . . . . 6
2.2.2 Salien yBased Methods . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 Arti ialIntelligen e Methods . . . . . . . . . . . . . . . . . . 9
3 Sensorless Control Using Extended Kalman Filter 11 3.1 Introdu tion tothe Extended KalmanFilter . . . . . . . . . . . . . . 11
3.1.1 The Dis rete KalmanFilter . . . . . . . . . . . . . . . . . . . 11
3.1.2 The ExtendedKalman Filter . . . . . . . . . . . . . . . . . . 14
3.2 Extended Kalman Filterin Sensorless Control . . . . . . . . . . . . . 15
3.2.1 EKF inthe Stator Referen e Frame . . . . . . . . . . . . . . . 16
3.2.2 EKF inthe Rotating Referen eFrame . . . . . . . . . . . . . 19
3.2.3 EKF in the RotatingReferen e Frame (SimpliedModel). . . 22
4 Sensorless Control Using Rotating High Frequen y Inje tion 25
4.1 Introdu tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Con ept of Salien y BasedMethods . . . . . . . . . . . . . . . . . . . 26
4.3 RotatingHigh Frequen y Inje tion . . . . . . . . . . . . . . . . . . . 28
5 Model Based Design 31
5.1 Introdu tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2 Model-based designusing Matlab/Simulink. . . . . . . . . . . . . . . 32
5.3 FPGA Implementation of the EKF . . . . . . . . . . . . . . . . . . . 35
6 Results and Analysis 41
6.1 Extended KalmanFilter inthe stationary frame . . . . . . . . . . . . 41
6.2 EKF inthe rotatingframe . . . . . . . . . . . . . . . . . . . . . . . . 46
6.3 HighFrequen y Inje tion . . . . . . . . . . . . . . . . . . . . . . . . . 52
7 Con lusion 57
Bibliography 59
Appendix 64
A List of Symbols 65
B Per-unit system 67
C Fixed Point Data Type 69
1.1 Field oriented ontrol. . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 Sensorless ontrol te hniques [1℄. . . . . . . . . . . . . . . . . . . . . . 6
3.1 Extended Kalman Filterin sensorless ontrol. . . . . . . . . . . . . . 17
4.1 Salient polema hine [15℄. . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 Magneti hysteresis loop[16℄. . . . . . . . . . . . . . . . . . . . . . . 28
4.3 High frequen y inje tion algorithm. . . . . . . . . . . . . . . . . . . . 30
5.1 Model based design inMatlab/Simulink[19℄ . . . . . . . . . . . . . . 34
5.2 FPGA-in-the-loopillustration[20℄. . . . . . . . . . . . . . . . . . . . 34
5.3 Blo k diagramof the EKF algorithm[12℄. . . . . . . . . . . . . . . . 35
5.4 Compensationblo kof the EKF. . . . . . . . . . . . . . . . . . . . . 36
5.5 Con ept of resour e sharing. . . . . . . . . . . . . . . . . . . . . . . . 38
6.1 EKF speed and position,in the stationaryframe, at500 rpm,with a step load at1s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.2 EKF speed and position,in the stationaryframe, at200 rpm,with a step load at1s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.3 EKFspeedandposition,inthestationaryframe,atdierentreferen e speeds, with a onstant load. . . . . . . . . . . . . . . . . . . . . . . . 43
6.4 EKF speed and position, in the stationary frame, fpga-in-the-loop simulationat500 rpm, witha step load at 0.5s. . . . . . . . . . . . . 44
6.5 EKF speed and position, in the stationary frame, fpga-in-the-loop simulation,200 rpm to 600 rpm with a onstant load. . . . . . . . . . 44
6.6 Estimated position and urrent using the Extended Kalman Filter
from-800 to-400 rpm, noload. . . . . . . . . . . . . . . . . . . . . . 46
6.7 Estimated position and urrent using the Extended Kalman Filter from-400 to-800 rpm, with load. . . . . . . . . . . . . . . . . . . . . 47
6.8 Estimated position and urrent using the Extended Kalman Filter from-400 to+800 rpm, noload. . . . . . . . . . . . . . . . . . . . . . 47
6.9 Estimated positionand urrentusingthe ExtendedKalmanFilterat -200rpm,noload. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.10 Estimated positionand urrentusingthe ExtendedKalmanFilterat -200rpm,with step load at 1s. . . . . . . . . . . . . . . . . . . . . . . 48
6.11 Estimated positionand urrentusingthe ExtendedKalmanFilterat -400rpm,with step load at 1.5s. . . . . . . . . . . . . . . . . . . . . . 49
6.12 EKF speed and positionsimulation at500 rpm inthe rotatingrefer- en e frame, with a step load at1s.. . . . . . . . . . . . . . . . . . . . 50
6.13 EKFspeedandpositionsimulationfordierentspeedsintherotating referen e frame. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.14 EKF speed and positionsimulation at500 rpm inthe rotatingrefer- en e frameusing the simplied model. . . . . . . . . . . . . . . . . . 51
6.15 Diagonal elements of the P matrix using the simpliedmodel. . . . . 51
6.16 Highfrequen y inje tion simulationat50 rpm. . . . . . . . . . . . . . 52
6.17 Highfrequen y inje tion simulationat100 rpm. . . . . . . . . . . . . 53
6.18 Test ben h results of the high frequen y inje tion algorithm at 200 rpm starting fromrest, no load. . . . . . . . . . . . . . . . . . . . . . 54
6.19 Test ben hresultsofthe highfrequen y inje tionalgorithmfrom200 to20 rpm atno load. . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
6.20 Testben hresultsofthehighfrequen yinje tionalgorithmat20rpm with load hange. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.21 Test ben h results of the high frequen y inje tion algorithm at on- stantload and speed hange. . . . . . . . . . . . . . . . . . . . . . . . 55
3.1 EKF pro ess table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2 Base values forthe normalization. . . . . . . . . . . . . . . . . . . . . 19
5.1 Matrix dimensions of the EKF . . . . . . . . . . . . . . . . . . . . . . 37
6.1 Te hni al data of the PMSM. . . . . . . . . . . . . . . . . . . . . . . 45
B.1 Base values equationsfor normalization. . . . . . . . . . . . . . . . . 68
Introdu tion
Permanent magnet syn hronous ma hines (PMSM) are repla ing the onventional
indu tion ma hine due to the advantages they oer: high e ien y, smaller size,
and faster dynami response [1℄. The only fa tor that might be slowing down the
use of these ma hines is the pri e and availability of the magnetsused. This isdue
to the fa t that the rotor has permanent magnetsinstead of opper windings, and
thesemagnetsaremanufa turedfromrearearthmaterial,whi harenotabundantly
available anywhere and are alwayssubje t topri e hanges.
The ontrol of PMSMhas alsoimproved during the lasttwo de ades. In re ent
years there has been a lot of resear h on the best ontrol strategy to be used.
The two main ontrol s hemes so far are: eld oriented ontrol and dire t torque
ontrol. Ea h s heme oers some advantages and disadvantages, of whi h the the
eld oriented ontrol is the most superior [2℄. New and more advan ed methods
su has predi tive ontrolhave been proposed. Thesemethodsoerfaster response
and less harmoni ontent onthe expense of in reased omplexity [2℄.
The resear h on the design, ontrol, and operation of PMSM is a ontinuing
work with the aim of a hieving higher e ien ies and lower osts, espe ially with
the re ent green poli ies implemented all around the world. There is a general
drive to de rease arbon emissions world wide with many solutions of whi h most
needele tri alma hines: windpower, ele tri ars,highspeed ele tri trains...hen e
thetenden ytoin rease theresear honele tri alma hinesandprovidenewdesigns
and new ontrolmethodsof whi h one is presented inthis report.
1.1 Motivation
Toperform a proper eld oriented ontrol, the position and speed of the rotor, and
the measured urrents have to be fed ba k from the ma hine. Normally this is
done by a me hani al en oder xed on the shaft of the rotor, and urrent sensors.
Figure 1.1 shows a typi al eld oriented ontrol s heme. The additional en oder
outputsagoodspeedandpositionsignal,ontheexpenseofin reased ost,additional
omplexity, in reasednoise,and redu ed reliabilitydue tothe riskofdamage. Thus
the need rises toremove this sensorand in rease the robustness of the system. The
possibility ofa hieving this goalin reased with the availabilityand improvementof
several dynami state estimators,where itwasshown that itis possibleto estimate
the speed and positionof the rotor using just urrentand voltage measurementsas
input, and themathemati almodelof the ma hine. The termsensorless iswidely
used in literature but a bit ina urate sin e there are still at least urrent sensors
used, whereas the term en oderless more resembles the system. Resear h in the
eld ofsensorless ontrolhasbeengoing onformorethan twenty years, andseveral
su essful methods have been proposed, however industrial implementation is still
slowwithonlyafewtomention[3℄. Thisisbe ausesensorlessmethodshavedierent
performan e for dierent ma hines and speed ranges, and the ompletely robust
oneswhi harereliableandsafeenoughtobeimplementedintheindustryarenotso
ommon. Themaindi ultiespreventing sensorless ontrolfromimplementationin
the industry are: robustness,fun tionalsafety, and hange of behaviouratdierent
loads or speed ranges.
Oneimportantthingto onsiderwhenimplementingasensorless ontrolmethod
is to hoose whether to implement the ontrol system on a Digital Signal Pro es-
sor (DSP) or on a Field Programmable Gate Array (FPGA) platform. The two
platforms have their advantages and disadvantages, all depending on the omplex-
ity of the system. DSP based systems have been used more often due to their low
ost andabilitytoimplement omplexmethodsonthe expense of limitedexe ution
time. FPGA based systems onthe other hand providefaster exe ution time onthe
expense ofhigher ost,and are usually less favored asthe omplexity of the system
ab abc ab
dq
+-
nref PIn PIq
PId
+-
+-
SVM Inverter
PMSM DC
ab dq idref=0
Encoder
iqref Ua
Ub
ia ib
q
q
Figure 1.1: Fieldoriented ontrol.
in reases. In [4℄, the authors have given a omparison between the two platforms
withanappli ationforoneofthesensorless ontrolmethods(theExtendedKalman
Filter). It was found that an FPGA implementation results in an exe ution speed
almostten times faster than aDSP implementation. That being said, the advan e-
ment in FPGA te hnology, and the de rease in pri e show that it ould provide a
better solution inthe eld of sensorless ontrol. One issue remains,and that is the
design pro ess. Traditionally this pro ess starts with the simulation of the algo-
rithm,then writingthe hardware des riptionlanguage, and nallysynthesizingand
downloading the bit stream on the FPGA. This pro ess takes a lot of time and is
prone to errors espe ially as the omplexity of an algorithm su h as the Kalman
lter is high. Thus the motivation to use the model based design (MBD) for FP-
GAs. This approa h de reases the design time, and the possibility of performing a
Hardware-in-the-loop (HIL) test prior to implementation enables testing for ee t
of the FPGA model on the system, whi h is not possible with traditional design
pro esses [5℄. In this proje t, the software Simulink from Mathworks
R
is used to
for simulationusing oatingpointand thenxed point, HDL ode generation,and
hardware-in-the-looptesting.
1.2 Thesis Outline
Belowabriefoverview ofthethesisisgivenwithashortdes riptionofea h hapter.
In the rst hapter, anintrodu tion tothe proje t is given, followed by a moti-
vationfor the workdone.
Inthese ond hapter, ba kgroundonsensorless ontrolingeneralisintrodu ed,
and a briefintrodu tionto the dierent methods found inliterature.
The third hapter introdu es the Kalam lter and the Extended Kalman lter
algorithm,and the implementationof the lter in sensorless ontrol.
The fourth hapter talks about salien y based methods in generaland the high
frequen y inje tionalgorithm inparti ular.
In the fth hapterthe modelbased design methodology is introdu ed,and the
stages that were followed inthis proje t.
Inthesixth hapter,the simulationandexperimentalresultsareshown withthe
analysis.
The appendix is made of three parts: the list of symbols, the per-unit system,
and xed point data type.