0% found this document useful (0 votes)
29 views

Chuong Trinh Chinh

This program controls a stepper motor with 6 button inputs: 1. The START button is pressed to start the program and motor operation. 2. The STOP button resets and stops the motor. 3. Individual buttons make the motor turn either half a step or full step depending on the mode selected. 4. The motor will continuously turn as long as the corresponding button is held down, selecting between half step or full step mode.

Uploaded by

Ngocan Huynh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Chuong Trinh Chinh

This program controls a stepper motor with 6 button inputs: 1. The START button is pressed to start the program and motor operation. 2. The STOP button resets and stops the motor. 3. Individual buttons make the motor turn either half a step or full step depending on the mode selected. 4. The motor will continuously turn as long as the corresponding button is held down, selecting between half step or full step mode.

Uploaded by

Ngocan Huynh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

CHNG TRNH HOT NG

;----------------------------------------------------------------------------------------------------------------; sinh vien : Trinh Ngoc Hoang - MSSV : 05112025


; Chuong trinh dieu khien dong co buoc -6 nut nhan:
; +Nhan START de khoi dong chuong trinh hoat dong
;
+ Nhan STOP (nut Reset cua vi dieu khien) de dong co buoc
;
+ Nhan thi dong co quay"1 buoc hay 1/2 buoc "phu thuoc theo su lua chon la
haftstep hay fullstep
;
+ Nhan lien tuc dong co quay lien tuc tuy thuoc vao che do chon la haftstep
hay fullstep
;--------------------------------------------------------------------------------------------------------ORG 00H
start
fullthuan
fullnghich
haftthuan
haftnghich

equ
equ
equ
equ
equ

p1.0
p1.1
p1.2
p1.3
p1.4

STEPPER

equ p2

MAIN:
mov A,#00000000B
; NAP TRNG THI U NG C BC
mov STEPPER,A
; XUT RA NG C
mov R0,#0
; GN BIN
;================================================================
KIEMTRAPHIM:
;------------------nutstart: mov r5,#50
a0: jb start,nutso1
djnz r5,a0
mov R0,#1
nutso1: mov r5,#100
a1:
jb fullthuan,nutso2
djnz r5,a1
mov R0,#2
;------------------nutso2:
mov r5,#100
a2: jb fullnghich,nutso3
djnz r5,a2
mov R0,#3

;------------------nutso3:
a3:

mov r5,#100
jb haftthuan ,nutso4
djnz r5,a3
mov R0,#4

;------------------nutso4:
mov r5,#100
a4: jb haftnghich,sosanh
djnz r5,a4
mov R0,#5
;================================================================
sosanh:
;----------------------------------------------------batdau:
cjne R0,#1,quayfullthuan
; CHUONG TRINH NUT START
mov A,#00000011B
acall quay
mov R0,#0
;--------------------------------------------------quayfullthuan:
cjne R0,#2,quayfullnghich
rl A
rl A
acall quay
mov R0,#0
;------------------quayfullnghich:
cjne R0,#3,quayhaftthuan
rr A
rr A
acall quay
mov R0,#0
;------------------quayhaftthuan:
cjne R0,#4,quayhaftnghich
rl A
acall quay
mov R0,#0

;------------------quayhaftnghich:
cjne R0,#5,quit
rr A
acall quay
mov R0,#0
;------------------quit:
ajmp KIEMTRAPHIM
ret
;================================================================
quay:
acall delay
mov STEPPER,A
PUSH ACC
call delay10ms
POP ACC
ret
;================================================================
;****** TAO THOI GIAN TRE KHOANG 200mS - TIME 0 - MODE1
delay:
push 00H
mov R0,#2
mov TMOD,#01H
loop2:
mov TH0,#HIGH(-50000)
mov TL0,#LOW(-50000)
setb TR0
jnb TF0,$
clr TR0
clr TF0
djnz R0,loop2
pop 00H
ret
;=================THOI GIAN DELAY DU DE TAT TRANG THAI LED TRUOC
;================================DO ============================
delay10ms:
mov R5,#100
del1: mov R6,#048
djnz R6,$
djnz R5,del1
ret
end

You might also like