Pages: [1] 2   Go Down
Author Topic: wierd running of motors using arduino and l293d  (Read 1593 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi guys,
i am experiencing  some weird problems while controlling two dc geared motors using arduino uno r3 with the help of a l293d driver.

i used the following code to test the circuit...

Code:
// --------------------------------------------------------------------------- Motors
int motor_left[] = {6,7};
int motor_right[] = {10,11};

// --------------------------------------------------------------------------- Setup
void setup() {
Serial.begin(9600);

// Setup motors
int i;
for(i = 0; i < 2; i++)
{
pinMode(motor_left[i], OUTPUT);
pinMode(motor_right[i], OUTPUT);
}

}

// --------------------------------------------------------------------------- Loop
void loop() {

drive_forward();
delay(3000);
motor_stop();
Serial.println("1");

drive_backward();
delay(3000);
motor_stop();
Serial.println("2");

turn_left();
delay(3000);
motor_stop();
Serial.println("3");

turn_right();
delay(3000);
motor_stop();
Serial.println("4");

motor_stop();
delay(3000);
motor_stop();
Serial.println("5");
}

// --------------------------------------------------------------------------- Drive

void motor_stop(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], LOW);
delay(25);
}

void drive_forward(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);


void drive_backward(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);
}

void turn_left(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);
}

void turn_right(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);
}

the motors move as following, when the following functions are implemented:
1) drive forward: both motors stop
2)drive backward: only left motor backwards
3) turn left:        only right motor backwards
4) turn right:     both motors backwards
5)motor stop:    both motor backwards  !!!

when i give commands to run the left motor alone, the motor perfectly runs forward, backward...
but when i do the same for the right motor it only runs backwards, that too only for the cases, high-low and low-low. for the rest it does not run.

but when i connect the motors directly to a 9V battery supplying about  8.2V, it runs both forward and backward on interchanging the polarities.

I just dunno wat the heck is going on.. Pls help me out guys.... Breaking my head for the past three days...  smiley-cry

Thanks in advance  smiley-red
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Power supply adequate?  how have you wired things up?
Logged

[ I won't respond to messages, use the forum please ]

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

Currently, I am supplying power to the arduno using my desktop's USB port. And I am using the 5v supply form the arduino to the motor driver circuit and grounded using arduino's gnd pin. For the raw voltage of the motors, I am using two 9v batteries in series, which gives it around 13v.. To the motors.

The wiring is exactly as described in the instrucatbles page:
http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/step2/Advanced-implementation/

Thank you MarkT for taking your time to reply... Feel free to ask any other extra details you need.



Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your 9V motors are the small ones (PP3 or equivalent)??

If so they won't be able to supply enough current really - not that this explains the behaviour.

Test all the wiring is sound, try unplugging each motor in turn (with the power off of course)
and see if each is behaving when on its own - that would suggest power issues.
Logged

[ I won't respond to messages, use the forum please ]

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

Mark, I don't know what you mean by those PP3 motors.... But all I know is that it's a basic DC geared motors, and they look exactly like this:

http://www.extreme-robots.nl/91-thickbox/dc-geared-motor-met-wiel-.jpg

And I will try controlling each of the motors independently using the motor driver and get back to you.

Thanks once again. smiley
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That instructable doesn't show the wiring between the 4 input pins of the L293d and the Arduino. Which pin of the L293D is Arduino pin 6 connected to? Same question for pins 7, 10,11. Also check these wires very carefully, make sure they are not shorting to anything.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mark, I don't know what you mean by those PP3 motors.... But all I know is that it's a basic DC geared motors, and they look exactly like this:


Whoops, typo, I meant PP3 batteries....
Logged

[ I won't respond to messages, use the forum please ]

0
Offline Offline
Sr. Member
****
Karma: 8
Posts: 394
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like a wiring error to me.
Logged

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

ya Mark, i am using those PP3 batteries.
And dc42, the pins 6,7,10 and 11 are the pins on arduino connected to the input pins on the motor driver.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And dc42, the pins 6,7,10 and 11 are the pins on arduino connected to the input pins on the motor driver.

yes, that's obvious from the code, but in WHAT ORDER? i.e. which Arduino pin goes to which L293D pin?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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

6 and 7 goes to the input pins 1 and 2 while, 10 and 11 go to the input pins 3 and 4(on the other side of the ic...)
Logged

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

Also my multimeter  beeps when i check for continuity between the motor terminals of both the motors. Is it a good sign??
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

6 and 7 goes to the input pins 1 and 2 while, 10 and 11 go to the input pins 3 and 4(on the other side of the ic...)

That's still not clear. The pin numbers are given on the L293D datasheet, http://www.datasheetcatalog.org/datasheet/texasinstruments/l293d.pdf. For your code to work, you need the following connections:

Arduino 6 -> L293D 2
Arduino 7 -> L293D 7
Arduino 10 -> L293D 15
Arduino 11 -> L293D 10

Swapping the connections for Arduino 6 & 7 would also work, if you also reversed the motor connections. Similarly for Arduino 10 and 11. So I think your connections are probably OK.

In case the problem is an inadequate power supply, I suggest you try disconnecting the right motor from the L293D, run the sequence again and report what the left motor does. Then do the same with only the right motor connected to the L293D, reporting what the right motor does.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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

err... dc42, just give me a two days time, coz the whole cirucuit stopped working suddenly.. so i have to figure out what's going on now... i suspect the ic itself.... lemme se

thanks
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

From the symptoms you described, it did seem to me quite likely that some of the chip outputs had gone short circuit to Vcc or ground.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: [1] 2   Go Up
Jump to: