BLDC Sinusoidal Control
BLDC Sinusoidal Control
algorithms for such functions as PID closed-loop control, and the elimination of external PWM generators
and expensive current sensing devices not only
increases efficiency but ultimately reduces overall
application cost.
Jorge Zambada
Microchip Technology Inc.
INTRODUCTION
In BLDC motor applications where audible noise and
torque ripple are issues, driving the motor with threephase sine waves instead of 6-step voltages is a desirable approach. This document describes application
software that enables the dsPIC30F digital signal controller to efficiently and robustly drive a BLDC motor
with sinusoidal voltages.
OVERVIEW
Figure 1 is a block diagram representation of the application software. The application runs closed-loop
based on the difference between the desired speed
and actual speed. The speed set point is established by
the voltage value of an external potentiometer. Actual
speed is measured from signals from Hall effect sensors. Proportional, integral and derivative interpretations of the speed error determine the amplitude of the
voltage sine wave, which in turn controls the motor
speed.
The dsPIC30F Motor Control devices include peripheral modules that are well suited for this application.
The Motor Control PWM (MCPWM), 10-bit A/D
Converter (ADC), input capture and general purpose
I/O modules provide essential functionality that
facilitate software control. The use of software
FIGURE 1:
Reference
Speed
Error
+-
Amplitude
PID
Duty
Cycles
Sine-Wave
Generation
Phase
3-Phase
Voltages
MCPWM
+5V
10-bit ADC
dsPIC30F Software
Period
3-Phase
Inverter
BLDC
Fault
Measured
Speed
Phase
Advance
Maximum
Phase Advance
Rotor
Sector
Speed
Calculation
Direction
Rotor
Sector
Calculation
Start /
Stop
Angular
Position
Main State
Machine
Input Capture
GPIO
Period
Hall
Sensors
Low-Pass
Passive
Filters
DS92003A-page 1
CE003
CODE EXAMPLE
Speed Calculation
Reference-Speed Measurement
Main Initialization
Period Measurement
The second part of the closed-loop system is the measured speed, which is used to either increase or
decrease the output voltage of the motor depending on
the calculated error between the desired speed (set
point) and the measured speed. The application
assumes that the motor uses Hall effect sensors to
detect rotor position. The signals from the Hall effect
sensors are conditioned by low-pass passive filters to
produce pulses that can be measured by the input capture module. One of the Hall effect sensors is used to
determine the Period, which must be known for two
reasons: first, to calculate the speed of the motor for
the closed-loop controller, and second, to keep the sine
wave phase locked to the angular position of the rotor.
The logic states of the three Hall effect sensors
determine the angular position of the rotor.
DS92003A-page 2
CE003
Sine-Wave Generation
Sine-wave generation uses the values of Amplitude,
Phase and Period to generate three-phase sine
waves. These sine-wave outputs are the corresponding duty cycles, which are fed to the duty cycle registers
in the MCPWM module. The MCPWM module converts
the duty cycle inputs into modulated square waves,
which drive an external inverter. The inductance of the
motor windings will filter the current from the PWM
output voltages.
DS92003A-page 3
CE003
SUMMARY
This code example document describes a representative project that implements a sinusoidal control of a
BLDC motor using peripherals dedicated to motor control applications. Also, the DSP engine of the dsPIC
digital signal controller was used to perform algorithms
such as a PID control loop. Operational aspects are
described in source-level comments in each file.
DS92003A-page 4
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC, and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
PICMASTER, SEEVAL, SmartSensor and The Embedded
Control Solutions Company are registered trademarks of
Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programming, ICSP, ICEPIC, Linear Active Thermistor,
MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM,
PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo,
PowerMate, PowerTool, rfLAB, rfPICDEM, Select Mode,
Smart Serial, SmartTel, Total Endurance and WiperLock are
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
2005, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
DS92003A-page 5
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://support.microchip.com
Web Address:
www.microchip.com
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
India - Bangalore
Tel: 91-80-2229-0061
Fax: 91-80-2229-0062
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
Austria - Weis
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829
China - Chengdu
Tel: 86-28-8676-6200
Fax: 86-28-8676-6599
India - Pune
Tel: 91-20-2566-1512
Fax: 91-20-2566-1513
France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
China - Fuzhou
Tel: 86-591-8750-3506
Fax: 86-591-8750-3521
Japan - Yokohama
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Korea - Gumi
Tel: 82-54-473-4301
Fax: 82-54-473-4302
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Atlanta
Alpharetta, GA
Tel: 770-640-0034
Fax: 770-640-0307
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
San Jose
Mountain View, CA
Tel: 650-215-1444
Fax: 650-961-0286
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
China - Shunde
Tel: 86-757-2839-5507
Fax: 86-757-2839-5571
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
China - Xian
Tel: 86-29-8833-7250
Fax: 86-29-8833-7256
Malaysia - Penang
Tel: 604-646-8870
Fax: 604-646-5086
Philippines - Manila
Tel: 632-634-9065
Fax: 632-634-9069
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Spain - Madrid
Tel: 34-91-352-30-52
Fax: 34-91-352-11-47
UK - Wokingham
Tel: 44-118-921-5869
Fax: 44-118-921-5820
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Hsin Chu
Tel: 886-3-572-9526
Fax: 886-3-572-6459
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
08/24/05
DS92003A-page 6