2

Whenever I run a program for running the DC motor, the motor suddenly slows down and finally stops, I don't know why it happens.

I use an L298N motor driver, an Arduino Uno, and a 9V battery for motor and separate power for the Arduino.

code:

int In3 = 7;
int In4 = 8;
int ENB = 5;
int SPEED = 250;
void setup(){
  pinMode(In3,OUTPUT);
  pinMode(In4,OUTPUT);
  pinMode(ENB, OUTPUT);
}
void loop(){
  analogWrite(ENB, 255); 
  digitalWrite(In3, HIGH);
  digitalWrite(In4, LOW);


}

I am following this circuit:

I am using a separate battery for motors and separate power for Arduino

Is something wrong with my code or is it a hardware problem?

JRE
  • 67,678
  • 8
  • 104
  • 179
  • 3
    It'll be that 9V battery. Measure it while running. It's going flat. –  Oct 30 '20 at 14:26
  • what can be the problem with it as per your thinking – Amit Nikhade Oct 30 '20 at 14:29
  • 2
    Try this: [L293, L298 and SN754410 H-bridge drivers on low voltage power supply](https://electronics.stackexchange.com/questions/108686/l293-l298-and-sn754410-h-bridge-drivers-on-low-voltage-power-supply) and, if you are using a crappy 9 volt battery it'll be much worse. – Andy aka Oct 30 '20 at 14:44
  • 2
    Your battery is utterly unsuitable to this task, the minimum you should consider is some number of AA's, probably at least six in series. But as illustrated at the link above, the L298 is a horrible choice for a battery powered low voltage project, you really want to replace it with an FET bridge. That's especially true if your motor really wants a lower voltage. – Chris Stratton Oct 30 '20 at 16:32
  • Why is `ENB` set using an `analogWrite` while the other pins are set using a `digital Write` ? Is the `ENA / ENB` pin allowed to be switched between high and low frequently ? I think those pins are not meant to be switched frequently. What does the data sheet of the L298 based board say ? – AJN Nov 01 '20 at 06:08

2 Answers2

3

In addition to the other answers posted, you need to connect pin 9 (logic supply voltage) on the L298 to 5V. It's marked as "5V" on your motor driver board. The reason you need this is because there's internal digital logic that sits between the Input1-4 pins and the H bridge power transistors. Without logic supply voltage, it'll act funky.

0

Hi that's a lot of area to cover. Possible Problems

  1. For your motor 9V battery might be insufficient
  2. I'm not sure if your pin connections are right. Cause the datasheet says otherwise...Datasheet for 208, ur using multiwatt15
  3. Burnt motor
  4. Burnt Arduino

So my best guess it not using the right pins. Check ur code for pins from Arduino to 298.

According to your code Arduino pins are (7,8,5) must connect with L298N side (10,12,11) respectively.

It has to be one of these 4 issues. my best guess is still on 2.

abi7ash
  • 11