Pages: [1]   Go Down
Author Topic: Looking for help getting DC motor to brake with L293D chip  (Read 1097 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I am experimenting with the L293D chip to power a small DC motor.
I have the chip hooked up so that both sides power my one motor, hopefully resulting in a little higher output amp potential as compared to powering the motor with just one side of the chips pins (?).
My simple program is working fine, except there is no braking force being applied when both direction pins are either both LOW, or both HI. Am I doing something wrong in the code, is the L293D hooked up incorrectly, or is it something with the particular motor that I am using?
I have tried the motor brake with the same code just using one side of the chip, with the same results.
I have tried two different motors with the same results. I can measure that both direction pins are going HIGH during the brake command (4.9v), but there is no braking resistance in the motor.
I have the L293D enable pins permanently wire to HIGH, and there is a description of the rest of the pin hook ups at the top of my code.
Any advice, help, suggestions are appreciated!

Code:
/* DC motor speed and direction using L293DNE IC (Texas Instm) 10-3-2012
L293DNE pinouts, set up for one motor being driven by both sets of H-bridges
  Pin 1, 9, 16 to +5V
  Pin 2 & 15 to Arduino PWM pin 5
  Pin 3 & 14 to motor lead A
  Pin 4, 5, 12 , 13 to Grnd
  Pin 6 & 11 to motor lead B
  Pin 7 & 10 to Arduino PWM pin 6
  Pin 8 to +V battery, battery negative to common Grnd
*/
int motorPin1 = 5;    // direction pin to Driver board Pin "D1", pins 7 & 10 on L293D chip
int motorPin2 = 6;   // direction pin to Driver board Pin "D2", pins 2 & 15 on L293D chip
//
void setup () {
  pinMode(motorPin1,OUTPUT);        //set pin 3 as output, L293D direction 1
  pinMode(motorPin2,OUTPUT);        // set pin 4 as output, L293D direction 2
}
//
void loop() {
    motorSpin();
 }
//
int motorSpin(){
  analogWrite(motorPin1,255); // PWM the direction pin (L293D pin 2)
  digitalWrite(motorPin2,LOW);
  delay(1000);
   
  digitalWrite(motorPin1,HIGH); // should be brake
  digitalWrite(motorPin2,HIGH);
  delay(2000);
 
  digitalWrite(motorPin1,LOW); // motor goes the other direction
  analogWrite(motorPin2,255);   // PWM the other direction pin (L293D pin 7)
  delay(1000);
 
  digitalWrite(motorPin1,HIGH); // another brake
  digitalWrite(motorPin2,HIGH);
  delay(2000);
  }
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
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

If you want good braking effect, use a mosfet H-bridge. Bipolar H-bridges don't provide as good a breaking effect due to their high saturation voltage and the need for the braking current to be carried by the flyback diodes.

You may get slightly better braking effect by pulling both inputs LOW instead of HIGH.
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: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks DC42, I also just today found the below, so it looks like the next step is a Mosfet H-bridge !

http://arduino.cc/playground/Main/AdafruitMotorShield

// The L293D motor driver ic doesn't have a good
// brake anyway.
// It uses transistors inside, and not mosfets.
// Some use a software break, by using a short
// reverse voltage.
// This brake will try to brake, by enabling
// the output and by pulling both outputs to ground.
// But it isn't a good break.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
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

Perhaps this one: http://www.pololu.com/catalog/product/2503.
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]   Go Up
Jump to: