Share This Article:

Design of the Brushless DC Motor Driving System Based on STM32

DOI: 10.4236/oalib.1103703    1,987 Downloads   3,371 Views  


As a mechanical and electrical integration product, brushless DC motor has better controllability and wide speed range. According to its characteristics, a brushless DC motor control system based on STM32F103ZET6 MCU is designed and realized, and then the control system was analyzed and discussed. Adopted GPIO module, PWM module, timer module, etc., coupled with efficient PID algorithm, three main functions of this system have been implemented, such as start stop control, position detection and closed-loop speed regulation. The experimental results show that this control system works well with low cost and high price-performance ratio.

1. Introduction

Brushless DC motor (BLDCM) is a new type of electromechanical integration with the development of semiconductor technology. It is a combination of modern electronic technology, control theory and motor technology. Due to the growth of market demand, brushless DC motor is widely used in automation equipment, aerospace, automobile, electronics, medical equipment, office automation and daily life and other fields. The brushless DC motor can be thought of as a DC motor with a stator and rotor inverted. Relative to a brushless dc motor, the motor without the spark and wear problems of brush and commutator, does not often need maintenance. The utility model has the advantages of high speed, high efficiency, low energy consumption, low noise, long service life, high reliability, servo control, stepless frequency conversion speed regulation, relatively low cost and easy use. These advantages make it get rapid development and popularization, and it has now become the most promising motor product [1] .

The commutation instant is determined by the rotor position in accordance with the operational principle of brushless DC motor. At present, there are two kinds of techniques to obtain the signal of the rotor position. The first type of technique is the use of sensorless control technique, the focus of which is to study a variety of indirect rotor position detection method instead of the direct installation of rotor position sensor to provide rotor position magnetic field information. In fact, the sensorless techniques increase the complexity of the control to reduce that of the motor structure from two aspects of hardware and software. The position detection circuit and the method mainly include: the back EMF zero crossing method, the back EMF integral detection method, the freewheeling diode method, the 3 harmonic back EMF detection method, and so on [1] . The advantages of the back EMF integral detection method are that the whole control process does not need to obtain the speed information, only by adjusting the threshold value of the motor to achieve the lead or lag phase change, and it’s insensitive to the switch signal [2] [3] [4] . The disadvantage is that there is a threshold setting problem and integral error. The three harmonic detection method of back electromotive force has the advantages of wide application range and small phase delay. However, due to the continuous accumulation of low speed noise signal, it often leads to errors in the integration process, resulting in inaccurate commutation [5] [6] .

The second technique is that it uses position sensors (such as Hall sensor) to obtain signals, which are widely used. It has three Hall devices, and the circular spatial configuration has two options: a distance of 60 degrees or 120 degrees apart. When the rotor rotates 60 degrees or 120 degrees electric angle, there is a Hall device changing its state, within the inverter corresponding to which a phase switch state will change again. This switch state changes six times to complete an electric turnover. Hall devices can output response of two states of square waves: “0” and “1”, in order to determine the position of the rotor winding [7] [8] . Hall sensor has the advantages of light weight, small size, low manufacturing cost and convenience for mass production. It meets the design requirements of this design. In this system, the sensor is used to measure the position of the rotor by using the sensor.

The commutation signal of motor is detected by Hall sensor. The current position of the motor can be obtained by the combination of the output signals of 3 hall sensors, so that the commutation sequence of the motor is obtained. And the chip STM32 has specialized input interface of Hall sensors for the motor control. In this case, the design of the interface circuit of the microcontroller and the hall sensor is greatly simplified [9] .

PID controller with its three terms functionality covers treatment for transient and steady-state response. It offers the simplest and most efficient solution to many real world control problems. PID algorithm is usually used in brushless DC motor control. PID control has the advantages of simple maturity, convenient parameter setting and good stability [10] .

The paper is organized as follows: the hardware system design is given in Section 2. It includes three parts: the drive circuit, the position and speed detection circuit and the speed PID adjustment. And the software system design is explained in Section 3. Concluding remarks and conclusion are outlined in Section 4.

2. Hardware System Design

The brushless DC motor is composed of a three-phase stator and a rotor. The rotor magnetic field interacts with the induction magnetic field to generate torque to rotate the motor. The current position of the rotor is the key information to control motor rotation which is measured by the hall sensor. According to the three hall element level sequence, the current position of the rotor could be judged, and the corresponding stator winding is electrified. For each phase change, three stator windings will be in different state: the forward power, the reverse power, and no electricity, respectively. Then the motor is driven to rotate [1] [7] .

2.1. Device Selection

STM32F103ZET6 (hereinafter referred to as STM32) is selected to be the main control chip. The chip is suitable for motor control design because it has rich AD conversion channels, advanced timers and PWM channels. As long as the corresponding module register configured, the main energy could be focused on how to improve the performance of the hardware circuit, regardless writing complex procedures which is modularized already. For the problems in the running process of the system, it is convenient to debug and maintain. In addition, the external pins of the chip are abundant. While only a small number of external pins is used, the other parts can be left to do more extended functionality of the development and application.

2.2. Hardware Function Design

STM32 could obtain kinds of data such as current and position signal, and then process the data. It is also responsible for the algorithm of motor control and the generation of pulse signal for Brushless DC motor rotation. According to the given instructions, the main-control chip generates the corresponding frequency of PWM signal to control the switching time of the drive circuit to reach the expected motor speed [11] [12] [13] [14] .

The control system is composed of power supply, drive circuit, STM32 microcontroller, position, speed detection, computer serial communication and so on. The system hardware block diagram is shown in Figure 1.

2.2.1. The Drive Circuit

Being a perfect front driver of three-phase brushless DC motor, the chip A4931

Figure 1. Block diagram of the hardware system.

is selected for the drive part. It may drive many kinds of power field effect transistor (MOSFET) with N channels. Its motor supply voltage is up to 30 V. Commutation logic is determined by the input signal of three Hall elements in 120 degrees apart. The magnitude of output current depends on the capacity of the external MOSFET. It also has a three-Hall input to control the trigger logic and has a rotor lock protection function. The delay detection of the rotor lock protection is set by an external capacitor connected to the CLD pin. The inputs pin of the ENABLE, DIRECTION and BRAKE can be used to control motor speed, position and torque. There are two kinds of current control mode for chip A4931: the one is by an external PWM signals from the ENABLE pin to control the MOSFET, and the others is by PWM current regulator built-in chip. With the characteristics of synchronous rectification, no matter what kind of current control mode is adopted, it can ensure that the appropriate MOSFET can be opened when the current is attenuated, so as to avoid unnecessary power loss.

The main design for the drive circuit includes two parts: the drive chip A4931 and the MOSFET FDS8949. Enable input (ENB), Brake mode (BREAK) and Direction signal (DIR) are three main control pins of the drive chip. They are introduced as follows respectively.

Enable input (ENB) can be connected with external PWM signal. The appropriate driver is closed and load current began to decay when ENB is high level. Meanwhile, the current will continue to increase until it reaches the level set by the internal current control circuit when ENB is lower level. The typical frequency scope of PWM is in 20 KHz to 30 KHz which is generated by the TIM timer of main control chip STM32. The duty cycle of the PWM signal can be adjusted to control the speed of the machine.

Under Brake mode (BREAK), the brake mode is activated as soon as the logic level of the BREAK pin is low, while normal work mode as logic level of the BREAK pin is high. The direction of motor is controlled by high and low level though DIR (Direction signal) pin.

Pin DIR receives the direction signal of high and low logic level to control motor direction.

Field effect tube adopts FDS8949 with double N channel logic level, which make Field effect tube has high power and current handling capacity. The brushless dc motor drive part is composed of the drive chip A4931 and Field effect tube, as shown in Figure 2 and Figure 3.

2.2.2. Detection Circuits of Position and Speed

Quadrature encoder, also known as incremental encoder or photoelectric encoder, can achieve closed-loop control of a variety of motor to detect the position and speed of the motion system. With the principle of photoelectric conversion, a pulse signal is generated per turn angle. The pulse signal usually named as phase A, B and Z output. Phase A and B are pulse signal delayed 1/4 cycle mutually. According to the delay relationship, the motor rotation direction is positive, if phase A leads B phase, while the rotation direction of the motor is reversed if phase A is behind phase B. The relationship of phase between phase A and B is shown in Figure 4. Phase Z generated per revolution is an index pulse which is used as a reference to determine the absolute position.

In this design, the three pins of the Hall sensor are connected with the external pins of the STM32F103ZET6 chip. It is effective for us to make full use of the external interrupt function of the chip and set it to an external interrupt capture mode.

1024 line orthogonal encoder is used in this system, and the pulse waveform

Figure 2. The circuit of the drive chip A4931.

Figure 3. The drive circuit of the A phase.

Figure 4. The (a) and (b) phase waveform of the motor’s forward and reverse.

of the encoder is made double edge detection through the MCU IO ports. The current speed can be calculated based on the number of pulses in a certain period of time in the timer, thus the speed detection accuracy is greatly improved, and the speed error is greatly reduced.

2.2.3. Speed PID Adjustment

PID control algorithm is one of the most mature control algorithms in control theory, and it is also the most widely used control method in the production process. PID control algorithm is widely used in mechanical, electrical and mechanical, chemical and other industries fields. The control chip generates adjustable PWM signal to control the switch off and achieve the purpose of speed regulation by changing the winding current. Compared with the positional PID control algorithm, the error of incremental PID control algorithm has no accumulation. Then incremental PID control algorithm make good control effect and has little influence on the production process with machine breakdowns, which meet the requirements of brushless dc motor. As a result, the incremental PID control algorithm is chosen eventually [15] .

u [ K ] = u [ K 1 ] + K p × E [ K ] K i × E [ K 1 ] + K d × E [ K 2 ] (1)

where E[K]: the difference between the given speed and the actual speed at the current step, Kp: proportional gain, Ki: integral gain, Kd: derivative gain. By Equation (1), the adjusted value can be calculated. And the duty cycle of PWM can be changed to regulate the speed and adapt to changes in the load.

3. Software System Design

The system is mainly composed of five main functions. The main functions implement hardware initialization, position detection, phase change, speed detection and speed PID adjustment and so on. Hardware initialization is mainly used to initialize the GPIO port, timer, interrupt control and PWM module, etc. The position detection is realized by detecting output pulse signal of the MCU IO port. Through the serial communication, the motor will stop after the number of laps set already is finished with a predetermined speed. Through the microcontroller IO port, the rotor position of Hall level state is detected which provides the information to change the current flow. According to the given speed read at every set interval the PWM signal with corresponding duty cycle is generated to modulate motor speed which makes the system have good dynamic and static characteristics. Most of the procedures are invoked in interrupt processing to meet the requirements of real-time control.

Figure 5 shows the system program flow chart. According to the software flow chart, the program is written and loaded to chip. The experiment result illustrates that the motor can realize running steadily with the specifying value of speed.

Under the closed loop speed regulation processing, the actual speed is calculated firstly, and the overcurrent detection is executed secondly. The current is judged whether it exceeds the fault current set before or not. The PWM output need to be reduced to decrease the current if the current exceeds the set. After that, the current speed is compared with the given one to realize the closed-loop speed regulation. The closed-loop regulation is over as soon as the two speeds are equal to each other reaches the specified one and there is no overcurrent simultaneously.

The drive circuit and the program are important for the brushless DC motor. Parts of the drive program are described as follows:

4. Conclusions

The experimental results show that this system can realize the control of Brushless DC motor. Combined with the precise PID algorithm, the system can be a good control of both motor speed and stable operation. Through the serial communication, the system has a good characteristic of start and stop, phase change, speed regulation. The protection circuit ensures the running of brushless DC motor stable and reliable. The overall structure of the system is shown in Figure 6.

Figure 5. Software system flow chart.

Figure 6. The overall structure of the system.

The design of drive control system of brushless motor with STM32 has advantages of simple coding and reliable controlling. After a long period of practice, it is evident that the design is stable and has a certain promotion value.

Conflicts of Interest

The authors declare no conflicts of interest.

Cite this paper

Jin, H. and Sun, X. (2017) Design of the Brushless DC Motor Driving System Based on STM32. Open Access Library Journal, 4, 1-9. doi: 10.4236/oalib.1103703.


[1] Tan, J. (2011) Permanent Magnet Brushless DC Motor Technology. Machinery Industry Press.
[2] Zhou, W., Pu, Q. and Shang, C. (2009) Research on Position Detection of Brushless DC Motor Based on Back EMF Integral Method. Industry and Mine Automation, 8, 63-65.
[3] Li, S., Ma, H., Lu, G. and Li, X. (2008) Brushless DC Motor Control Based on Back EMF Integral Compensation Method. Small and Special Electrical Machines, 6, 37-39.
[4] Zhou, B., Wei, J., Mu, X. and Yan, Y. (2000) Brushless DC Motor Position Sensorless Based on Back EMF Logic Level Integral Comparison Method. Transactions of China Electrotechnical Society, 15, 5-9.
[5] Chen, J., Lu, Y. and Yu, Z. (2002) Three Harmonic Detection Method for Brushless DC Motor Drive Control. Micromotors, 35, 23-25.
[6] Wei, K., Ren, J. and Zhang, Z. (2004) Research on Rotor Position of Brushless DC Motor Based on Three Harmonic Detection. Proceeding of the Chinese Society for Electrical Engineering, 24, 163-167.
[7] Ye, J. (2007) The Principle and Design of Modern Brushless DC Permanent Magnet Motor. Science Press, Beijing.
[8] Xia, C. (2009) Brushless DC Motor Control System. Science Press, Beijing.
[9] Jiang, Z. and Li, D. (2014) A Brushless Motor Controller Design Based on ARM. Machinery and Electronics, No. 8, 56-58
[10] Huang, X. and He, Y. (2011) Design of Three Phase Brushless DC Motor Drive Board. Mechanical Design and Manufacturing, 5, 60-62.
[11] Duan, D., Xu, S. and Sun, W. (2008) MOSFET Gate Drive Circuit for Brushless DC Motor Control System. Electronic Device, 31, 533-536.
[12] Tian, Y., Chen, P., Nie, S. and Lu, Q. (2015) Design and Application of Power MOSFET Driver Protection Circuit. Power Electronic Technology, 39, 73-74.
[13] Wu, F., Gao, H. and Sun, L. (2005) Design of Power MOSFET Driver Circuit for Bridge Topology. Electric Drive, 35, 32-34.
[14] Guo, Y., Su, X., Li, Z. and Chen, L. (2012) Design and Application of MOSFET Drive and Protection Circuit. International Electric Elements, 20, 169-171, 174.
[15] Guo, Y. and Yao, M. (2009) Realization of Brushless DC Motor Speed Regulation. Electric Machines and Control Application, 36, 13-16.

comments powered by Disqus

Copyright © 2019 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.