Pages: [1] 2 3   Go Down
Author Topic: Help with L293DNE motor driver.  (Read 1800 times)
0 Members and 1 Guest are viewing this topic.
India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: April 16, 2014, 01:50:01 am by rakshithgb » Logged

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:



Code:
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);
}

« Last Edit: April 16, 2014, 01:49:29 am by rakshithgb » Logged

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
  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.
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Oregon, USA
Offline Offline
Edison Member
*
Karma: 72
Posts: 2482
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

"It seems to run on some form of electricity"

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
  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 ?

* L293DNE.pdf (372.33 KB - downloaded 10 times.)
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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) :





« Last Edit: April 16, 2014, 01:09:08 pm by rakshithgb » Logged

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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   ?

Code:
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)
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* Multi-MotorShieldSchematic.jpg (383.51 KB, 1899x1130 - viewed 58 times.)
* TWO_DC_MOTORS.ino (1.1 KB - downloaded 10 times.)
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Faraday Member
**
Karma: 101
Posts: 6202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.


* dcmotor_bb.png (167.95 KB, 1452x986 - viewed 40 times.)

* dcmotor_bb2.png (161.57 KB, 1480x908 - viewed 44 times.)

* L293 instructable-1.jpg (66.7 KB, 500x375 - viewed 27 times.)

* hbridge_labpinout.jpg (157.27 KB, 1024x612 - viewed 25 times.)
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Pages: [1] 2 3   Go Up
Jump to: