Let's Make Robots!

problems with L293D + Arduino

lordofthedonuts's picture

I wired up a L293D to my arduino, planning to run 2 motors with it, and just for testing I runned the blinkie program on it changing the LEDpin to the to the digital pin that goes to the l293d but only half of the pin works, like it turns in only one direction. Is it normal ?

 

It's 4 in the morning so I did not do a lot of trouble shooting, just changed the pins that were on PWM to digital, it didn't changed anything.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I've been struggling with the very same problem! I can get one motor working but not the other :-(  I have concluded that perhaps I fried the L293D with ESD since one of the motor pins remains low regardless of input. I've ordered a protective desk cover and wrist strap! But I will keep trying to figure it out, in case I'm wrong.

 

SubMicro

I'm with you too. I'm measuring about 1.5 volts signal from the arduino when the output is going into the L239D, but 5 volts with any other output. I'm assuming it was fried as I had the chip backwards for a bit...stupid mistake but I own up to it. Ordering a new chip from Digikey so I'll confirm when I get a new chip.

I understand L293D is controlled by MCU inputs.

Is it necessary L293D and the MCU to share the power source?? for example common ground

TeleFox's picture

The L293D has two power inputs - one for logic and the other for the motor drivers.
The logic power must be the same voltage (or close to it) as your microcontroller, or else the logic levels won't be compatible to allow the micro to control the L293D properly.
The motor driver power can be any voltage supported by the L293D, this will be the power source that feeds the motors.
Ground lines must be connected to ensure a common reference for the logic levels.

lordofthedonuts's picture

Ok I gave the whole arduino + motor driver and motors to my friend Philippe who's buidling the robot with me.

He never did any code until yesterday and figured out how the whole thing works. It took me months to just understand the syntax and he solves the problem in one day, damn he's good. 

But there's still a little "bug"  The two motors work if they're used one at a time, he's able to control the speed and direction but he can't control 2 motors at the same time, either nothing happens or only one spins randomly.

robologist's picture
Sounds like the motors are browning out the processor when starting, so perhaps you can power the motors with another battery. Just plug it into V2 on the chip, and tie the grounds together and see if it works better.
CaptainObvious's picture

I've still yet to code even my first blinking LED, but only time shall prevail!

But one thing I noticed in your loop, your motors are set on LOW, from what I've read (not much), almost everycode you use to power something is either a HIGH (1)  or a LOW (0), could this be why you're not getting anything?
Again, I'm a newb so don't mind the questions if they're not the brightest:D

And looking at the Arduino website, stating it as a LOW status, grounds it, giving 0 Volts, when a HIGH in a digital output, or 3.3v for older boards.

I dunno I'm so confused :P

lordofthedonuts's picture

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  VARIABLES

int motorSpeed = 200;  // motor speed - from 0 to 255;

// Motor Pins
// the H bridge takes two outputs from the Arduino to control each motor.
int motor1_Pin0 = 11;
int motor1_Pin1 = 6;

int motor2_Pin0 = 5;
int motor2_Pin1 = 3;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  SETUP
void setup() {
 
  // set Arduino pins as outputs
  pinMode(motor1_Pin0, OUTPUT);
  pinMode(motor1_Pin1, OUTPUT);
 
  pinMode(motor2_Pin0, OUTPUT);
  pinMode(motor2_Pin1, OUTPUT);
 
  delay(500);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  LOOP
void loop() {
      
  analogWrite(motor1_Pin0, motorSpeed);
  digitalWrite(motor1_Pin1, LOW);
      
  analogWrite(motor2_Pin0, motorSpeed);
  digitalWrite(motor2_Pin1, LOW);
 
  delay (1000);
      
  digitalWrite(motor1_Pin0, LOW);
  analogWrite(motor1_Pin1, motorSpeed);
      
  digitalWrite(motor2_Pin0, LOW);
  analogWrite(motor2_Pin1, motorSpeed);
 
  delay (1000);
 
}

 

 

lordofthedonuts's picture

I've tested every PWM (3, 5, 6, 11) that goes form the Arduino to the motor driver, the only pin that gives me something is pin 11, with +4.08v. there's still 3 pins left, I'm guessing that the problem comes from the code, but I'm not sur at all.

 P.S. My new table is awesome, I can work on my electronics and do thing on my computer now, I don't have to go back to my garage every time I want to solder a pin.

robologist's picture

Sounds liike you're on your way to finding it, now just need someone who works with the Arduiono to look at your code to see if the PWMs need to be initalized somehow.

Congrats on the table.  Oh, one thing, you can scrub the flux off the motor driver board, to prevent it from eating into your connections. Looks like a well soldered board.