51 single chip microcomputer drives stepper motor circuit and program

Publisher:彭勇Latest update time:2011-01-25 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Here we introduce the method of using 51 single-chip microcomputer to drive 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.

The method of driving ULN2003 with 51 is used for driving.

The driver of ULN2003 directly uses the 5V voltage of the microcontroller system, but the torque is not very large. You can increase the driving voltage to 12V by yourself.

;******************************************************************

;********************************Stepper motor drive*******************************************

; DESIGN BY BENLADN911 FOSC = 12MHz 2005.05.19

;---------------------------------------------------------------------------------

; The driving signal of the stepper motor must be a pulse signal!!! The rotation speed is proportional to the pulse frequency!!!

; The step angle of this stepper motor is 7.5 degrees. One circle is 360 degrees, which requires 48 pulses 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: AB group -- BC group -- CD group -- DA group (i.e. one pulse, 7.5 degrees forward rotation)

;----------------------------------------------------------------------------------

;----------------------------Forward--------------------------

ORG 0000H

LJMP MAIN

ORG 0100H

MAIN:

MOV R3,#144 forward rotation 3 circles, 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, it goes 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

RIGHT

DELAY1: MOV R4,#20 2S delay subroutine

DEL2: MOV R3,#200

DEL3: MOV R2,#250

DJNZ R2,$

DJNZ R3,DEL3

DJNZ R4,DEL2

RIGHT

TABLE:

DB 30H,60H,0C0H,90H forward table

DB 00 Forward rotation ends

DB 30H,90H,0C0H,60H Reversal table

DB 00 Reversal end

END

Reference address:51 single chip microcomputer drives stepper motor circuit and program

Previous article:51 MCU RTL8019AS network card driver
Next article:Hybrid Scheduler C51 Source Code

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号