One motor is slower than the other no matter what

First and foremost, I double-checked every connection on the board four times. The problem persists despite switching motors, speed controllers, connectors, and electricity. The code does not appear to be an issue. A PS2 controller and a wireless receiver are also used to regulate the speed and directions. Furthermore, the board is powered by my laptop, while the speed controllers are supplied by a 6v power source (the motors are suggested for 5 volts). The competition is approaching, and I'm having trouble coming up with a solution. The issue I mentioned has to do with test motors. At 20v, the genuine motors are a lot more powerful, and there will be four of them.

`#include <RobojaxBTS7960.h>

#include <PS2X_lib.h>  //for v1.6

/******************************************************************
 * set pins connected to PS2 controller:
 *   - 1e column: original 
 *   - 2e colmun: Stef?
 * replace pin numbers by the ones you use
 ******************************************************************/
#define PS2_DAT        22  //14    
#define PS2_CMD        23  //15
#define PS2_SEL        24  //16
#define PS2_CLK        25  //17

#define RPWM 3 // define pin 3 for RPWM pin (output)
#define R_EN 40 // define pin 2 for R_EN pin (input)
#define R_IS 42 // define pin 5 for R_IS pin (output)

#define LPWM 2 // define pin 6 for LPWM pin (output)
#define L_EN 41 // define pin 7 for L_EN pin (input)
#define L_IS 43 // define pin 8 for L_IS pin (output)



#define RPWM_2 6 // define pin 3 for RPWM pin (output)
#define R_EN_2 32 // define pin 2 for R_EN pin (input)
#define R_IS_2 34// define pin 5 for R_IS pin (output)

#define LPWM_2 5 // define pin 6 for LPWM pin (output)
#define L_EN_2 33 // define pin 7 for L_EN pin (input)
#define L_IS_2 35 // define pin 8 for L_IS pin (output)

#define CW 1 //do not change
#define CCW 0 //do not change
#define debug 1

RobojaxBTS7960 motor1(R_EN,RPWM,R_IS, L_EN,LPWM,L_IS,debug);
RobojaxBTS7960 motor2(R_EN_2,RPWM_2,R_IS_2,L_EN_2,LPWM_2,L_IS_2,debug);


/******************************************************************
 * select modes of PS2 controller:
 *   - pressures = analog reading of push-butttons 
 *   - rumble    = motor rumbling
 * uncomment 1 of the lines for each mode selection
 ******************************************************************/
//#define pressures   true
#define pressures   false
//#define rumble      true
#define rumble      false

PS2X ps2x; // create PS2 Controller Class

//right now, the library does NOT support hot pluggable controllers, meaning 
//you must always either restart your Arduino after you connect the controller, 
//or call config_gamepad(pins) again after connecting the controller.

int error = 0;
byte type = 0;
byte vibrate = 0;
int tax=0;
int tax2=0;
void setup(){

    motor1.begin();
    motor2.begin();
  Serial.begin(9600);
  
  delay(300);  //added delay to give wireless ps2 module some time to startup, before configuring it
   
  //CHANGES for v1.6 HERE!!! **************PAY ATTENTION*************
  
  //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
  error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble);
  
  if(error == 0){
    Serial.print("Found Controller, configured successful ");
    Serial.print("pressures = ");
  if (pressures)
    Serial.println("true ");
  else
    Serial.println("false");
  Serial.print("rumble = ");
  if (rumble)
    Serial.println("true)");
  else
    Serial.println("false");
    Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;");
    Serial.println("holding L1 or R1 will print out the analog stick values.");
    Serial.println("Note: Go to www.billporter.info for updates and to report bugs.");
  }  
  else if(error == 1)
    Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");
   
  else if(error == 2)
    Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");

  else if(error == 3)
    Serial.println("Controller refusing to enter Pressures mode, may not support it. ");
  
//  Serial.print(ps2x.Analog(1), HEX);
  
  type = ps2x.readType(); 
  switch(type) {
    case 0:
      Serial.print("Unknown Controller type found ");
      break;
    case 1:
      Serial.print("DualShock Controller found ");
      break;
  case 2:
      Serial.print("Wireless Sony DualShock Controller found ");
      break;
   }
}

void loop() {

  if(error == 1) //skip loop if no controller found
    return;
  
  else { //DualShock Controller
    ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed

if(ps2x.Analog(PSS_LY)==128)
  motor1.stop();
if(ps2x.Analog(PSS_LY)<128){
  tax = map((ps2x.Analog(PSS_LY)),128,0,0,100);
  motor1.rotate(tax,CW);
}
if(ps2x.Analog(PSS_LY)>128){
  tax = map((ps2x.Analog(PSS_LY)),128,255,0,100);
  motor1.rotate(tax,CCW);
  }
if(ps2x.Analog(PSS_RY)==128);
  motor2.stop();
if(ps2x.Analog(PSS_RY)<128){
  tax2 = map((ps2x.Analog(PSS_RY)),128,0,0,100);
  motor2.rotate(tax2,CW); 
  } 
if(ps2x.Analog(PSS_RY)>128){
  tax2 = map((ps2x.Analog(PSS_RY)),128,255,0,100);
  motor2.rotate(tax2,CCW);
}
  }
}
   `

Hi, @giorgos5como
Welcome to the forum.

Have you written your code in stages?
If you have you should have code that JUST controls the motors back and forth, nothing else in the code or connected, JUST the motors and their hardware.

Check if you still have the same problem.
A simple code that exhibits the phenomenon make a solution quicker to arrive at.

A circuit diagram would be good, just an image of a hand drawn schematic with component names and pin labels will be ideal.

Have you got a DMM?
What Arduino controller are you using?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Speed depends primarily on the speed controllers. How do the controllers get RPM feedback? Do the motors have different pulse count per rev?

The circuit works with 2 joysticks, the left for the left motor and the right for the right motor, always the motor that is connected to the right joystick is a lot slower than it should, despite i see the values of the speed in the serial monitor.

On the left motor, it's getting 5.97 volts, which I find pretty normal. On the right motor, the values on the voltmeter are not stable and usually not even logical. I will do as you say and just make the motor have a simple movement. That's a really good idea, and thank you for your suggestion.

The speed controller I am using is the BTS7960, which can support up to 29 volts with a minimum of 6 volts.The motors are OK with 6 volts since they are both identical.

Hi,
What Arduino controller are you using?
A circuit diagram would help.
Are you sure you are using PWM pins?

Tom.... :smiley: :+1: :coffee: :australia:

Yea i am 100% sure that i am using the pwm pins for the RPWM and The LPWM for both the controllers. All the other pins i use digital output.
How can i create a diagram online. Is there a tool that i can use?

Hi,

Hand draw your circuit and post an image.

What model Arduino are you using?

Tom.... :smiley: :+1: :coffee: :australia:

I found the problem, basically i was putting 4.5 volts which the controller cant handle, i relly appreciate your time tho.

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