Problems running a DC 6 - 15v motor with L293D H bridge

Hello,

I've built a machine that runs a DC 6 - 15 volt motor http://uk.rs-online.com/web/p/dc-geared-motors/0420596/ forward for roughly 45 seconds then in reverse for the same period. I've also added in a stop between each transition.

I'm using a L293D H bridge to facilitate the forward and reverse. I've attached a diagram of wiring. The code I'm using is

int enablePin = 11;
int input1pin = 10;
int input2pin = 9;
int potPin = 0;

boolean polarity = true;

void setup() {
// put your setup code here, to run once:

pinMode(enablePin, OUTPUT);
pinMode(input1pin, OUTPUT);
pinMode(input2pin, OUTPUT);

}

void loop() {

int speed = analogRead(potPin) / 4;

polarity = true;
setMotor(speed, polarity);
delay(46000); //43 seconds

analogWrite(11, LOW);
delay(1000);
analogWrite(11, HIGH);

polarity = false;
setMotor(speed, polarity);
delay(43000); //43 seconds

analogWrite(11, LOW);
delay(1000);
analogWrite(11, HIGH);

}

/*

  • Sets motor to a speed and a polarity
    */
    void setMotor(int speed, boolean polarity) {
    analogWrite(enablePin, speed);
    digitalWrite(input1pin, polarity);
    digitalWrite(input2pin, ! polarity);

}

Initially it ran well but has since stopped running consistently. It will now run for two periods of 45 seconds then slow significantly, then stop. I've tried a new motor but this does the same thing. The small motor 6/9v that came with the starter kit runs fine but has insufficient torque for the machine I have constructed. I'm wondering if there is insufficient current going to the motor? I wondered if maybe I need to power the motor separately from the Arduino board? If so is there a simple way of doing this?

I should mention that initially I had the motor running forward and then into reverse without stopping. I thought this had damaged the motor, but since trying a new motor found this not to be the case. Could I have damaged the board instead?

I'm relatively new to electronics and this is my first project using an Arduino board. I apologise for not using all the terminology.

I'd really appreciate any help given, the machine is a piece of Artwork I intend to exhibit at the end of the week!!!

Sarah

Screen Shot 2015-09-07 at 12.57.42.png

In fact the small 6/9v motor is also having problems. I now believe there is something wrong with the board?

This sounds like a power issue. You shouldn't power your motors directly from arduino. You need an external power source and a motor driver.

Depending on the ratings of your motor (voltage and current) there are many batteries and drivers that you can use.

Agreed, you should never power a motor from the Arduino. That can actually destroy the Arduino board!

There are several other problems with your setup, one of which is that it is unlikely that the L293D can handle the startup current of the motor, and perhaps not even the running current. It is unclear from the product page which motor you have, but a current draw of several amperes is possible at startup and stall -- way above the capabilities of the ancient L293D.

Furthermore, rapidly reversing a motor can cause it to briefly draw twice the stall current, so the H bridge overheats and shuts down. Always allow the motor to stop before reversing.

I recommend the Pololu line of motor drivers. This one would probably work well with your motor.