Closed-loop driver of stepping motor
By combining the STM32F103CBT6 or RP2040 chip with the MT6816 or AS5047D magnetic angular position sensor in the stepper motor driver, three-loop closed-loop control is achieved. This solves the problems of insufficient position control accuracy and anti-interference in traditional stepper motor drivers under complex working conditions, and improves the stability and reliability of the motor.
Patent Information
- Application Number
- CN202511037318.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-28
- Publication Date
- 2025-10-14
AI Technical Summary
Traditional stepper motor drivers lack real-time position feedback and effective closed-loop control under complex working conditions, resulting in insufficient position control accuracy, prone to loss of steps, and susceptible to interference in complex electromagnetic environments, affecting equipment stability and reliability.
The main control unit STM32F103CBT6 or RP2040 chip is combined with the position feedback unit MT6816 or AS5047D magnetic angular position sensor, and the three-loop closed-loop control of torque, speed and position is achieved through the FOC vector control algorithm. Combined with the dual H-bridge drive architecture and sampling resistor current detection, an optical coupling chip is used to isolate the high-current drive circuit, and anti-interference is achieved through CAN bus differential transmission.
It enables the motor to accurately track the target position under various working conditions, improves the position control accuracy and stability, enhances the anti-interference performance, and ensures the reliability of the control system and the accuracy of data transmission.
Smart Images

Figure CN120785227A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of stepper motor, more particularly, to a stepper motor closed-loop driver. BACKGROUND
[0002] In the field of industrial automation control, stepper motors are widely used due to their simple structure and low cost. However, traditional stepper motor drivers face a key technical problem in actual operation: under complex working conditions (such as high-speed operation, load mutation, or long-distance transmission), the lack of real-time position feedback mechanism and effective closed-loop control strategy leads to insufficient motor position control accuracy, and easy loss of synchronization, which seriously affects the stability of the equipment operation and the control accuracy.
[0003] In the prior art, some stepper motor drivers attempt to improve performance through open-loop control or simple current regulation, but still have the following limitations: In open-loop control mode, the motor speed and position completely depend on the input pulse, and cannot be dynamically adjusted according to the actual operating state. When high load or high-frequency pulse input occurs, the loss of synchronization problem is particularly prominent.
[0004] The current detection and filtering method of the traditional drive circuit is relatively rough, making it difficult to accurately control the motor winding current, resulting in large torque fluctuations during motor operation, which further affects the position control accuracy.
[0005] Lack of perfect anti-interference design, in the complex electromagnetic environment of industrial field, the driver is easy to be disturbed and appear communication failure or control signal distortion, reduce the reliability of the system, in view of this, we propose a stepper motor closed-loop driver. SUMMARY
[0006] The purpose of the present application is to provide a stepper motor closed-loop driver to solve the technical problem of insufficient position control accuracy and easy loss of synchronization of traditional stepper motor drivers under complex working conditions due to the lack of real-time position feedback and effective closed-loop control strategy.
[0007] To solve the above technical problems, the present application provides the following technical solution: a stepper motor closed-loop driver, comprising: A main control unit for generating control signals and processing feedback data, the main control unit being an STM32F103CBT6 single-chip microcomputer or an RP2040 chip; A drive circuit connected to the main control unit for driving the stepper motor, including a double H-bridge drive chip TB67H450 or TMC2209; A position feedback unit connected to the main control unit for detecting the motor rotor position, including an MT6816 or AS5047D magnetic angle position sensor; A communication interface unit, connected with the master control unit, for realizing data interaction between the driver and external devices, including a CAN bus interface and an RS485 interface; A man-machine interaction unit, connected with the master control unit, for parameter setting and state display, including an OLED screen and a button.
[0008] The application realizes three-loop closed-loop control of torque, speed and position by combining the position feedback unit with the FOC vector control algorithm, uses an MT6816 or AS5047D magnetic angle position sensor to detect the motor rotor position in real time, and feeds back the data to the master control unit, and the master control unit calculates accurate control signals through the FOC algorithm, dynamically adjusts the motor operating state, effectively solves the problems of insufficient position control accuracy and out-of-step under traditional open-loop control, and enables the motor to accurately track the target position under various working conditions.
[0009] Preferably, the driving circuit adopts a double-H bridge structure, realizes current detection through a sampling resistor, and optimizes the signal through a second-order filter, and the resistance value of the sampling resistor is 100 mΩ.
[0010] Preferably, when the master control unit adopts an STM32F103CBT6 chip, torque, speed and position three-loop control is realized through the FOC vector control algorithm; and when the master control unit adopts an RP2040 chip, the motor driving and external device cooperative work are realized through an integrated control algorithm.
[0011] Preferably, in the communication interface unit, the CAN bus interface adopts a TJA1044GT / 1Z or MCP2542FD-E / SN transceiver, the RS485 interface adopts an SP3485EEN transceiver, and 120Ω or 60.4Ω terminal resistors are connected in parallel between the CAN-H and CAN-L of the CAN bus interface.
[0012] Preferably, the position feedback unit communicates with the master control unit through an SPI interface, the SPI interface includes SPI1 or SPI0, and the CS pin of the sensor is controlled by the GPIO pin of the master control unit.
[0013] Preferably, an optical coupling chip is further included for isolating the high-current driving circuit and the low-voltage signal circuit, and the optical coupling chip is an EL3H7C.
[0014] Preferably, the OLED screen of the man-machine interaction unit communicates with the master control unit through an SPI2 or I2C interface, the screen size is 0.91 inches or 1.3 inches, and the number of buttons is 2-3, which are used for mode switching and parameter adjustment.
[0015] Preferably, the driver supports 12-24V wide voltage input, has power-on self-test function, displays error codes including temperature anomaly, communication failure or motor overload through the OLED screen.
[0016] Preferably, the human-computer interaction unit further includes a state indicating lamp, which flickers at low frequency in normal operation and flickers at high frequency or changes color in failure, and the driver realizes power input and serial debugging through a Type-C interface.
[0017] Compared with the prior art, the application has the following beneficial effects: 1. The application realizes three-loop closed-loop control of torque, speed and position by combining the position feedback unit with the FOC vector control algorithm, uses the MT6816 or AS5047D magnetic angle position sensor to detect the motor rotor position in real time, feeds the data back to the main control unit, and calculates the accurate control signal through the FOC algorithm, dynamically adjusts the motor operating state, effectively solves the problems of insufficient position control accuracy and out-of-step under traditional open-loop control, and enables the motor to accurately track the target position under various working conditions.
[0018] 2. The application also adopts a double-H-bridge driving architecture, combines sampling resistance current detection and second-order filter signal optimization. This design can accurately collect motor winding currents and eliminate high-frequency noise through a filter to realize accurate control of the current. This not only improves the stability of motor operation and reduces torque fluctuation, but also further improves the accuracy and stability of position control, especially in low-speed operation and precise positioning scenarios.
[0019] 3. The application also isolates the high-current driving circuit from the low-voltage signal circuit through an optical coupling chip, and cooperates with CAN bus differential transmission and other anti-interference designs. The optical coupling chip EL3H7C effectively isolates the interference of the driving circuit on the main control circuit, and the differential signal transmission method of the CAN bus has strong anti-common-mode interference ability, plus the TVS tube and filter capacitor at the power supply end and other measures, which significantly enhances the anti-interference performance of the driver, enabling it to operate stably in complex industrial electromagnetic environments, ensuring the reliability of the control system and the accuracy of data transmission. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 It is a pin connection schematic diagram of the STM32F103CBT6 single-chip microcomputer in the application; Figure 2 It is a pin connection schematic diagram of the RP2040 chip in the application; Figure 3 It is a pin connection schematic diagram of the TMC2209 stepper motor driving chip in the application. DETAILED DESCRIPTION
[0021] Square stepping motor closed-loop driver embodiment: as Figure 1 The application relates to a stepping motor closed-loop driver, which comprises the following components. Master control unit: an STM32F103CBT6 single-chip microcomputer is used as a control core, and pin distribution is as follows: In the embodiment of the application, PD0 and PD1 are used for external crystal oscillator input to provide a system clock; PA11 and PA12 are connected with CAN_RX and CAN_TX respectively to realize CAN bus communication; PB10 and PB11 are used for TX and RX signal transmission of RS485 communication; PA0-PA7, PB0-PB7 and the like are used for driving signal output and sensor signal acquisition.
[0022] The driving circuit comprises two TB67H450FNG chips to form a double-H-bridge driving circuit, and each TB67H450FNG chip is responsible for driving a phase winding.
[0023] In the embodiment of the application, the IN1 and IN2 pins of the TB67H450FNG chip receive PWM signals from the STM32 to control the rotating speed and direction of the motor; the OUT1 and OUT2 pins are connected with the winding of the stepping motor to output driving current; a sampling resistor (100 m omega) is connected in series in the winding loop for current detection, and a sampling voltage is input to the ADC pin of the STM32 after being filtered.
[0024] The position feedback unit adopts an MT6816 magnetic angle position sensor, the MT6816 magnetic angle position sensor communicates with the STM32 through an SPI1 interface, and the SPI1-SCK, SPI1-MOSI and SPI1-MISO are connected with the PA5, PA7 and PA6 pins of the STM32 respectively.
[0025] In the embodiment of the application, the CS pin of the MT6816 magnetic angle position sensor is controlled by the PB4 of the STM32 to realize the chip selection function; the power supply end and the ground end of the sensor are connected with a 3.3V power supply and GND respectively, and a 100nF decoupling capacitor is connected in parallel.
[0026] The communication interface comprises a CAN bus interface and an RS485 interface. The CAN bus interface adopts a TJA1044GT / 1Z transceiver, and 120 omega terminal resistors are connected in parallel between CAN-H and CAN-L to improve signal stability.
[0027] The RS485 interface uses an SP3485EEN transceiver, and the DE and RE pins are used to control the data receiving and sending directions and are connected with the PB10 and PB11 pins of the STM32.
[0028] The man-machine interaction unit comprises an OLED screen and a plurality of keys. 0.91-inch OLED screen communicates with STM32 through SPI2 interface, SPI2-SCK, SPI2-MOSI, and SPI2-MISO are connected to PB13, PB15, and PB14 pins of STM32 respectively, and the DC and RES pins of the OLED screen are controlled by PA8 and PA9 of STM32 to realize display data and reset functions. Two buttons (BUTTON-1 and BUTTON-2) are connected to the GPIO pins of STM32 for parameter setting and mode switching.
[0029] Working principle: Initialization and self-test: After the driver is powered on, STM32 first performs system initialization to configure GPIO, SPI, CAN, and other peripheral interfaces. Then it starts MT6816 sensor for position calibration, reads the current rotor position, and displays the initialization information on the screen. At the same time, it detects the power voltage, temperature sensor state, etc., and if an abnormality is found, it prompts the error code on the screen.
[0030] Control mode switching: Users can select open-loop, vector closed-loop, or serial port control mode through buttons or serial port commands.
[0031] Open-loop mode: STM32 generates corresponding PWM waveforms based on the input pulse signal and direction signal to control TB67H450 to rotate the motor, which does not rely on position feedback and is suitable for scenarios with low precision requirements.
[0032] Vector closed-loop mode: STM32 reads the position data of MT6816 in real time, compares it with the target position to generate an error signal, calculates the required current vector through FOC algorithm, adjusts the PWM waveform, and realizes closed-loop control to ensure that the motor accurately tracks the target position.
[0033] Serial port control mode: The driver receives control instructions from the host computer through the CAN or RS485 interface, including target position, speed, torque, and other parameters. STM32 executes the corresponding control strategy according to the instructions and feeds back the running status to the host computer.
[0034] Subdivision control implementation: STM32 generates subdivision interpolation pulses through software algorithms, subdivides the traditional whole-step drive into multiple micro-steps, and improves the smoothness and precision of motor operation. Users can set the subdivision multiple (1-256) through the screen or serial port, and STM32 adjusts the frequency and duty cycle of the PWM pulse according to the settings to realize motor control under different subdivisions.
[0035] Anti-interference design: Optocoupler chips (such as EL3H7C) isolate the drive circuit from the main control circuit to prevent interference from high-current drive circuits on low-voltage signal circuits.
[0036] CAN bus adopts differential signal transmission, has strong anti-common-mode interference ability, cooperates with shielded cable, and can further improve the anti-interference performance.
[0037] A TVS tube (SMBJ28CA) and a filter capacitor are added to the power input end to suppress power surges and high-frequency noise.
[0038] The embodiment of the circular stepping motor closed-loop driver is as shown in the figure. Figures 2 to 3 The embodiment of the circular stepping motor closed-loop driver is as shown in the figure. The main control unit takes RP2040 chip as the core, and the functions of the GPIO pins are as follows: As another embodiment of the present application, GPIO7-GPIO15, GPIO20-GPIO25 are used to connect various peripherals and sensors; GPIO9, GPIO10 are configured as CAN_TX and CAN_RX respectively to realize CAN bus communication; GPIO11, GPIO12, GPIO13, GPIO14 are used for SPI communication, and are connected with magnetic encoders, accelerometers and other devices; GPIO26-GPIO29 are used as ADC pins for temperature sensor and power voltage detection.
[0039] The driving circuit board is loaded with TMC2209 stepping motor driving chip, adopts UART mode control, receives control signals from RP2040 through STEP, DIR and EN pins, and the A+, A-, B+ and B- pins of the TMC2209 stepping motor driving chip are connected with the windings of the 36 circular stepping motors, supporting low-noise and high-resolution stepping control.
[0040] The position feedback unit adopts AS5047D magnetic encoder as a position sensor, communicates with RP2040 through SPI0 interface, and SPI0-SCK, SPI0-MOSI, SPI0-MISO and SPI0-CS are connected with GPIO11, GPIO12, GPIO13 and GPIO14 of RP2040 respectively, and the on-board ADXL345 accelerometer is connected with RP2040 through SPI interface, and is used for detecting the vibration condition of the motor during operation, and assisting in adjusting the control strategy. As another embodiment of the present application, the temperature detection part includes PT100 sensor (converted through MAX31865 chip) and NTC100k resistor, which are used for detecting the motor winding temperature and the internal temperature of the driver respectively, and the MAX31865 chip communicates with RP2040 through SPI interface.
[0041] The communication interface includes CAN bus interface, Type-C interface, multiple XH2.54 interfaces and BLTOUCH interface. The CAN bus interface uses MCP2542FD-E / SN transceiver, and 60.4Ω terminal resistors are connected between CAN-H and CAN-L to improve communication stability.
[0042] The Type-C interface is used for power input and serial debugging, supports 5V power input, and is connected with the USB interface of the RP2040 through the USB-DM and USB-DP pins.
[0043] A plurality of XH2.54 interfaces are provided for connecting peripherals such as fans, heating rods, RGB-LEDs, and a BLTOUCH interface for automatic leveling of the three-dimensional printer.
[0044] The human-computer interaction unit includes an OLED display screen, a plurality of keys, and a status indicator light; A 1.3-inch OLED display screen is selected, which is connected with the RP2040 through an I2C interface, and the SCL and SDA pins are connected with the GPIO1 and GPIO0 of the RP2040, respectively. Compared with the SPI interface, the pin occupation is reduced, which is convenient for layout on the compact 6-layer circuit board. The display screen can display key parameters such as motor running state, temperature, speed, and target position in real time.
[0045] Three keys (KEY1, KEY2, and KEY3) are configured and connected with the GPIO2, GPIO3, and GPIO4 pins of the RP2040, respectively. Among them, KEY1 is used for mode switching (such as printing mode and debugging mode); KEY2 is used for parameter incremental adjustment; and KEY3 is used for parameter decremental adjustment. Users can quickly set parameters such as motor subdivision multiple, target speed, and temperature alarm threshold through key operation, and after the operation is completed, the parameters are automatically saved to the internal storage area of the RP2040.
[0046] A status indicator light (LED) is additionally provided and connected with the GPIO5 pin of the RP2040. When running normally, the LED flashes at low frequency; when detecting problems such as temperature abnormalities, communication failures, or motor overloads, the LED flashes at high frequency or changes color (such as red indicating a serious fault), which facilitates users to quickly identify the running state of the device.
[0047] Working principle: Three-dimensional printer adaptation: For the extruder application of the three-dimensional printer, the circular drive board is connected with the controller and the printing tool head through four wires (two 12V power lines and two CAN buses), replacing the traditional multiple cables, which simplifies the electrical layout and reduces interference sources. The high real-time performance and anti-interference capability of the CAN bus ensure the accuracy and stability of motor control during printing.
[0048] Temperature and vibration control: RP2040 reads PT100 temperature data and NTC resistance voltage converted by MAX31865 in real time, and automatically adjusts the driving current or starts the fan to dissipate heat when the temperature exceeds the threshold, preventing the motor and driver from overheating. At the same time, the OLED display screen will highlight the temperature abnormal information, and the status indicator light will turn red and high-frequency flash.
[0049] ADXL345 accelerometer monitors the motor vibration in real time, and adjusts the stepping parameters through algorithm when detecting abnormal vibration to reduce resonance and improve printing quality. At this time, the OLED display screen will prompt the vibration abnormality and display the vibration amplitude value.
[0050] Integrated control: 6-layer circuit board design integrates CAN transceiver, TMC2209 driver, acceleration sensor, temperature sensor interface and other human-computer interaction units in a compact space, shortens the signal transmission path, reduces the interference risk, and is convenient for installation and maintenance. Users can directly view the integrated operation data and status of the equipment through the human-computer interaction unit.
[0051] The embodiments of the present application are disclosed, but are not limited to this, and those skilled in the art can easily understand the spirit of the present application according to the above embodiments, and make different inferences and changes, as long as they do not deviate from the spirit of the present application, they are within the protection scope of the present application.
Claims
1. A stepper motor closed-loop driver, characterized in that: include: A main control unit is used to generate control signals and process feedback data. The main control unit is an STM32F103CBT6 microcontroller or an RP2040 chip; A drive circuit, connected to the main control unit, for driving a stepper motor, including a dual H-bridge driver chip TB67H450 or TMC2209; A position feedback unit, connected to the main control unit, for detecting the position of the motor rotor, including an MT6816 or AS5047D magnetic angular position sensor; A communication interface unit, connected to the main control unit, is used to realize data interaction between the driver and external devices, including a CAN bus interface and an RS485 interface; The human-computer interaction unit is connected to the main control unit and is used for parameter setting and status display, including an OLED screen and buttons.
2. A stepper motor closed-loop driver according to claim 1, characterized in that: The driving circuit adopts a dual H-bridge architecture, realizes current detection through a sampling resistor, and optimizes the signal through a second-order filter. The resistance of the sampling resistor is 100mΩ.
3. A stepper motor closed-loop driver according to claim 1, characterized in that: When the main control unit adopts the STM32F103CBT6 chip, the three-loop control of torque, speed and position is realized through the FOC vector control algorithm; when the RP2040 chip is adopted, the motor drive and peripherals work in coordination through the integrated control algorithm.
4. A stepper motor closed-loop driver according to claim 1, characterized in that: The CAN bus interface in the communication interface unit adopts TJA1044GT / 1Z or MCP2542FD-E / SN transceiver, the RS485 interface adopts SP3485EEN transceiver, and a 120Ω or 60.4Ω terminal resistor is connected in parallel between CAN-H and CAN-L of the CAN bus interface.
5. A stepper motor closed-loop driver according to claim 1, characterized in that: The position feedback unit communicates with the main control unit via an SPI interface, wherein the SPI interface includes SPI1 or SPI0, and the CS pin of the sensor is controlled by the GPIO pin of the main control unit.
6. A stepper motor closed-loop driver according to claim 1, characterized in that: It also includes an optical coupling chip for isolating the high-current drive circuit from the low-voltage signal circuit. The optical coupling chip model is EL3H7C.
7. A stepper motor closed-loop driver according to claim 1, characterized in that: The OLED screen of the human-computer interaction unit communicates with the main control unit via an SPI2 or I2C interface. The screen size is 0.91 inches or 1.3 inches, and the number of buttons is 2-3 for mode switching and parameter adjustment.
8. A stepper motor closed-loop driver according to claim 1, characterized in that: The driver supports a wide voltage input of 12-24V, has a power-on self-test function, and displays error codes on the OLED screen. The error codes include temperature anomalies, communication failures, or motor overloads.
9. A stepper motor closed-loop driver according to claim 1, characterized in that: The human-computer interaction unit also includes a status indicator light, which flashes at a low frequency during normal operation and flashes at a high frequency or changes color when a fault occurs. The driver realizes power input and serial port debugging through a Type-C interface.