4 wheel tank drive mechanics

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!

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.

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 ?

L298N to control OUT1 OUT2 on the board controls right side motors and OUT3 and OUT4 control left

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

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.

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

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.

the wheel/motor assembly

Have a look at my steering simulation, showing fourteen ways to steer. (does not include @jim-p method in post #11)

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.... :smiley: :+1: :coffee: :australia:

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.

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.

applying PWM speed to 0 on opposite of drive side has worked, even on carpeted surfaces, thanks!

Are your motors 6V or 12V?

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