Can't control speed of 4 DC motors using L298N

Hi,
I have problems controlling speed of my DC motors, if I set value to 130 to 250 it works, but if I want to slow it down, it's like It doesn't have power (I don't see logic here, if I have power for full speed, I don't know how I don't have power for less usage), there is picture of my scheme, it's bigger project but I only have problem with this, everything else is working, so I will put only this piece with code

#define speedControlR 10	
#define speedControlL 3	

#define rightMotorForward 6	
#define rightMotorBackward 7		

#define leftMotorForward 4			
#define leftMotorBackward 5	

void setup()
{
  pinMode(speedControlR , OUTPUT);			
  pinMode(speedControlL , OUTPUT);			

  pinMode(rightMotorForward , OUTPUT);			
  pinMode(rightMotorBackward , OUTPUT);			
  pinMode(leftMotorForward , OUTPUT);				
  pinMode(leftMotorBackward , OUTPUT);	
}	

void loop()
{
  //my code is going here where I call other functions
}

void forward()			
{
  analogWrite(speedControlR, 80);			
  analogWrite(speedControlL, 80);

  digitalWrite(rightMotorForward, HIGH);	
  digitalWrite(rightMotorBackward, LOW);		
  digitalWrite(leftMotorForward, HIGH);		
  digitalWrite(leftMotorBackward, LOW);		
}

void backward()			
{
  analogWrite(speedControlR, 80);			
  analogWrite(speedControlL, 80);

  digitalWrite(rightMotorForward, LOW);	
  digitalWrite(rightMotorBackward, HIGH);		
  digitalWrite(leftMotorForward, LOW);		
  digitalWrite(leftMotorBackward, HIGH);	
}

void right()			
{
  analogWrite(speedControlR, 80);			
  analogWrite(speedControlL, 80);

  digitalWrite(rightMotorForward, LOW);	
  digitalWrite(rightMotorBackward, HIGH);		
  digitalWrite(leftMotorForward, HIGH);		
  digitalWrite(leftMotorBackward, LOW);		
}

void left()				
{
  analogWrite(speedControlR, 80);			
  analogWrite(speedControlL, 80);

  digitalWrite(rightMotorForward, HIGH);	
  digitalWrite(rightMotorBackward, LOW);	
  digitalWrite(leftMotorForward, LOW);	
  digitalWrite(leftMotorBackward, HIGH);	
}
void stop()			
{
  analogWrite(speedControlR, 80);			
  analogWrite(speedControlL, 80);

  digitalWrite(rightMotorForward, LOW);	
  digitalWrite(rightMotorBackward, LOW);		
  digitalWrite(leftMotorForward, LOW);		
  digitalWrite(leftMotorBackward, LOW);		
}	

The logic is in the fact that your motors require some amount of power to even begin to turn. Anything below that value means NO turning. The world is not linear. You need to experiment and find the minimum value that will let the motors turn. No guessing!

Hi, @mltc
Welcome to the forum.

Thanks for using code tags. :+1:

Can you please tell us the motor specs and what are your power sources.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Like I said, it works from 130-250, so minimum value is 130, but shouldn't it be 0-250?

text is on serbian, but you can see all components, Water Pump, Servo Motor, 5 segment flame sensor, etc.

Hi,

Motors are not 100% efficient, they need power to just turn themselves over.
If you are using the cheap hobby motors, then their efficiency is not very high.
So you are using the power provided from the 0 to 130 of the PWM value just to get the motor to begin to turn.

What voltage are you powering the motors?
What voltage ratings are the motors?

The 298 driver you are using will drop 2V from your power supply for a start.
It is not a very efficient driver.

Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.