A brushless DC motor driver based on STM32
By integrating multiple industrial communication protocols and high-precision control algorithms in brushless motor drivers, the limitations of traditional drivers in terms of communication capabilities and control accuracy are solved, and high-precision closed-loop control of brushless motors and communication functions suitable for multi-scenarios are realized.
Patent Information
- Application Number
- CN202411686105.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-24
- Publication Date
- 2025-04-04
AI Technical Summary
Traditional brushless motor drivers have limitations in communication capabilities, control accuracy and scalability, which are difficult to meet the needs of multi-device interconnection and complex industrial environments. The open-loop control mode responds slowly when load changes and has low accuracy, which does not meet the requirements of modern industry for high dynamic performance and stability.
A brushless DC motor driver based on STM32 is designed, integrating various industrial communication protocols such as CAN, Modbus and EtherCAT, combined with PID three-closed loop and FOC control algorithm to realize high-precision motor drive and communication functions suitable for multiple scenarios.
It realizes high-precision closed-loop control of brushless motors, improves communication capabilities and control accuracy, and is suitable for application scenarios such as industrial automation, intelligent manufacturing and robot control, and provides efficient and reliable solutions.
Smart Images

Figure CN119766004A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of motor control and industrial automation technology, and in particular to a brushless DC motor driver based on STM32. The driver integrates multiple industrial communication protocols, and realizes high-precision closed-loop control of brushless motors through FOC space vector control and PID control algorithm, and is widely applicable to application scenarios such as industrial automation, intelligent manufacturing and robot control. Background Art
[0002] Brushless motors have become the core actuators widely used in industrial control and intelligent devices due to their high efficiency, low noise and long life. However, traditional brushless motor drivers have many limitations in terms of communication capabilities, control accuracy and scalability. For example, existing drivers often use a single communication method, which is difficult to meet the needs of multi-device interconnection and complex industrial environments; in terms of control performance, the traditional open-loop control mode responds slowly and has low accuracy when the load changes, which is not suitable for the requirements of modern industry for high dynamic performance and stability. Summary of the invention
[0003] In order to improve the communication capability and control accuracy of the brushless motor driver, the present invention proposes a brushless DC motor driver based on STM32, which integrates multiple industrial communication protocols such as CAN, Modbus and EtherCAT, and combines PID three-loop and FOC control algorithms to achieve high-precision motor drive and communication functions suitable for multiple scenarios, providing an efficient and reliable solution for industrial automation and intelligent manufacturing.
[0004] To achieve the above object, the present invention provides the following technical scheme: a brushless DC motor driver based on STM32 single-chip microcomputer, which consists of an STM32 controller, an EEPROM module, a CAN communication module, an RS485 communication module, an EtherCat communication module, a three-phase inverter motor drive module, a WIFI module, a Hall sensor interface, and a high-precision ADC acquisition circuit.
[0005] As a further solution of the present invention: the motor drive circuit adopts a three-phase inverter circuit, and the three-phase inverter circuit part is composed of 6 power switch tubes (MOSFET or IGBT), which respectively control the on and off of the U, V, and W three-phase windings of the motor. The topological structure adopts a full-bridge inverter circuit, which is composed of three upper bridge arms and three lower bridge arms, and each bridge arm controls a phase winding. The power switch device selects a low on-resistance, fast-switching MOSFET to ensure high efficiency and fast response. The drive circuit uses the driver chip IR2110 to drive the MOSFET, provides sufficient gate drive voltage and current, and has dead time protection to avoid short circuits of the upper and lower bridge arms.
[0006] As a further solution of the present invention: the high-precision ADC is used to collect information such as voltage and current of a brushless DC motor (BLDC) during operation. The current collection uses a shunt resistor with an accuracy of 0.1% and a resistance of 5 mΩ in series to the phase current path of the motor. The INA240 operational amplifier is used to connect the two ends of the shunt resistor to amplify the tiny voltage difference and output a single-ended voltage (range 0–3.3V). The output signal of the operational amplifier is connected to the ADC sampling channel of the STM32. In the voltage collection part, because the DC bus voltage of the brushless motor is usually high and exceeds the ADC input voltage range of the STM32, we use a voltage divider resistor network to connect the output end of the voltage divider resistor network to the non-inverting input end of the operational amplifier, and the operational amplifier works in a unit gain configuration. A protection circuit is added to the ADC input end, and a Schottky diode is connected to the positive and negative poles of the power supply to prevent overvoltage caused by abnormal voltage divider network or operational amplifier.
[0007] As a further solution of the present invention: the motor drive adopts FOC and PID three-closed loop control. Based on the speed-position-current three-closed loop control, the outermost loop is the speed loop, the middle loop is the position loop, and the inner loop is the current loop. The actual speed of the speed loop is obtained by the encoder, the actual position of the position loop is obtained by the Hall sensor, and the actual current of the current loop is obtained by ADC acquisition. After the PID calculates the error, the system adjusts the current size according to the error, and then controls the speed, thereby achieving precise control of the motor speed.
[0008] As a further solution of the present invention: This brushless DC motor driver supports the Modbus communication protocol, and the Modbus protocol uses the RS485 interface circuit in hardware and uses the MAX485 chip as the communication driver. The terminal resistor (120Ω) on the RS-485 bus is used for anti-interference. The USART interface of STM32 is used to connect the MAX485 communication interface, and the DE / RE pin is controlled by GPIO to realize the switching between sending and receiving. And set the Modbus register mapping table, design the corresponding storage table, store the corresponding motor parameters, status, error code, etc., so that the user can realize the control, status monitoring and error diagnosis of the motor through Modbus. For example: The master device writes the target speed (register address 0x0020) through the function code 0x06, and the STM32 adjusts the speed loop target according to the value. The master device reads the error register (register address 0x0060) through the function code 0x03 for diagnosing motor operation problems.
[0009] As a further solution of the present invention: This brushless DC motor driver supports the CAN communication protocol, and the CAN communication realizes data interaction between the host computer (or main controller) and the brushless motor driver, which is used to transmit motor control instructions and feedback information. The chip TJA1050 is used in hardware to convert the CAN_TX and CAN_RX interface signals of STM32 into differential signals of the CAN bus. In software, the 11-bit standard frame ID is assigned to different functions. For example, ID=0x100 is a motor control frame, and ID=0x200 is a motor status feedback frame. The control frame contains instructions such as start / stop, target speed, and target position. The feedback frame contains status information such as actual speed, position, current, and voltage. The external device can specify the operating parameters (such as target speed, position, etc.) of the target motor by sending a control frame instruction. The motor driver sends the real-time operating status to the bus through the feedback frame for the main controller or the host computer to read.
[0010] As a further solution of the present invention: This brushless DC motor driver supports the EtherCat communication protocol. The EtherCat is used to realize high-speed data interaction between the master station and the driver, and supports parallel and precise control of multiple motors. Using a slave chip (such as LAN9252) that supports the EtherCAT protocol on the hardware, EtherCat defines real-time control and feedback data by defining PDO. Define the control PDO to set the target speed, target position, and control mode of the motor. Define the feedback PDO to obtain the actual speed, current, position, and status word of the motor.
[0011] Figure 1 A schematic diagram of a brushless DC motor driver based on STM32.
[0012] Specific implementation method: Specific implementation method: Next, the technical scheme in the embodiment of the present invention will be clearly and completely described in conjunction with the drawings of the embodiment of the present invention. Obviously, the embodiment is only a part of the present invention, not all embodiments. Based on the embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should be regarded as the scope of protection of the present invention.
[0013] See also Figure 1In the present invention, a brushless DC motor driver based on STM32 single-chip microcomputer is proposed, which is composed of STM32 controller, EEPROM module, CAN communication module, RS485 communication module, EtherCat communication module, three-phase inverter motor drive module, WIFI module, Hall sensor interface, and high-precision ADC acquisition circuit. It integrates multiple industrial communication protocols such as CAN, Modbus and EtherCAT, combines PID three-closed loop and FOC control algorithm, realizes high-precision motor drive and communication functions applicable to multiple scenarios, and provides efficient and reliable solutions for industrial automation and intelligent manufacturing.
[0014] The motor drive circuit adopts a three-phase inverter circuit, which is composed of 6 power switch tubes (MOSFET or IGBT), which respectively control the on and off of the U, V, and W three-phase windings of the motor. The topology adopts a full-bridge inverter circuit, which consists of three upper bridge arms and three lower bridge arms, and each bridge arm controls a phase winding. The power switch device selects a low on-resistance, fast-switching MOSFET to ensure high efficiency and fast response. The drive circuit uses the driver chip IR2110 to drive the MOSFET, providing sufficient gate drive voltage and current, and has dead time protection to avoid short circuits of the upper and lower bridge arms.
[0015] The high-precision ADC is used to collect information such as voltage and current of the brushless DC motor (BLDC) during operation. The current acquisition uses a shunt resistor with an accuracy of 0.1% and a resistance of 5 mΩ in series to the phase current path of the motor. The INA240 operational amplifier is used to connect the two ends of the shunt resistor to amplify the tiny voltage difference and output a single-ended voltage (range 0–3.3V). The output signal of the operational amplifier is connected to the ADC sampling channel of the STM32. In the voltage acquisition part, because the DC bus voltage of the brushless motor is usually high and exceeds the ADC input voltage range of the STM32, we use a voltage divider resistor network to connect the output of the voltage divider resistor network to the non-inverting input of the operational amplifier, and the operational amplifier works in a unit gain configuration. A protection circuit is added to the ADC input end, and a Schottky diode is connected to the positive and negative poles of the power supply to prevent overvoltage caused by abnormal voltage divider network or operational amplifier.
[0016] The motor control algorithm adopts FOC and PID three-loop control. Based on the speed-position-current three-loop control, the outermost loop is the speed loop, the middle loop is the position loop, and the inner loop is the current loop. The actual speed of the speed loop is obtained by the encoder, the actual position of the position loop is obtained by the Hall sensor, and the actual current of the current loop is obtained by ADC acquisition. After PID calculates the error, the system adjusts the current size according to the error, and then controls the speed, thereby achieving precise control of the motor speed.
[0017] The Modbus protocol uses the RS485 interface circuit in hardware and uses the MAX485 chip as the communication driver. The terminal resistor (120Ω) on the RS-485 bus is used for anti-interference. Use the USART interface of STM32 to connect the MAX485 communication interface, and control the DE / RE pin through GPIO to achieve the switching between sending and receiving. And set the Modbus register mapping table, design the corresponding storage table, store the corresponding motor parameters, status, error code, etc., so that users can realize the control, status monitoring and error diagnosis of the motor through Modbus. For example: The master device writes the target speed (register address 0x0020) through function code 0x06, and STM32 adjusts the speed loop target according to this value. The master device reads the error register (register address 0x0060) through function code 0x03 to diagnose motor operation problems.
[0018] The CAN communication realizes data interaction between the host computer (or main controller) and the brushless motor driver, and is used to transmit motor control instructions and feedback information. The chip TJA1050 is used in hardware to convert the CAN_TX and CAN_RX interface signals of STM32 into differential signals of the CAN bus. In software, the 11-bit standard frame ID is assigned to different functions. For example, ID=0x100 is a motor control frame, and ID=0x200 is a motor status feedback frame. The control frame contains instructions such as start / stop, target speed, and target position. The feedback frame contains status information such as actual speed, position, current, and voltage. The external device can specify the operating parameters of the target motor (such as target speed, position, etc.) by sending control frame instructions. The motor driver sends the real-time operating status to the bus through the feedback frame for the main controller or host computer to read.
[0019] The EtherCat is used to achieve high-speed data interaction between the master and the driver, and supports parallel precise control of multiple motors. Using a slave chip (such as LAN9252) that supports the EtherCAT protocol on the hardware, EtherCat defines real-time control and feedback data by defining PDO. Define the control PDO to set the target speed, target position, and control mode of the motor. Define the feedback PDO to obtain the actual speed, current, position, and status word of the motor.
[0020] It is obvious to those skilled in the art that the present invention is not limited to the specific details of the above-mentioned exemplary embodiments. The present invention can be implemented in other specific forms without departing from the basic spirit or core features of the present invention. Therefore, these embodiments should be regarded as exemplary rather than restrictive from any perspective. The scope of protection of the present invention is defined by the attached claims, rather than relying solely on the foregoing explanations, so all changes that meet the equivalent content of the claims should be included in the present invention. In addition, any graphical mark in the claims should not be regarded as a limitation on the relevant claims.
[0021] In addition, it should be clear that although this specification is described in terms of implementation methods, not every implementation method involves only one independent technical solution. Such a narrative method is only for ease of understanding. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can be appropriately combined to form other understandable implementation methods.
Claims
1. A brushless DC motor driver based on STM32, comprising an STM32 microcontroller, a power drive unit, a Hall sensor interface, a voltage and current acquisition interface, a communication module, and a FOC control algorithm, wherein the Hall sensor interface is used to collect the rotor position signal of the motor; the voltage and current are collected by ADC, and the collected signals are processed in real time by the STM32 microcontroller to realize closed-loop control; the communication module supports CAN, Modbus and EtherCAT protocols, realizes high-speed data transmission with external control equipment through a transceiver chip, and adapts to different industrial control scenarios; the control algorithm is based on field-oriented control (FOC), including three closed-loop controls of current loop, speed loop and position loop, and realizes precise control of the brushless motor through the operation of the STM32 microcontroller.
2. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The power drive unit adopts a three-phase inverter bridge structure, including six power switching devices and corresponding gate drive circuits; the power switching device is IGBT or MOSFET, and the appropriate device type is selected according to the power requirement of the motor, MOSFET is selected for low voltage, and IGBT is selected for high voltage; the gate drive circuit supports short circuit protection, over-temperature protection and under-voltage protection to ensure the safety and stability of system operation.
3. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The Hall sensor interface detects the position and direction of the motor rotor through three Hall signal inputs, and realizes speed measurement and commutation control in combination with the timer inside the STM32 microcontroller; it also supports incremental encoder signal input, expanding its application capabilities in high-precision scenarios.
4. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The current acquisition interface collects the three-phase current signal of the motor through a shunt resistor or a Hall current sensor, and realizes high-precision data acquisition through the built-in ADC module of STM32; the collected data is used for current loop control in the control algorithm to ensure the stable operation of the motor under different load conditions.
5. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The control algorithm is based on field-oriented control (FOC), including three-level closed-loop control of current loop, speed loop and position loop; the current loop is responsible for real-time regulation of three-phase current, the speed loop adjusts the current reference value according to the target speed, and the position loop controls the precise positioning of the motor in combination with the encoder signal; the control algorithm is run by STM32, which can quickly respond to load changes and improve the dynamic performance of the system.
6. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The Modbus protocol in the communication module supports RTU mode and realizes data transmission through the RS485 interface; the driver can receive control instructions as a Modbus slave and respond to query data, including motor speed, current and alarm status, and is suitable for industrial field data acquisition and control.
7. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The EtherCAT protocol in the communication module is based on real-time industrial Ethernet technology and realizes high-speed communication through the EtherCAT slave controller chip; it supports chain topology to meet the needs of multi-drive synchronous control; the EtherCAT protocol is used for high-speed transmission of motor operating status, control commands and alarm information.
8. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The motor driver has a comprehensive protection mechanism, including short-circuit protection, overcurrent protection, overvoltage protection and undervoltage protection; STM32 collects DC bus voltage and phase current signals through ADC, combines the protection algorithm to detect the system status in real time, automatically turns off the PWM output when the protection is triggered, and sends an alarm message through the communication module.
9. A brushless DC motor driver based on STM32 according to claim 1, characterized in that: The driver supports modular design, and each functional unit includes a power drive unit, a sensor interface module, a communication module and an algorithm module; users can flexibly adjust the module configuration according to needs; the driver also supports online firmware upgrades to facilitate function expansion and system maintenance, and is suitable for industrial automation, robot control and intelligent device application fields.
Citation Information
Cited By
Intelligent blind guiding system based on omnidirectional wheel driving and multi-mode sensing and control method
CN120938778A