AN992

AN992
Sensorless BLDC Motor Control Using dsPIC30F2010
Author:
Stan D’Souza
Technical Fellow
INTRODUCTION
This application note describes how to provide sensorless BLDC motor control with the dsPIC30F2010
Digital Signal Controller. The technique used is based
on another Microchip application note: Using the
dsPIC30F for Sensorless BLDC Control (AN901).
This application note explains how to apply the
dsPIC30F2010 device to the hardware and software
described in AN901, which uses the dsPIC30F6010
device and dsPICDEM™ MC1 Motor Control Development Board. The 80-pin dsPIC30F6010 has 144
Kbytes of Flash Program Memory, 8 Kbytes of RAM
available and abundant I/O.
The 28-pin
dsPIC30F2010, on the other hand, has limited I/O, only
12 Kbytes of Flash program memory and 512 bytes of
RAM. As you can see, the resources are finite.
This application note prescribes changes to the hardware, software and user interface described in AN901
to facilitate the easy transfer of the code to the
dsPIC30F2010 device. You will want to thoroughly
FIGURE 1:
review AN901 for details on BLDC sensorless design
using the dsPIC30F. Functionally, the code does not
change, so all BLDC control functions available and
described in AN901 are still the same.
HARDWARE REQUIRED
You will need the following hardware to implement the
described motor control application:
• PICDEM™ MCLV Development Board (Figure 1)
• Hurst DMB0224C10002 CL B 6403 24 V BLDC
Motor
• 24 VDC Power Supply
You can purchase these items from Microchip as a
complete kit or as individual components. Check the
Development Tools section of the Microchip web site
for ordering information.
HARDWARE MODIFICATIONS
Figure 2 is a simplified block diagram for a Sensorless
BLDC motor control application. This diagram will help
you develop your own hardware, if you so choose, to
drive a sensorless BLDC motor. Schematics for the
PICDEM MCLV board are included in Appendix A.
PICDEM™ MCLV DEVELOPMENT BOARD
© 2005 Microchip Technology Inc.
DS00992A-page 1
AN992
FIGURE 2:
PICDEM™ MCLV BOARD FUNCTIONALITY
dsPIC30F2010
BLDC
PWM3H
PWM3L
PWM2H
PWM2L
PWM1H
PWM1L
FLTA
AN0
AN1
AN2
3-Phase
Inverter
R49
Fault
VDC
R41
R34 R36
IBUS
R44
R52
Demand
VBUS
R63
AN3
AN4
VDC
R64
AN5
Phase Terminal Voltage Feedback
Except for the dsPIC30F2010 device, the basic block
diagram is exactly the same as that used in AN901.
• A pot selects the demand for the speed.
• VBUS voltage is sensed as VDC using resistor
pairs R63/R64. VDC/2 is used as the “zerocrossing” voltage for back EMF sensing.
• Feedback voltage is sensed using resistor pairs
R34/R36, R41/R44 and R49/R52.
• Current feedback is provided through a simple
operational amplifier circuit (U10A)
• Fault input is received through a comparator
circuit (U7D) connected with the current feedback
circuit. The current is sensed using a 0.1 ohm
resistor (R26). The current gain is 11 and the
threshold of the comparator can be adjusted using
pot R60.
You can very easily adjust the values of the resistors to
accommodate the current capabilities of the motor
being used for the application. The motor drive circuit,
on the other hand, is designed to drive a 24V BLDC
motor. You can change the drive requirement of the
motor (refer to the PICDEM™ MCLV Development
Board User’s Guide for details on how to change the
hardware for use with motors greater or less than 24V).
On the low side, the voltage limit is 10V. On the high
side, the voltage limit is 40V. It is important to note that
the heat sink on the IGBTs have very limited heat dissipation, so high power requirements may not be easily
met with the PICDEM MCLV board.
To use the PICDEM MCLV board for this application,
use the jumper settings shown in Table 1 and the motor
connections shown in Table 2.
DS00992A-page 2
TABLE 1:
JUMPER SETTINGS FOR
PICDEM™ MCLV BOARD
Jumper
Sensorless Control
J7, J11, J13
Short between 2-3
J15
Open
J8,J12,J14
Open
J10, J16, J17, J19
Open
TABLE 2:
MOTOR CONNECTIONS
Connector J9
Label
Sensorless Control
M1
Phase C (Red)
M2
Phase A (White)
M3
Phase B (Black)
G
Ground (Green) If available
The colors referenced in Table 2 are as per the Hurst
24V motor available from Microchip. The ground wire is
sometimes not available on some motors.
Once the code is developed and downloaded to the
system, you will need to press switch S2 to start and
stop the motor. The pot marked REF (R14) sets the
demand for the speed. It is rotated clockwise to
increase the speed of the motor.
Due to the limited I/O on the dsPIC30F2010, the LEDs
on the board are not used to signal fault conditions.
Instead, fault conditions are displayed on Windows®
HyperTerminal® on your PC using the serial port.
© 2005 Microchip Technology Inc.
AN992
PROGRAMMING THE dsPIC30F2010
USER INTERFACE
The dsPIC30F2010 can be programmed using the
PICDEM MCLV board. Due to the limited I/O resources
on the dsPIC30F2010, the serial port is shared with the
programming pins. When you are ready to program the
part, DIP switch S4 should have its TAB in the PRGM
direction. When programming is completed, the DIP
switches must be moved to the DEBUG position to execute the code. If the IDC2 is connected to the PICDEM
MCLV board as a debugger, then the connector at J6
should be attached. If, however the ICD2 is being used
as a programmer, then the connector at J6 should be
unplugged from the ICD2 for normal execution.
The user interface is necessary to tune the different
parameters used in the sensorless BLDC motor control
applications. There are 45 user parameters that can be
modified in the applications. For more details on these
parameters, their functions/uses and how to tune them,
refer to the Using the dsPIC30F for Sensorless BLDC
Control (AN901) application note.
The following configuration settings are required for the
applications to work on a PICDEM MCLV board:
Oscillator Source:
Primary Oscillator
Primary Oscillator Mode:
XT w/PLL 8x
Comm Channel Select:
EMUC2 and EMUD2
Other settings can be enabled or disabled as needed,
or modified in the application.
SOFTWARE MODIFICATIONS:
The software has not been modified significantly from
that described in AN901. However, the user interface to
the LCD and the debug routines have been removed.
The LCD interface has been replaced by the Serial
User Interface mentioned in the next section. The User
Interface does add to the code space and will require a
dsPIC30F3010 device during the development stage of
the application.
During the development mode you must set:
#define DEVELOPMODE TRUE
This setting in the def.s file allows for all the conditional statements in the code to automatically enable
the UART and run the user interface mode. Once the
code has been fully developed, you can then select:
In AN901, the user parameters are modified using an
LCD display and key switches. Since an LCD display
is not available on the PICDEM MCLV board, the user
interface has been modified to a 2 wire serial interface.
The new user interface for this application uses the
RS-232 port on the dsPIC30F2010 connected to a
communication
terminal
(e.g.,
Windows
HyperTerminal) running at 19200 Baud.
The communication terminal is then used to change
parameters in the user interface. All the parameters in
AN901 that were set on the PICDEM MC1 Motor Control Development Board using the LCD screen can now
be set through the serial interface.
Table 3 lists the parameter names, abbreviations and
descriptions. A total of 45 control parameters are available for the user interface.
The parameters are categorized by:
• Motor Parameters - parameters that relate to the
motor
• Starting Parameters - parameters that relate to
the starting ramp
• Control Parameters - parameters that relate to
the different PI or PID control parameters used in
the software
• Limit Parameters - parameters that relate to the
various limit settings in the software
• Board Parameters - parameters that relate to the
components on the board and how they interact
with the software
#define DEVELOPMODE FALSE
This setting in the defs.s file disables the serial user
interface and hard codes the parameters to Flash
memory.
To ensure that the code fits into the dsPIC30F2010,
you must use the space optimization option in the C30
compiler options. From the MPLAB Main menu, select
Project>Build Options>Project. When the Build
Options dialog displays, select the MPLAB® C30 tab
and set Categories>Optimization>Optimization level>s
(for space optimized).
Note:
The source code for this application is
available on the Microchip web site
(www.Microchip.com), appended to the
electronic (pdf) version of this application
note.
© 2005 Microchip Technology Inc.
DS00992A-page 3
AN992
TABLE 3:
MOTOR CONTROL PARAMETERS
For This Parameter
Type This Abbreviation
Comment
Motor Parameters
DIRECTION
DD 0 or
DD 1
0 = Forward
1 = Backward
No. Motor Poles
MP <Value>
Number of Motor Poles
Blanking Count
BC <Value>
Windmilling Dem
WD <Value>
Starting Parameters
Lock Pos.1 Time
LP1T <Value>
In 10-msec intervals
Lock Pos.2 Time
LP2T <Value>
In 10-msec intervals
Lock Pos.1 Dem
LP1D <Value>
In PWM duty cycle percentage
Lock Pos.2 Dem
LP2D <Value>
In PWM duty cycle percentage
Ramp Start Speed
RSS <Value>
Ramp Start Speed in RPM
Ramp End Speed
RES <Value>
Ramp End Speed in RPM
Ramp Start Dem
RSD <Value>
In PWM duty cycle percentage
Ramp End Dem
RED <Value>
In PWM duty cycle percentage
Ramp Duration
RD <Value>
In 10 msec intervals
Tolerance Check
TC <Value>
Auto Re-acquire
ARA 0 or ARA 1
0 = disable
1 = enable
Starting Control
SC 0
and SC 1
0 = Voltage Control
1 = Current Control
Acquire Method
AM 0 or
AM 1
0 = Method 1
1 = Method 2
ZeroX Enable Spd
ZXES <Value>
Speed at which zero crossing is enabled
DS00992A-page 4
© 2005 Microchip Technology Inc.
AN992
TABLE 3:
MOTOR CONTROL PARAMETERS (CONTINUED)
For This Parameter
Type This Abbreviation
Comment
Control Parameters
CONTROL MODE
CM 0,
CM 1,
CM 2 or
CM 3
Phase Adv. Enable Spd
PAES <Value>
Phase Adv. Slope
PAS <Value>
Current P Gain
CKP <Value>
Current I Gain
CKI <Value>
Current D Gain
CKD <Value>
Speed P Gain
SKP <Value>
Speed I Gain
SKI <Value>
Voltage Demand
VD <Value>
Volts P Gain
VKP <Value>
Volts I Gain
VKI <Value>
0 = Closed Volts
1 = Closed Current
2 = Open Volts
3 = Open Current
Limit Parameters
Stall Time Limit
STL <Value>
Over Speed Limit
OSL <Value>
Over Volts Limit
OVL <Value>
Over Current Lim
OCL <Value>
Over Speed Limit in RPM
Board Parameters
Current Scale X
CSX <Value>
Current Scale /
CSD <Value>
Volts Scale X
VSX <Value>
Volts Scale /
VSD <Value>
Zero X Level Thd
ZXL <Value>
Acquire Threshld
AT <Value>
Acquire Level Td
AL <Value>
Rotation Timeout
RT <Value>
Pot / for Duty
PDD <Value>
Pot / for Currnt
PDC <Value>
Pot X for Speed
PXS <Value>
Braking Ramp T
BRT <Value>
© 2005 Microchip Technology Inc.
DS00992A-page 5
AN992
USING THE SERIAL USER
INTERFACE
The command set is case sensitive. If you type a
command incorrectly, the message shown in Figure 3
displays.
The user parameters can only be modified during the
standby or reset state of the system. When the motor is
running, the communications terminal displays the
speed and the percentage duty cycle of the PWM.
To get more information about the command set, type
The terminal must be connected to the PICDEM MCLV
board at the RS232 connector (J1) and set to operate
with these parameters:
Bits per second
19200
Data bits
8
Parity
None
Stop bits
1
Flow control
None
FIGURE 3:
INCORRECT COMMAND MESSAGE
FIGURE 4:
COMMAND SET HELP MENU
DS00992A-page 6
?? <Return>
In response, the message shown in Figure 4 prompts
for a more specific request.
To get information about a specific category of commands, type a question mark followed by the letter that
corresponds to the command set category.
© 2005 Microchip Technology Inc.
AN992
Motor Parameters
Motor Parameters are displayed by typing:
?M<Return>
The response message lists the motor parameters and
displays their current value, as shown in Figure 5. To
change any of the parameters, you type the parameter
abbreviation followed by the new value (separated by a
space).
The DIRECTION parameter (DD) uses only two parameter values: ‘0’ or ‘1’.To change the direction of the
motor rotation, you type:
Note that DD is upper case and there is a space
between the parameter abbreviation and the value 1.
The command and its response are shown in Figure 6.
The value has changed from ‘00000’ to ‘00001’ (the
opposite direction).
Suppose you want to change the number of motor
poles from 10 to 8. You would type:
MP<Space>8<Return>
This command and its response are shown in Figure 7.
The value has changed from ‘00010’ to ‘00008’.
DD<Space>1<Return>
FIGURE 5:
MOTOR PARAMETERS
FIGURE 6:
MOTOR DIRECTION COMMAND AND RESPONSE
© 2005 Microchip Technology Inc.
DS00992A-page 7
AN992
FIGURE 7:
MOTOR POLES COMMAND AND RESPONSE
Control Parameters:
The Control Parameters and their current values are
displayed in response to the ‘?C’ command, as shown
in Figure 8.
FIGURE 8:
DS00992A-page 8
To change a control parameter, type the parameter
abbreviation followed by the desired value. For example, if the Speed Integral Gain needs to go from 40 to
200, you would type ‘SKI 200’.
CONTROL PARAMETERS
© 2005 Microchip Technology Inc.
AN992
Starting Parameters
The Starting Parameters fine tune the sensorless starting algorithm and are probably the most often modified
parameters. Because some of the parameters are varied by tens of milliseconds, please note the comments
in Table 3 and carefully review AN901.
FIGURE 9:
STARTING PARAMETERS
© 2005 Microchip Technology Inc.
DS00992A-page 9
AN992
Limit Parameters
The limit parameters are shown in Figure 10.
FIGURE 10:
LIMIT PARAMETERS
Board Parameters
The board parameters are shown in Figure 11. Refer to
AN901 for details on these parameters.
FIGURE 11:
DS00992A-page 10
BOARD PARAMETERS
© 2005 Microchip Technology Inc.
AN992
Run Time Mode
As noted before, the parameters can be viewed in
Standby mode only. During the actual operation of the
motor, the speed of the motor and the percentage Duty
Cycle being used by the motor PWM are constantly
updated, as shown in Figure 12.
FIGURE 12:
RUN TIME DISPLAY OF SPEED AND PWM DUTY CYCLE
Fault Condition
If a fault condition occurs during the starting or operation of the motor, it is reported as shown in Figure 13.
The faults reported include:
•
•
•
•
•
•
•
FAILED TO START
OVER CURRENT
OVER VOLTAGE
HARDWARE TRIP
OVER SPEED
SENSORLESS LOST
STALLED
To reset the fault or stop the motor, you must press S2
on the board. When the system resets, you can edit the
necessary parameters.
FIGURE 13:
FAULT MESSAGE
© 2005 Microchip Technology Inc.
DS00992A-page 11
AN992
CONCLUSION
The 28-pin dsPIC30F2010 is an ideal low-cost solution
to control a sensorless BLDC motor. Using the flexible
serial user interface described in this application note,
you can fine tune the application parameters required
to start and run a sensorless BLDC motor application
as described in detail in AN901.
DS00992A-page 12
© 2005 Microchip Technology Inc.
AN992
APPENDIX A:
FIGURE A-1:
SCHEMATICS
BLDC MOTOR CONTROL BOARD (SHEET 1 OF 2)
© 2005 Microchip Technology Inc.
DS00992A-page 13
DS00992A-page 14
VCC 1
LO 5
COM 4
VB 8
HO 7
VS 6
VCC 1
LO 5
COM 4
VB 8
HO 7
VS 6
VCC 1
LO 5
COM 4
VB 8
HO 7
VS 6
FIGURE A-2:
2 HIN
3 LIN
2 HIN
3 LIN
2 HIN
3 LIN
AN992
BLDC MOTOR CONTROL BOARD (SHEET 1 OF 2)
© 2005 Microchip Technology Inc.
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 Microchip’s 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 Microchip’s 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.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,
WRITTEN OR ORAL, STATUTORY OR OTHERWISE,
RELATED TO THE INFORMATION, INCLUDING BUT NOT
LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE,
MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and
its use. Use of Microchip’s products as critical components in
life support systems is not authorized except with express
written approval by Microchip. No licenses are conveyed,
implicitly or otherwise, under any Microchip intellectual property
rights.
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.
Microchip received ISO/TS-16949:2002 quality system certification for
its worldwide headquarters, design and wafer fabrication facilities in
Chandler and Tempe, Arizona and Mountain View, California in
October 2003. The Company’s quality system processes and
procedures are for its PICmicro® 8-bit MCUs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
© 2005 Microchip Technology Inc.
DS00992A-page 15
WORLDWIDE SALES AND SERVICE
AMERICAS
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
India - New Delhi
Tel: 91-11-5160-8631
Fax: 91-11-5160-8632
Austria - Weis
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark - Ballerup
Tel: 45-4450-2828
Fax: 45-4485-2829
China - Chengdu
Tel: 86-28-8676-6200
Fax: 86-28-8676-6599
Japan - Kanagawa
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
France - Massy
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
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Germany - Ismaning
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
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
China - Hong Kong SAR
Tel: 852-2401-1200
Fax: 852-2401-3431
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 - Qingdao
Tel: 86-532-502-7355
Fax: 86-532-502-7205
Malaysia - Penang
Tel:011-604-646-8870
Fax:011-604-646-5086
Philippines - Manila
Tel: 011-632-634-9065
Fax: 011-632-634-9069
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
England - Berkshire
Tel: 44-118-921-5869
Fax: 44-118-921-5820
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
Taiwan - Hsinchu
Tel: 886-3-572-9526
Fax: 886-3-572-6459
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
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
04/20/05
DS00992A-page 16
© 2005 Microchip Technology Inc.