2

I have a little problem. I have a motor driver (L298N). When I engage in electricity, my 2 motors start and after 5 second stop. Then they stop for about 2 seconds, and then start and in a moment (0.5 second) turn off. This make still around (go about 0.5 s, stop for 2 seconds...). And my motor driver is very hot after 1 minute.

Is it possible that it is because of weak voltage? (The motor driver is for 6-35 V, and I have a 6 V battery).

enter image description here

L298n: enter image description here

There is my code on Arduino:

const int motorPin1  = 9;  
const int motorPin2  = 10; 
const int motorPin3  = 6; 
const int motorPin4  = 5;  

void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);    
}

void loop() {
  forw(3000);
  back(3000);
}

int fast = 255;

void forw(int timer) {
  analogWrite(motorPin1, 0);
  analogWrite(motorPin2, fast);
  analogWrite(motorPin3, 0);
  analogWrite(motorPin4, fast);
  delay(timer);
}

void back(int timer) {
  analogWrite(motorPin1, fast);
  analogWrite(motorPin2, 0);
  analogWrite(motorPin3, fast);
  analogWrite(motorPin4, 0);
  delay(timer);
}
  • Could you please recheck the wiring, the driver getting hot may be due to incorrect wiring or heavy load usually. the code seems correct as far as I know. if you suspect low voltage go for a 9v battery and check the delay issue. – Naren Murali Aug 7 '17 at 13:22
  • Show how you have things wired. The 2 seconds off sounds like the board is resetting and you're waiting through the bootloader. – Delta_G Aug 7 '17 at 15:48
  • Also what is the current draw of the motors? Do you have a part number or datasheet? The driver getting hot suggests that you're running too much current through it. These little drivers cannot route much current. – TomServo Aug 7 '17 at 16:00
  • I add 9V battery and it go good, but after first back() function stop, and after 2 second back() again, but slowly. There is scheme: link – programeer Aug 7 '17 at 16:54
  • 1
    Please do not vandalize your post. Contributions to Stack Exchanges are subject to the SE Terms Of Service. This includes "You agree that all Subscriber Content that You contribute to the Network is perpetually and irrevocably licensed to Stack Exchange under the Creative Commons Attribution Share Alike license.". Since people have taken the trouble to answer your question, deleting or vandalizing the question is impolite. – Nick Gammon Jan 3 '18 at 21:19
2

I ran the code on my arduino(kinda old), when I checked with my multimeter I noticed that the 5th PWM pin didnt osciallate every 3 seconds, could you please try the below code where I changed the 5th pin to 3rd PWM pin, also please change the connections on the l298 board.

const int motorPin1  = 9;  
const int motorPin2  = 10; 
const int motorPin3  = 6; 
const int motorPin4  = 3;  

void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);    
}

void loop() {
  forw(3000);
  back(3000);
}

int fast = 255;

void forw(int timer) {
  analogWrite(motorPin1, 0);
  analogWrite(motorPin2, fast);
  analogWrite(motorPin3, 0);
  analogWrite(motorPin4, fast);
  delay(timer);
}

void back(int timer) {
  analogWrite(motorPin1, fast);
  analogWrite(motorPin2, 0);
  analogWrite(motorPin3, fast);
  analogWrite(motorPin4, 0);
  delay(timer);
}
2

The L298 is a very old, obsolete design based on bipolar transistors, which means it has a lot of internal losses.

The energy consumed in those losses shows up as heat.

It also has some degree of overload or overtemperature protection, so what you are observing is an automatic shutdown. Or perhaps, your motor is causing the battery voltage to sag and resetting your Arduino at which point the sketch resumes after a bootloader delay. 6v is really too low an input voltage to the Arduino's regulator, but too high for direct input without the regulator.

You need to make sure that the current draw of your motors is reasonable, and you likely want to replace the terrible L298 with a more modern, low less FET driver. You will need to select one rated for the actual current draw of your motor: you should consider not only free rotation of the motor, but the increased current draw if it is mechanically stalled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.