Slow turning in one direction

My son and I have just finished building the MagPi issue 51 robot, all the parts used were the same as the article.
It's working well except whilst using the Rock Candy controller it turns slowly in the following scenarios.

Moving forwards, turning left, (right hand motors running) it slows down considerably, turning right in this direction it doesn't slow down.

Moving backwards, turning right, (left hand motors running) it slows down considerably, turning left in this direction it doesn't slow down.

Any ideas why it's doing this?

piborg's picture

There are two main culprits I can think of:

  1. The battery is not providing enough power
  2. Some of the motors are running slow or poorly

I would first try a brand new fresh 9V battery.
If using a rechargeable make sure it has just been charged.
If using a non-rechargeable make sure it is a good quality alkaline, such as a Duracell or Energizer.
We have found some 9V batteries are quite bad, in particular avoid any labelled as "heavy duty".

If that does not help you should check each of the motors.
Put the robot so the wheels are off the ground and can spin freely.
Apply a small amount of power to each motor, try both directions.
You are looking to see if any run slowly or make any unusual noises such as grinding, clicking, or crunching.

I realised this was not just when turning, going straight the motors on each side run at different speeds. Running at slow speed upside down, forwards motors 1 and 2 start then if you increase the power 3 and 4 start, in reverse 3 and 4 start first then if you increase the power 1 and 2 start. I measured the voltage to each motor in forwards and reverse at full power, see below the voltage is higher on the side that starts first.

Forwards
Motor 1 = 5.99
Motor 2 = 5.95
Motor 3 = 5.10
Motor 4 = 4.90

Reverse
Motor 1 = 5.01
Motor 2 = 4.55
Motor 3 = 5.92
Motor 4 = 5.89

It seems to be the voltage supplied to the motors rather than the motors causing the speed difference.

I also checked the speed of the wheels with a laser tacho each wheel shows about 70 rpm difference between forwards and reverse (390 rpm vs 320 rpm)

We are using NiMH batteries, freshly charged, I replaced the battery leads with thicker cable as that was quite a small gauge but that made no difference, I also tried a new alkaline battery but still the same, it runs for ages on the NiMH batteries.

To eliminate the batteries will the ZeroBorg work with a PSU plugged into the Pi through it's power socket?

piborg's picture

Okay, I know what the problem is now.

Basically there is a bit of a difference between the motor outputs in forward and reverse operation.
In the zbJoystick.py script we run the left side motors the other direction from the right ones.

I suggest you have all of the motors running the same way.
First open zbJoystick.py in an editor and look for these lines:

                # Set the motors to the new speeds
                ZB.SetMotor1(-driveLeft * maxPower)
                ZB.SetMotor2(-driveLeft * maxPower)
                ZB.SetMotor3(driveRight * maxPower)
                ZB.SetMotor4(driveRight * maxPower)

What you need to do is add a - sign in front of driveRight, like this:

                # Set the motors to the new speeds
                ZB.SetMotor1(-driveLeft * maxPower)
                ZB.SetMotor2(-driveLeft * maxPower)
                ZB.SetMotor3(-driveRight * maxPower)
                ZB.SetMotor4(-driveRight * maxPower)

Once you have changed the code swap the + and - connections on motors 3 and 4 on the ZeroBorg.
This will make them move in the correct direction again.

I was sceptical when I saw your advice as it seemed that nothing would be changed by making these changes, but we tried it and now it runs in a straight line, it now runs faster forwards than in reverse which explains the issue, I have looked at the code and I can't see anything that makes it run slower in reverse, can you explain what makes it run slower in reverse?

It turns much better than it did but there is still a difference, right turns are tighter than left turns (turning circle right = 30cm, left =60cm), I didn't have time to measure voltage or rpm for this, I would think this could be tuned out by changing the code for turning, I will investigate further.

Thanks for your help

piborg's picture

The difference between positive and negative power levels on the ZeroBorg all comes down to free-wheeling.

For positive power levels the "off" part of the PWM lets the motors free-wheel.
This saves some power, but makes the output voltage less accurate.
This is also true at a power level of 0.

For Negative power levels the "off" part of the PWM does connect the motor to 0V.
This effectively acts like braking, making the output voltage more accurate.

The turning circle problem could be due to the motors free-wheeling when at 0%.
You could try clamping the steering to 99% to see if it will turn tighter.

To clamp the steering look for these lines in zbJoystick.py:

                # Apply steering speeds
                if not joystick.get_button(buttonFastTurn):
                    leftRight *= 0.5

then add a 0.99 multiplier as well like this:

                # Apply steering speeds
                if not joystick.get_button(buttonFastTurn):
                    leftRight *= 0.5 * 0.99

What this should do is set the motors to 100% and 1% at full steering instead of 100% and 0% when not in tank steering mode.
This should then cause the slow side to actually apply brakes to the motors instead of letting them free-wheel.

With the new setting the turning circle is about 30cm turning both left and right so this has resolved the unequal steering.

We did find that the turning circle was a bit tight and when running straight small changes in direction were difficult as it turned too much, so we changed the 0.5 in the same line to 0.3 this increased the turning circle to about 60cm

Thanks so much for your help, the robot runs really well now

This sorted the issues i was having as well, everything is working much better however i do still have 2 problems i am hoping to solve,
first with all these changes it runs very slowly in reverse and is almost impossible to steer in reverse. is there a way to fix this.
second is a power problem, one pp3 battery lasts just a few minutes which seems crazy to me. is there any advice on improving the power eg using a different battery such as a lipo battery. i have loads as i have many RC cars planes and helicopters so i have most kinds of battery.
many thnaks
Tim.

piborg's picture

The reverse speed issue can be solved by adding a 'boost' value when the wheels are running backwards. This is fairly easy to do to any ZeroBorg script.

To add this to the altered version of zbJoystick.py from the previous post we first need to add our boost level to the settings section towards the top:

# Settings for the joystick
axisUpDown = 1                          # Joystick axis to read for up / down position
axisUpDownInverted = False              # Set this to True if up and down appear to be swapped
axisLeftRight = 2                       # Joystick axis to read for left / right position
axisLeftRightInverted = False           # Set this to True if left and right appear to be swapped
buttonResetEpo = 3                      # Joystick button number to perform an EPO reset (Start)
buttonSlow = 8                          # Joystick button number for driving slowly whilst held (L2)
slowFactor = 0.5                        # Speed to slow to when the drive slowly button is held, e.g. 0.5 would be half speed
buttonFastTurn = 9                      # Joystick button number for turning fast (R2)
interval = 0.00                         # Time between updates in seconds, smaller responds faster but uses more processor time
reverseBoost = 1.2                      # Multiplier for when the wheels are running backwards, 1.0 is the same as forwards

Now before the SetMotor calls multiply any negative drive value by this new boost level:

                # Apply reverse boost if needed
                if driveLeft < 0:
                    driveLeft *= reverseBoost
                if driveRight < 0:
                    driveRight *= reverseBoost
                # Set the motors to the new speeds
                ZB.SetMotor1(-driveLeft * maxPower)
                ZB.SetMotor2(-driveLeft * maxPower)
                ZB.SetMotor3(-driveRight * maxPower)
                ZB.SetMotor4(-driveRight * maxPower)

You will probably need to experiment with the value used for the boost as it will depend on what battery you use and what motors are driving the wheels :) Be careful not to make it too large, if you do you could put more power into the motors then they are designed for!

As for batteries you should be able to use almost any kind you like. If you are using a KS2 ZeroBorg (DC/DC fitted) then you will need a battery between 7.0 and 10.8 V. For LiPos the only option which meets this requirement are the 2S batteries (7.4 V), which should work nicely :)

If you do use a different style of battery it will probably be easier to connect it to the V+ and GND screw terminals instead of the 9V connector on the KS2 boards.

When you have changed the battery remember to change the voltageIn value in the scripts to match the new battery voltage. You will probably also need to retune the reverseBoost value for the new output levels.

Subscribe to Comments for &quot;Slow turning in one direction&quot;