tfapps
August 9, 2025, 2:49pm
1
4 Wheel vehicle - each wheel has 6V DC motor, all powered by 8 series nimh AAs. Forward and Backward work great but when attempting to turn the motors stall, not enough torque to spin the entire vehicle it seems, any way to overcome this from a software/PWM perspective (something like pwmSpeed + 50 perhaps?)
Current pwmSpeed is default val of 180/255
Here are my code blocks for motor control
// Motor control functions
void moveForward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
analogWrite(ENA, pwmSpeed);
analogWrite(ENB, pwmSpeed);
}
void moveBackward() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENA, pwmSpeed);
analogWrite(ENB, pwmSpeed);
}
void turnLeft() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
analogWrite(ENA, pwmSpeed);
analogWrite(ENB, pwmSpeed);
}
void turnRight() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENA, pwmSpeed);
analogWrite(ENB, pwmSpeed);
}
void stopMotors() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
analogWrite(ENA, 0);
analogWrite(ENB, 0);
}
So tell us in your own words how you are attempting to make your device turn!
jim-p
August 9, 2025, 2:57pm
3
Don't use the ENA, ENB pins to control the speed, use one of the IN pins. It will give you a wider PWM control range.
tfapps:
code blocks
Some comments on the pin handling were appreciated. What does IN1 mean?
I'd enable only 2 motors in curves.
What motor controller board are you using and where are the motor power leads connected to ?
tfapps
August 9, 2025, 3:09pm
6
L298N to control OUT1 OUT2 on the board controls right side motors and OUT3 and OUT4 control left
tfapps
August 9, 2025, 3:10pm
7
basically to turn right I need left drive forward, right drive reverse and for left I need right forward and left reverse, it works in principle on the blocks but not when on the ground
tfapps
August 9, 2025, 3:11pm
8
would that be something like this then?
void moveForward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
//Updates
analogWrite(IN1, pwmSpeed);
analogWrite(IN3, pwmSpeed);
}
If your tires have directional tread, then those results are to be expected.
tfapps
August 9, 2025, 3:12pm
10
IN1 for the L298N pin, I could try to drive with only opposite turning side but not sure if I can overcome the non spinning side
jim-p
August 9, 2025, 3:15pm
11
Considering motor A:
Set ENA high
Use IN1 to control direction, set HIGH or LOW
Use IN2 to control the speed, analogWrite()
Set IN1 = IN2 = 0 to stop or Set ENA LOW.
xfpd
August 9, 2025, 3:21pm
13
Have a look at my steering simulation, showing fourteen ways to steer. (does not include @jim-p method in post #11 )
Run IoT and embedded projects in your browser: ESP32, STM32, Arduino, Pi Pico, and more. No installation required!
what is the wheelbase of the robot and what type of surface are you running it on ?
I ask because with 4 wheel geometry trying to spin on the spot needs to move the wheels sideways across the surface as they rotate.
My guess would be that the power available is not enough to do this thus the robot does not turn
Can you measure the voltage of the power supply whilst attempting to turn on the ground ?
Hi, @tfapps
What model Arduino are you using?
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.
If a UNO or Nano, then not all pins are PWM capable.
Tom....
tfapps:
L298N
That is a major problem. Up to half of the battery power is wasted as heat in that 1980s dinosaur. Furthermore, when the motors stall, the L298N overheats and shuts down.
Pololu has the best selection of modern, much more efficient MOSFET motor drivers.
tfapps:
IN1 for the L298N pin,
Please describe or name the pins for direction, speed, brake and enable.
L298 cause up to 4V drop on the motor voltage supply. Use a newer MOSFET driver with less loss.
tfapps
August 9, 2025, 4:18pm
18
applying PWM speed to 0 on opposite of drive side has worked, even on carpeted surfaces, thanks!
jim-p
August 9, 2025, 4:58pm
19
Are your motors 6V or 12V?
system
Closed
February 5, 2026, 4:58pm
20
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.