RC Kart Using MDDS30 and Arduino Uno V3

Howdy. My team and I have been working on a remote controlled kart for school that we essentially inherited from another team. It hasn’t been responding well to the RC controls in forward mode, but, weirdly, does pretty good in reverse. I can’t begin to explain why it would work better in one direction as none of us are well-versed in electronics. But based on some reading I’m beginning to suspect it’s a grounding issue: nothing is grounded to the aluminum and steel kart itself. I have the schematic here, but I wanted to see if anyone had some input before I just started running wires from everything labeled “GND” to a common ground point on the chassis. Is there a simpler way to do it? Does anything else about this jump out at you? Thank you for your time.

Please post the code that you are using following the advice given in the link below when posting code

Oh, sorry. I assumed it was more a question of ground, so I didn’t think it was necessary. But I suppose it could be code, too. Here it is:

#define MTR 5 //motor right
#define MTL 6 //motor left
#define DIR_R 7 //right direction
#define DIR_L 8 //left direction
#define FWD LOW
#define RVS HIGH
void setup() {
  pinMode(10,INPUT); //Channel 1 (steer)
  pinMode(11,INPUT); //Channel 3 (throttle)
  pinMode(9,INPUT); //Channel 5 (direction)
  pinMode(MTR,OUTPUT);
  pinMode(MTL,OUTPUT);
  pinMode(FWD,OUTPUT);
  pinMode(RVS, OUTPUT);
  Serial.begin(9600);
}

int steer; //steering number
int throttle; //throttle number
int pwm = 0; // pwm number
int fwd = 1 ; 
int direc = analogRead(A0);
void speedFunct(){
  //full power
  if(pwm >= 250){
    analogWrite(MTR,255);
    analogWrite(MTL,255);
  }
  //no power
  else if(pwm <= 0){
    analogWrite(MTR,0);
    analogWrite(MTL,0);
  }
  //percentage of power (duty cycle)
  else{
    analogWrite(MTR,pwm);
    analogWrite(MTL,pwm);
  }
}
void steerFunct(){
  //drive straight
  if(1450 < steer < 1550){
    if(fwd == 1){
       digitalWrite(DIR_R, FWD);
       digitalWrite(DIR_L, FWD);
    }
    else{
       digitalWrite(DIR_R, RVS);
       digitalWrite(DIR_L, RVS);
    }
     speedFunct();
      delay(5);
  }
  //steer right
  if(steer >= 1550){
    digitalWrite(DIR_R, RVS);
    digitalWrite(DIR_L, FWD);
    speedFunct();
    delay(5);
  }
  //steer left
  if(steer <= 1450){ // 1400
    digitalWrite(DIR_R, FWD);
    digitalWrite(DIR_L, RVS);
    speedFunct();
    delay(5);
  }
}

void loop() {
  //Pin setup
  steer = pulseIn(10, HIGH, 250000);
  throttle = pulseIn(11, HIGH, 250000);
  direc = pulseIn(9, HIGH, 250000);
  Serial.println(throttle);
  Serial.println(steer);
  /***Direction control***/
  //Forward
  if(direc <= 1000){
    analogWrite(DIR_R, FWD);
    analogWrite(DIR_L, FWD);
    pwm = map(throttle, 990, 1983 ,0 ,255);
    fwd = 1;
    steerFunct();
    delay(5);
    Serial.print("Direction: ");
    Serial.println("Forward");
    Serial.println("\n");
    
  }
  //Reverse
  if(direc >= 1900){
    digitalWrite(DIR_R, RVS);
    digitalWrite(DIR_L, RVS);
    pwm = map(throttle, 990, 1983 ,0 ,255);
    fwd = 0;
    steerFunct();
    delay(5);
    Serial.print("Direction: ");
    Serial.println("Reverse");
    Serial.println("\n");
  }
  //Dead Zone(No movement)
  if(1400 < direc && direc < 1500){
    //pwm = 0;
    //speedFunct();
    digitalWrite(MTR, LOW);
    digitalWrite(MTL,LOW);
    delay(5);
    Serial.print("Direction: ");
    Serial.println("Stop");
    Serial.println("\n");
  }
  
  delay(5);
}

There are problems with your code which may or may not cause the problem that you describe

For instance

  if (1450 < steer < 1550)

is not the way to test whether a variable is within a range. It should be

  if (1450 < steer && steer < 1550)

Personally I prefer

  if (steer > 1450 && steer < 1550)

as I find it easier to read, but there are reasons to do it the first way

Thank you for that, UKHeliBob. Perhaps. I’d rather not touch that until I rule out the grounding issues as I’m fairly certain it’s something that needs to be done, regardless. I made a mock up of what I think I’d like to do (in green).

Am I putting any of the components in danger? Is grounding both sides of the motor driver unnecessary?

It is wrong. Fix it now and be done with it

Turns out it was RFI. Not code or grounding related. Thanks anyway.

I take it that you fixed the problem with the sketch

If you’re talking about the schematic, I don’t know what you’re referring to. If you’re talking about the code, no - I’m hoping to make bigger changes to it now, anyway.

Have you fixed

if (1450 < steer < 1550)

It wasn’t necessary to solve my previous problem, but I’ll certainly see about it in my next code change.