Wheels go in opposite directions when should be going the same


#1

Suddenly, the wheels started to go in opposite directions when direction for both motors assigned the same.Reset everything and even reinstalled both mbot and arduino, have to assign opposite values to the motor speed in order to get robot going straight. Please, help!


#2

@Vinci,

This could be a wiring issue. On the wheel that is not going in the intended direction, try switching the polarity of the wires.

Mike


#3

@ Vinci: Turn the two motors actually in different directions? – or does it only look like that, because the second motor is installed 180 degrees turned?

Gerhard


#4

Actually, this is exactly what you do…assign opposite values to the motors.

I found that out in the code for the default firmware available in the library zip file.

You could switch the wiring, but then the bot wouldn’t work with any of the standard programs…just yours.

Here’s a link to a demo program showing how to do this:

http://somedisassemblyrequired.com/index.php/2017/01/01/mbot-example-program

and here are forward and reverse function examples in C code (note the use of the negative sign):

//——————————————————————————————
// moveFwd
//
// Moves the robot forward by driving both motors at speed of moveSpeed.
//
// The motors are driven in opposite directions as they are mounted on opposite sides, so
// forward and backwards are reversed between the two.
//

void moveFwd(){

MotorL.run(-moveSpeed); MotorR.run(moveSpeed);

}// end of moveFwd
//——————————————————————————————

//——————————————————————————————
// moveRev
//
// Moves the robot backwards by driving both motors at speed of moveSpeed.
//
// The motors are driven in opposite directions as they are mounted on opposite sides, so
// forward and backwards are reversed between the two.
//

void moveRev(){

MotorL.run(moveSpeed); MotorR.run(-moveSpeed);

}// end of moveRev
//——————————————————————————————


#5