Professional Documents
Culture Documents
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
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.
PAGE 1
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)
PAGE 2
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
PAGE 3
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.
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
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.
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
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.
PAGE 6
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.
In the following, we will illustrate IPM and the corresponding driver, position sensors and RS232 communication module in detail.
PAGE 8
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
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
Drive
+5V R28 330
P+5V
P+5V
P+5V
R25 1K
R29 330
R26 1K
R30 330
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
S3
R32 10K
S5
R33 10K
32
32
32
WP
IPM-MW IPM-MW 34
R37 3.9K
R38 3.9K
R39 3.9K
P+5V
P+5V
P+5V
R46 BRP58F0.082-K
C42 0.22uF/50V
35
R43 330
R40 1K
R44 330
R41 1K
R45 330
C40 0.22uF
S4 C47 3300pF
R47 10K
32
32
32
WN
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
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
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
5 11 10 12 9
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
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
C99 0.1uF
C100 0.1uF
Q18 2N3904 1
R148 100 +5V 2 D21 3.3V C101 0.1uF ProbeEN ProbeSCL ProbeSDA R149 200K
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
VDC
VDC
1 D28 P6KE200A
T2
10
D27
2 C110 + 470uF/25V
EARTH
22
2 +
D5 1N4148 3 1
MUR160 6
TR-10
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
S S S S
TL431 IC36
R172 10K
4 -
C23 JACK-470uF/400V
R20 200K,1/2W
2 3 7 8
+5V
C25 Y 2-2200pF/250VAC
+5V/P+15V/P+5V power
+12V 1 5
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
P+5V
EMI
C117 47uF
C118 0.1uF
C119 0.1uF
C124 47uF
C123 0.1uF
C125 0.1uF
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.
PAGE 10
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
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
PAGE 11
35
P+5V
P+5V
P+5V
IC9 PC817 UP
IC10 PC817 VP
+5V
R28 330
R25 1K
R29 330
R26 1K
R30 330
C30 0.22uF
S1
R31 10K
S3
R32 10K
S5
R33 10K
32
32
32
WP
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
R44 330
R41 1K
R45 330
C40 0.22uF
S4
R47 10K
S6
R48 10K
S2
R49 10K
32
32
32
WN
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
9 SCFO 10
12 13
C49 1000pF
PAGE 12
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
R131 2.2K
2
Q19 2N3904
1
C85 0.1uF
PAGE 13
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)
(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
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
u ( k ) = Kp[e( k ) +
T k Td e( j ) + T e(k )] Ti j =1
(Formula 3-3)
u ( k ) = Kp* e( k ) + Ki * T e( j ) +
j =1
Kd e ( k ) T
(Formula 3-4)
PAGE 15
To avoid calculating
e( j )
j =1
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 ) +
u ( k ) = Kp{[e( k ) e( k 1)] +
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:
(Formula 3-8)
PAGE 16
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.
C C lib lib
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)
PAGE 17
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
PAGE 18
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
PAGE 19
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
/*=============================================================*/ 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; } }
PAGE 21
PAGE 22
6 MCU Resource
CPU Type
SPMC75F2413A crystal
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
PAGE 23
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
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
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.
PAGE 25
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
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%.
PAGE 27
Figure 7-8 shows the step response curve at Kp= 0.225 when the rotate speed ranges from 0rpm to 2000rpm.
PAGE 28
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.
PAGE 29
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-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-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.
PAGE 30
PAGE 31
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.
PAGE 32