I am working on a schoolproject for a line-following car. We are using 2 motors, which operate between 12-24 Volts ( https://uk.rs-online.com/web/p/dc-geared-motors/4130638/ ). We use 3 9V batteries in series to get 27V. When we connect this to the motordriver (L298N) and try to rotate the motors at the same speed using the same PWM value (writing values between 0 and 255) we get that one motor turns faster than the other. We used a multimeter to measure the voltages between the terminals for both the motors. We noticed that one of the terminals gives lower voltages. For example: If we write PWM signal of 150, one motor gets 18V while the other gets 15V (only if we use PMW signal of 255, the motors have the same speed and thus the same voltage about 23V). The motors aren't the problem, as we changed the motors to the other terminals. One terminal constantly gives a lower voltage. We used two different motordrivers of the type L298N and also got the same result. Does anyone know why there is a different voltage drop at the 2 motorterminals? Thanks in advance.
The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g. 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6.
and PWM pins 5 and 6 have different default base frequency then the other PWM pins.
Use PWM pin pair controlled by the same timer. 5 and 6 or 3 and 11 or 9 and 10
*This miniature gearbox is of steel and brass construction with brass gears and is mounted on a 1mm thickness steel bracket. It incorporates a high quality three pole motor with sleeved bearings. The design and construction of the unit make it suitable for a host of model and light* //no capacitor mentionend
I think the problem is actually the controller. One major drawback to working with brushed motors is the large amounts of electrical noise they produce. This noise can interfere with your sensors and can even impair your microcontroller by causing voltage dips on your regulated power line. Large enough voltage dips can corrupt the data in microcontroller registers or cause the microcontroller to reset.
You can avoid this problem by soldering capacitors along your motor terminals. Use 1µF ceramic capacitors for example