Remote Control Motor Program

Publisher:atech123Latest update time:2011-02-27 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;************************************************************************************
;*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

Reference address:Remote Control Motor Program

Previous article:The control system of stepper motor composed of DSP and PBL3717A
Next article:Small power synchronous motor speed regulator

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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号