0% found this document useful (0 votes)
29 views7 pages

MATLAB Function Based Approach To FOC of PMSM Drive

This document presents a MATLAB Function based approach for modeling and simulating speed sensored field-oriented control (FOC) of a permanent magnet synchronous motor (PMSM) drive. It emphasizes the advantages of using MATLAB programming in MATLAB/Simulink over traditional block diagram methods, particularly in terms of ease of modification and cost-effectiveness. The study includes the development of a simulation model, implementation on a TMS320F28335 microcontroller, and a comparison of simulation results with experimental data.

Uploaded by

ny28mxj5v
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)
29 views7 pages

MATLAB Function Based Approach To FOC of PMSM Drive

This document presents a MATLAB Function based approach for modeling and simulating speed sensored field-oriented control (FOC) of a permanent magnet synchronous motor (PMSM) drive. It emphasizes the advantages of using MATLAB programming in MATLAB/Simulink over traditional block diagram methods, particularly in terms of ease of modification and cost-effectiveness. The study includes the development of a simulation model, implementation on a TMS320F28335 microcontroller, and a comparison of simulation results with experimental data.

Uploaded by

ny28mxj5v
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/ 7

2015 IEEE European Modelling Symposium

MATLAB Function Based Approach to FOC of PMSM Drive

Omer Cihan Kivanc and Salih Baris Ozturk


Department of Electrical and Electronics Engineering
Okan University
34959 Tuzla / Istanbul, TURKEY
E-mail: [email protected]

Abstract—In this study, modeling and simulation of a speed the Texas InstrumentsTM (TI) C2000 microprocessor family
sensored field-oriented control (FOC) of a permanent magnet which is widely used in motion control applications. The
synchronous motor (PMSM) drive is developed by using C2000 family offers superior performance in motor control
MATLAB Function blocks in MATLAB/Simulink. This meth-
applications. If the experimental motor control system con-
od allows easier algorithm and software development stages for
experimental studies compared to the classical block diagram sists of a C2000 microcontroller family, it is an option to
approach. The superiority of the method over commonly used build the simulation model of an AC motor drive system by
“Code Generation” tools is also emphasized. First, a using the blocks provided in Embedded Coder. However,
MATLAB/Simulink model of the FOC of PMSM drive is de- this toolbox is an additional cost to the standard
veloped by using MATLAB programming in MATLAB Func- MATLAB/Simulink package and does not allow modifica-
tions similar to C coding techniques. The results of the simula-
tions in its blocks.
tion are presented. Then, the MATLAB programming based
codes developed in simulation are implemented in a The simpler, easily modifiable and more economical
TMS320F28335 floating-point MCU by using C programming choice of MATLAB/Simulink modeling and simulation of
language and the experimental results are obtained. Finally, an AC motor drive is to use MATLAB Functions. The hand-
the results of the simulation and experiments are compared. icaps given above are overcome by using MATLAB Func-
tion blocks in MATLAB/Simulink. Most of the motor con-
Keywords—Permanent magnet synchronous motor; PMSM;
AC motor drive; field-oriented control; FOC; speed control;
trol applications nowadays require the C programming lan-
modeling; simulation; MATLAB/Simulink; MATLAB Function; guage. Therefore using C programming like MATLAB Pro-
Embedded Coder; Digital Motor Control; DMC gramming in MATLAB Functions in MATLAB/Simulink
produces a similar approach as opposed to the classical block
I. INTRODUCTION diagram based modeling of an actual system. Using the clas-
Recently, AC motor control and driving strategies are at- sical block diagram approach also creates difficulties in un-
tracting more and more interest. Development of embedded derstanding and improving the system during future modifi-
systems, observers and control systems are enabling new al- cations.
gorithms in motor control. The complex nature of these algo- In this paper, a proposed MATLAB/Simulink model of a
rithms cause difficulties in programming. speed sensored field-oriented control (FOC) of a PMSM
MATLAB/Simulink® is commonly used for modeling and drive is developed by using MATLAB programming in
simulation of electromechanical systems and their control MATLAB Functions similar to the C programming lan-
applications before the realization step. It is usually expected guage. Therefore, the goal of a simple, easily modifiable and
that experiments yield results similar to those obtained in the economical MATLAB/Simulink modeling method that helps
MATLAB/Simulink simulation environment. the smooth transition to the experimental stage is achieved.
Usually, a MATLAB/Simulink simulation model of an This is especially true for systems that are programmed in
AC motor drive is developed in the literature by using classi- the C language. During the application stage, MATLAB
cal Simulink® blocks that are available in the standard Sim- function based drive modules are manually converted to the
ulink Library [1]–[7]. Although, initial developments of the C language and implemented in a TI's TMS320F28335
algorithms designed by connecting the library blocks in Delfino floating-point MCU. Finally, the results of the simu-
Simulink Library makes the development stage easy, the fu- lation and experiments are compared.
ture addition or modifications of the system become quite
difficult. Moreover, the development of AC motor drive II. FOC OF PMSM DRIVE
simulation models can also be achieved by using the motor A. Dynamic Mathematical Model of Interior PMSM
control blocks in MATLAB/Simulink Embedded Coder® The 𝑑𝑞 model in the rotating synchronous reference
[8]–[10]. The MathWorks®, Inc. developed the Embedded frame is used to analyze the IPMSM for the field-oriented
Coder toolbox for certain microprocessor families such as control (FOC). The stator voltage equations of the IPMSM in

978-1-5090-0206-1/15 $31.00 © 2015 IEEE 96


DOI 10.1109/EMS.2015.81
Authorized licensed use limited to: Thapar Institute of Engineering & Technology. Downloaded on August 21,2025 at 11:28:31 UTC from IEEE Xplore. Restrictions apply.
Rs Lq Rs Ld rent PI regulators generate stator 𝑑𝑞–axes voltage references
+ iq + id which are also in DC quantities. To apply sinewave currents
+ to the motor, these DC voltage quantities are then trans-
vq ωλdr vd formed into the instantaneous sinusoidal voltage commands
ωLd id ωLqiq
for the individual stator phases using the rotor angle feed-
- + - + back and the inverse reference frame transformation matrix
(inverse Park transformation).
q-axis circuit d-axis circuit
The space vector PWM generator converts the stationary
Figure 1. Equivalent electrical circuit diagrams of quadrate 𝑞– and 𝑑–axes reference frame voltage references into 𝑎𝑏𝑐 frame based duty
synchronous reference frame that apply to both surface-mount and interior
permanent magnet synchronous machines [11], [12]. cycle equivalences. These three-phase duty cycles (𝑇𝑎 , 𝑇𝑏 ,
and 𝑇𝑐 ) are then brought into a PWM generator for the in-
the rotating 𝑑𝑞 reference frame are given by (1) and (2), verter to generate the appropriate three-phase pulsed-
omitting the influences of magnetic field saturation and voltages that are applied to the motor. To obtain the 𝑑𝑞–axes
magnetic hysteresis as current feedbacks in DC quantities, first 𝑎– and 𝑏–axes AC
currents are transformed into stationary values using Clarke
𝑑𝑖𝑞 transformation and then the stationary current values ac-
𝑣𝑞 = 𝑅𝑠 + 𝐿𝑞 + (𝜔𝑖𝑞 𝐿𝑑 + 𝜔𝜆𝑑𝑟 ) (1)
𝑑𝑡 quired from Clarke transformation are set up as inputs to the
Park transformation along with the rotor position feedback
𝑑𝑖𝑑
𝑣𝑞 = 𝑖𝑑 𝑅𝑠 + 𝐿𝑑 − 𝜔𝑖𝑞 𝐿𝑑 (2) signal to generate the equivalent DC feedback quantities in
𝑑𝑡 𝑑𝑞 reference frame.
where 𝑣𝑑 , 𝑣𝑞 , 𝑖𝑑 , 𝑖𝑞 are the stator 𝑑– and 𝑞–axes voltages and In PMSM, the rotor windings are already along the 𝑑–
currents in the rotor reference frame, respectively; 𝑅𝑠 is the and 𝑞–axes, only the stator windings quantities need trans-
stator winding resistance; 𝐿𝑑 and 𝐿𝑞 denote the 𝑑– and 𝑞– formation from three-phase quantities to the two-phase 𝑑𝑞
axes inductance, respectively; 𝜔 is the rotor angular electrical rotor rotating reference frame quantities. Therefore, Park
velocity; and 𝜆𝑑𝑟 is the flux linkages due to the permanent transformation is used to transform the stator quantities of a
magnet rotor flux [11]–[13]. PMSM onto a 𝑑𝑞 reference frame that is fixed to the rotor,
with the positive 𝑑–axis aligned with the magnetic axis of the
B. Vector Control of PMSM rotor which has a permanent magnet in PMSM. The 𝑑𝑞
For superior driving performance of PMSM, vector con- transformation matrix (Park transformation) used for cur-
trol, or field-oriented control (FOC), is widely used. For rents and the inverse Park transformation used for voltages
simplicity and to remove the time-varying quantities, the are given respectively by
two-axis theory is used for FOC of sinewave drives. To pro-
duce the maximum torque in FOC, 𝑞–axis current and the 𝑖 𝑐𝑜𝑠 𝜃 𝑠𝑖𝑛 𝜃 𝑖𝛼
rotor flux linkage aligned with the 𝑑–axis are kept in quadra- � 𝑑� = � �� � (3)
𝑖𝑞 − 𝑠𝑖𝑛 𝜃 𝑐𝑜𝑠 𝜃 𝑖𝛽
ture form. The 𝑑– and 𝑞–axes current phasor components, 𝑖𝑑
and 𝑖𝑞 , are generally fixed to the rotor reference frame. To 𝑣𝛼 𝑐𝑜𝑠 𝜃 𝑠𝑖𝑛 𝜃 𝑣𝑑
�𝑣 � = � � � �. (4)
obtain 𝑖𝑑 and 𝑖𝑞 from the instantaneous phase currents, a ref- 𝛽 − 𝑠𝑖𝑛 𝜃 𝑐𝑜𝑠 𝜃 𝑣𝑞
erence frame transformation, such as Park transformation is
employed [11]. It is possible to separate the motor complex space vectors
into stationary real and imaginary parts with the Clarke
C. Components of FOC of PMSM Drive transformation. By using the Clarke transformation in FOC
The major components of the FOC of PMSM drive is of AC motor drive, stator currents are transformed from
shown in Fig. 2. The system consists of speed, 𝑑– and 𝑞–axes three-phase to two-phase quadrature equivalent values as in-
current PI regulators, Park and Clarke transformations, in- puts to the Park transformation. The Clarke transformation
verse Park transformation, space vector generation, speed matrix for a balanced three-phase system is defined as
calculation, current and encoder signal conditionings and
PWM generator modules. In Fig. 2, an incoming speed 𝑖 1 0 𝑖𝑎
command profile goes into a speed PI regulator which out- � 𝛼 � = �√1 √2 � � 𝑖 �.
(5)
𝑖𝛽 3 3 𝑏
puts 𝑞–axis reference current. The 𝑑–axis current reference is
set to zero for surface-mount PMSM. These current refer- III. PROPOSED FOC OF PMSM DRIVE MODEL BASED ON
ences and their corresponding feedbacks are DC quantities MATLAB FUNCTIONS IN MATLAB/SIMULINK
for the PI regulators to track easily. The outputs of the cur-

97

Authorized licensed use limited to: Thapar Institute of Engineering & Technology. Downloaded on August 21,2025 at 11:28:31 UTC from IEEE Xplore. Restrictions apply.
Vdc

TargetValue RMP spd_pi_reg(Ref)


=
CNTL SetpointValue Out pi_reg(Ref) PWM1 3-Phase
SpeedRef PI_CONT. PI_CONT. Out ipark(Qs) Alpha svgen(Ualpha) Ta PWM PWM2
INV.
spd_pi_reg(Fdb) pi_reg(Fdb) IPARK SVGEN
pi_spd pi_iq ipark(Angle) Tb
GEN PWM3
PWM4
IdRef = 0 pi_reg(Ref) Out ipark(Ds) Beta svgen(Ubeta) Tc PWM5
PI_CONT.
pi_reg(Fdb) PWM6
pi_id

Ds park(Alpha) Alpha
PARK CLARKE clarke(As)
park(Angle)
clarke(Bs)
Qs park(Beta) Beta

PMSM
SPEED
FR
Speed
speed_fr(ElecTheta) Encoder

Figure 2. Overall block diagram of the speed sensored FOC of PMSM drive [14].

3 Ta
1
Vd Ualpha
1 Ta
2 1
Ualpha 2 Tb
Vq ipark Ualpha
svgen_dq Tb
ipark 2
1 2 Ubeta
SVGEN_DQ 3 Tc
Ubeta
Angle Ubeta Tc
SVGEN

function [Alpha,Beta] = ipark(Ds,Qs,Angle) Figure 5. “Code Generation” toolbox blocks (Embedded Coder DMC
modules).
Alpha = (Ds*cos(2*pi*Angle) - Qs*sin(2*pi*Angle));
Beta = (Qs*cos(2*pi*Angle) + Ds*sin(2*pi*Angle));
nents in the same system model. Although, this causes an
additional cost to the system, more realistic simulation mod-
end els are obtained. The cost effective solution is to represent
Figure 3. MATLAB Function based inverse Park transformation. the electrical machine and inverter models mathematically
by using classical Simulink and MATLAB Function blocks.
Ds DMC DMC Ta

Qs
Alpha Ua
Tb
MATLAB Function blocks can also be used in Embedded
Angle IPark
Beta Ub
SVGenDQ Tc Coder for real-time implementation of FOC of PMSM drive
Inverse Park Space Vector if desired.
Transformation Generator
The MATLAB Function based inverse Park transfor-
Figure 4. “Code Generation” toolbox blocks (Embedded Coder DMC mation model given in (10) is shown in Fig. 3. The mathe-
modules). matical representation written in the MATLAB Program-
ming language is provided in the bottom side of the Fig. 3. In
C programming like codes written in MATLAB Pro-
a similar fashion, Clarke and Park transformations, PI Con-
gramming language are developed for the simulation of the
trollers, Space Vector PWM Generator, Ramp Control, and
FOC of PMSM drive in MATLAB/Simulink using
Speed Calculation modules are also created by MATLAB
MATLAB Function blocks without using expensive addi-
Functions. The developed MATLAB Functions work in the
tional toolboxes such as Embedded Coder. Motor control
same manner as the blocks in Embedded Coder. However,
codes developed in C language by Texas Instruments are
there are limitations in the Embedded Coder since TI's Digi-
created in a modular basis [14]. Developers that create algo-
tal Motor Controller (DMC) blocks in Embedded Coder do
rithms using the same basis can model the system by using
not allow modifications. In Fig. 4, inverse Park transfor-
MATLAB Function blocks.
mation and Space Vector Generator DMC blocks (modules)
As algorithms are being developed in MATLAB Func-
are illustrated. MATLAB Function blocks require C like
tion blocks, other electrical components such as electrical
MATLAB programming language. By this method, it is easy
machines and inverters can also be modeled by using
to develop and test the algorithms which are suitable for TI
MATLAB/Simulink SimPowerSystemsTM library compo-
C2000 microcontrollers.

98

Authorized licensed use limited to: Thapar Institute of Engineering & Technology. Downloaded on August 21,2025 at 11:28:31 UTC from IEEE Xplore. Restrictions apply.
Angle
PWM1 T_l IdFdb
0.5 Angle Ta Ta
rmp_cntl Ualpha Ualpha PWM2 TL <Stator current is_a (A)>
IqRef Tm As
TargetValue = SpeedRef (pu) spd_pi_reg
RMP_CNTL Vq PWM3
IqFdb
Vq Tb
Tb A IqFdb
SPD_PI_REG PWM4 m
<Stator current is_b (A)> Bs
B
0 IdRef Ubeta Ubeta
Vd Tc PWM5
Vd Tc C CLARKE & PARK
IdRef IdFdb PWM6 <Rotor angle thetam (rad)>
IPARK SVGEN Permanent Magnet
PI_REGs PWMGEN Synchronous Machine

g
+
A Discrete, f(u)
Vdc
B Ts = 1e-07 s.
thetae_(0-1pu)
-
C powergui
3-ph IGBT Inverter

Speed (pu) ElecTheta (pu)


speed_fr
SPEED_FR

Figure 6. Overall MATLAB/Simulink block diagram of the proposed speed sensored FOC of PMSM drive using MATLAB Function.

Development of the simulation model before the actual 500


implementation is important. It is quite hard to switch from

Sim. rotor speed [r/min]


the simulation platform of FOC of PMSM drive to the exper- 400
imental stage. Moreover, programming microcontrollers is a
300
quite tedious task. The FOC algorithms tested in the
MATLAB/Simulink simulation platform by using MATLAB 200
Functions instead of classical Simulink blocks makes switch-
ing to the experimental stage a lot easier due to the above 100
mentioned reasons and generates much more realistic results
0
in simulation. 0 2.5 5 7.5 10 12.5 15
One of the other advantages of using the MATLAB Time [s]
Function based blocks instead of DMC blocks is to enable Figure 7. Simulated rotor speed feedback under full load start-up (2 N·m).
development of new algorithms instead of the known ones
4
that are provided in the Embedded Coder toolbox. The six-
switch version of Space Vector Generator (SVGenDQ) block
Sim. phase-a current [A]

from DMC module is shown in Fig. 4. In this block, modifi- 2


cations are not allowed. However, Fig. 5 shows the
MATLAB Function based SVGEN_DQ block which is easi- 0
ly modifiable.
The inside of the SVGEN_DQ MATLAB Function mod- -2
ule is provided in Appendix B. Appendix C represents the C
code version of the SVGEN_DQ module available in the TI -4
5 5.02 5.04 5.06 5.08 5.1
motor development application library. Appendix D includes Time [s]
flowchart and pseudo code of the SVGEN_DQ module. The
Figure 8. Simulated phase–a current waveform at steady-state (0.5 p.u. =
similarities are clearly seen between MATLAB Function 450 r/min) under full load condition.
version and C programming version of the SVGEN_DQ
module. The FOC of PMSM drive that is proposed by Texas MATLAB Functions along with electrical components is
Instruments is illustrated in Fig. 2. In this figure, the closed shown. Inverter and electrical machine parameters are select-
loop speed control is performed with a ramp shape speed ed to be the same as the experimental setup. The MATLAB
reference profile. The speed control is achieved by applying Function blocks are then manually converted to the C lan-
a speed PI regulator. Position information is obtained by an guage based version to be used in the Code Composer
optical encoder. The encoder signals are converted to speed StudioTM (CCS) IDE. It is observed that any modifications
information by SPEED_FR block. The rest of the FOC com- made either in simulation or in experiment produce the same
ponents are also seen in Fig. 2. In Fig. 6, FOC of PMSM results in each platform.
drive model developed in MATLAB/Simulink with

99

Authorized licensed use limited to: Thapar Institute of Engineering & Technology. Downloaded on August 21,2025 at 11:28:31 UTC from IEEE Xplore. Restrictions apply.
SEMIKRON
Magtrol Inverter

Meas. rotor speed [125 rpm/div]


TM
eZdsp &
DSP6001 Dy- Interface Card
namometer
Controller
Signal
Cond. Card

(a)

Torque/Speed
Transducer Integrated
Encoder Time [2.5 s/div]
Figure 10. Experimental rotor speed waveform under full load start-up
PMSM (2 N·m).

Hysteresis
Brake
(b)
Figure 9. Experimental test-bed. (a) Dynamometer controller, inverter,
DSP control unit, and interface and signal-conditioning cards. (b) PM
synchronous motor with integrated incremental position encoder (2500
pulse/rev.) coupled to hysteresis brake through torque/speed transducer.

IV. SIMULATION AND EXPERIMENTAL RESULTS


A. Simulation Results Figure 11. Experimental phase–a current waveform at steady-state (0.5 p.u.
The proposed drive system shown in Fig. 6 has been = 450 r/min) under full load condition (1A/100mV).
simulated in MATLAB/Simulink using an electrical IGBT
form under nominal full load at start-up. At 7.5 s (steady-
inverter and electrical PM motor model from the
state), step-down full load rejection (full load to zero load)
SimPowerSystems toolbox in order to demonstrate the va-
is applied and the speed response is provided in Fig. 7. No
lidity of the speed sensored FOC of a PM synchronous mo-
instability is observed even under full load rejection at
tor drive.
steady-state.
To set the gating signals of the power switches from the
output of the SVPWM module easily and represent the real B. Experimental Results
conditions in simulation as close as possible, the proposed The feasibility and practical features of the sensored
drive scheme including the electrical model of the actual speed control scheme of a PMSM drive with sinusoidal
PM motor and the inverter with power semiconductor back-EMF have been evaluated using an experimental test-
switches considering the snubber circuit and the parameters bed, shown in Figs. 9(a) and (b). The same conditions are
of the switches are designed in MATLAB/Simulink using applied as in simulation. The control algorithm is digitally
the SimPowerSystems blocksets. The dead-time of the in- implemented using the eZdsp board from Spectrum Digital,
verter and non ideal effects of the PM synchronous machine Inc. based on a TI's floating-point Delfino MCU
are neglected in the simulation models. The dc-link voltage (TMS320F28335), as shown in Fig 9(a).
𝑽𝒅𝒄 is set to 400 V [15], [16]. The experimental results are shown in Figs. 10 and 11.
In Fig. 7, the speed results under full load start-up condi- Fig. 10 shows experimental waveform of the speed response
tion (2 N·m) is given with a ramp speed reference from zero when zero to 0.5 p.u. ramp speed reference is applied start-
speed to 0.5 p.u. (450 r/min) in 2 s. As it can be seen in Fig. ing at the tenth seconds under nominal load condition as in
7 that the proposed MATLAB Function based speed simulations. It is seen in Fig. 10 that the feedback speed
sensored field-oriented control is able to drive the PM motor reaches the reference top speed in 2 s as in simulation. The
without any instability under full load start-up condition. full load rejection is applied at 17.5 s. The drive system un-
Fig. 8 demonstrates the steady-state phase–𝒂 current wave- der full load rejection is still stable and the speed feedback

100

Authorized licensed use limited to: Thapar Institute of Engineering & Technology. Downloaded on August 21,2025 at 11:28:31 UTC from IEEE Xplore. Restrictions apply.
tracks the reference speed closely. Fig. 11 shows the steady- APPENDIX A
state current waveform under full load condition. PARAMETERS AND SPECIFICATIONS OF THE PMSM
It is seen that the results obtained from experiments are Number of poles 8
similar to those that are obtained in the simulations. The dif- Line-to-neutral rms voltage (V) 230
ferences observed in the transient responses between simu- Rated rms current (A) 4
Rated torque (N·m) 2
lation and experiment are because of the dissimilarities in
Stator inductance (mH) 0.0033
data sampling rate, additional delay due to dynamometer Stator resistance (Ω) 3.4
torque controller, nonlinear characteristics of the machine Rotor magnetic flux linkage (Wb) 0.095
and hysteresis brake, mismatch of moment of inertia, damp- Moment of inertia (kg.m2) 0.0075
ing and friction of the overall system compared to the one
APPENDIX B
used in simulations.
function [Ta,Tb,Tc] = svgen_dq(Ualpha,Ubeta)
Due to slight misalignment and mechanical possible
slippage in the motor coupling, phase current shows some tmp1 = Ubeta;
tmp2 = Ubeta/2 + sqrt(3)/2 * Ualpha;
harmonic signatures on the positive cycle and the rotor tmp3 = tmp2 - tmp1;
speed has oscillatory behavior at start-up as seen in Figs. 10
and 11, respectively. Moreover, because the dead-time ef- VecSector = 3;
if (tmp2 > 0)
fect is not compensated, the phase current waveform exhib- VecSector = VecSector - 1;
end
its some additional distortion especially at zero crossings if (tmp3 > 0)
and at around positive and negative peaks. The rotor speed VecSector = VecSector - 1;
end
data are obtained by using M-TEST 5.0 Motor Testing if (tmp1 < 0)
Software of Magtrol dynamometer at 0.01 s sample rate. VecSector = 7 - VecSector;
end
V. CONCLUSION if(VecSector == 1 || VecSector == 4)
In this paper, a simple, easily modifiable and more eco- Ta = tmp2;
Tb = tmp1 - tmp3;
nomical choice of modeling and simulation of a speed Tc = -tmp2;
elseif(VecSector == 2 || VecSector == 5)
sensored field-oriented control (FOC) of a permanent mag- Ta = tmp3 + tmp2;
net synchronous motor (PMSM) drive is developed by using Tb = tmp1;
Tc = -tmp1;
MATLAB Function blocks in MATLAB/Simulink. This else
method allows easier algorithm and software development Ta = tmp3;
Tb = -tmp3;
stages for experimental studies compared to the classical Tc = -(tmp1 + tmp2);
block diagram approach. The superiority of the method over end
commonly used “Code Generation” tools such as end
MATLAB/Simulink Embedded Coder is also emphasized.
The proposed MATLAB/Simulink model of a speed APPENDIX C
sensored FOC of a PMSM drive scheme is built by using v.tmp1= v.Ubeta;
MATLAB programming in MATLAB Functions similar to v.tmp2= _IQdiv2(v.Ubeta) +(_IQmpy(_IQ(0.866),v.Ualpha));
v.tmp3= v.tmp2 - v.tmp1;
C programming language. Then, the MATLAB program-
ming based codes developed in simulation are implemented v.VecSector=3;
in a TI's TMS320F28335 Delfino floating-point MCU by v.VecSector=(v.tmp2> 0)?( v.VecSector-1):v.VecSector;
using C programming. Simulation and experimental results v.VecSector=(v.tmp3> 0)?( v.VecSector-1):v.VecSector;
v.VecSector=(v.tmp1< 0)?(7-v.VecSector) :v.VecSector;
are compared and the results show the effectiveness of the
proposed modeling of the FOC of PMSM drive. if(v.VecSector==1 || v.VecSector==4)
{ v.Ta= v.tmp2;
v.Tb= v.tmp1-v.tmp3;
ACKNOWLEDGMENTS v.Tc=-v.tmp2;
}
This work was supported by The Scientific and Techno-
logical Research Council of Turkey (TUBITAK) funded else if(v.VecSector==2 || v.VecSector==5)
{ v.Ta= v.tmp3+v.tmp2;
project (112E263). The authors would like to thank Gurkan v.Tb= v.tmp1;
Bozkurt for his help in preparation of the experimental setup v.Tc=-v.tmp1;
}
and to Dr. Basar Ozkan for his help in reviewing the paper.
The authors also thank Dr. Burak Kelleci for insightful else
{ v.Ta= v.tmp3;
technical discussions and his valuable feedback which v.Tb=-v.tmp3;
helped in improving the paper. v.Tc=-(v.tmp1+v.tmp2);
}

101

Authorized licensed use limited to: Thapar Institute of Engineering & Technology. Downloaded on August 21,2025 at 11:28:31 UTC from IEEE Xplore. Restrictions apply.
APPENDIX D [8] R. Duma, P. Dobra, M. Abrudean, and M. Dobra, “Rapid prototyping
of control systems using embedded target for TI C2000 DSP,” in
Start Proc. IEEE MED, Athens, Greece, Jun. 27–29, 2007, pp. 1–5.
[9] C. Rusu, I. Birou, M. M. Radulecu, and A. Bara, “Developing
embedded control system platform for testing PMSM drives,” in
Proc. IEEE EPE, Iasi, Romania, Oct. 16–18, 2014, pp. 677–682.
Determine quadrant of Uout [10] C. Rusu, M. M. Radulescu, S. Enikö, R. K. Melinda, and Z. L. Jakab,
“Embedded motor drive prototype platform for testing control
algorithms,” in Proc. IEEE ICATE, Craiova, Romania, Oct. 23–25,
2014, pp. 1–6.
Calculate alpha and beta
components of Uout
[11] B. K. Bose. Power Electronics and Variable Frequency Drives -
Technology and Application. Piscataway, NJ: IEEE Press, 1997.
[12] R. Krishnan. Permanent Magnet Synchronous and Brushless DC
Motor Drives. Boca Raton, FL: CRC Press, 2009.
Calculate Ta, Tb, and Tc [13] P. Pillay and R. Krishnan, “Modeling, simulation and analysis of
permanent magnet motor drives, Part I: The permanent magnet
synchronous motor drive,” IEEE Trans. Ind. Appl., vol. 25, no. 2, pp.
265–273, Mar./Apr. 1989.
Determine sector number [14] M. Bhardwaj, “Sensored Field Oriented Control of 3-Phase
Permanent Magnet Synchronous Motors,” Texas Instruments, Dallas,
TX, USA, Appl. Rep. SPRABQ2, Jul. 2013.
[15] S. B. Ozturk and H. A. Toliyat, “Direct torque and indirect flux
End control of brushless dc motor,” IEEE/ASME Trans. Mechatronics,
vol. 16, no. 2, pp. 351–360, Apr. 2011.
Pseudo Code:
[16] S. B. Ozturk, W. C. Alexander, and H. A. Toliyat, “Direct torque
Start
Determine quadrant of Uout
control of four-switch brushless dc motor with non-sinusoidal back
EMF,” IEEE Trans. Power Electron., vol. 25, no. 2, pp. 263–271,
Calculate alpha and beta components of Uout Feb. 2010.
Calculate Ta, Tb, and Tc

Determine sector number


End

REFERENCES
[1] L. H. Hoang, “Modeling and simulation of electrical drives using
MATLAB/Simulink and Power System Blockset,” in Proc. IEEE
IECON, Denver, CO, Nov. 29–Dec. 2, 2001, vol. 3, pp. 1603–1611.
[2] S. B. Ozturk, B. Akin, H. A. Toliyat, and F. Ashrafzadeh, “Low-cost
direct torque control of permanent magnet synchronous motor using
Hall-effect sensors,” in Proc. IEEE APEC, Dallas, TX, Mar. 19–23,
2006, pp. 667-673.
[3] H. S. Zhuqiang, H. L. Hess, and K. M. Buck, “The modeling and
simulation of a permanent magnet synchronous motor with direct
torque control based on Matlab/Simulink,” in Proc. IEEE IEMDC,
San Antonio, TX, May 15–18, 2005, pp. 1150–1156.
[4] L. Ting, Y. Tan, G. Wu, and W. Shumao, “Simulation of PMSM
vector control system based on Matlab/Simulink,” in Proc. IEEE
ICMTMA, vol. 2, Zhangjiajie, Hunan, China, Apr. 11–12, 2009, pp.
343–346.
[5] X. Wang, R. Na, and N. Liu, “Simulation of PMSM field-oriented
control based on SVPWM,” in Proc. IEEE VPPC, Dearborn, MI, Sep.
7–10, 2009, pp. 1465–1469.
[6] Z. Zhang and J. Shu, “Matlab-based permanent magnet synchronous
motor vector control simulation,” in Proc. IEEE ICCSIT, Amsterdam,
Netherlands, Dec. 10–11, 2010, pp. 539–542.
[7] A. Kamalaselvan and S. L. Prakash, “Modeling simulation and
analysis of closed loop speed control of PMSM drive system,” in
Proc. IEEE ICCPCT, Nagercoil, India, Mar. 20–21, 2014, pp. 692–
697.

102

Authorized licensed use limited to: Thapar Institute of Engineering & Technology. Downloaded on August 21,2025 at 11:28:31 UTC from IEEE Xplore. Restrictions apply.

You might also like