Control Stepper Motor Steering

Source: Internet
Author: User

Single turn

Code segement
Assume Cs:code,ds:code
Org 100h
START:JMP begin
Psta db 05h,15h,14h,54h,50h,51h,41h,45h; phase sequence table
Message db ' press SW2 to start! ' ; System hints
DB 0dh,0ah
DB ' If you want to quit,press SW1! '
DB 0dh,0ah, ' $ '
Begin:mov Ax,cs
MOV Ds,ax
mov ah,09h; display prompt information
MOV dx,seg message
int 21h
MOV dx,303h; initialize 8255A
MOV a1,81h
Out Dx,al
mov al,09h; pc4=1, off 74LS37
Out Dx,al
L:mov dx,302h; check SW2 press? (pc1=0?) )
In AL,DX
and al,02h; not pressed, waiting
JNZ L
mov dx,303h; pc4=0, open 74ls37
MOV al,08h
Out Dx,al
Reload:mov Si,sffset Psta; Set the phase order table pointer
MOV cx,8; set 8 beats cycle times
Lop:mov dx,302h; check SW1 press? (pc0=0?) )
In AL,DX
and al,01h
JZ quit; pressed, exited
MOV al,[si]; not pressed, send phase order form code to PA
MOV dx,300h
Out Dx,al
MOV di,0afh
MOV BX,0FFFFH; delay
Delay:dec BX
JNZ delay
Dec di
JNZ delay
Inc si; Phase sequence table pointer +1
Dec CX; Number of cycles-1
JNZ Lop; less than 8 times, continue
JMP Reload; 8 times, re-
Quit:mov dx,303h; pc4=1
MOV al,09
Out Dx,al
MOV ah,4ch; program exit
int 21h
Code ends
End Start

Positive and negative turn

Code segment

Assume Cs:code,ds:code
Org 100h
START:JMP begin
Psta DB 05h,15h,14h,54h,50h,51h,41h,45h
PSTB db 45h,41h,51h,50h,54h,14h,15h,05h; phase sequence table
Message db ' press SW2 to start! ' ; System hints
DB 0dh,0ah
DB ' If you want to quit,press SW1! '
DB 0dh,0ah, ' $ '
Begin:mov Ax,cs
MOV Ds,ax
mov ah,09h; display prompt information
MOV dx,seg message
MOV ds,dx
MOV Dx,offset message
int 21h
MOV dx,303h; initialize 8255A
MOV al,81h
Out Dx,al
mov al,09h; pc4=1, off 74LS37
Out Dx,al
L:mov dx,302h; check SW2 press? (pc1=0?) )
In AL,DX
and al,02h; not pressed, waiting
JNZ L
mov dx,303h; pc4=0, open 74ls37
MOV al,08h
Out Dx,al
Reload:mov Si,offset Psta
MOV cx,8; set 8 beats cycle times
Lop1:mov dx,302h; check SW1 press? (pc0=0?) )
In AL,DX
and al,01h
JZ lop2; pressed, exited
MOV al,[si]; not pressed, send phase order form code to PA
MOV dx,300h
Out Dx,al
MOV di,0afh
MOV BX,0FFFFH; delay
Delay1:dec BX
JNZ delay1
Dec di
JNZ delay1
Inc si; Phase sequence table pointer +1
Dec CX; Number of cycles-1
JNZ Lop1; Less than 8 times, continue
JMP Reload; 8 times, re-
Reload1:mov Si,offset Pstb
MOV cx,8; set 8 beats cycle times
Lop2:mov dx,302h; check SW1 press? (pc0=0?) )
In AL,DX
and al,02h
JZ lop1; pressed, exited
MOV al,[si]; not pressed, send phase order form code to PA
MOV dx,300h
Out Dx,al
MOV di,0afh
MOV BX,0FFFFH; delay
Delay:dec BX
JNZ delay
Dec di
JNZ delay
Inc si; Phase sequence table pointer +1
Dec CX; Number of cycles-1
JNZ lop2; Less than 8 times, continue
JMP Reload1; 8 times, re-

Code ends
End Start

Control Stepper Motor Steering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.