I'm trying to control a re used DC motor from a drill (3,6V) with a L298N and a Arduino. It's powered with a 5V - 60A power supply.
I tried to follow this step by step tutorial (https://www.youtube.com/watch?v=dyjo_ggEtVU) but the motor is not spinning..yet. I can ear a noise, it starts to spin a micron and then stops.
I though that it could be something wrong with the power supply but I connected the 4V battery from the drill and the same thing is happening. If I connect the motor directly to the battery it is spinning nicely...
I though then that it was a code issue but I tried a no load test and measured the voltage without the motor -> I've the 4V required voltage. When the motor is connected I have 300mV instead of 4V.
Do you know what could go wrong? Is the L298 dead? just got it a few hours ago...
Would be nice if you have any clue.
Many thanks.
// Commande moteur int enA = 9; int in1 = 8; int in2 = 7;
void setup()
{
// Définition des sorties
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
//Sens de rotation du moteur
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
//Vitesse de rotation du moteur
analogWrite(enA, 200);
//Delay
delay(5000);
//Arrêt du moteur
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
}
1 Answer 1
The L239 is a terrible motor driver. It's the kind of motor driver Noah used to control The Ark.
It requires a power supply that is at least 2.5V more than the "logic input high" voltage, which is rated at 2.3V. That means an absolute minimum of 4.8V, which is borderline for the Arduino's 5V pin, especially if you are running off USB (which can drop as low as 4.75V and still be within specification) and way out when powered from the battery. It's really designed for driving motors in the 12V+ range.
To drive a low voltage motor like yours you need to pick a more modern MOSFET based motor driver.
-
Thanks for the feedback, what if I use a 12V power supply and I use the AnalogWrite to drop the motor voltage to 4V?Anthony De Faria– Anthony De Faria05/31/2020 18:18:35Commented May 31, 2020 at 18:18
-
It might work... until that fateful day when you accidentally send 12V straight to the motor...Majenko– Majenko05/31/2020 18:19:23Commented May 31, 2020 at 18:19
-
I tried with a 20V DC power supply and it's not going to work because analogWrite(pin,1) gives me a minimum of 12V DC at the motor.Anthony De Faria– Anthony De Faria06/01/2020 06:20:37Commented Jun 1, 2020 at 6:20
-
Then you should get a proper motor driver that is suitable for your motor, or get a better motor that is suitable for your power supply. Matching your components to your needs is step one of learning to be an electronic engineer...Majenko– Majenko06/01/2020 10:19:35Commented Jun 1, 2020 at 10:19