Notifications
Clear all

L298n pwm

2 Posts
2 Users
0 Reactions
2,295 Views
(@keran)
Member
Joined: 5 years ago
Posts: 1
Topic starter  

Hi, this is my first post. I'm unable to find an answer to my questions. 

I'm building a robot base which uses 2x L298n to run 4 DC Gearmotors 12V, connecting to a Arduino Mega. I have encoutered a repeating problem with the driver. Everything is connected and running. I have used a power supply to test it (up to 31 V and 10 A) the problem i'm having is that no matter how high of voltage i'm using i can't send a command with lower PWM (0-255 enA, enB) signal than 130 to run the motors.

Example: With the power supply and 255 pwm i can run both of the motors with 3 V, but with the 16 V i'm unable to lower the speed below 130 pwm, which basiclly means that my speeds are fast - very fast which makes no difference to me, i want to have lower speeds as well. 

For the code I'm using the completely basic one with pin Modes, digital Write to HIGH/LOW and analogWrite to set the speed. I don't know much about PWM or L298n and the videos i have watch don't really talk about it, I have L298n from two different suppliers and the same thing happens with both. 

If i were to guess I would say that the problem lies in communication between my MEGA and L298n, maybe the PWM frequency. Should I try with the PWM frequency arduino library or does that have nothing to do with my problem? 

Dino Keran 


   
Quote
Topic Tags
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1111
 

Hi Dino

First of all welcome to the forum!

Is it possible that the pin you are using on your Arduino is not one of the PWM-enabled ones?  I'm asking because your problem sounds like what would happen if you did an analogwrite to a non-PWM pin.

Of the 54 digital I/O pins on the Arduino Mega only 15 of them are capable of PWM.

And at the risk of sounding blatantly self-promotional I did a video and article about using the L298N with an Arduino, perhaps it will help you.

Hope some of this helps, again welcome to the forum!

?

Bill

 

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote