Unequal Motor Speeds

My self-build PiCy / PicoBorg kit arrived last week and the build has gone really well so far :)
I've completed the wiring as per the instructions and have now reached the coding stage.

Using the TurtleBorg.py and the TurtleBorgTest.py code, both motors operate according to commands but one is rotating faster than the other causing it to continually track to the right :(

As I'm still testing the device, I'm running the Pi on a mains adapter with plenty of slack cable and powering the motors using 2 Duracell non-rechargeable AA batteries. Communication is handled over a WiFi.

With regards to wiring, all terminals have been soldered correctly.
I've also tested each motor during a testing 20 second test and found both are getting around 2.09v
When turned by hand the 'slower' wheel does feel as though it may have a little more resistance.

Could this a be a mechanical issue inside the motor housing or a coding issue?

Any help would be most welcome!

piborg's picture

The most likely explanation is that the motors are not quite the same, one is providing more resistance than the other so it rotates slower with the same amount of power supplied.

The problem can be solved either with code or with some fiddling, aiming to slow the left motor down to the speed of the right motor.

To solve it with code you need to use PWM control on the GPIO pins, you want the power to the right motor to be slower.
This can be done using WiringPi version 2, which you can install with:
sudo easy_install wiringpi2
The new version TurtleBorgPwm.py is attached below, save it to the same folder as the other scripts.
To make TurtleBorgTest.py use this new load change line 4 to:
import TurtleBorgPwm as TurtleBorg
To correct the speed of the left motor adjust line 22 in TurtleBorgPwm.py, smaller numbers are slower.

To solve it with wiring you would need to add a resistor in series with the left motor, the larger the resistors value the more it will slow the motor down.
If you do this though be careful, the resistor will likely get hot.

Personally I would use the software change unless it causes problems for other reasons.

Hope this helps you.

Attachments: 

Ok that's great - I'll download these and give it a go.

Could you clarify if I need to make any configurations in Wiring Pi v2 ?

Editing and executing the new TurtleBorg script should be fine. I'll post my results from the tests...

Thanks Again

piborg's picture

Wiring Pi 2 should work fine after installation, like the RPi.GPIO and the previous version of Wiring Pi it will need superuser permissions though.
e.g. start Python using sudo
sudo ./TurtleBorgPwm.py

I applied the new script and installed Wiring Pi v2 and this as definitely helped. I was able to fine tune the speed of each motor until they run at equal speeds (I still have some issues with wheel tracking but I'll start another thread for that).

I'm finding that the directional commands are backwards though - for example: 'MoveLeft' results in right turn. The wires from the picoBorg are correct. Is this best resolved in the software? If so, how?

Thanks

piborg's picture

This is easiest to resolve by changing the software.
What you want to do is rename the MoveLeft and MoveRight functions so that line 44 is
def MoveRight(n):
and line 51 is
def MoveLeft(n):

Thats great!
I suspected it would be something like this but was unsure which lines to edit!

Thanks

I too had this issue - received my PiCY last week and assembled it per instructions only to have it track to the left. TurtleBorgPwm.py fixed the problem really well! thanks!

Subscribe to Comments for "Unequal Motor Speeds"