toothache

# Sixth Lichuang Electric Competition #ESP32 two-phase four-wire hybrid stepper motor closed-loop driver

 
Overview

1. Introduction to project functions



Stepper motors are widely used in production and life because of their high positioning accuracy, low cost, and simple control.

 

Compared with open-loop stepper motors, closed-loop stepper motors have a certain overload capability and will not lose steps. They can adjust the current according to the load to reduce motor heating.

 

Due to the skyrocketing chip prices, the cost of closed-loop stepper motor controllers has skyrocketed. This design proposes a closed-loop stepper motor controller solution using the domestic chip ESP32 as the main control.

 

This design is based on Yang Gong's closed-loop stepper motor driver. The hardware has been modified and redesigned. The software has transplanted and reconstructed the code, and extracted part of the code of Grbl_ESP32 as the running framework of the core algorithm.

 

characteristic:

1. EN/DIR/STEP interface control, compatible with 3D printer motherboard

2. Serial port/Bluetooth/Telnet online parameter adjustment

3. 3.3A peak current

4. Position closed loop/position open loop mode can be switched

5. Overheating protection

6. Voltage monitoring

7. Real-time data feedback

 

typical application:

1. 3D printer, laser engraving machine, flat plotter

2. Robot

3. Electric slide

4. Smart curtains

5. Electric turntable

aj01nyuauIaMpA3oaM77ghiXP8JLW4ClB9JB9DSr.png

Figure 1 Arduino style pin diagram

 

2. Project attributes


The project is made public for the first time;

The project is original;

The project has not won awards in other competitions;

The project has not participated in a defense defense at school;

 

 

3. Open source agreement


Open source license: CC-BY-NC-SA 3.0

 

Quote: #四 session的立chuangcompetition#HyperStepper Integrated low-cost, high-speed, high-precision fully closed-loop stepper motor  (open source protocol: BSD)

Citation: Grbl_Esp32 (Open Source License: GPL-3.0)

Self-citation: [Hangshun Training Camp] Closed-loop stepper motor controller

Self reference: ESP32 Closed Loop Stepper Motor Controller

 

4. Hardware part


(1) Drive circuit:

This design uses two A4950 chips as driver chips. This chip is a full-bridge DMOS PWM motor driver and has a current limiting function. Constant current control can be achieved based on this function.

 

1ZW8O2q9X8nonUUj8RmtNqft44TryUgTca9SHMze.png

Figure 2 A4950 structural block diagram

 

The constant output current can be changed by adjusting the Verf pin voltage, Imax  = Verf/(10*Rsense). In this design, the Verf pins of the two A4950s are connected to the DAC output pins of the ESP32 respectively, using 0.1Ω current sampling resistor, so the maximum output current is 3.3A

 

6Fh8m2m2ZoQdXKOr2OTIqdYxsReg3mduYBffoALU.png

Figure 3 A4950 circuit diagram

 

(2)BUCK step-down circuit & LDO step-down circuit:

In this design, the control system power supply is obtained by stepping down the motor power supply to 5V through the BUCK circuit and then stepping down the voltage twice through the LDO buck circuit.

The BUCK chip model used in this design is JW5026, which has a withstand voltage of up to 40V and a maximum output current of 1A. It requires a small number of peripheral components and low filtering inductance requirements, so it saves PCB space.

wfcENinDP8Hm1JNESqZIrHDqWjHH5I4UtSy4Pe7u.png

Figure 4 BUCK step-down circuit

 

The LDO model used in this design has a maximum output current of up to 900mA, which is very suitable for powering ESP32

 

GfUvv43fbn7X5iWdGO6868cDtGcnWXyGLawA5irg.png

Figure 5 LDO buck circuit

 

(3)External signal input circuit:

In this design, the external input signal is isolated with an optocoupler. EN is a low-speed signal, so a low-speed optocoupler is used. The DIR/CLK signal is a high-speed signal, so a high-speed optocoupler is used.

uu8AFH9fLOTD4hcYlfqyZCj3PAkIU0PuKloyDNcf.png

Figure 6 External input signal circuit

 

(4) MCU minimum system:

This design uses ESP32-PICO-D4 as the main control, which integrates crystal oscillator/SPI FLASH/RF filter circuit/decoupling capacitor, etc., and requires very few peripheral components.

This design reserves a GH1.25 6pin interface as the program burning interface and serial communication interface

 

zQT5xxP6KiLRCbhvXalJcicDXOESWrnDl7FMtGsQ.png

Figure 7 MCU minimum system

 

(5) Encoder circuit:

This design uses the domestic 14-bit high-precision absolute magnetic encoder MT6816. You can choose to use its SPI interface or ABI interface (not supported yet). It is installed on the back of the PCB and obtains the motor rotor angle through the radial magnetizing magnet installed at the tail of the motor.

jBmBQQC49hOdByxXc3rwooD79ZHtRnirmKeIUc08.png

Figure 8 Encoder circuit

 

(6) Motor power supply voltage sampling circuit & driver IC temperature sampling circuit:

GO60ZPLMACKfAm4i1A5QhIt7M7eHdFTM5ZZ9Qr05.png

 

Figure 9 Motor power supply voltage sampling circuit & driver IC temperature sampling circuit

 

(7) Motor power supply filter circuit:

This design uses an SS54 on the motor power supply to prevent the electric energy generated when the stepper motor is in the power generation state from causing the system to start incorrectly, and uses an SMBJ30CA to prevent the stepper motor from being in the feedback braking state or the power generation state. Voltage burnout A4950 also uses a large-capacity MLCC for line energy storage to reduce the voltage ripple of the motor power supply when it is running.

dNE4lIeGu1e4O6rYSvEG7fv2ImcjTcfekDmGLzXh.png

Figure 10 Motor power supply filter circuit

 

5. Software part


Code: https://gitee.com/STM32G474RET6/xbdrive (not yet complete)

KOAOuPJbQTaiclfOyfYau7GasVuhDA9rXWgvIDtv.png

 

Figure 11 Code screenshot

 

yI7z1Fhed3pu6bLGZnIQcHyfQzZnIjzUf2Nrp8jd.png

 

                 Figure 12 System framework

 

6. BOM list


w8qMSCwFg8TSj1pRPYTkgJ2evsICZiSDSLzC5iXr.png

 

Figure 13 Screenshot of BOM table (including transfer module and serial port module components)

 

7. Contest LOGO verification


zJEoOCwBbeDARXgAz5xxukrCZ7ZhofZyX57MKWKh.png

Figure 14 Back picture

 

8. Demonstration video

 

参考设计图片
×
Design Files
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-15 03:23:21

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号