You are on page 1of 33

3-Phase BLDC Motor Control with Hall Sensor

V1.3 - Dec 22, 2006 English Version

19, Innovation First Road Science Park Hsin-Chu Taiwan 300 R.O.C. Tel: 886-3-578-6005 Fax: 886-3-578-4418 E-mail: mcu@sunplus.com

http://www.sunplusmcu.com

http://mcu.sunplus.com

3-Phase BLDC Motor Control with Hall Sensor

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLOGY CO. is believed to be accurate and reliable. However, SUNPLUS No TECHNOLOGY CO. makes no warranty for any errors which may appear in this document. Contact SUNPLUS TECHNOLOGY CO. to obtain the latest version of device specifications before placing your order. responsibility is assumed by SUNPLUS TECHNOLOGY CO. for any infringement of patent or other rights of third parties which may result from its use. In addition, SUNPLUS products are not authorized for use as critical components in life support systems or aviation systems, where a malfunction or failure of the product may reasonably be expected to result in significant injury to the user, without the express written approval of Sunplus.

Sunplus Technology Co., Ltd.

PAGE 1

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Revision History
Revision V1.3 V1.2 Date 2006/12/22 2006/05/25 By Li Jing Li Jing Proofreading Translate 3-Phase BLDC Motor Control with Hall Sensor V1.2, Chinese version Remark Page Number(s)

Sunplus Technology Co., Ltd.

PAGE 2

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Table of Content
PAGE

1 Operation Principle ............................................................................................................................ 4 1.1 Summary of BLDC......................................................................................................................... 4 1.2 Basic Principle ............................................................................................................................... 4 1.3 Driving for BLDC............................................................................................................................ 5 1.4 Speed Regulation by PWM Control............................................................................................... 6 2 Hardware Design ................................................................................................................................ 8 2.1 SPMC75F2413A Application Circuit ............................................................................................ 10 2.2 IPM Module and Driver................................................................................................................ 10 2.3 Position Detecting........................................................................................................................ 13 3 PID Controller ................................................................................................................................... 14 4 Software Design................................................................................................................................ 17 4.1 Software Description ................................................................................................................... 17 4.2 Source File .................................................................................................................................. 17 4.3 DMC Interface ............................................................................................................................. 17 4.4 Subroutines ................................................................................................................................. 17 5 Demo Listing..................................................................................................................................... 20 5.1 Demo ........................................................................................................................................... 20 5.2 Main Process Description............................................................................................................ 21 5.3 ISR Description............................................................................................................................ 22 6 MCU Resource .................................................................................................................................. 23 7 Test..................................................................................................................................................... 24 7.1 Control Signals ............................................................................................................................ 24 7.2 Speed Adjustment........................................................................................................................ 26 7.3 Current Waveform ....................................................................................................................... 27 7.4 System Response ....................................................................................................................... 28 8 Reference .......................................................................................................................................... 32

Sunplus Technology Co., Ltd.

PAGE 3

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

1 Operation Principle
1.1 Summary of BLDC
Since current BLDC has substituted the electrical commutator for the mechanical one, it conquered the disadvantages of noise, spark, electromagnetic disturbance, short lifetime, etc. Now BLDC is provided with advantages of simple structure, dependable operation and easy maintenance as AC motor does, as well as advantages of high efficiency, no excitation cost and functional speed regulation as traditional DC motor does. Thus, it is widely used in various fields of industrial control presently.

1.2 Basic Principle


Usually, motor stator winding is three-phase symmetry star connection type which is similar to three-phase asynchronous motor. Since motor rotor is assembled with magnetized permanent magnet, in order to detect rotor polarity, a position sensor is built in motor. Motor driver, consisting of inverters and integrated circuit, is designed for: receiving start/stop/brake signals to control the motor operations; capturing position and forward/backward rotate signals to control the transistors state and make BLDC generate the continuous torque; receiving speed command and speed feedback signal to control and adjust rotate speed; protecting BLDC. The basic principle of BLDC is shown as Figure 1-1.

Figure 1-1 BLDC Control Principle

The main circuit is a typical voltage source AC-DC-AC converter. The inverters supplies a symmetrical rectangular voltage with a permanent amplitude & frequency (5 ~24 KHz). Alternating the N-S pole of permanent magnet makes the position sensor generate H1, H2 and H3 waveform with 120 phase-different, which forms six condition codes: 010, 011, 001, 101, 100, and 110. Via some logic components, these codes control to conduct V6 V1, V5 V6, V4 V5, V3 V4, V2 V3, V1 V2 respectively, that is, load bus of U - >V, W - >V, W - >U, V - >U, V - >W, U - >W with DC voltage in turns. Therefore, each time the rotor revolves a pole-pair, the transistors V1, V2, V3, V4, V5 and V6 are conducted one
Sunplus Technology Co., Ltd. PAGE 4 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

by one according to their condition code and the magnetic field produced by stator winding rotates 60 electrical degree for that only two phases winding are loaded. Consequently, the rotor rotates 60 electrical degrees. The new position signal of rotor will be captured via the sensor to form a new set of condition codes, thus to drive the corresponding transistors, which makes the rotor rotate 60 electrical degrees further. Circulating unceasingly, BLDC will generate a continuous torque to rotate the load continuously.

1.3 Driving for BLDC


This application is designed for driving the IGBT built in IPM (Intelligent Power Module) using 120-degree waveform, thus to drive BLDC. The signals of driving IGBT are generated according to the motor position. The feedback position signal is encoded as six condition codes: 010, 011, 001, 101, 100, and 110, which can determine the assignment of IGBT driving signal. Here we add PWM signal to the upper phase and active voltage to the lower one so that we can vary the output voltage by changing the PWM duty. The timing of driving assignment and position signals are shown as Figure 1-2.

Figure 1-2 Driving and Position Signals

Where, the upper phase transistors V1, V3, V5 and the lower phase transistors V2, V4, V6 consist of a three-phase full-bridge circuit which controls the current direction of U, V, W phases which are connected as shown in Figure 1-1. H1, H2 and H3 are hall signals.
Sunplus Technology Co., Ltd. PAGE 5 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

If the motor is driven in forward direction as shown in Figure 1-2, the transistors are conducted as the sequence: 010 (H3 H2 H1) V6-V1, 011 (H3 H2 H1) V5-V6, 001 (H3 H2 H1) V4-V5, 101 (H3 H2 H1) V3-V4, 100 (H3 H2 H1) V2-V3, 110 (H3 H2 H1) V1-V2. Accordingly, based on the position signal, the conducting sequence of transistors when the motor rotates in backward direction can be obtained as: 001 (H3 H2 H1) V1-V2, 011 (H3 H2 H1) V2-V3, 010 (H3 H2 H1) V3-V4, 110 (H3 H2 H1) V4-V5, 100 (H3 H2 H1) V5-V6, and 101 (H3 H2 H1) V6-V1. The commutate timing should be considered carefully; otherwise, BLDC will vibrate or doesnt work, or will have a larger current with a wrong waveform. The control signals mentioned above control the state of transistors, thus make the current flow into the three-phase coil (U, V, W) in turn and accordingly generate rotating magnetic field within BLDC. Figure 1-3 shows the current timing of each phase.

Figure 1-3 Current Timing

1.4 Speed Regulation by PWM Control


The inverters are based on the PWM modulation, which means that they can vary the output voltage fundamental with different PWM duty, thus to control the motor speed. There are totally 4 methods to add PWM-based control: upper phase, lower phase, pre-sixty degree and post-sixty degree as shown in Figure 1-4.

Sunplus Technology Co., Ltd.

PAGE 6

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

(a) Upper Phase PWM

(b) Lower Phase PWM

(c) Pre-sixty Degree PWM

(d) Post-sixty Degree PWM


Figure 1-4 Commutate Timing When Active High
Sunplus Technology Co., Ltd. PAGE 7 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

2 Hardware Design
BLDC is widely applied in various technology fields with different control methods. This application adopts SPMC75F2413A chip equipped with a 16-bit TPM (Timer PWM Mode, TPM) timer and IPM (Intelligent Power Module) via basic driving algorithm to drive and adjust rotate speed of three-phase winding BLDC The hardware circuit mainly contains power supply, control system, IPM and the corresponding driver, position sensors and RS232 communication module. The hardware block diagram and schematic are shown in Figure 2-1 and Figure 2-2 respectively.

Figure 2-1 System Block Diagram

In the following, we will illustrate IPM and the corresponding driver, position sensors and RS232 communication module in detail.

Sunplus Technology Co., Ltd.

PAGE 8

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

VDC

VDC

31

IC8 P VUFS NC VUFB VP1 NC UP VVFS NC VVFB VP1 NC VP VWFS NC VWFB VP1 NC WP NC VNO UN VN WN FO CFO CIN VNC VN1 NC NC

IPM-MU IPM-MU 32

CON3 TO-MOTOR 1 2 3 C36 0.22uF/630VDC

IPM-MV IPM-MV 33

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

VVFS VVFB

IC9 PC817 UP

IC10 PC817 VP

1 2 3 4 5 6

VUFS VUFB P+15V UP C31 0.22uF/50V

Drive
+5V R28 330

P+5V

P+5V

P+5V

R25 1K

C28 0.22uF +5V

R29 330

R26 1K

C29 0.22uF +5V

R30 330

R27 1K IC11 PC817

C30 0.22uF

P+15V VP VWFS VWFB P+15V WP N UN VN WN FO CIN C41 0.022uF/50V C43 LXZ-33uF/35V P+15V +5V + C37 0.22uF/50V R175 10K P+5V C35 0.22uF/50V S1

R31 10K

2 Q2 2N3904 R34 3.9K C32 100pF

S3

R32 10K

2 Q3 2N3904 R35 3.9K C33 100pF

S5

R33 10K

32

32

32

WP

2 Q4 2N3904 R36 3.9K C34 100pF

IPM-MW IPM-MW 34

R37 3.9K

R38 3.9K

R39 3.9K

P+5V

P+5V

P+5V

R46 BRP58F0.082-K

PS21563 R53 CIN 1.8K

C42 0.22uF/50V

IC12 PC817 UN S6 R48 10K

IC13 PC817 VN S2 R49 10K

35

R43 330

R40 1K

C38 0.22uF +5V

R44 330

R41 1K

C39 0.22uF +5V

3 R42 1K IC14 PC817

R45 330

C40 0.22uF

S4 C47 3300pF

R47 10K

32

32

32

WN

2 Q5 2N3904 R50 3.9K C44 100pF

2 Q6 2N3904 R51 3.9K C45 100pF

2 Q7 2N3904 R52 3.9K C46 100pF

R54 3.9K

R55 3.9K

R56 3.9K

IPM
VUFB IC15 IC4A 3 74HC00_0 4 5 74HC00_0 IC4B 6 +5V FOIN1 MOTOR1-UP MOTOR1-VP MOTOR1-WP MOTOR1-UN FOIN1 MOTOR1-VN MOTOR1-WN MOTOR1-UP MOTOR1-VP MOTOR1-WP MOTOR1-UN MOTOR1-VN MOTOR1-WN 3 4 7 8 13 14 17 18 11 1 20 1D 2D 3D 4D 5D 6D 7D 8D LE OE VCC 74HC373 IC4D 11 FO 2 74HC00_0 3 P+5V R59 1K 1 4 IC16 PC817 1Q 2Q 3Q 4Q 5Q 6Q 7Q 8Q 2 5 6 9 12 15 16 19 S1 S3 S5 S4 S6 S2 +5V VCC VUFS C55 0.1uF VVFB R57 5.1K SCFO VWFB C49 1000pF C54 0.22uF/50V + 2 VVFS + 2 C50 0.22uF/50V + C48 LXZ-33uF/35V D9 MUR160 1 2 D8 MUR160 1 R58 10 P+15V

DRV-EN

DRV-EN

1 2

R60 1K

R61 P+15V 10

C52 0.22uF/50V

C51 LXZ-33uF/35V D10 MUR160 1

R62 P+15V 10

IC4C 8 74HC00_0

12 13

Protect

SCFO

10

VWFS

C53 LXZ-33uF/35V

SPMC75F2413A
C95 1 2 20pF C96 XTAL1 HCUR VBUS AVCMD TSEN5 TSEN4 TSEN3 TSEN2 TSEN1 Y1 6M XTAL2 AVSS +5VA 2 +5V 1 C102 0.1uF 2 1 1 IC29 C1+ VCC

UART
16 +5V C103 0.1uF 2 6 1 C105 0.1uF T1OUT R1IN 2 1 6 2 7 3 8 4 9 5 CONNECTOR DB9

D20 1N4148 1

R140 10K RESET

3 4

C1C2+

Vs+ Vs-

P4

20pF HCUR VBUS AVCMD TSEN5 TSEN4 TSEN3 TSEN2 TSEN1 XTAL2 XTAL1 VDDL LED4 LED3 LED2 LED1 IOD7 IOD6 IOD5 IOD4 S1 SW

1 C104 0.1uF 2 UART-TXD

5 11 10 12 9

C2T1IN T2IN R1OUT R2OUT MAX232

GND T1OUT T2OUT R1IN R2IN

15 14 7 13 8

T1OUT R1IN

1 C94 0.1uF 2

UART-RXD

U1

HALL-U2 HALL-V2 HALL-W2 FOIN2 FAN-UP FAN-VP FAN-WP FAN-UN FAN-VN FAN-WN

TEST ICECLK ICESDA IOD0/ICECLK IOD1/ICESDA IOD2 RESET IOD3 NC NC IOB0/TIO3F/W1N IOB1/TIO3E/V1N IOB2/TIO3D/U1N IOB3/TIO3C/W1 IOB4/TIO3B/V1 IOB5/TIO3A/U1 IOB6/FTIN1 IOB7/OL1 IOB8/TIO0C IOB9/TIO0B IOB10/TIO0A IOB11/SCK IOB12/SDI/RXD1 IOB13/SDO/TXD1

UART-RXD UART-TXD EMGSTOP INFRAD BUZZER HALL-U2 HALL-V2 HALL-W2 OLIN2 FOIN2 FAN-UP FAN-VP FAN-WP FAN-UN FAN-VN FAN-WN

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

IOC0/RXD2 IOC1/TXD2 IOC2/EXINT0 IOC3/EXINT1 IOC4/BZO IOC5/TIO1A IOC6/TIO1B IOC7/TIO1C IOC8/OL2 IOC9/FTIN2 IOC10/TIO4A/U2 IOC11/TIO4B/V2 IOC12/TIO4C/W2 IOC13/TIO4D/U2N IOC14/TIO4E/V2N IOC15/TIO4F/W2N

NC IOD11 IOD10 IOD9 IOD8 IOD7 IOD6 IOD5 IOD4 VSSL XTAL2 XTAL1 VDDL AVDD AVSS VEXTREF IOA7/AN7 IOA6/AN6 IOA5/AN5 IOA4/AN4 IOA3/AN3 IOA2/AN2 IOA1/AN1 IOA0/AN0

64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41

SPMC75F2413A - QFP80

VSS VDD IOA15/ADCTRG IOA14/TCLKD IOA13/TCLKC IOA12/TCLKB IOA11/TCLKA IOA10/TIO2B IOA9/TIO2A IOA8 IOD15 IOD14 IOD13 IOD12 IOB15 IOB14

40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25

SOFT-RELAY +5V ACI-CLKD ACI-CLKC ACI-CLKB ACI-CLKA DIR-VALVE ACZVC ACZVC STU-LED STEP-BN STEP-B STEP-AN STEP-A MPSTE DRV-EN DRV-EN

SOFT-RELAY

+5V R117 MHALL-U 3.3K 3 R118 2.2K 2 Q17 2N3904 1 C79 0.1uF +5V +5V + C98 220uF/16V R122 MHALL-V 3.3K 3 R123 2.2K 2 C82 0.1uF +5V +5V R129 3.3K MHALL-W Q19 2N3904 1 R131 2.2K 2 C85 0.1uF +5V CON6 1 2 3 4 5 HALL SENSOR

ProbeEN ProbeSCL ProbeSDA SEG4 SEG3 SEG2 RESET SEG1

MOTOR1-WN MOTOR1-VN MOTOR1-UN MOTOR1-WP MOTOR1-VP MOTOR1-UP FOIN1 OLIN1 HALL-W1 HALL-V1 HALL-U1 MPCLK MISO MOSI

VDDL +

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

C93 0.1uF

C92 10uF/16V

+5VA

FB1 60_ohm_3A_1206 1206 + C97 220uF/16V 1206 AVSS FB2 60_ohm_3A_1206 R150 220

MOTOR1-WN MOTOR1-VN MOTOR1-UN MOTOR1-WP MOTOR1-VP MOTOR1-UP FOIN1

HALL-W1 HALL-V1 HALL-U1

C99 0.1uF

C100 0.1uF

Q18 2N3904 1

R148 100 +5V 2 D21 3.3V C101 0.1uF ProbeEN ProbeSCL ProbeSDA R149 200K

CON8 1 2 3 4 5 Probe conn 1 STU-LED 2

D22 1 LED

HALL

SOFT-RELAY P1 N ZNR1 15G471K F1 CON11 1 2 3 VAC input 10A ZNR3 15G471K C19 X1-0.22uF/250VAC L1 Choke ZNR2 15G471K

SOFT-RELAY +5V 1K R19 Q1 2N3904 1 2 2

VDC

VDC

1 D28 P6KE200A

T2

10

D27

2 C110 + 470uF/25V

L2 3.3uH P+18V L4 3.3uH +12V + C115 470uF/25V C111 + 470uF/25V

MUR160 R165 1M RLY 1 6 1 3 ROUT 1 R167 910K 9 7 D29

EARTH

22

3 D30 MUR160 4 D32 C116 0.1uF 2 1N4148 1 5

2 +

D5 1N4148 3 1

MUR160 6

L5 100uH C114 470uF/25V R166 0

TR-10

C18 Y 2-2200pF/250VAC C20 X1-0.22uF/250VAC C22 Y 2-2200pF/250VAC

RT1 G6B-1174P-US

R168 470 4 1 PC817 IC34 3 IC35 TOP234P 4 3 R171 3.3K C120 0.1uF 2

C21 KH-103K/250VAC

PTC SOUT 1 5

R170 680

R169 39.2K

M VDC 1 VDC

ROUT

T1 CT

D C

1 C121 33uF/35V + R173 10

S S S S

TL431 IC36

R172 10K

CT2 CT1 SOUT

4 -

+ 3 DB1 GBU6K 2 C24 224K/630VDC

C23 JACK-470uF/400V

R20 200K,1/2W

ZNR4 15G471K C122 KX-2200pF/250VAC

2 3 7 8

Switching Power Supply


+5V VCC L3 100uH

+5V

C25 Y 2-2200pF/250VAC

+5V/P+15V/P+5V power
+12V 1 5

IC32 SI-8050S VIN SS SWOUT GND VOS 2 4 D31 1N5822 1 2

ROUT R23 20K

D6 1N4148

2 2 D7

R22 470 1 4

R21 10K ACZVC IC7 PC817 2 3 C26 100pF IC33 7815 VI ACZVC

C112 470uF/35V

C113 0.1uF

SOUT

R24 200K

C27 0.1uF 1

1N4148

P+18V

VO GND

R174 51, 1W P+15V P+15V

IC37 78L05 VI GND VO

P+5V

EMI

C117 47uF

C118 0.1uF

C119 0.1uF

C124 47uF

C123 0.1uF

C125 0.1uF

Figure 2-2 Hardware Schematic


Sunplus Technology Co., Ltd. PAGE 9 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

2.1 SPMC75F2413A Application Circuit


The SPMC75F2413A is the embedded 16-bit micro-controller, designed for inverter-fed motor driver, power electronics, home appliance and car fan control system, etc. Figure 2-3 shows the hardware schematic of SPMC75F2413A.

Figure 2-3 SPMC75F2413A Hardware Block Diagram

Connecting the embedded In-Circuit-Emulation circuit of SPMC75F2413A via Probe can facilitate the development for user, accordingly improve the production efficiency and reduce time to market.

2.2 IPM Module and Driver


IPM (Intelligent Power Module) product is designed and developed with the advantages of reduced design, development and manufacturing costs as well as increased system reliability through self protection circuits (such as over-current, over-voltage, and over-temperature circuits) . It also supplies a solution for users to drive low-power BLDC. Figure 2-4 shows IPM electrical connections.

Sunplus Technology Co., Ltd.

PAGE 10

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

VDC

VDC

31

IC8
P VUFS NC VUFB VP1 NC UP VVFS NC VVFB VP1 NC VP VWFS NC VWFB VP1 NC WP NC VNO UN VN WN FO CFO CIN VNC VN1 NC NC

IPM-MU

1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24 25 26 27 28 29 30

VUFS

VUFB
P+15V
UP

IPM-MU

32

VVFS
VVFB

C31 0.22uF/50V

CON3 TO-MOTOR
1 2 3
C36 0.22uF/630VDC

IPM-MV
IPM-MV

P+15V
VP
C35 0.22uF/50V

33

VWFS

VWFB
P+15V
WP

IPM-MW
IPM-MW

P+5V

34

N UN VN WN FO

C37 0.22uF/50V

R175 10K

CIN

C41 0.022uF/50V
C43 LXZ-33uF/35V
P+15V

R46 BRP58F0.082-K

PS21563

C42 0.22uF/50V

R53
CIN

1.8K

C47 3300pF

Figure 2-4 IPM Electrical Connections

To protect MCU, electrical isolation is done between IPM and MCU with HVDC (High Voltage Direct Current) which improves the stability and reliability of system. Figure 2-5 shows the electrical diagrams via optical isolating the drive between IPM and MCU. Where: IC8: IPM PS21563

C31, C35, C37: bootstrap capacitor 0.22uF/50V C41: C42: C43: C47: R46: malfunction pulse width timing capacitor (ceramic material) 0.022uF/50V decoupling capacitor 0.22uF/50V power supply filter capacitor 33uF/35V short-circuit sampling RC filter capacitor 3300pF short-circuit current limiting resistance 0.082

Sunplus Technology Co., Ltd.

PAGE 11

35

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

P+5V

P+5V

P+5V

IC9 PC817 UP

IC10 PC817 VP

+5V

R28 330

R25 1K

C28 0.22uF +5V

R29 330

R26 1K

C29 0.22uF +5V

R30 330

R27 1K IC11 PC817

C30 0.22uF

S1

R31 10K

2 Q2 2N3904 R34 3.9K C32 100pF

S3

R32 10K

2 Q3 2N3904 R35 3.9K C33 100pF

S5

R33 10K

32

32

32

WP

2 Q4 2N3904 R36 3.9K C34 100pF

R37 3.9K

R38 3.9K

R39 3.9K

P+5V

P+5V

P+5V

IC12 PC817 UN

IC13 PC817 VN

+5V

R43 330

R40 1K

C38 0.22uF +5V

R44 330

R41 1K

C39 0.22uF +5V

3 R42 1K IC14 PC817

R45 330

C40 0.22uF

S4

R47 10K

2 Q5 2N3904 R50 3.9K C44 100pF

S6

R48 10K

2 Q6 2N3904 R51 3.9K C45 100pF

S2

R49 10K

32

32

32

WN

2 Q7 2N3904 R52 3.9K C46 100pF

R54 3.9K

R55 3.9K

R56 3.9K

Figure 2-5 Optical Isolate the Drive Between IPM and MCU

Where, OC (Optical Coupler) must be connected to different power supplies in its two sides to implement electrical isolation. It is recommended to adopt quick OC, however, when the carrier wave frequency is not required too high, PC817/TLP521 OC can also be considered to reduce the cost. Additionally, the ability of the IPM to self protect in fault situations is critical when MCU runs abnormally. Therefore, a protect lock is specially designed into hardware circuit. Once an error is detected, the driving signal sent to IPM will be cut off immediately and the hardware will request for IRQ to MCU at the same time. Upon eliminating the error, MCU enables the signal output bit to run IPM again. Figure 2-6 shows the hardware protection circuit.
IC15 IC4A 3 74HC00_0 4 5 74HC00_0 IC4B 6 +5V FOIN1 MOTOR1-UP MOTOR1-VP MOTOR1-WP MOTOR1-UN FOIN1 MOTOR1-VN MOTOR1-WN MOTOR1-UP MOTOR1-VP MOTOR1-WP MOTOR1-UN MOTOR1-VN MOTOR1-WN 3 4 7 8 13 14 17 18 11 1 20 1D 2D 3D 4D 5D 6D 7D 8D LE OE VCC 74HC373 IC4C 8 74HC00_0 IC4D 11 FO 2 74HC00_0 3 P+5V R59 1K 1 4 IC16 PC817 1Q 2Q 3Q 4Q 5Q 6Q 7Q 8Q 2 5 6 9 12 15 16 19 S1 S3 S5 S4 S6 S2 +5V

DRV-EN

DRV-EN

1 2

R60 1K

R57 5.1K SCFO

9 SCFO 10

12 13

C49 1000pF

Figure 2-6 Hardware Protection Circuit

Where, IC15: 74HC373; IC4: 74HC00.

Sunplus Technology Co., Ltd.

PAGE 12

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

2.3 Position Detecting


Since commutate timing of BLDC depends on rotor position which determines the next excited phase, it is important to detect the current rotor position for driving BLDC. This application selects the BLDC integrated with Hall sensor as shown in Figure 2-7.
+5V
R117
MHALL-U

R118 2.2K

3.3K
3

Q17 2N3904
1

2
C79 0.1uF

+5V
R122
MHALL-V
R123 2.2K

+5V
CON6
1 2 3 4 5

3.3K

Q18 2N3904
1

2
C82 0.1uF
+5V

HALL SENSOR

R129 3.3K MHALL-W

R131 2.2K
2

Q19 2N3904
1

C85 0.1uF

Figure 2-7 Hall Sensor

Sunplus Technology Co., Ltd.

PAGE 13

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

3 PID Controller
The PID controller is commonly used to adjust speed. It receives signals from sensors and computes corrective action to the actuators from a computation based on the error (Proportion), the sum of all previous errors (Integral) and the rate of change of the error (Derivative). The mathematical model of the PID controller can be represented as:

u(t ) = Kp[e(t ) +
Where: u(t) e(t)

1 t de(t ) 0 e(t )dt + Td dt ] Ti

(Formula 3-1)

Output of PID controller Input of PID controller, which is the error between the desired input value and the actual output value, so called error signal. Proportional gain Integral time, also called integral gain Derivative time, also called derivative gain

Kp Ti Td

The mathematical model of the PID controller consists of Proportional Response, Integral Response and Derivative Response which are described as follows: 1. Proportional Response The proportional component can be expressed as Kp*e(t). In PID controller, the effect of controlling error depends on the proportional gain (Kp). In general, increasing the proportional gain will increase the speed of the control system response and reduce the steady-state error. However, if the proportional gain is too large, the system will begin to oscillate and become unstable. Thus, Kp must be suitably selected to keep the system stable and reduce the rise time and steady-state error. 2. Integral Response

Kp t e(t )dt . The integral component can be expressed as Ti 0


From the expression shown above, we can see that the integral component sums the error term over time. The result is that even a small error term will cause the integral component to increase slowly. The integral response will continually increase over time unless the error is zero, so the effect is to drive the Steady-State error to zero. But the integral control will reduce the speed of the overall control system response and increase the overshoot. Increasing the integral gain (Ti) will cause the integral component to accumulate weakly and reduce the overshoot, thus it will make system not oscillate during the rising time, therefore improve its stability. However, it will slow the
Sunplus Technology Co., Ltd. PAGE 14 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

process of eliminating Steady-State error. Reducing Ti will strengthen the accumulation of integral component and shorten the time of eliminating error, but it will make the system oscillate. So Ti should be selected according to the practical needs. 3. Derivative Response The derivative component can be expressed as

Kp * Td

de(t ) dt .

The effect of derivative component depends on the derivative time constant (Td). In general, the larger Td, the better the effect to restrain the change of e(t) and vice versa. Thus, to select Td properly can make the derivative component better meets the system requirement. The appearance of computer makes it easy to perform PID control by software to realize the control of Formula 3-1 is called digital PID control. Since software control method uses sampling, which calculates the control signals based on the error at the sampling point, the signal cannot be output serially as analog control method does. Therefore, the integral and derivative components must be discrete.

u ( k ) = Kp[ e( k ) +
Where: K Uk ek

T k e( k ) e( k 1) ] e( j ) + Td Ti j =1 T

(Formula 3-2)

Sampling number, k=0, 1, 2 Output value sampling at the K times Error sampling at the K times Accumulative error sampling from the first time to the k times Sampling period

e( j )
j =1

In Formula 3-2, make e( k ) = e( k ) e( k 1) Thus:

u ( k ) = Kp[e( k ) +

T k Td e( j ) + T e(k )] Ti j =1

(Formula 3-3)

In the above formula, let Ki = Kp / Ti , Kd = Kp * Td Thus:

u ( k ) = Kp* e( k ) + Ki * T e( j ) +
j =1

Kd e ( k ) T

(Formula 3-4)

Sunplus Technology Co., Ltd.

PAGE 15

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

To avoid calculating

e( j )
j =1

(the sum of errors), the recursion formula ( u ( t ) ) of

increment PID algorithm is instead in practice where u ( k ) = u ( k ) u ( k 1) . Since

u ( k - 1) = Kp* e( k 1) + Ki * T e( j ) +
j =1

k 1

Kd e( k 1) T

(Formula 3-5)

And

e( k ) = e( k ) e( k 1) e( k 1) = e( k 1) e( k 2)
Thus:

u( k ) = Kp[e( k ) e( k 1)] + Ki * T * e( k ) +

Kd [e( k ) 2e( k 1) + e( k 2)] T


(Formula 3-6)

Formula 3-6 can also be transformed as:

u ( k ) = Kp{[e( k ) e( k 1)] +

T Td e( k ) + [e( k ) 2e( k 1) + e( k 2)]} Ti T


(Formula 3-7)

A closed loop control system puts the regulator under pure proportion function, then changes the proportional gain from small to large to make the system oscillate continuously. The current proportional gain is called the critical gain Ku and the time interval between two neighboring peaks is called critical oscillation period Tu. Based on Z-N tuning method:

T = 0.1Tu Ti = 0.5Tu Td = 0.125Tu


Thus:

u( k) = Kp[2.45e(k ) 3.5e(k 1) + 1.25e(k 2)]


Obviously, the constant Kp is easy to be corrected using above formula.

(Formula 3-8)

Sunplus Technology Co., Ltd.

PAGE 16

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

4 Software Design
4.1 Software Description
This application is designed for driving BLDC using 120-degree upper phase PWM waveform via hall sensor and adjusting motor speed by PID controller. Here we use SPMC75F2413A as an example for demonstration purpose.

4.2 Source File


File Name Function Initialize parameters for driving BLDC, monitor BLDC running status (which is also performed in interrupt subroutine) Start up, run, protect BLDC and adjust its speed Functions for driving BLDC DMC communication program Type

Main ISR Spmc75 _BLDC_V100 Spmc75_dmc_lib_V100.lib

C C lib lib

4.3 DMC Interface


Speed1_Cmd: Speed1_Now: User_R0: User_R1: Set the rotate speed of motor Feedback the current rotate speed of motor Current value in P_TMR3_TGRA Error between the desired speed and the actual speed

Motor 1 Start and Motor 1 Stop: Start/Stop the motor

4.4 Subroutines
Spmc75_System_Init ( )
Prototype Description Input Arguments Output Arguments Head File Library File Note void Spmc75_System_Init(void) Initializations for I/O, PDC, MCP, CMT, Fault, PID and DMC None None Spmc75_BLDC.h Spmc75_BLDC_V100 Initialize the resources occupied: PDC: Timer0; MCP, Fault: Timer3; CMT: CMT0; I/O enable: IOB14; DMC communication interface: UART2 (IOC0-RXD/IOC1-TXD)

Sunplus Technology Co., Ltd.

PAGE 17

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Example

Spmc75_System_Init();

BLDC_Motor_Startup ( )
Prototype Description Input Arguments Output Arguments Head File Library File Note Example void BLDC_Motor_Startup (void) BLDC start-up ISR None None Spmc75_BLDC.h Spmc75_BLDC_V100 Call this subroutine when BLDC starts up or runs at quite a lower speed. It is recommended to call it in TCV interrupt of IRQ1 BLDC_Motor_Startup();

BLDC_Motor_Normalrun ( )
Prototype Description Input Arguments Output Arguments Head File Library File Note Example void BLDC_Motor_Normalrun (void) BLDC running ISR None None Spmc75_BLDC.h Spmc75_BLDC_V100 Call this subroutine in PDC interrupt of IRQ1 to keep BLDC run normally (including position detection, commutation and speed calculation). BLDC_Motor_Normalrun ();

BLDC_Motor_Actiyator ( )
Prototype Description Input Arguments Output Arguments Head File Library File Note void BLDC_Motor_Actiyator(void) BLDC speed control including charging IPM, moving filter, PID adjustment and PWM amplitude limiting. None None Spmc75_BLDC.h Spmc75_BLDC_V100 This subroutine is critical to adjust BLDC speed. It is recommended to call this subroutine periodically using timer interrupt (512Hz). The calling frequency is determined by the highest speed of motor. BLDC_Motor_Actiyator ();

Example

Sunplus Technology Co., Ltd.

PAGE 18

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

BLDC_Run_Service ( )
Prototype Description Input Arguments Output Arguments Head File Library File Note void BLDC_Run_Service(void) Monitor BLDC running status None None Spmc75_BLDC.h Spmc75_BLDC_V100 This subroutine responds for detecting and receiving the start-up/stop command, which can be called in main loop or timer interrupt within 10KHz. BLDC_Run_Service();

Example

IPM_Fault_Protect ( )
Prototype Description Input Arguments Output Arguments Head File Library File Note void IPM_Fault_Protect(void) External fault protection None None Spmc75_BLDC.h Spmc75_BLDC_V100 This subroutine which must be called by IRQ0, is designed for protecting BLDC. Once an external fault input signal occurs, interrupt will generate when the output pins are set to high-resistance state. IPM_Fault_Protect();

Example

Sunplus Technology Co., Ltd.

PAGE 19

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

5 Demo Listing
5.1 Demo
/*=============================================*/ // Application Note /*=============================================*/ #include "Spmc75_regs.h" #include "Spmc_typedef.h" #include "unspmacro.h" #include "Spmc75_BLDC.h" main() { P_IOA_SPE->W = 0x0000; P_IOB_SPE->W = 0x0000; P_IOC_SPE->W = 0x0000; Spmc75_System_Init(); while(1) { BLDC_Run_Service(); NOP(); } // Spmc75 system initialization

// Status Monitor

} //================================================================= // Description: IRQ0 interrupt source is XXX,used to XXX // Notes: Error Protection //================================================================= void IRQ0(void) __attribute__ ((ISR)); void IRQ0(void) { IPM_Fault_Protect(); } //================================================================= // Description: IRQ1 interrupt source is XXX,used to XXX // Notes: BLDC start up and running service //================================================================= void IRQ1(void) __attribute__ ((ISR)); void IRQ1(void) { /*=============================================================*/ // Position detection change interrupt /*=============================================================*/ if(P_TMR0_Status->B.PDCIF && P_TMR0_INT->B.PDCIE) { BLDC_Motor_Normalrun(); } /*=============================================================*/ // Timer Counter Overflow
Sunplus Technology Co., Ltd. PAGE 20 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

/*=============================================================*/ if(P_TMR0_Status->B.TCVIF && P_TMR0_INT->B.TCVIE) { BLDC_Motor_Startup(); } P_TMR0_Status->W = P_TMR0_Status->W; } //================================================================= // Description: IRQ6 interrupt source is XXX,used to XXX // Notes: DMC receives ISR //================================================================= void IRQ6(void) __attribute__ ((ISR)); void IRQ6(void) { if(P_INT_Status->B.UARTIF) { if(P_UART_Status->B.RXIF) MC75_DMC_RcvStream(); if(P_UART_Status->B.TXIF && P_UART_Ctrl->B.TXIE); } } /*==================================================================== Description: IRQ7 interrupt source is XXX,used to XXX Notes: 512Hz timing interrupt for adjusting speed by PID controller ====================================================================*/ void IRQ7(void) __attribute__ ((ISR)); void IRQ7(void) { if(P_INT_Status->B.CMTIF) { if(P_CMT_Ctrl->B.CM0IF && P_CMT_Ctrl->B.CM0IE) { BLDC_Motor_Actiyator(); } P_CMT_Ctrl->W = P_CMT_Ctrl->W; } }

5.2 Main Process Description


Main program performs the system initializations, and ISR routines respond for the real time motor operations. The ISR include: input/output error interrupt (IRQ0), PDC and TCV interrupt (IRQ1), UART RXD interrupt (IRQ6) and CMT0 timer interrupt. Figure 5-1 flow charts the main loop.

Sunplus Technology Co., Ltd.

PAGE 21

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Figure 5-1 BLDC Main Process

5.3 ISR Description


Fault input, output short circuit, PDC, TCV, RXD and CMT0 interrupt routines help to control BLDC starting, working, speed adjusting and fault protection. These interrupt sources have been configured in the system initialization routines. Figure 5-2 shows the interrupt operation process of PDC and TCV for your reference.

Figure 5-2 PDC and TCV Interrupt

Sunplus Technology Co., Ltd.

PAGE 22

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

6 MCU Resource

CPU Type

SPMC75F2413A crystal

Package Frequency Input frequency

QFP80-1.0 6MHz

Oscillator external WATCHDOG Enable IOB[0-5] IOB6 IO IOB[8-10] IOC[0-1] Other IOs PDC0 Timer MCP3 CMT0 FTIN1(IRQ0) PDC0(IRQ1) Interrupt MCP3(IRQ3) UART(IRQ6) CMT0(IRQ7) ROM 6.15K Words Disable MCP3: BLDC control Motor drive external fault input Hall sensor interface for position detection UART RXD2, TXD2 Main control /GND Motor position detection Generate waveform by driving BLDC motor System clock External fault protection Motor start-up and running normal control Motor driving waveform control DMC controls UART communication BLDC speed adjustment

Sunplus Technology Co., Ltd.

PAGE 23

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

7 Test
This test is aimed to use 120-degree upper phase PWM waveform to drive BLDC with hall sensor and adjust motor speed by PID controller. Test contents: Six phase output signals WN2: IOB0/W1N VN6: UN4: W5: V3: U1: IOB1/V1N IOB2/U1N IOB3/W1 IOB4/V1 IOB5/U1 Three phase hall input signals H3: H2: H1: IOB8/TIO0C IOB9/TIO0B IOB10/TIO0A

7.1 Control Signals


The relationship between control signal and position feedback signal is available through theoretical analysis and practical operation. Figure 7-1 shows the 120-degree upper phase PWM waveform when the motor is driven in forward direction and Figure 7-2 shows that in backward direction.

Figure 7-1 120-degree Upper Phase PWM Waveforms When the Motor Is Driven in Forward Direction
Sunplus Technology Co., Ltd. PAGE 24 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

From the waveform, we can see that when the motor is driven in forward direction, the corresponding relationship between position detection and control signals can be obtained as: 010 (H3 H2 H1) V6-V1, 011 (H3 H2 H1) V5-V6, 001 (H3 H2 H1) V4-V5, 101 (H3 H2 H1) V3-V4, 100 (H3 H2 H1) V2-V3, 110 (H3 H2 H1) V1-V2.

Figure 7-2 120-degree Upper Phase PWM Waveform When the Motor Is Driven in Backward Direction

From the waveform, we can see that when the motor is driven in backward direction, the corresponding relationship between position detection and control signals can be obtained as: 001 (H3 H2 H1) V1-V2, 011 (H3 H2 H1) V2-V3, 010 (H3 H2 H1) V3-V4, 110 (H3 H2 H1) V4-V5, 100 (H3 H2 H1) V5-V6, 101 (H3 H2 H1) V6-V1. The SPMC75F2413A chip is dedicated to drive motor which can generate various driving signals such as pre-sixty degree PWM waveform shown in Figure 7-3. Here we simply demonstrate a possible design idea and give a reference for users further application.

Sunplus Technology Co., Ltd.

PAGE 25

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Figure 7-3 Pre-sixty Degree PWM Waveform

7.2 Speed Adjustment


As mentioned above, BLDC speed is adjusted by PID controller which can vary the output voltage fundamental with different PWM duty, thus to control the motor speed. Figure 7-4 and Figure 7-6 respectively depict the waveforms when BLDC runs at 1000rpm and 3200rpm.

Figure 7-4 PWM Waveform (1000rpm)

From the waveform, we can see that when BLDC runs at 1000rpm: Hpwm=22us, Lpwm=102us. Thus PWM duty can be calculated as: Dpwm=Hpwm/ (Hpwm+Lpwm)*100%=22us/124us*100%=17.74%.
Sunplus Technology Co., Ltd. PAGE 26 V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Figure 7-5 PWM Waveform (3200rpm)

From the waveform, we can see that when BLDC runs at 3200rpm: Hpwm=94us, Lpwm=32us. Thus PWM duty can be calculated as: Dpwm=Hpwm/ (Hpwm+Lpwm)*100%=94us/126us*100%=74.6%.

7.3 Current Waveform


Figure 7-6 is current waveform tested via current probe during BLDC running. The test conditions are: small load, low current, and 6 KHz PWM carrier waveform.

Figure 7-6 Current Waveform

Sunplus Technology Co., Ltd.

PAGE 27

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

7.4 System Response


As described in Chapter 3, in order to correct system response, the only thing to do is to chang Kp. Following depicts the system response curves when Kp is set as different values. Figure 7-7 shows the steady-state characteristic test curve at Kp= 0.385. Obviously, the system oscillates when the rotate speed is low (1000rpm) and has a long duration during rising time (1000rpm ~1500rpm).

Figure 7-7 Steady-State Characteristic Test

Figure 7-8 shows the step response curve at Kp= 0.225 when the rotate speed ranges from 0rpm to 2000rpm.

Sunplus Technology Co., Ltd.

PAGE 28

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Figure 7-8 Step Response(0rpm ~ 2000rpm)

From above, we can estimate the overshoot using the formula: = (Cmax-C) / C * 100%, here =230rpm/2000rpm * 100% =11.5%. Figure 7-9 shows the step response curve at Kp= 0.225 when the rotate speed ranges from 2000rpm to 3500rpm.

Figure 7-9 Step Response (2000rpm ~ 3500rpm)

Sunplus Technology Co., Ltd.

PAGE 29

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Additionally, steady-state error must be considered into the speed feedback system. Figure 7-10 shows the steady-state error curve when the rotate speed is 1000rpm, where steady-state error=(C (t)-C) / C * 100% < 10/1000 * 100%=1%.

Figure 7-10 Steady-State Error when the Rotate Speed is 1000rpm

Figure 7-11 shows the steady-state error curve when the rotate speed is 3000rpm, where steady-state error =(C (t)-C) / C * 100% < 12/3000 * 100%=0.4%.

Figure 7-11 Steady-State Error when the Rotate Speed is 3000rpm

Figure 7-12 shows the step response curve at Kp=0.225 when the rotate speed ranges from 1000rpm to 3000rpm. We can see that the overshoot is always zero and no oscillation occurs. But the error (C (t)-C) is always higher than 150rpm irrespective of whether the rotate speed is lower or higher.

Sunplus Technology Co., Ltd.

PAGE 30

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

Figure 7-12 Step Response (1000rpm ~ 3000rpm)

Sunplus Technology Co., Ltd.

PAGE 31

V1.3 - Dec 22, 2006

3-Phase BLDC Motor Control with Hall Sensor

8 Reference
1SUNPLUS. SPMC75F2413A Programming Guide V1.0. Oct 12 2004. 2 Zhang Chen. BLDC Fundamentals and Applications (Version 2). China Machine Press. 3Yu Yongquan, Zeng Bi. Fuzzy Logic Control Based on MCU. Beijing University of Aeronautics and Astronautics Press.

Sunplus Technology Co., Ltd.

PAGE 32

V1.3 - Dec 22, 2006

You might also like