Sei sulla pagina 1di 14

Interfacing of Stepper Motor with Microcontroller 8051

Prepared By:
Uday Korat (100280111022) Himanshi Gajjar(100280111032)
1

CERTIFICATE

This

is

to Studying

certify in 5th

that__________________________

semester, B.E. (Electronics and Communications) has successfully completed his project on
MICROCONTROLLER AND INTERFACING

within four walls of L.D. College Of

Engineering,

Ahmedabad -15 for the term ending in November. 2012

Date of Submission: _________

Staff in-Charge Mr.Pankaj Prajapati

Head of Department Prof. K.R.Parmar

L.D. College of Engineering


Gujarat Technological University, Ahmedabad-380015. 2

Table Of Content:
1. 2. 3. 4. 5. 6. 7. 8. Introduction Component List Stepper Motor 8051 Microcontroller L293D (Quadruple Half H-Bridge IC) Circuit Diagram Flowchart C Program

Component List
8051 Controller 8051 Development board L293D(Motor Driver) Stepper Motor(Bipolar) SPST switch Connectors

Stepper Motor
A stepper motor is a widely used device that translates electric pulse into mechanical movement. Stepper motor is one of the commonly used motors for precise angular movement. The advantage of using a stepper motor is that the angular position of the motor shaft can be controlled without any feedback mechanism. Stepper motors are widely used in industrial and commercial applications. They are also commonly used as in drive systems of autonomous robots. A stepper motor is an electric motor that can perform a 360-degree rotation divided into a number of steps. The number of steps differs for various stepper motors. The micro stepping concept can be used in a stepper motor to increase the number of steps and to provide smooth rotation by eliminating jerky behavior between each step. Two full-bridge motor drivers can be connected to a stepper motor to perform micro steps.

Concepts Related to Stepper Motor Step Angle


The Step angle is the minimum degree of rotation associated with a single step. Steps per Second & rpm Relation
Steps per Second = rpm * Steps per revolution
60

Motor Speed The speed of motor is measured in steps per second(Steps/s) is a function of Switching Rate.

Types Of Stepper Motor


Stepper Motor is mainly classified into 2 types: 1. Unipolar Stepper Motor 2. Bipolar Stepper Motor

1. Unipolar Stepper Motor


Unipolar stepper motors are characterised by their centertapped windings.

2. Bipolar Stepper motor


The Bipolar Stepper motor has 2 coils. The coils are identical and are not electrically connected. You can identify the separate coils by touching the terminal wires together-- If the terminals of a coil are connected, the shaft becomes harder to turn.

Step Sequence for Bipolar stepper motor 1. 4-Step Wave Drive Sequence
Step 0 1 2 3 1a 1 0 0 0 1b 0 1 0 0 2a 0 0 1 0 2b 0 0 0 1

2. 8-Step (Half Step) Sequence Step


0 1 2 3 4 5 6 7

1a
1 1 0 0 0 0 0 1

1b
0 1 1 1 0 0 0 0

2a
0 0 0 1 1 1 0 0

2b
0 0 0 0 0 1 1 1

8051 Microcontroller
o Features
8 bit ALU. 16 bit PC and DPTR. 8 bit stack pointer and 8 bit PSW. 4K internal ROM 128 bytes of Internal RAM. 32 bits arranged as four,8 bit ports P0-P3. Two 16 bit timer/counters, T0 & T1. Full duplex serial Port. Control Registers TCON,TMOD,SCON,PCON,IP,IE etc (SFRs). Two External and three internal interrupt sources. 0-12 MHz clock. 40 pin DIP package. Powerful Instruction set.

Pin Diagram

L293D(Motor Driver IC)


L293D are quadruple high-current half-H drivers. Output Clamp Diodes for Inductive Transient Suppression The L293D is designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V. All inputs are TTL compatible. Drivers are enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an enable input is high, the associated drivers are enabled and their outputs are active and in phase with their inputs. When the enable input is low, those drivers are disabled and their outputs are off and in the highimpedance state. With the proper data inputs, each pair of drivers forms a full-H (or bridge) reversible drive suitable for solenoid or motor applications.

10

Circuit Diagram

Hardware Description
Port1 of microcontroller is configured as output port. 4 pins of port1 in connected with 4 input of the L293D. 2 enable of the L293D is connected with the 5 Volts. Vss of L293D is connected with 12Volts supply. Vcc of L293D is connected with 5Volts supply. Stepper Motor is connected with L293D. Vss is used as Motor Power Supply.

11

For changing direction of rotation, a SPST switch is used, which is connected between port 2.0 and Ground. Port2 of Microcontroller is configured as Input Port. Switch is connected with pin 0 of the port2, As we know ports of Microcontroller are Bit-Addressable. So direction of rotation is depends upon the status of pin 0 of port2. When switch is connected with ground, pin 2.0 will get 0 as Input, So Motor will rotate in Clockwise Direction. When switch is not connected with ground, pin 2.0 will get 1 as input, as pin 2.0 is configured as input port by giving 1 to the pin. So motor will rotate in Anticlockwise Direction.

Flowchart

12

C Program
/************ BIPOLAR STEPPER (BOTH DIRECTION) *****************/ /************AUTHOR: HIMANSHI & KORAT*****************/ /************PORTC AS OUTPUT AND CONNECTED WITH L293D*********/ /************SPST SWITCH CONNECTED WITH PORTB.0 FOR DIRECTION CHANGE*********/

#include<avr/io.h> #include<util/delay.h> void motor_stop(void); void motor_clockwise(void); void motor_anticlockwise(void); #define SET(x,b) x|=(1<<b) #define CLR(x,b) x=x&(~(1<<b)) #define CHK(x,b) (x&(1<<b)) #define x CHK(PINB,0) #define a 0x08 #define b 0x02 #define c 0x04 #define d 0x01 void main(void) { DDRC=0XFF; CLR(DDRB,0); SET(PORTB,0); //motor_stop(); while(1) { if(!x) { motor_stop(); while(!x) { motor_clockwise(); } } else { motor_stop();

13

while(x) { motor_anticlockwise(); } } } } void motor_stop(void) { PORTC=0X00; _delay_ms(100); } void motor_clockwise(void) { PORTC=a; _delay_ms(10); PORTC=b; _delay_ms(10); PORTC=c; _delay_ms(10); PORTC=d; _delay_ms(10); } void motor-anticlockwise(void) { PORTC=a; _delay_ms(10); PORTC=d; _delay_ms(10); PORTC=c; _delay_ms(10); PORTC=b; _delay_ms(10); }

14

Potrebbero piacerti anche