DC Gear motors not working

Hello,

I have connected 4 DC gear motors to L293D and mounted them to an Arduino Uno. I am using 4x1.5V AA batteries as a power source.

This is the code I used:


#include <AFMotor.h>

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

void setup() {

  motor1.setSpeed(1000);
  motor2.setSpeed(1000);
  motor3.setSpeed(1000);
  motor4.setSpeed(1000);
  
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  
}

void loop() {
  
  
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);

  delay(4000);
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  delay(200);
  
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);

  delay(4000);
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  delay(200);
 
 
}

The motors do not work; they don't spin although I hear a hum or beep sound. When I give it a spin with my hand, they move. I have tested the motors individually by connecting them to the power source. And also one thing I would like to add, when I disconnect the USB from the Arduino Uno, they don't make any hum or beep sound nor do they move when i give it a little spin as if I haven't uploaded the code to the Arduino at all.

What is the rated voltage and the stall current specifications of the motors? Please post a data sheet for the motors.

The L293 driver is ancient and inefficient tech. They drop 2V to over 4V of the motor supply voltage (more voltage drop for higher current) and dissipate that power as heat. The L293 is only good for 600mA.

Pololu has a good line of modern motor drivers.

Here:

  • Operating Voltage Range: 3~7.5V

  • Rated Voltage: 6V

  • Max. No-load Current(3V): 140 mA

  • Max. No-load Current(6V): 170 mA

  • No-load Speed(3V): 90 rpm

  • No-load Speed(6V): 160 rpm

  • Max. Output Torque: 0.8 kgf.cm

  • Max. Stall Current: 2.8 A

  • Rated Load: 0.2 kgf.cm

  • Operating Temperature: -10~+60 ℃

  • Storage Temperature: -30~+85 ℃

  • Motor Type: 130

I'm still very new to this stuff, I'm only doing this for a school project so I had no idea what to buy.

Hi! Welcome to the Forum and congratulations for posting your code in code tags on your very first post.

What means the number 1000 on this line?

That is over 4 times the current that the L293 is capable of supplying. Do you have a Digital Multi Meter or Volt meter? What is the voltage across the motor when you try to run it?

Are you using an L293D or are you using an Adafruit Motor Shield? Because the library you have is the VERY old one for the Adafruit motor shield. There is a newer version of that library if you are using a motor shield purchased anytime in the last 5-7 years.

And if you do have a motor shield, take a look at the example. You are missing a lot of important code necessary to initiate connection with the motor shield.

If you are truly using an L293D, then I would suggest you look at an example of how you control 2 DC motors with one L293D. If you want to control 4, you would need two of them. Because each motor takes up 2 pin on the L293D.

I highly recommend you get a driver that has MOSFET outputs. The L293D is not a good part to use especially with batteries. It in itself consumes about 35mA. It has a bipolar darling ton output on each motor lead which will drop about 1.5V (0.7V * 2 leads). That works out to your 6V voltage from the fresh batteries will give you about 3 volts on the motors so do not expect much performance. You will also have a voltage drop from the batterer because of there internal resistance. You need a heat sink with it because of all of your power is being burnt up as heat. If my memory is correct this was first introduced as a H-Bridge for automotive mirror motors.

I found this on the internet, it sums it up nicely: " The TB6612FNG is smaller than the L298N, and doesn't require a heat sink. It also features a much higher efficiency at over 90% versus 40-70% for the L298N, and a low-current standby mode that the L' lacks."

Whatever driver you use, your code needs to be compatible with that driver. You just cant use any library just cause it has motor in it.

setSpeed(speed)

Sets the speed of the motor.
Parameters:

  • speed- Valid values for 'speed' are between 0 and 255 with 0 being off and 255 as full throttle.

Example:

Note : DC Motor response is not typically linear, and so the actual RPM will not necessarily be proportional to the programmed speed.

class AF_DCMotor
{
 public:
  AF_DCMotor(uint8_t motornum, uint8_t freq = DC_MOTOR_PWM_RATE);
  void run(uint8_t);
  void setSpeed(uint8_t);

 private:
  uint8_t motornum, pwmfreq;
};

I know it. I just wanted the OP to see it too. :wink:

(sorry) @Brazilino

1 Like

i have four outputs on my l293D

Have you measured your batteries? Each motor wants 6vdc. Only if your 4x1.5AA are fresh will they all work (for a couple minutes). Add a fifth (5x1.5 = 7.5) in series, or try a 6vdc mains power supply.

What do you mean "4 octopus"? Dou mean you are doubling up connecting two motors to each of the outputs? That still doesn't make any sense. That would means you would only have two motors to control. Not 4.

Plus, your code is not going to work with your controller....ever. It's using the wrong library and it's not even using it correctly.

So I connected 4x(3.7V 1300 mAh) batteries to l293D (which is connected to four dc gear motors) and there was smoke coming from l293D. If I try to replace one of the batteries with a 1.5V battery, the motors won't work. What should I do?

That dinosaur did you a favor by self-destructing.

Buy a modern brushed D.C. motor driver and be sure to wire it correctly. Pololu has the best selection.

I don't think that is available where I live. I have a school project due this wednesday.

You have no choice but to buy what is available. Be sure to wire it correctly.

should i get TB6612FNG ?

do u know any motor controllers for four motors?