P. 1
DC motor direction control using L293d(h bridge)

# DC motor direction control using L293d(h bridge)

|Views: 295|Likes:

See more
See less

03/15/2014

pdf

text

original

# DC motor direction control using L293d

This is another tutorial for microcontroller interfacing series. This is all about how to interface/control a simple DC motor using microcontrollers. Controlling a DC motor is nothing but controlling the direction and speed of a motor. It is very necessary to go through motor controlling concept, if you are designing an autonomous robot.

How DC Motor works ???

Lets start with how actually DC motor runs. Direction control of a DC motor is very simple, just reverse the polarity, means every DC motor has two terminals out. When we apply DC voltage with proper current to a motor, it rotates in a particular direction but when we reverse the connection of voltage between two terminals, motor rotates in another direction.

Controlling using Micro Controllers !!!
I think you are now familiar how to change the direction of DC motor. Now let us consider how to control motor using Microcontroller provided: 1. Microcontroller provides us only digital logic (1 or a 0). 2. We cant provide polarity from microcontroller.

we can drive a maximum of two DC motor and One stepper motor using one L293d. We cant connect motors to Controller as mostly motors runs on volatage higher that +5V. It is a circuit which allows motor rotation in both directions. and motors demands high current (depends). Now the solution to above limitations is use of a “H Bridge”. From four terminals of H bridge you can control a DC motor.3. . its a dual half H brige IC. Using L293d Dual half H Bridge … We can make our own H bridge using transistors but it will be better if we use a ready made IC named as L293d.

this will result in controlled power input on motor.Decision Table will look like IN1 0 1 IN2 1 0 Motor1 Rotates in one direction Rotates in other direction Similar is true for another motor connected to Out3 and Out4 of L293d and can be controled through IN3 and IN4. . To control the speed of DC motor one can use a Pulse Width Modulated signal on Enable1 and Enable2 pins of L293d. This is all about controlling direction of DC motor using L293d and ATmega16. so speed is controlled.

h> #include<util/delay. ***************************************************** ****************/ #include<avr/io. // PORTC declared as output port PORTC=0x00. // PORTD Pull Ups enabled initialized DDRC=0XFF. // PORTD declared as input port PORTD=0xFF.h> int main(void) { DDRD=0x00. // PORTC initialized ./**************************************************** ***************** Example program for DC motor control using L293d H bridge IC This program simply make both of 2 Dc motors to rotate some time in one direction and sometime in other.

// motor rotates in one particular direction } else if(!(PIND&0x02)) // PIN D1 is used as another input { _delay_ms(50). // debounce time while(!(PIND&0x02)). PORTC=0b00000010.while(1) { if(!(PIND&0x01)) // PIN D0 is used as input { _delay_ms(50). // Debounce time while(!(PIND&0x01)). PORTC=0b00000001. devesh@electroons.Do not connect toy car small DC motor directly to L293d as they consume lot of current and has small internel resistance. // Stop motor } // else end here } // While(1) ends here } // main() ends here Note.com Best viewed at Firefox 1024x768 resolution . // motor rotates in another direction } else { PORTC=0x00.

scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->