Speed Control of 2 Motors with L298N

Hello. I'm working on a project which involves building a car with two DC motors. I'm controlling their speed through the L298N driver, but when I put it into operation, one of the wheels spins faster than the other and the car doesn't go straight.

I've been taking measurements and I see that it provides different voltage and current through the connection pins to the motor cables (OUT1, OUT2, OUT3, and OUT4). I suppose this is why the motors aren't spinning at the same speed.

I'm not sure what could be causing this. I'm powering the L298N with a regular 9V battery, and the Arduino with the 5V output from the driver. Can anyone help me?

Not without seeing the code. Nobody can help without that, at least. Don't forget to use code tags, please. Also, details about your circuit, a drawing is helpful, the more detail you give, the better help we can give. Are they straight DC motors? Identical? Gearboxes?

That's normal for none precision motors.

1. Check that your Motors' wirings are similar to the following (Fig-1):


Figure-1:

2. Check that your codes comply with the following Truth Table (Figure-2):
L298DriverTruth
Figure-2:

Here is the code:

//RIGHT MOTOR VARIABLES
int IN1 = 7;
int IN2 = 8;
int ENA = 9;
int PWM_RIGHT = 100;

//LEFT MOTOR VARIABLES
int IN3 = 12;
int IN4 = 13;
int ENB = 11;
int PWM_LEFT = 100;

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENB, OUTPUT);
}

void loop() {
  //START RIGHT MOTOR FORWARD
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  analogWrite(ENA, PWM_RIGHT);

  //START LEFT MOTOR FORWARD
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  analogWrite(ENB, PWM_LEFT);
}

And schematic drawing:

They are identical straight DC motors. I bought it by Amazon by this link:
https://www.amazon.es/gp/product/B096ZH5WQ6/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&th=1
Here is a screenshot of the characteristics shown in Amazon:

Thank you for your help.

And the motors turn in the directions you want them to, just gradually veering to one side? I mean, by the drawing, they are wired identically. Without seeing it in person, if you reverse the wires on one of the motors does it make the problem better or worse?

That sounds like a classic 9V battery problem. They do not have the capacity to properly drive motors. Try an external power supply.

its the same

but what if I want it to be autonomous?

I understood that one of the engines turns faster than the other.
Just to better understand, what happens if you reverse the connection of the motors.
Connect the engine on the left where the one on the right is and the one on the right where the one on the left is.
What happens?
Does the higher speed change with the engine or not?

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