AN4548
AN4548
Contents
This application note describes design of a dual 3-phase 2 System concept............................ ........................... 1
BLDC motor control drive using a sensorless algorithm. The 3 BLDC sensorless control.........................................2
design is targeted at automotive applications. This cost-
effective solution is based on NXP MPC5643L device 4 MPC5643L - Controller Board
dedicated to automotive motor control and safety systems. configuration........................................................... 8
The system is designed to drive two independent 3-phase 5 Software implementation............... ....................... 13
BLDC motors without a positional feedback sensor. Features 6 Application performance............. ......................... 22
of this design include:
• Sensorless 6-step commutation control of a BLDC 7 FreeMASTER user interface............ .................... 23
motor that can be configured for single-motor or dual- 8 Conclusion.............................................................24
motor application
• BEMF sensing and zero-crossing detection 9 References............................. ................................24
• Application control user interface using the 10 Revision history.................................................... 24
FreeMASTER debugging tool
• Maximal motor current limitation
2 System concept
The system is designed to drive two independent 3-phase
BLDC motors using the NXP MTRCKTDBN5643L motor-
control development kit. The application meets the following
performance specifications:
• Targeted at the MPC5643L Controller (refer to the
dedicated user manual for the MPC5643L, available at
www.nxp.com )
© 2016 Freescale Semiconductor, Inc.
BLDC sensorless control
• Running on the MPC5643L Control drive board (refer to the dedicated user manual for the MPC5643L Controller
Board)
• Control technique incorporating:
• Sensorless control of a 3-phase brushless DC motor
• Zero-crossing technique
• Closed-loop speed control
• Closed-loop current control
• Open-loop start-up sequence with alignment
• BackEMF voltage sensing
• 50 μs sampling period with the FreeMASTER recorder
• Floating-point implementation
• FreeMASTER software control interface (motor start/stop, speed set-up)
• FreeMASTER software monitor
• DC-Bus over-voltage and under-voltage, over-current, overload protection
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
2 Freescale Semiconductor, Inc.
BLDC sensorless control
revolution and the mechanical revolution. The BLDC motor is equivalent to an inverted DC brushed motor, where the
magnet rotates while the conductors remain stationary. In the DC brushed motor, the commutator and brushes reverse the
current polarity in such way that the stator and rotor magnetic fields are perpendicular. However, in the brushless DC motor,
a power transistor (which must be switched in synchronization with the rotor position) performs the polarity reversal. This
process is also known as electronic commutation. The displacement of the magnets on the rotor creates a trapezoidal back-
electromotive force (Back-EMF) shape when the rotor is spinning. Neglecting the higher-order harmonic terms, the Back-
EMF in the motor phase (ea, eb, ec) is indicated in the following figure. Each Back-EMF has a constant amplitude for 120
electrical degrees, followed by a 60 electrical degree transition in each half-cycle.
Voltage
Phase A
Phase B
Phase C
efA
efB
efC
Electrical
angle
30º 60º 90º 120º 150º 180º 210º 240º 270º 300º 330º 0º
Sector 1 2 3 4 5 6
Whatever a zero-crossing is, the reasons and conditions for its correct evaluation are shown in the following sections.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 3
BLDC sensorless control
phases. Six semiconductor power switches form a 3-phase power inverter, designed using the IGBT or MOSFET switches.
The power for the system is provided by the DC-bus voltage UDCB. The semiconductor switches and diodes are modeled as
ideal devices in this figure.
UDCB
SAB SBB SCB
Rshunt B
IDCB
UR
UB
UL
UiB
UiA UiC
UA UC
UL UL
UR UR
A C
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
4 Freescale Semiconductor, Inc.
BLDC sensorless control
To explain and simulate the idea of Back-EMF sensing techniques, a simplified mathematical model founded on the basic
circuit topology (see Figure 3) is provided. The voltage for a 3-phase BLDC motor is supplied by a typical 3-phase power
stage designed using IGBT or MOSFET switches. The power stage switches are controlled by the MCU on-chip flexPWM
module, which creates the desired control patterns. The goal of the model is to find out the dependency between the motor
characteristics and switching angle. The switching angle is the angular difference between a real switching event and the
ideal one. The motor drive model consists of a 3-phase power stage and a brushless DC motor. The power for the system is
provided by a DC-bus voltage source UDCB. Six semiconductor switches (SA/B/C/T/B) deliver the rectangular voltage
waveforms to the motor (see Figure 2). The semiconductor switches and diodes are simulated as ideal devices. The natural
voltage level of the whole model is referenced to half of the DC-bus voltage, which simplifies the mathematical expressions.
+UDCB
UR
UB
UL
UiB
UiA UiC
UA UC
UL UL
UR UR
A C
GND
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 5
BLDC sensorless control
PC_HSS
AGND AGND
R57 R69 R72 TP8
51K 35.7K 16K VDCB
BEMF_C
AGND
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
6 Freescale Semiconductor, Inc.
BLDC sensorless control
AN_11 AN11
R18
120 C18
82pF
GNDA
AN_12 AN12
R22
120 C21
82pF
GNDA
AN_13 AN13
R27
120 C24
82pF
GNDA
3.3.1 Alignment
It has come up before that the main task of a BLDC motor for sensorless control is the position estimation. Before starting the
motor, the rotor position is not known. The main aim of the alignment state is to align the rotor to a known position. This
known position is necessary to start rotation in the proper direction and to generate a maximal torque during startup. During
alignment, all three phases are powered. Phase A is connected to the positive DC-Bus voltage, and Phases B and C are
connected to the negative DCBus voltage. The alignment time depends on the mechanical constant of the motor, including
load, and also on the applied motor current. In this state, the motor current (torque) is controlled by the PI controller on every
PWM reload event.
3.3.2 Start-up
In the start-up state, the motor commutation is controlled in an open-loop without any rotor position feedback. The
commutation period is controlled with a linear open-loop starting ramp. The open-loop start should be a short state and at a
very low speed where the Back-EMF is too small, so that the zero-crossing events cannot be reliably detected.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 7
MPC5643L - Controller Board configuration
3.3.3 Run
Running Sensorless mode includes the Back-EMF acquisition with zero-crossing detection for the commutation control. The
motor speed is controlled using zero-crossing period feedback to the speed PI regulator. The motor current is measured and
filtered during commutation event and used as feedback into the current controller. Its output limits the speed controller
output to achieve the maximal motor current in the required range.
DC bus
current limit + Current limitation
PI controller
–
Actual DC
bus current
Required
speed [RPM] + Speed
PI controller
–
Actual speed
[RPM]
Zero-crossing period
filtered/estimated
Speed_const / T
The MPC5643L device includes special modules (flexPWM, CTU, ADC, and eTIMER) dedicated for motor control
applications. These modules are directly interconnected and can be set-up in-line with any type of application or
requirements. Figure 8 shows module interconnections. The modules are described below and a detailed description can be
found in the MPC5643L reference manual.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
8 Freescale Semiconductor, Inc.
MPC5643L - Controller Board configuration
External External
pins pins
External External
pins FlexPWM_1 pins FlexPWM_0 CTU
PWMA0 Master Reload PWMA0 Master Reload PWM_REL TRIGGER_0
PWMB0 OUT_TRIG0_0 PWMB0 OUT_TRIG0_0 PWM_ODD_0 ADC_CMD_0
PWMA1 OUT_TRIG0_1 PWMA1 OUT_TRIG0_1 PWM_ODD_1 NEXT_CMD_0 ADC0
PWMB1 OUT_TRIG0_2 PWMB1 OUT_TRIG0_2 PWM_ODD_2 FIFO_0
PWMA2 OUT_TRIG0_3 PWMA2 OUT_TRIG0_3 PWM_ODD_3
PWMB2 OUT_TRIG1_0 PWMB2 OUT_TRIG1_0 PWM_EVEN_0
PWMA3 OUT_TRIG1_1 PWMA3 OUT_TRIG1_1 PWM_EVEN_1
PWMB3 OUT_TRIG1_2 PWMB3 OUT_TRIG1_2 PWM_EVEN_2 TRIGGER_1
OUT_TRIG1_3 OUT_TRIG1_3 PWM_EVEN_3 ADC_CMD_1
PWMX0 PWMX0 NEXT_CMD_1 ADC1
RPWM_0 FIFO_1
FAULT0 PWMX1 FAULT0 PWMX1 RPWM_1
FAULT1 PWMX2 FAULT1 PWMX2
FAULT2 FAULT2 RPWM_2 EXT_IN External
FAULT3 PWMX3 FAULT3 PWMX3 RPWM_3 EXT_TRG pins
EXT_FORCE EXT_FORCE ETIMER0_TRG ETIMER0_IN
EXT_SYNC CLOCK EXT_SYNC CLOCK ETIMER1_TRG ETIMER1_IN
ETIMER2_TRG
ETIMER3_TRG
eTIMER0
CHANNEL 0
CHANNEL 1
DSPI1 CHANNEL 2 External
AUX_0 CHANNEL 3 pins
AUX_1 CHANNEL 4
SCK AUX_2 CHANNEL 5
eTIMER1
CHANNEL 0
CHANNEL 1
FlexRay CHANNEL 2 External
AUX_0 CHANNEL 3 pins
AUX_1 CHANNEL 4
FR_CA_TX AUX_2 CHANNEL 5
eTIMER2
CHANNEL 0
CHANNEL 1
CHANNEL 2 External
AUX_0 CHANNEL 3 pins
AUX_1 CHANNEL 4
AUX_2 CHANNEL 5
4.1 FlexPWM
The MPC5643L device includes two PLLs. PLL1 is used to generate the motor clock time domain of 120 MHz. The Clock
Generation Module generates the reference clock MC_PLL_CLK for all the motor control modules (flexPWM, CTU, ADC0
and 1, eTimer0 and 1). The MPC5643L device contains two independent flexPWM modules. Each module can handle one 3-
phase electrical motor and another pair of PWM outputs is also available.
The FlexPWM module zero can synchronize second module while using MRS signal as showed in Figure 8.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 9
MPC5643L - Controller Board configuration
The FlexPWM0 sub-module #0 is configured to run as a master and to generate the Master Reload Signal (MRS) and counter
synchronization signal (master sync) for other submodules in module 0 and also for FlexPWM1 and its sub-modules. The
MRS signal is generated at every occurrence of sub-module #0, VAL1 compare, that is, a half cycle reload. All double
buffered registers are updated on occurrence of an MRS, therefore, the update of a new PWM duty cycle is done after every
PWM period.
The application uses centre-aligned PWMs. The VAL0 register defines the centre of the period and is set to zero and the INIT
register to the negative value of VAL1. Suppose the PWM clock frequency is 120 MHz and the required PWM output 20
kHz, then the VAL1, VAL0, and INIT registers are set as follows:
• VAL1 = (120000000/20000)/2 = 3000 = 0x0BB8hex
• VAL0 = 0
• INIT = –VAL1 = –3000 = 0xF448hex
The duty cycle is given by setting the value of the registers VAL2 and VAL3. The VAL2 register value is the negative of
VAL3.
• VAL3 = (DC * PERIOD)/2 = (0.1 * 6000)/2 = 300 = 0x012Chex
• VAL2 = –VAL3 = –300 = 0xFED4hex
The synchronization between module 0 and 1 is done by MRS from module 0. This signal is internally connected to “external
sync” input module 1. The module 1 is set to generate the MRS in the middle of the PWM period. PWM signals from module
0 and 1 that are shifted by half of period can be seen in Figure 9. This leads to the uniform use of energy from power source
and less EMI radiation.
FlexPWM0_submod0 3000
counter 0
-3000
FlexPWM0_submod0
MRS
FlexPWM1_submod0 3000
counter 0
FlexPWM1_submod0 -3000
MRS
FlexPWM0
Phase A output
FlexPWM1
Phase A output
Read
motor 0
Read values
CTU trigger 0 event motor 1
values
CTU trigger 1 event
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
10 Freescale Semiconductor, Inc.
MPC5643L - Controller Board configuration
The application uses two trigger events for measuring the Back-EMF, DC-Bus voltage, and DC-Bus current for motor 0 and
1. The other triggers are free and can be used for triggering other application events.
• T0CR = 120DEC - motor 0 analog quantities
• T2CR = 3120DEC - motor 1analog quantities
T0CR and T2CR values are set up with respect to the real delays in the system as shown in Figure 9. The minimal delay
value is given by the dead-time value for a rising edge, the power transistor turn-on delay, and the rise time and settling time
of the Back-EMF RC filter.
The CTU Scheduler subUnit (SU) generates the trigger event according to the occurred trigger event. The following trigger
event is generated:
• ADC command output:
T0CR generates an ADC command event output for motor 0, with the command offset initially set to zero. This is used as the
synchronization signal to the ADC (ADC commands #0 for Back-EMF voltages, DC-Bus voltage, and DC-Bus current
measurement).
T2CR generates an ADC command event output for motor 1, with the command offset initially set to three. This is used as
the synchronization signal to the ADC (ADC commands #3 for Back-EMF voltages, DC-Bus voltage, and DC-Bus current
measurement).
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 11
MPC5643L - Controller Board configuration
4.3 eTimer
The eTimer module0.channel1 generates, through OFLAG output, a forced signal for the flexPWM module 0, which changes
the PWM output with regard to the new motor commutation state, as shown in Figure 8. The time base for the counter is
derived from MC_PLL_CLK. The prescaler register divides the MC_PLL_CLK by 128. The time base for commutation
events is:
— fCOMM = (120000000/128) = 937500 Hz
The value of the COMP1 register defines the time of the next commutation event. The eTimer output (OFLAG) is set at the
compare occurrence, and generates an external forced signal for the flexPWM module. The external forced signal updates the
PWM outputs in-step with the preloaded state according to the newly applied sector pattern.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
12 Freescale Semiconductor, Inc.
Software implementation
The same approach is implemented on the flexPWM module 1 (second BLDC motor). The force signal is derived from
eTimer module1.channel3 OFLAG output.
This ensures both independently controlled motor commutation without any delay. Both events generate interrupt. The PWM
module settings are preset for next commutation sectors in this interrupt service routine and are stored in the double buffered
registers. The flexPWM module waits for the next force signal that rewrites new PWM setup into registers.
5 Software implementation
5.1 Introduction
This section describes the software design of the dual BLDC sensorless control algorithm. Figure 11 shows the application
block diagram.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 13
Software implementation
U
V
BLDC wmech
W
SAB SBB SCB
–DCBUS
IDCBUS
FreeMASTER
START/
STOP UP DOWN
Force
ADC
MRS command
USB GPIO FlexPWM CTU ADC0/1 eTimer0/channel1
Driver Driver Driver Driver Driver Driver
Application control Sector
Zero cross New
Required Dutycycle detection
speed commutation
[RPM] event
PWM
+ Speed PI modulation
controller functions
Required –
current
limit Current
+ limitation
PI
–
controller
Actual speed [RPM] Zero-crossing period
Speed, torque
Actual motor current Motor torque filtered MPC5643L
calculation
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
14 Freescale Semiconductor, Inc.
Software implementation
MAIN
state = reset;
event = e_reset;
state_table();
FreeMASTER_Poll();
True
while(1);
False
END
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 15
Software implementation
False False
State_table();
Calculate new Calculate new
commutation time commutation time
RTFI
Set new Set new
commutation event commutation event
RTFI RTFI
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
16 Freescale Semiconductor, Inc.
Software implementation
where:
• TREAL is the real commutation period
• TCLK is the period of the eTIMER0.channel1 or eTimer1.channel3
• T is the value measured in the eTIMER0.channel1 or eTimer1.channel3 increments
• fCLK is the eTIMER0.channel1 or eTimer1.channel3 clock rate
If commutation period is known, the period of one electrical revolution can be calculated by:
where:
• Telrev is the real period of one electrical revolution
• N is number of commutations in one electrical period
To calculate the period of one mechanical revolution, the result of above equation must be multiplied by the number of pole-
pairs:
and finally we can calculate the mechanical speed in revolutions per minute:
If the clock rate is 937500 Hz, the number of commutations per electrical revolution is 6, and the number of pole-pairs is 4;
we can get the constant:
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 17
Software implementation
where:
• c is the mechanical speed constant, that is, 14.0625x106.
To achieve a better resolution, the mechanical speed is multiplied by 1000 in fixed-point implementation.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
18 Freescale Semiconductor, Inc.
Software implementation
INIT
executed before main on entry:
RESET – PWM output disable
executed in ISR
READY e_reset
on exit to e_init_done
e_app_off faultDetection()
CALIB IB: e_rest_done
– PWM output
enable
To signalize/initiate a change of the state, 15 application events are defined and selected using the variable event defined as
AppEvents:
• e_reset - event = 0
• e_reset_done - event = 1
• e_fault - event = 2
• e_fault_clear - event = 3
• e_init_done - event = 4
• e_ready - event = 5
• e_app_on - event = 6
• e_calib - event = 7
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 19
Software implementation
• e_calib_done - event = 8
• e_align - event = 9
• e_align_done - event = 10
• e_run - event = 11
• e_app_off - event = 12
• e_start - event = 13
• e_start_done - event = 14
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
20 Freescale Semiconductor, Inc.
Software implementation
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 21
Application performance
Transition to the INIT state is performed by setting the variable event to event=e_app_off, which is done automatically on the
falling edge of switchAppOnOff=false using FreeMASTER, or the other way to change its value is to switch off the external
switch on the MPC5643L controller board.
6 Application performance
The fixed-point implementation takes 18.4 μs average and 25.4 μs maximum. The floating-point implementation takes 5.6 μs
average and 9.5 μs maximum for one motor application, which is maximum 20% of CPU load by fast loop calculation
frequency 20 kHz. Dual motor application takes 10.8 μs and 17.8 μs maximum.
Application code was compiled using a Green Hills compiler with optimization options listed in Table 2. The timing was
measured on the e200z4 core at a 80 MHz system clock frequency using optimal flash read/write wait state control and
address pipelining control settings.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
22 Freescale Semiconductor, Inc.
FreeMASTER user interface
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 23
Conclusion
8 Conclusion
The described design shows simplicity and efficiency in use of the MPC5643L microcontroller for independent two BLDC
motor controls, and introduces it as an appropriate candidate for different low-cost two motor applications in the automotive
area. Both types of implementation show the mentioned microcontroller is developed to achieve application safety
requirements.
9 References
1. 3-phase BLDC Sensorless Motor Control Development Kit with MPC5643L, available at http://www.nxp.com/
AutoMCDevKits
2. MPC5643L Microcontroller Reference Manual (document MPC5643LRM )
3. MPC5643L Controller Board User Manual (document MPC5643LMCBUM )
4. 3-Phase BLDC/PMSM Low Voltage Power Stage User Manual (document 3PHLVPSUG )
5. MC33937 Three Phase Field Effect Transistor Pre-driver Data Sheet (document MC33937 )
6. Automotive Math and Motor Control Library Set for MPC564xL, http://www.nxp.com/AutoMCLib
7. FreeMASTER Run-Time Debugging Tool, http://www.nxp.com/FREEMASTER
10 Revision history
This section documents the changes done to this document.
Table 3. Revision history
Revision Date Substantive changes
0 08/2012 Initial release.
1 02/2016 Updated Figure 1, added Figure 15, and various small updates.
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
24 Freescale Semiconductor, Inc.
Revision history
Dual 3-Phase Sensorless BLDC Kit with MPC5643L MCU, Rev. 1, 02/2016
Freescale Semiconductor, Inc. 25
How to Reach Us: Information in this document is provided solely to enable system and
software implementers to use Freescale products. There are no express
Home Page:
or implied copyright licenses granted hereunder to design or fabricate
freescale.com
any integrated circuits based on the information in this document.
Web Support: Freescale reserves the right to make changes without further notice to
freescale.com/support any products herein.
Freescale makes no warranty, representation, or guarantee regarding
the suitability of its products for any particular purpose, nor does
Freescale assume any liability arising out of the application or use of
any product or circuit, and specifically disclaims any and all liability,
including without limitation consequential or incidental damages.
“Typical” parameters that may be provided in Freescale data sheets
and/or specifications can and do vary in different applications, and
actual performance may vary over time. All operating parameters,
including “typicals,” must be validated for each customer application by
customer's technical experts. Freescale does not convey any license
under its patent rights nor the rights of others. Freescale sells products
pursuant to standard terms and conditions of sale, which can be found
at the following address: www.freescale.com/salestermsandconditions.
Freescale and the Freescale logo are trademarks of Freescale
Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other product or
service names are the property of their respective owners. All rights
reserved.
© 2016 Freescale Semiconductor, Inc.