Here is an introduction to the method of using a 51 single-chip microcomputer to drive a 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. It is
driven by 51 driving ULN2003. The ULN2003 is driven directly by the 5V voltage of the microcontroller system, so the torque is not very large. You can increase the driving voltage to 12V.
;************************************************************************************
;********************************Stepper motor drive***************************************
; DESIGN BY BENLADN911 FOSC = 12MHz 2005.05.19
;---------------------------------------------------------------------------------
; The driving signal of the stepper motor must be a pulse signal!!! The speed of rotation is proportional to the frequency of the pulse!!!
; The step angle of this stepper motor is 7.5 degrees. One circle is 360 degrees, and 48 pulses are required 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: Group AB--Group BC--Group CD--Group DA (i.e. one pulse, 7.5 degrees forward rotation)
;----------------------------------------------------------------------------------
;----------------------------Forward rotation--------------------------
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV R3,#144 forward rotation 3 turns, total 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, go 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
RET
DELAY1: MOV R4,#20 2S delay subroutine
DEL2: MOV R3,#200
DEL3: MOV R2,#250
DJNZ R2,$
DJNZ R3,DEL3
DJNZ R4,DEL2
RET
TABLE:
DB 30H,60H,0C0H,90H Forward table
DB 00 Forward end
DB 30H,90H,0C0H,60H Reverse table
DB 00 Reverse end
END
Previous article:51 MCU I/O port read and write operations
Next article:Implementation of Real-time Operating System Based on 51 Single-Chip Microcomputer
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- Javascript Smart Watch
- Introduction to Zigbee communication technology transmission distance and wall penetration capability
- 51 single chip microcomputer
- HyperLynx High-Speed Circuit Design and Simulation (XI) Quantitative Analysis of Signal Overdrive and Underdrive
- TI seems to have a DCDC switching power supply verification platform, which is controlled by DSP and can achieve voltage boost or voltage reduction by controlling different NMOS.
- Data丨Xunwei IMX6ULL development board-main frequency and clock configuration routine (Part 2)
- Problems still occur after installing AD16
- [Environmental Expert's Smart Watch] Part 6: BLE broadcast temperature, humidity and air pressure data
- How to clear the OE bit of the TMS320C6748 serial port register LSR
- Small Home Weather Station