Professional Documents
Culture Documents
CN 11-5904/U
, 2014 , 5 2
J Automotive Safety and Energy, 2014, Vol. 5 No. 2
8/13
166 171
Abstract: PMSM (permanent magnet synchronous motor) drive systems has been having general used in
various industries needed high precision control due to a rapid development of microprocessors. The proper
system configuration is still complex and time consuming. To overcome such a limitation, this paper presents
a FOC (Field Oriented Control) algorithm for PMSM speed control algorithm performed in Matlab/Simulink by
using standard blocks only, which is realized in almost any DSP (Digital Signal Processing) processor by using
auto-coding tool in Matlab. STM32F4 microcontroller was employed. Simple Active Currents Reading Error
Compensator was introduced for appropriate feedback signals filtering. Precision of the signal was set to around
10 mA of current 10 Bit with an Analog-to-Digital Converter operated by three bidirectional 5-A Hall current
sensors. A PMSM sensored motor was tested in 0~2 000 r/min. The experimental step responses to desired
speeds show good dynamic and smooth performance of the entire system.
Key words: permanent magnetism synchronous motor (PMSM); field oriented control (FOC); Matlab/Simulink;
currents reading error compensator; autocoding
Matlab/Simulink PMSM
Pawel Stojaczyk [ ]Dawid Woroch *
100084
PMSM
PMSM PMSM
(FOC) MATLAB/Simulink Matlab
DSP STM32F4
3 5-A Hall 10 mA
10 Bit 0~2 000 r/min PMSM
/ Received 2013-12-06
/ Supported by
(51275265, 51175286)
/ First author Pawel Stojaczyk (1988), male , Poland, bachelors degree. E-mail: pawel.stojaczyk@gmail.com
* / Corresponding author weiyt@tsinghua.edu.cn
Pawel Stojaczyk, et al: Design and implementation of FOC control algorithm for PMSM motor based on Matlab/Simulink
INTRODUCTION
167
1 SYSTEM DESCRIPTION
The main algorithm of the controller is developed as a
Simulinks model using standard blocks only. The model is
converted into C language by Matlab Embedded Coder tool and
linked into the Keil Vision where all the remaining functions
are implemented, along with:
1) Controlling the internal peripherals of the
microcontroller like proper I/O pins configuration
2) Simultaneously three phase currents reading by
Analog to Digital Converter (ADC)
3) Time values for SVM (Space Vector Control)
algorithm calculations
4) Encoder supervision
5) Simple interface for the operator
6) Interaction with Simulinks model (inputs and outputs
signals)
C code for
perhipherials
control
M ATLAB
SIMULINK
KeiluVision c/c++
Compiled
code
168
USB
UDC
CAN
STM32F405
I d= 0
USART
Ud
RId
dq
n
Rn
Uq
RIq
SVM
fault
U DC
n1
speed
calculation
Id
Iq
dq
abc
Ia
Ib
Ic
A/C
Converter
Ia
Ib
Ic
PMSM
speed
direction
encoder
Fig. 2 Block Diagram
PWM 1
Duty
TD
TD
TD
PWM 2
PWM 3
TD
TD
PWM 4
TN
TS
TS
TS
TS
TN
TN
TS
TS
TS
TS
TN
TN
TS
TS
TS
TS
TN
phase A
phase B
phase C
6 s
4 s
Sampling start
Pawel Stojaczyk, et al: Design and implementation of FOC control algorithm for PMSM motor based on Matlab/Simulink
169
(1)
0.4
current a
current b
-0.2
current c
I/A
0.2
-0.4
0
0.3
t/s
0.2
0.1
0.5
0.4
0.6
I/A
0.4
0.2
current a
current b
-0.2
current c
-0.4
0
0.1
0.3
0.2
0.4
0.5
0.6
t/s
Fig. 5 The Same Three Phase Currents after Compensation by Formula (1) Shows More Smooth Reading
(2)
K1
K3
K5
t0
2
t1
t2
t0
2
t0
2
t2
t1
t0 = t - t1 - t2 .
Where t0 is the duration of the null vector [9].
t0
2
170
2 CONTROL ALGORITHM
desired_speed
+-
PID(z)
Discrete PID Controller2
+-
ldref
ud
ualpha
uq
PID(z)
ubeta
theta
lpark
+-
2
actual_speed
theta
ld
lalpha
lq
lbeta
Park
PWM1
1
pwm1
PWM2
2
pwm2
Ualfa
Ubeta
3
pwm3
PWM3
SVPWM
electric_angle
1
lalfa
lbeta
la
lb
lc
Clark
la
3
lc
lb
4
(4)
Park inverse transform:
(5)
PMSM motor which was tested has parameters as follows:
Ld = L q = 0.59 mH, R = 2.5 , p (number of pole pairs) = 4 and
supplied with encoder with 2 500 pulses per revolution. The
switching frequency was set to 20 kHz. Experiments were done
by using especially prepared for this experiment controller
presented on the Figures 8 and 9, shows the whole laboratory
where all tests were performed.
Pawel Stojaczyk, et al: Design and implementation of FOC control algorithm for PMSM motor based on Matlab/Simulink
EXPERIMENT RESULT
4 CONCLUSIONS
n / (rmin-1)
600
400
200
Speed responded
0
-200
10
20
(a)
1 500
t / ms
30
40
50
n = 500 r/min
n / (rmin-1)
1 000
500
Speed desired
Speed responded
0
-500
10
(b)
2 500
t / ms
20
30
n = 1 000 r/min
n / (rmin-1)
2 000
1 500
Speed desired
1 000
Speed responded
500
0
-500
10
20
(c)
t / ms
30
40
n = 2 000 r/min
REFERNCES / ( )
Speed desired
171
50