To solve these problems you may use transistorized H Bridge in which freewheeling diodes are used to avoid problems due to back emf. Thus it requires minimum four transistors, diodes and resistors for each motor. It is better to use readymade ICs such as L293D or L293 instead of making your own H Bridge, which simplifies your project.
L293D is a Quadruple Half H-Bridge driver commonly used for motor driving. We needn’t connect any transistors, resistors or freewheeling diodes. All the four outputs of this IC are TTL compatible and output clamp diodes are provided to drive inductive loads. L293D can provide up to 600mA current, in the voltage raging from 4.5 to 36v. L293 is a similar IC which can provide up to 1A in the same voltage range.
L293 or L293D contains four Half H Bridge drivers and are enabled in pairs. Input EN1 is used to enable pair 1 (IN1-OUT1, IN2-OUT2) and input EN2 is used to enable pair 2 (IN3-OUT3, IN4-OUT4). We can drive two DC Motors with one L293D, but here for demonstration we are using only one. You can connect second DC Motor to driver pair 2 according to your needs.
Circuit Diagram
Motor Supply is given to the Vs pin of L293D and motor is connected to the first pair of drivers, which is enabled by connecting EN1 to logic HIGH. Vss pin is used to provide logic input to L293D. Control signals is given by using Atmega32 microcontroller which operates at 5V, hence Vss is connected to 5V.
Atmel Studio C Program
Code: Select all
#ifndef F_CPU
#define F_CPU 8000000UL // 16MHz clock speed
#endif
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRC = 0xFF; //PORTB as Output
while(1)
{
//Rotates Motor in Antilockwise
PORTC = 0x01; //00000001
_delay_ms(4000);
//Stops Motor
PORTC = 0x00; //00000000
_delay_ms(4000);
//Rotates Motor in Clockwise
PORTC = 0x02; //00000010
_delay_ms(4000);
//Stops Motor
PORTC = 0x03; //00000011
_delay_ms(4000);
}
}
Control Signals and Motor Status
Article courtesy of electrosome.com