;*Stepper motor control program p3.2 forward, p3.3 reverse, p3.4 stop stepper motor connected to p1.0p1.1p1.2p1.3 *
;********************************************************************************
;* Date: 2007-3-25 *
;* Version: 3.0 *
;* Author: Shenzhen Xuelin Electronics Co., Ltd. Professional 8051 Microcontroller Tutorial Station*
;* Email: sxj1974@163.com *
;* Website: http://www.51c51.com http://www.8951.com For more routines, please visit the website*
;********************************************************************************
;* Hardware: This program runs on our company's xlisp series microcontroller experiment instrument*
;********************************************************************************
;* 【Copyright】 Copyright(C)Shenzhen Xuelin Electronics Co., Ltd.www.51c51.com All Rights Reserved *
;* 【Statement】 This program is only for learning and reference. Please indicate the copyright and author information when quoting! *
;********************************************************************************
Download the hex format file (right click, save the target as hex and burn it directly)
org 00h
stop: orl p1,#0ffh ; stepper motor stops
loop: jnb p3.2,for2 ; if p3.2 is pressed, forward
jnb p3.3,rev2 ; if p3.3 is pressed, reverse
jnb p3.4,stop1 ; if p3.4 is pressed, stop
jmp loop ; repeatedly monitor keyboard
for: mov r0,#00h ; forward to tab to get code pointer initial value
for1: mov a,r0 ; get code
mov dptr,#table ;
movc a,@a+dptr
jz for ; whether it has reached the end code 00h
cpl a ; reverse acc
mov p1,a ; output to p1 to start forward
jnb p3.4,stop1 ; if p3.4 is pressed, stop
jnb p3.3,rev2 ; if p3.3 is pressed, reverse
call delay ; speed of rotation
inc r0 ; get the next code
jmp for1 ; continue forward
rev: mov r0,#05h ; reverse to tab to get the initial value of the code pointer
rev1: mov a,r0
mov dptr,#table ; get the code
movc a,@a+table
jz rev ; has it reached the end code 00h
cpl a ; reverse acc
mov p1,a ; output to p1 to start reversing
jnb p3.4,stop1 ; if p3.4 is pressed, stop
jnb p3.3,rev2 ; if p3.3 is pressed, reverse
call delay ; the speed of rotation
inc r0 ; get the next code
jmp rev1 ; continue to reverse
stop1: call delay ; press p3.4 to eliminate
jnb p3.4,$ ; is p3.4 released?
call delay ; release to eliminate
jmp stop
for2: call delay ; press p3.2 to eliminate
jnb p3.2,$ ; is p3.2 released?
call delay ; release to eliminate
jmp for
rev2: call delay ;Press p3.3 to eliminate jitter
jnb p3.3,$ ; Is p3.3 released?
call delay ;Release to eliminate jitter
jmp rev
delay: mov r1,#40 ;Stepper motor speed 20ms
d1:mov r2,#248
djnz r2,$
djnz r1,d1
ret
table:
db 03h,09h,0ch,06h ;Forward table
db 00 ;Forward end
db 03h,06h,0ch,09h ;Reverse
db 00 ;Reverse
end end
Previous article:The control system of stepper motor composed of DSP and PBL3717A
Next article:Small power synchronous motor speed regulator
- 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
- EEWORLD University - How to use independent measurement ADC to design high-precision CT phase meter
- A collection of selected PCB design resources, free points download for a limited time
- MCU model confirmation and decryption
- [Zero-knowledge ESP8266 tutorial] Quick start 25 Blynk control RGB LED
- Need a 10uh inductor, ESR < 0.2Ω, saturation current > 0.8A
- Ti DSP optimization basic strategy
- Bluetooth Protocol Stack-01
- Thanks to shihuntaotie netizen for donating a large number of development boards!
- Scattered Noise Figure
- [Mil MYC-JX8MPQ Review] Running TDengine