Xmotion V3 – Motor Outputs Not Balanced, Causing Robot to Drift

Hi everyone,

A few weeks ago, I bought a Black Magic Mini Sumo kit, and I’ve been running into an issue I can’t seem to solve.

After assembling the robot and programming it to move in a straight line, I noticed that it consistently drifts to the right. After some testing, I found that the two motors were spinning at different speeds, and there was a voltage difference of about 0.9–1V between the motor outputs.

Here’s what I’ve tried so far:

  • I swapped the motors, and the slower side followed the motor. So it’s not a mechanical issue on one side of the chassis.
  • I connected both motors in parallel to a DC lab power supply, and the robot moved perfectly straight. So the motors themselves seem fine.
  • I purchased a new Xmotion V3 controller, but the problem remained exactly the same.
  • I replaced the silicone tires, tested with both the Xmotion V3 library and my own code, but the drift still persists.
  • I even tried running it at higher speeds, hoping the drift would reduce, but it didn’t help.

It seems like the issue is related to inconsistent motor output from the controller.

Has anyone experienced something similar with this kit or with Xmotion V3? Could this be a hardware issue, or is there something else I could test in code?

Thanks in advance for any suggestions!

I'm not familiar with the hardware you describe.

But I know it's normal for robot vehicles to drift away from straight ahead if they don't have any feedback to tell them when they are not going straight ahead. Just turning the wheels at what should be the same speed with no feedback mechanism won't work and drift will be inevitable.

So what feedback is available for your robot to know if it is going straight?

Encoders on the wheels is a common method, but not perfect when the wheels can slip.

A magnetometer is another technique but is also not perfect, especially in buildings with steel frames or where other large metallic objects are nearby.

Looking at the XMotionV3 library, I can see that as well as the Forward() and Backward() functions there is another function called ArcTurn().

The ArcTurn() function is similar to the Forward() function, but whereas Forward() accepts a single parameter for the speed, ArcTurn() accepts separate parameters for the left and right motor speeds.

Forward()
void XMotionClass::Forward(byte speed, int Time){
   
   speed = constrain(speed,0,100);
   speed = map(speed,0,100,0,255);
   digitalWrite(RM_DIR,HIGH);
   digitalWrite(LM_DIR,HIGH);
   analogWrite(RM_PWM, speed);
   analogWrite(LM_PWM, speed);
   delay(Time);
   
}

ArcTurn()
void XMotionClass::ArcTurn(byte LeftSpeed, byte RightSpeed, int Time){
	
	LeftSpeed = constrain(LeftSpeed,0,100);
	LeftSpeed = map(LeftSpeed,0,100,0,255);
	RightSpeed = constrain(RightSpeed,0,100);
	RightSpeed = map(RightSpeed,0,100,0,255);
	digitalWrite(RM_DIR,HIGH);
    digitalWrite(LM_DIR,HIGH);
    analogWrite(RM_PWM, RightSpeed);
    analogWrite(LM_PWM, LeftSpeed);
    delay(Time);
	
}

Try using the ArcTurn() function, putting in slightly different values for RightSpeed and LeftSpeed.
Put in a lower value for the motor that is currently running faster.

By trial and error, you should be able to get the robot to run in a straight line using that function.

You might be able to come up with a rule such as:
RightSpeed = 0.85 * LeftSpeed;
that keeps the robot going in a straight line.

They seem fine without load but behave differently under load.

What's the feedback from the motors? Try to tweak the PIDs to each motor characteristic.