Here we introduce the method of using 51 single-chip microcomputer to drive stepper motor.
The driving voltage of this stepper motor is 12V, and the step angle is 7.5 degrees. One circle is 360 degrees, and it takes 48 pulses to complete!!!
The stepper motor has 6 leads, arranged in the following order: 1: red, 2: red, 3: orange, 4: brown, 5: yellow, 6: black.
The method of driving ULN2003 with 51 is used for driving.
The driver of ULN2003 directly uses the 5V voltage of the microcontroller system, but the torque is not very large. You can increase the driving voltage to 12V by yourself.
;******************************************************************
;********************************Stepper motor drive*******************************************
; DESIGN BY BENLADN911 FOSC = 12MHz 2005.05.19
;---------------------------------------------------------------------------------
; The driving signal of the stepper motor must be a pulse signal!!! The rotation speed is proportional to the pulse frequency!!!
; The step angle of this stepper motor is 7.5 degrees. One circle is 360 degrees, which requires 48 pulses to complete!!!
;---------------------------------------------------------------------------------
; Group A coil corresponds to P2.4
; Group B coil corresponds to P2.5
; Group C coil corresponds to P2.6
; Group D coil corresponds to P2.7
; Forward rotation order: AB group -- BC group -- CD group -- DA group (i.e. one pulse, 7.5 degrees forward rotation)
;----------------------------------------------------------------------------------
;----------------------------Forward--------------------------
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV R3,#144 forward rotation 3 circles, 144 pulses START:
MOV R0,#00H
START1:
MOV P2,#00H
MOV A,R0
MOV DPTR,#TABLE
MOVC A,@A+DPTR
JZ START judges A, when A = 0, it goes to START
MOV P2,A
LCALL DELAY
INC R0
DJNZ R3,START1
MOV P2,#00H
LCALL DELAY1
;-----------------------------Reverse------------------------
MOV R3,#144 reverses one circle, a total of 144 pulses
START2:
MOV P2,#00H
MOV R0,#05
START3:
MOV A,R0
MOV DPTR,#TABLE
MOVC A,@A+DPTR
JZ START2
MOV P2,A
CALL DELAY
INC R0
DJNZ R3,START3
MOV P2,#00H
LCALL DELAY1
LJMP MAIN
DELAY: MOV R7,#40 Stepper motor speed
M3: MOV R6,#248
DJNZ R6,$
DJNZ R7,M3
RIGHT
DELAY1: MOV R4,#20 2S delay subroutine
DEL2: MOV R3,#200
DEL3: MOV R2,#250
DJNZ R2,$
DJNZ R3,DEL3
DJNZ R4,DEL2
RIGHT
TABLE:
DB 30H,60H,0C0H,90H forward table
DB 00 Forward rotation ends
DB 30H,90H,0C0H,60H Reversal table
DB 00 Reversal end
END
Previous article:51 MCU RTL8019AS network card driver
Next article:Hybrid Scheduler C51 Source Code
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- R16 core board features
- Design of vehicle-mounted turntable dynamic monitoring system based on DSP and AD1674 AID conversion chip
- Playing with Zynq Serial 30——[ex52] GPIO control based on Zynq PS
- [ESP32-Audio-Kit Audio Development Board] - 4: Run "esp-adf" build on Ubuntu 20.04
- Schematic diagram/PCB package of HuaDa Semiconductor MCU general and low power series products
- TF card disassembly and structure diagram
- Common power symbols and their meanings
- EEWORLD University - Teach you how to learn LittleVGL
- Altera SoC Architecture Excerpt - Altera SoC FPGA Adaptive Debug.pdf
- 5. Common Emitter Amplifier Circuit