The microcontroller controls the stepper motor to move forward and reversely in 1 step, 10 steps, and 100 steps

Publisher:星光闪耀Latest update time:2016-03-28 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Conception of program design:

1)  Control principle of stepper motor

The stepper motor is an open-loop control element that converts electrical pulse signals into angular displacement or linear displacement. In the case of non-overload, the motor's speed and stop position depend only on the frequency and number of pulses of the pulse signal, and are not affected by load changes. That is, when a signal is added to the motor, the motor rotates a step angle. The existence of this linear relationship, coupled with the characteristics of the stepper motor having only periodic errors but no accumulated errors, makes it very simple to use stepper motors to control in the field of linear speed, position and other control areas.

2)  Analysis and Design

Use the microcontroller to drive the stepper motor in software mode. Through the editing method, the speed, reciprocating angle and number of rotations of the stepper motor can be controlled within a certain range. It can also conveniently and flexibly control the operating status of the stepper motor:

3) Schematic diagram:

4) Connection diagram:

 

Output

Input

A

C1

P2.0

KM1

P1.0

1B

B

C2

P2.1

KM2

P1.1

2B

C

C3

P2.2

KM3

P1.2

3B

D

C4

P2.3

KM4

P1.3

4B

 

 

P2.4

KM5

 

 

 

 

 

5) Application components and circuit diagram

 

Component Name

model

Number of items

Microcontroller

AT89C51

1

Crystal Oscillator

CRYSTAL

1

capacitance

CAP    22PF 47UF

2

resistance

RES   0.6W 10K

1

Stepper Motor

STEPER    4-phase

1

Stepper motor chip

ULN2003A

1

Button

BUTTON

6

 

 

 

2. Experimental Procedure

org 0000H

start:

jnb p2.0,step

jnb p2.1,step

sjmp start

step:

jnb p2.2,one

jnb p2.3,ten

jnb p2.4,hundred

ljmp start

one:

mov r0,#2

jnb p2.0,zh1

jnb p2.1,fan1

ljmp start

ten:

mov r0,#10

jnb p2.0,zh1

jnb p2.1,fan1

ljmp start

hundred:

mov r0,#100

jnb p2.0,zh1

jnb p2.1,fan1

ljmp start

zh1:

mov p1,#03H

lcall delay

jnb p2.7,stop

djnz r0,zh2

ljmp stop

zh2:

mov p1,#06H

lcall delay

jnb p2.7,stop

djnz r0,zh3

ljmp stop

zh3:

mov p1,#0cH

lcall delay

jnb p2.7,stop

djnz r0,zh4

ljmp stop

zh4:

mov p1,#09H

lcall delay

jnb p2.7,stop

djnz r0,zh1

sjmp stop

fan1:

mov p1,#09H

lcall delay

jnb p2.7,stop

djnz r0,fan2

ljmp stop

fan2:

mov p1,#0cH

lcall delay

jnb p2.7,stop

djnz r0,fan3

ljmp stop

fan3:

mov p1,#06H

lcall delay

jnb p2.7,stop

djnz r0,fan4

ljmp stop

fan4:

mov p1,#03H

lcall delay

jnb p2.7,stop

djnz r0,fan1

sjmp stop

stop:

mov p1,#00H

ljmp start

delay:

mov r2,#200

d1:mov r1,#200

djnz r1,$

djnz r2,d1

ret

end

3. Debugging records:

After the program is compiled and downloaded to the microcontroller, it is found that the 10-step button cannot be run during the operation, while the others are running normally. When checking the program, it is found that there is an error in the 10-step program. After correction, it can be run.

Reference address:The microcontroller controls the stepper motor to move forward and reversely in 1 step, 10 steps, and 100 steps

Previous article:Summary of MCU learning experience 2.
Next article:Microcontroller clock design

Latest Microcontroller Articles
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号