Infineon-AP32359 BLDC Motor Control Software-An-V01 00-En
Infineon-AP32359 BLDC Motor Control Software-An-V01 00-En
Infineon-AP32359 BLDC Motor Control Software-An-V01 00-En
This application notes describes the implementation of the BLDC Motor Control Software using the Infineon
XMC1302 microcontroller. Features such as various control schemes, adaptive Hall pattern learning and motor
parameter configuration are provided in the software.
Intended audience
This document is intended for customers who would like a highly configurable system for scalar control and to
select between sensor-based control using Hall sensors or sensor-less control on XMC series microcontrollers.
References
[1] The Users Manual can be downloaded from http://www.infineon.com/XMC.
Application Note Please read the Important Notice and Warnings at the end of this document 1.0
www.infineon.com 2017-01-03
BLDC motor control software using XMC
XMC1000, XMC4000
Table of contents
Table of contents
About this document ......................................................................................................................... 1
Table of contents .............................................................................................................................. 2
1 BLDC overview ................................................................................................................ 3
1.1 Key features ............................................................................................................................................. 4
1.2 Peripherals............................................................................................................................................... 5
1.3 Supported devices .................................................................................................................................. 5
1.4 Limitations ............................................................................................................................................... 6
1.4.1 Sensor-based control scope of use ................................................................................................... 6
1.4.2 Sensor-less control scope of use ....................................................................................................... 6
2 BLDC motor control software components......................................................................... 7
2.1 Control schemes ...................................................................................................................................... 8
2.1.1 Voltage control ................................................................................................................................... 8
2.1.2 Speed control ..................................................................................................................................... 8
2.1.3 Current control ................................................................................................................................... 9
2.1.4 Speed with current control ................................................................................................................ 9
2.2 Voltage compensator ............................................................................................................................ 10
2.3 PWM generator ...................................................................................................................................... 10
2.3.1 PWM pattern update ........................................................................................................................ 10
2.3.2 PWM scheme .................................................................................................................................... 12
2.4 Current and voltage calculation ........................................................................................................... 14
2.5 Speed and position calculation ............................................................................................................ 16
2.5.1 Speed and position calculation for sensor-based control ............................................................. 16
2.5.2 Speed and position calculation for sensor-less control ................................................................. 17
2.6 Adaptive Hall pattern learning.............................................................................................................. 19
2.6.1 Input settings for adaptive Hall pattern learning ........................................................................... 19
2.7 Sensor-less Motor control start-up mechanism................................................................................... 19
3 BLDC motor control software configuration ......................................................................20
3.1 Software organization and file structure ............................................................................................. 20
3.2 Configuring the BLDC motor control software ..................................................................................... 24
4 Resources ......................................................................................................................25
Revision history ...............................................................................................................................26
1 BLDC overview
Scalar control of 3-phase BLDC motors is an electronic commutation scheme, commonly known as trapezoidal
commutation, or 1200 commutation. In this control scheme, each phase conducts for 1200 during the positive
and negative half of a Back-EMF cycle, and is off or un-energized for the remainder of the cycle.
In terms of phase to phase conduction, each phase-pair conducts in steps of 600 electric degrees. A 3-phase
BLDC motor is synchronous, therefore to produce the maximum torque for the applied stator current the stator
magnetic fields must rotate in synchronism with the rotor, and its orientation should be in space quadrature to
rotor magnetic field. To achieve these objectives, the trapezoidal control algorithm requires rotor position
feedback for every 600 (electric degrees). Based on the rotor position feedback mechanism, trapezoidal
commutation is characterized as:
Sensor-based commutation in which Hall- sensor provides rotor position feedback.
Sensor-less commutation scheme which derives the rotor position based on Back-EMF sensing of the un-
energized phase.
The key difference in the implementation between sensor-based and sensor-less motor control is the method
to determine rotor position feedback mechanism.
1.2 Peripherals
The following table lists the functions of the XMC microcontroller peripherals:
1.4 Limitations
VDC
Motor
3-Phase v
Set Value Digital
Ramp
Control Scheme
Voltage
Modulator
PWM-Unit 2-Level Voltage u
Generator Compensator Source Inverter
Set Value Analog CCU8 (VSI)
w
Trigger ADC
VDC
Current/ Voltage
Calculation
ADC
Rshunt
Gain
Hall
CCU4 POSIF
Speed & Position
Sensors
Calculation
Legend:
SW
XMC HW
HW
User Configuration
VDC
Motor
3-Phase v
Set Value Digital
Ramp
Control Scheme
Voltage
Modulator
PWM-Unit 2-Level Voltage u
Generator Compensator Source Inverter
Set Value Analog CCU8 (VSI)
w
Trigger ADC
VDC
Current/ Voltage
Calculation
Rshunt
Gain
ADC
Zero
CCU4 Crossing Back EMF
Speed & Position Detection
Calculation
Legend:
SW
XMC HW
HW
User Configuration
VDC
3-Phase
PWM-Unit 2-Level Voltage
Modulator Source Inverter
CCU8 (VSI)
VDC
P0.0 U_H
CCU8.CC80
P0.1 U_L
3-Phase
2-Level Voltage
MCM
P0.7 V_H
Modulator CCU8.CC81
P0.6 V_L
Source Inverter
CCU8.CC82
P0.8 W_H (VSI)
P0.9 W_L
Update
Speed & Position Multichannel pattern update is done via the POSIF module
Calculation Sensor-based: Hall Sensor Control with Multi-Channel Mode
Sensor-less: Stand-Alone Multi-Channel Mode
+++-
++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++
Note: In XMC1300 devices, the ADC on-chip amplifier can be used for current measurement.
VDC
3-Phase
PWM-Unit 2-Level Voltage
Source Inverter
CCU8 (VSI)
Trigger ADC
VDC
Current/ Voltage
ADC
Calcuation
Gain
Figure 13 Voltage and current measurement is triggered by Phase V compare match of CCU8
Blanking
CCU40.ST0
Hall event
CCU40.CC40 POSIF0.OUT0
Hall
Speed & Position POSIF0
CCU40.CC42
Hall event
Sensors
Calculation (Motor Speed)
POSIF0.OUT1
MCM Sync
CCU40.PS1
CCU40.CC41
Figure 15 Hardware block interconnect for speed and position calculation module
CCU40.CC42 This slice is configured in Capture Mode, to capture the time between -
Correct Hall Events (storing the motor speed between two correct Hall
events).
The POSIFx.OUT1 of the POSIF is used as capture trigger for the Slice.
VADC0.G0CH5
Figure 18 Hardware block inter-connect for speed and position calculation module
CCU40.CC42 This slice is configured in Capture Mode, to capture the time between -
two consecutive zero-crossing events.
VADC_G0.CH5 Phase U BEMF Channel configured for inbound event with global -
boundary to determine the BEMF zero-crossing point.
VADC_G0.CH6 Phase V BEMF Channel configured for inbound event with global -
boundary to determine the BEMF zero-crossing point.
VADC_G0.CH7 Phase W BEMF Channel configured for inbound event with global -
boundary to determine the BEMF zero-crossing point.
These open loop settings (speed and voltage) are defined by the load on the motor, and are required to get the
motor locked at some position. At this point Hall sensor output is read to get the Hall pattern corresponding to
the applied commutation pattern. The next commutation pattern is applied to move the motor forward and get
the Hall pattern. This procedure is repeated to capture the required sequences.
Note: If the motor does not rotate, the motor voltage needs to increase gradually until the motor rotates
correctly.
Attention: The effect of wrong phase energization can lead to reverse rotation in start-up. This is a
condition that must be avoided.
Table 13 Folders
File Options Sensor-based Sensor-less
Configuration folder
bldc_scalar_mcuhw_config.h Pin Selection.
bldc_scalar_user_config.h Motor and Power Board selection.
ADC Measurement configurations.
Hall Pattern Learning configurations.
Protection modes.
Interrupts folder
bldc_scalar_state_machine.c System timer events used for state -
bldc_scalar_sl_state_machine.c machine. -
4 Resources
XMC1000 motor control application kit.
http://www.infineon.com/cms/en/product/productType.html?productType=db3a30443ba77cfd013ba
ec9ca5c0caa
XMC4400 motor control application kit.
http://www.infineon.com/cms/en/product/evaluation-
boards/KIT_XMC44_AE3_001/productType.html?productType=db3a30443cd75eda013cd984f125047e
BLDC Motor Control 3-Hall Sensor Example with uC Probe for XMC1300 series.
http://www.infineon.com/cms/en/product/productType.html?productType=db3a30443ba77cfd013ba
ec9ca5c0caa#ispnTab12
BLDC Motor Control Sensorless Example with uC Probe for XMC1300 series.
http://www.infineon.com/cms/en/product/productType.html?productType=db3a30443ba77cfd013ba
ec9ca5c0caa#ispnTab12
BLDC Motor Control 3-Hall Sensor Example with uC Probe for XMC4400 series.
Revision history
Major changes since the last revision
Page or Reference Description of change
All pages Initial release
Other Trademarks
All referenced product or service names and trademarks are the property of their respective owners.
IMPORTANT NOTICE
Edition 2017-01-03 The information contained in this application note For further information on the product, technology,
is given as a hint for the implementation of the delivery terms and conditions and prices please
Published by product only and shall in no event be regarded as a contact your nearest Infineon Technologies office
description or warranty of a certain functionality, (www.infineon.com).
Infineon Technologies AG condition or quality of the product. Before
81726 Munich, Germany implementation of the product, the recipient of this
application note must verify any function and other WARNINGS
technical information given herein in the real Due to technical requirements products may
AP32359owners.
2017 Infineon Technologies AG. application. Infineon Technologies hereby contain dangerous substances. For information on
disclaims any and all warranties and liabilities of the types in question please contact your nearest
All Rights Reserved. any kind (including without limitation warranties of Infineon Technologies office.
non-infringement of intellectual property rights of
Do you have a question about this any third party) with respect to any and all
information given in this application note. Except as otherwise explicitly approved by Infineon
document? Technologies in a written document signed by
authorized representatives of Infineon
Email: [email protected] The data contained in this document is exclusively Technologies, Infineon Technologies products may
intended for technically trained staff. It is the not be used in any applications where a failure of
responsibility of customers technical departments the product or any consequences of the use thereof
Document reference to evaluate the suitability of the product for the can reasonably be expected to result in personal
AP32359 intended application and the completeness of the injury.
product information given in this document with
respect to such application.