Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
Engineering,
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.
Motor Speed The speed of motor is measured in steps per second(Steps/s) is a function of Switching Rate.
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
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
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