Help with L293DNE motor driver.

Ok I’m trying to build a robot with ultrasonic sensor HC-SR04 and 2nos. 12V DC motors with L293DNE IC using an Arduino UNO board. Testing the motors I figured out that each of them draw about 1.2amps of current. I’m using a 12V 7.2AH battery to power these motors. When I power my motors the atmega chip on my Arduino is heating up too quickly. I haven’t used any capacitors or resistors for proper implementation of the circuit because I don’t know what it’s exactly doing. My code works fine. I want to know if it’s ok for the chip to heat up if not then any help with my circuit?

What circuit ? Where's the schematic of how you connected the power ? Draw a schematic and take a photo with a cell phone and post it.

This is exactly how i built my circuit on my breadboard and this is the code used instead of the 9V battery I used 12V battery:

const int Motor1Pin1 = 8;
const int Motor1Pin2 = 9;
const int Motor2Pin1 = 10;
const int Motor2Pin2 = 11;
int trigPin = 13;
int echoPin = 12;

void setup() 
{
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);  
  pinMode(Motor1Pin1, OUTPUT);   
  pinMode(Motor1Pin2, OUTPUT);   
  pinMode(Motor2Pin1, OUTPUT);   
  pinMode(Motor2Pin2, OUTPUT);     
}


void loop() 
{ 
  long duration,distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration=pulseIn(echoPin, HIGH);
  distance=(duration/2)/29.1;
  if (distance>4)
  {
  GoForward();
  }
  else
  {
  GoBackward();
  }
  if(distance>=200 || distance <=0)
  {
    Serial.println("OUT OF RANGE");
  }
  else
  {
    Serial.print(distance);
    Serial.println(" cm");
  }
  delay(500);
 }

void GoForward()
{
  digitalWrite(Motor1Pin2, LOW);
  digitalWrite(Motor1Pin1, HIGH);
  digitalWrite(Motor2Pin2, LOW);
  digitalWrite(Motor2Pin1, HIGH);
}

void GoBackward()
{
  digitalWrite(Motor1Pin1, LOW);
  digitalWrite(Motor1Pin2, HIGH);
  digitalWrite(Motor2Pin1, LOW);
  digitalWrite(Motor2Pin2, HIGH);
}

Draw a schematic and take a photo with a cell phone and post it.

This is not a schematic. If you want help on the forum, follow instructions. What you gave me is not what I asked for. Get a pen and paper. Draw a schematic. Take a photo with your cell phone. Post it using "Additional Options" button below. A wiring diagram does me no good. It is only a representation of how the circuit SHOULD be wired. I want a photo as proof. Now I want a photo of your circuit as well, with the same kind of detail. And voltage measurements on ALL the signal and power wires going to the arduino while you are running the motors.

The L293DNE chip is old, inefficient technology and is rated for 1.2 amperes absolute maximum. And that is being optimistic. It can't handle the current your motors require, especially without a heat sink.

I suggest to consider modern, inexpensive motor driver boards like those from Pololu http://www.pololu.com/category/11/brushed-dc-motor-drivers , perhaps this one: http://www.pololu.com/product/713

Let me make something perfectly clear.
The arduino processor chip (ATmeg328) should NEVER get hot , period. And I mean NEVER. If it is getting hot, then there are some voltages on those pins that exceed the allowable maximum or there is a ground connection problem. Make sure you don’t have 12V on the CPU chip or any of the I/O pins.

I can build heat sinks using capacitors right? That was my question in the beginning of this post regarding how to build them. I'm still using USB cable to power the Arduino board I'll power it later with a 9V DC battery and none of those mentioned pins are connected to the 12V battery. This is my schematic:

I'd also like to know if there are better sensors with longer range other than HC-SR04. This one measures upto 4cm which is too less.

If you want help on the forum, follow instructions.

Where is the photo of YOUR circuit and hardware ?
Your circuit is not wired per the datasheet. (see attached)
You have a motor connected 11 & 14
The chip in the Fritzing diagram is NOT an L293DNE. Look at the number on the chip. Does that say L293DNE ?
Now I want the link where you got the wiring diagram for the circuit to begin with so we can find out what you did by using a wiring diagram for one chip and connecting for a different chip.
Look at the attached datasheet for the L293DNE. Do you see a motor connected from pin-11 to pin-14 ?

l293d.pdf (372 KB)

Sorry I drew my schematic wrong. I've wired it properly. My IC is L293DNE. I've wired it accordingly to this tutorial : http://itp.nyu.edu/physcomp/Labs/DCMotorControl The only changes I made in mine was replacing the switch with the sensor and using pins 8,9,10,11 of Arduino for the motor control.

I referred this also: http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/

These are pictures of my robot and circuit (without connecting the motors) :

Ok, you're moving in the right direction but the photo is useless. The photo has to be taken DIRECTLY ABOVE the circuit. (about 12 to 18" above.) Before taking the photo, separate the wires and tape them down so they are like diagonal lines I can follow but completely flush against the surface they are on and not sticking up. Use some kind of tape that works well. Then because you are using wires that are the same color you need to make little paper labels and scotch tape them next to the wires with the "TO & FROM " pin #s on it. (UNO-D8=>U-4). Before you do that I need you to answer my question about the motor testing. Do both 'motors work now with the library example ?

 const int Motor1Pin1 = 8;
const int Motor1Pin2 = 9;
const int Motor2Pin1 = 10;
const int Motor2Pin2 = 11;
int trigPin = 13;
int echoPin = 12;

void setup() 
{
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);  
  pinMode(Motor1Pin1, OUTPUT);   
  pinMode(Motor1Pin2, OUTPUT);   
  pinMode(Motor2Pin1, OUTPUT);   
  pinMode(Motor2Pin2, OUTPUT);     
}


void loop() 
{ 
  long duration,distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration=pulseIn(echoPin, HIGH);
  distance=(duration/2)/29.1;
  if (distance>4)
  {
  GoForward();
  }
  else
  {
  GoBackward();
  }
  if(distance>=200 || distance <=0)
  {
    Serial.println("OUT OF RANGE");
  }
  else
  {
    Serial.print(distance);
    Serial.println(" cm");
  }
  delay(500);
 }

void GoForward()
{
  digitalWrite(Motor1Pin2, LOW);
  digitalWrite(Motor1Pin1, HIGH);
  digitalWrite(Motor2Pin2, LOW);
  digitalWrite(Motor2Pin1, HIGH);
}

void GoBackward()
{
  digitalWrite(Motor1Pin1, LOW);
  digitalWrite(Motor1Pin2, HIGH);
  digitalWrite(Motor2Pin1, LOW);
  digitalWrite(Motor2Pin2, HIGH);
}

What the heck is this ? Is this the code you are using ? You've taken wiring from two tutorials and you have not tested your circuit with the code given in the tutorial ? LUCY ! YOU GOTTO WHOLE LOTTA SPAININ' TO DO ! (You better have a good explanation for why you posted that code)

I'll re-post a proper photo in a day or two, I'll use connector wires instead of jumper so the wiring can be minimized. I first tried both the tutorials with a single motor and the codes they provided, it worked fine. So i worked on another code to try two motors running at the same time. It worked fine for forward condition when there was no obstacle within the range of the sensor, but for backwards condition only the motor connected to the first half of L293DNE was running and the other motor was not. I felt my IC wasn't working properly because my IC had overheated while trying out one of the tutorials, I had grounded the 12V battery in the wrong place. So I've decided to purchase a set of new ICs and to start over. I posted the code so that you're aware of what exactly my robot is doing. If there's something wrong with my code or if it can be improvised please help me out.

My robot finally will run on 4 motors (2 for base & 2 for arms) and 2 sensors, so can I use all the pins available on my Arduino?

PS: You still haven't answered my question about the sensors available for longer range.

I'll test your code tonight . I have a motor shield and two motors. I might have an L293 chip. I have to look.

Your schematic is wrong . (see attached datasheet-right half of page /DC MOTORS)
PINOUT
PIN#
1-PWM0B
2 M3A
3 MOTOR3-TERM-1
4 GND
5 GND
6 MOTOR3-TERM-2
7 M3B
8 VCC2-MOTOR POWER (+) LEAD /+ LEAD OF 47uF CAP
9 PWM0A
10 M4B
11 MOTOR4-TERM-1
12 GND
13 GND
14 MOTOR4-TERM-2
15 M4A
16 VCC1 -+5V /+ LEAD OF 100uFCAP

TEAR YOU CIRCUIT APART AND REWIRE IT LIKE THIS
POST A WIRING CHECKLIST THAT SHOWS YOU VERIFIED EVERY WIRE !

FYI- MY TWO MOTORS ARE RUNNING WITH ATTACHED SKETCH

TWO_DC_MOTORS.ino (1.1 KB)

According to your schematic pin no. 1 and 2 of L293D is connected to PWM2A and PWM2B of arduino board, but according to the tutorials (previous 2 links I posted) both these pins are connected to +5 Vcc of the arduino boards.

By the way did you try out my code?

According to your schematic pin no. 1 and 2 of L293D is connected to PWM2A and PWM2B of arduino board, but according to the tutorials (previous 2 links I posted) both these pins are connected to +5 Vcc of the arduino boards.

That’s not what I see in the attached photos from the attached photos. Pin 1 (EN can be hardwired HIGH or s/w EN . Pin 2 should not be connected to +5V . See all the photos. Look at the code for the those programs (declarations)
Your schematic was clearly very wrong, most importantly because you had a motor connected to pin 2.
I didn’t try your sketch because I didn’t have an L293 chip. I use an L293 Motor driver shield and I don’t want to pull a chip out of it because it works and I’d like to keep it that way.

L293 instructable-1.jpg

Sorry I typed it wrong. I meant pin 1 and pin 9. So both these pins can be hardwired to input HIGH right? And yes I know I drew my schematic wrong. If you notice my schematic and the wiring diagram don't match. I drew it in a hurry, the motors are connected to pin3,6,11,13. The motor will not run if it's connected to pin 2. Anyway out of curiosity I'd like to know which L293 motor driver shield you used. I guess I should just purchase a shield rather than trying to build a proper one. And according to jremington, he stated that L293 can't handle so much current my motors are using so do you think I should use a different IC?

Yes . You can't use an L293 with your motors. http://www.pololu.com/product/2503

Here's one. Google "arduino 1.5A motor shields" to look for others

That is too expensive. I need all components under $30 to finish this robot. How about this one? http://www.ebay.com/itm/L298N-DC-Motor-Driver-Module-Robot-for-Arduino-PIC-AVR-L298N-/251506006357

That is rated for up to 4A so it will work. Before you test it draw a new schematic and take a photo of the schematic and circuit and post it.

I purchased this shield (attached). Please help me out with the wiring now? And the schematic is also attached. I dont know how to use this motor shield now. I did some experimenting and L298 chip on the board got overheated so I disconnected the power immediately (it was attached to 12V battery) , so I dont know if Ive burnt my board or not . :roll_eyes: :sweat_smile: