Getting unwanted feedback with motor controller

I am having feedback from other pots for some reason with my motor controller, 18v7. I have 3 three pots, for for ‘wheel’, one for ‘steer’ and one for ‘brake’. When I do not connect the 12V to the motor controller and just take take readings from serial monitor for my ‘brake’ pot I get:

I mapped the values to 0-4 with 1-4 applying brake.

Brake = 166
Brake is not applied: 0
Brake Motor Forward
Brake = 182
Brake is not applied: 0
Brake Motor Forward
Brake = 198
Brake is not applied: 0
Brake Motor Forward
Brake = 215
Brake is not applied: 0
Brake Motor Forward
Brake = 231
Brake is not applied: 0
Brake Motor Forward
Brake = 248
Brake is not applied: 0
Brake Motor Forward
Brake = 264
Brake is applied: 1
Brake Motor Reverse
Brake = 280
Brake is applied: 1
Brake Motor Reverse
Brake = 296
Brake is applied: 1
Brake Motor Reverse
Brake = 312
Brake is applied: 1
Brake Motor Reverse
Brake = 329
Brake is applied: 1
Brake Motor Reverse
Brake = 345
Brake is applied: 1
Brake Motor Reverse
Brake = 361
Brake is applied: 1
Brake Motor Reverse
Brake = 378
Brake is applied: 1
Brake Motor Reverse
Brake = 394
Brake is applied: 1
Brake Motor Reverse
Brake = 4
Brake is not applied: 0
Brake Motor Forward
Brake = 427
Brake is applied: 1
Brake Motor Reverse
Brake = 589
Brake is applied: 2
Brake Motor Reverse
Brake = 735
Brake is applied: 2
Brake Motor Reverse
Brake = 833
Brake is applied: 3
Brake Motor Reverse
Brake = 817
Brake is applied: 3
Brake Motor Reverse
Brake = 801
Brake is applied: 3
Brake Motor Reverse
Brake = 768
Brake is applied: 3
Brake Motor Reverse

When I apply the 12V to the motor controller and try to test the actuator I get this when I press the brake pot:

Brake = 167
Brake is not applied: 0
Brake Motor Forward
Brake = 183
Brake is not applied: 0
Brake Motor Forward
Steer = 559
Wheel = 299
Steer = 584
Wheel = 297
Brake = 200
Brake is not applied: 0
Brake Motor Forward
Steer = 567
Wheel = 297
Brake = 224
Brake is not applied: 0
Brake Motor Forward
Steer = 584
Wheel = 298
Brake = 241
Brake is not applied: 0
Brake Motor Forward
Brake = 259
Brake is applied: 1
Brake Motor Reverse

And the actuator is jumpy and not smooth obviously, also get the red/yellow leds toggling. Not sure if it is my code as I tested it above without the motor controller and it looks smooth. Any possible solutions?

The code I am using is just like the one mentioned in the arduino example for brake, applying either 3200 or -3200 using pin4.

Hello.

How do you have everything wired? Can you post the simplest code that doesn’t do what you expect it to?

- Ryan

I have pin5 going to RX of motor controller, GND going to motor controller GND, not using TXIN or TX, and have ERR going into pin4. The actuator responds but it very jerky and acts like it doesn’t know what to do. Here is part of my code, process brake will receive the pot value 0-1023.

#include <SoftwareSerial.h>

#define rxBrake 3 //not used
#define txBrake 5 //pin5 connects to RX motor controller
SoftwareSerial brake = SoftwareSerial(rxBrake, txBrake);

#define errorPin 4 //pin for error, high or low
// current state-machine state
states state = NONE;
// current partial number
unsigned int currentValue;

void setup ()
{
  Serial.begin (9600);
  brake.begin(9600);
  brake.write(0xAA);
  state = NONE;
  exitSafeStart();
}  // end of setup

void exitSafeStart()
{
  brake.write(0x83);
  //steer.write(0x83);
}

void processBrake (const unsigned int value)
{
  // do something with brake 
  Serial.print ("Brake = ");
  Serial.println (value);
  int Bval = map(value, 0 , 1023, 0,4);

  if(Bval > 0)
  {
    Serial.print("Brake is applied: ");
    Serial.println(Bval);
    //int PWMval = map(value, 0,1023, 0,64); //PWM between 0-255 with 255 being max
    //motorForward(PWMval/8);
    setBrake(-3200); //full-speed reverse
    delay(10);
  }

  else
  {
    Serial.print("Brake is not applied: ");
    Serial.println(Bval);
    setBrake(3200); //full-speed forward
    delay(10);
  }
}

//Brake
void setBrake(int brakeVal)
{
  //both directions take two speed bytes
  //first byte is low five bits of speed
  //second byte is high seven bits of speed
  //both commands are the same, only just direction
  if(brakeVal < 0)
  {
    Serial.println("Brake Motor Reverse");
    //sets motor target speed in reverse
    //must be number 0-3200
    brake.write(0x86); 
    brakeVal = -brakeVal;

  }

  else
  {
    Serial.println("Brake Motor Forward");
    brake.write(0x85); //motor forward command
  }

  brake.write(brakeVal & 0x1F);
  brake.write(brakeVal >> 5);

}

It is hard for me to tell what is going on because you haven’t posted all of your code. Could you post the simplest program that does not do what you expect to test your serial commands? What you have here looks okay, but I don’t see the point of having Bval when you are only following the true branch of the if statement every time.

- Ryan

Ok, well here is a full explanation.

First picture shows our actuator. It goes into the motor controller and is supplied by the GND and 12V wire that is unplugged(circled), it is wrapped in a type of tape(forgot name) to try to defer the interference by did not help.
i.imgur.com/7cMzW.jpg

Second picture is the whole back of cart with all the wiring. Shows the actuator wiring in red, 5V rail, 12V rail and 36V rail. The green are the signal wires going into the arduino from the pots in the front. Have the +5V coming from the pots and the black wire from the pots to GND.
i.imgur.com/M1FBk.jpg

So, my main problem is interference with the possible 12V wire that is going to the motor controller for the actuator(circled in red). When this 12V wire is disconnected and not powering the actuator…I can press all the pots and everything prints out great with no interference.

When I connect the actuator up, I press the brake pot and I get a lot of the steering pot interference without it even being touched. The Gas pedal pot is fine. When I turn the steering pot I get no interference with anything…it’s only when I press the brake pot is when I get interference from the steering pot and it records values without even being touched. We have tried moving wires, disconnecting the steering pot from the +5V but it still records a little(if I remember correctly). Only thing we can think of right is is to run the 12V/GND source to the actuator motor controller underneath the piece of wood everything is on. Or wrap the wire in the tape we have(forgot name, I did not do it).

Any possible solutions or thoughts?

Here is my code that it could possible have a problem, but like I said…it outputs perfect for all pots when the actuator is not powered.

typedef enum {
  NONE, GOT_B, GOT_G, GOT_S, GOT_W} 
states;
#include <SoftwareSerial.h>

#define rxBrake 3 //not used
#define txBrake 5 //pin5 connects to RX motor controller
SoftwareSerial brake = SoftwareSerial(rxBrake, txBrake);

#define errorPin 4 //pin for error, high or low
// current state-machine state
states state = NONE;
// current partial number
unsigned int currentValue;

void setup ()
{
  Serial.begin (9600);
  brake.begin(9600);
  brake.write(0xAA);
  state = NONE;
  exitSafeStart();
}  // end of setup

void exitSafeStart()
{
  brake.write(0x83);
}

int processBrake (const unsigned int value)
{
  // do something with brake 
  Serial.print ("Brake = ");
  Serial.println (value);
  static int previousValue = 0;

  if(value > 200)
  {
   if(value > 900)
    {
      Serial.println("All the way");
      setBrake(-3200);
    }
   else if(value > previousValue)
    {
      Serial.println("Brake is applied");
      //int PWMval = map(value, 0,1023, 0,64); //PWM between 0-255 with 255 being max
      //motorForward(PWMval/8);
      setBrake(-3200); //full-speed reverse
    }
    else if(previousValue > value)
    {
      Serial.println("Decreasing Value, Brake not applied");
      setBrake(3200);
    }
  }

  else
  {
    Serial.println("Brake is not applied");
    setBrake(3200); //full-speed forward
  }
  
  previousValue = value;
  return value;
}

//Brake
void setBrake(int brakeVal)
{
  //both directions take two speed bytes
  //first byte is low five bits of speed
  //second byte is high seven bits of speed
  //both commands are the same, only just direction
  if(brakeVal < 0)
  {
    Serial.println("Brake Motor Reverse");
    //sets motor target speed in reverse
    //must be number 0-3200
    brake.write(0x86); 
    brakeVal = -brakeVal;

  }

  else
  {
    Serial.println("Brake Motor Forward");
    brake.write(0x85); //motor forward command
  }

  brake.write(brakeVal & 0x1F);
  brake.write(brakeVal >> 5);

}
/****END BRAKE******/

void processGas (const unsigned int value)
{
  // do something with gas 
  Serial.print ("Gas = ");
  Serial.println (value);
}

void processSteer (const unsigned int value)
{
  // do something with steer
  Serial.print ("Steer = ");
  Serial.println (value); 
} // end of processGear

void processWheel(const unsigned int value)
{
  Serial.print("Wheel = ");
  Serial.println(value);
}

void handlePreviousState ()
{
  switch (state)
  {
  case GOT_B:
    static int check = 0;

    if(abs(currentValue-check) > 150)
      break;
    else
      check = processBrake(currentValue);  
    break;
  case GOT_G:
    processGas (currentValue);
    break;
  case GOT_S: //processes first part of Sxxx,xxx
    processSteer (currentValue);
    break;
  case GOT_W:
    processWheel(currentValue);
    break;
  }  // end of switch  

  currentValue = 0; 
}  // end of handlePreviousState

void processIncomingByte (const byte c)
{
  if (isdigit (c))
  {
    currentValue *= 10;
    currentValue += c - '0';
  }  // end of digit

  else 
  {

    // The end of the number signals a state change
    handlePreviousState ();

    // set the new state, if we recognize it
    switch (c)
    {
    case 'B':
      state = GOT_B;
      break;
    case 'G':
      state = GOT_G;
      break;
    case 'S':
      state = GOT_S;
      break;
    case 'W':
      state = GOT_W;
      break;
    default:
      state = NONE;
      break;
    }  // end of switch on incoming byte
  } // end of not digit  

} // end of processIncomingByte

void loop ()
{
  if (Serial.available ())
    processIncomingByte (Serial.read ());

  //if error is stopping motor, try to re-enable the motor
  if(digitalRead(errorPin) == HIGH)
  {
    exitSafeStart();
  }

}  // end of loop

Output with actuator powered, the first part is me actually turning the steer/wheel pot and values change and it is smooth. Once I start turning the brake pot I get interference as you can see and the steer/wheel pot just shows the current value it is at.

Steer = 692
Wheel = 612
Steer = 714
Wheel = 613
Steer = 759
Wheel = 613
Steer = 781
Wheel = 612
Steer = 759
Wheel = 613
Steer = 737
Wheel = 610
Steer = 714
Wheel = 610
Steer = 692
Wheel = 613
Steer = 669
Wheel = 609
Steer = 692
Wheel = 612
Steer = 714
Wheel = 613
Steer = 760
Wheel = 612
Steer = 782
Wheel = 613
Steer = 804
Wheel = 614
Steer = 782
Wheel = 612
Steer = 760
Wheel = 613
Steer = 738
Wheel = 615
Steer = 715
Brake = 129
Brake is not applied
Brake Motor Forward
Brake = 146
Brake is not applied
Brake Motor Forward
Steer = 636
Wheel = 613
Steer = 684
Wheel = 6
Brake = 146
Brake is not applied
Brake Motor Forward
Wheel = 605
Brake = 120
Brake is not applied
Brake Motor Forward
Brake = 146
Brake is not applied
Brake Motor Forward
Steer = 640
Wheel = 61
Brake = 124
Brake is not applied
Brake Motor Forward
Brake = 144
Brake is not applied
Brake Motor Forward
Brake = 120
Brake is not applied
Brake Motor Forward
Brake = 145
Brake is not applied
Brake Motor Forward
Wheel = 612
Steer = 63
Wheel = 617
Wheel = 613
Steer = 0
Wheel = 611
Wheel = 61
Steer = 70
Steer = 6
Wheel = 609
Steer = 673
Wheel = 614
Steer = 40
Wheel = 0
Steer = 672
Brake = 118
Brake is not applied
Brake Motor Forward
Brake = 124
Brake is not applied
Brake Motor Forward
Brake = 0
Brake is not applied
Brake Motor Forward
Steer = 649
Steer = 679
Steer = 643
Wheel = 612
Steer = 671
Wheel = 617
Brake = 117
Brake is not applied
Brake Motor Forward
Brake = 145
Brake is not applied
Brake Motor Forward
Steer = 639
Wheel = 613
Wheel = 0
Brake = 0
Brake is not applied
Brake Motor Forward

Output with the actuator not powered, 12V unplugged

Brake = 147
Brake is not applied
Brake Motor Forward
Brake = 164
Brake is not applied
Brake Motor Forward
Brake = 180
Brake is not applied
Brake Motor Forward
Brake = 196
Brake is not applied
Brake Motor Forward
Brake = 180
Brake is not applied
Brake Motor Forward
Brake = 162
Brake is not applied
Brake Motor Forward
Brake = 146
Brake is not applied
Brake Motor Forward
Brake = 162
Brake is not applied
Brake Motor Forward
Brake = 178
Brake is not applied
Brake Motor Forward
Brake = 194
Brake is not applied
Brake Motor Forward
Brake = 210
Brake is applied
Brake Motor Reverse
Brake = 226
Brake is applied
Brake Motor Reverse
Brake = 258
Brake is applied
Brake Motor Reverse
Brake = 274
Brake is applied
Brake Motor Reverse
Brake = 290
Brake is applied
Brake Motor Reverse
Brake = 306
Brake is applied
Brake Motor Reverse
Brake = 323
Brake is applied
Brake Motor Reverse
Brake = 339
Brake is applied
Brake Motor Reverse
Brake = 387
Brake is applied
Brake Motor Reverse
Brake = 404
Brake is applied
Brake Motor Reverse
Brake = 420
Brake is applied
Brake Motor Reverse
Brake = 437
Brake is applied
Brake Motor Reverse
Brake = 454
Brake is applied
Brake Motor Reverse
Brake = 470
Brake is applied
Brake Motor Reverse
Brake = 486
Brake is applied
Brake Motor Reverse
Brake = 534
Brake is applied
Brake Motor Reverse
Brake = 680
Brake is applied
Brake Motor Reverse
Brake = 828
Brake is applied
Brake Motor Reverse
Brake = 893
Brake is applied
Brake Motor Reverse
Brake = 975
All the way
Brake Motor Reverse
Brake = 1023
All the way
Brake Motor Reverse
Brake = 1007
All the way
Brake Motor Reverse
Brake = 988
All the way
Brake Motor Reverse
Brake = 971
All the way
Brake Motor Reverse
Brake = 950
All the way
Brake Motor Reverse
Brake = 933
All the way
Brake Motor Reverse
Brake = 915
All the way
Brake Motor Reverse
Brake = 898
Decreasing Value, Brake not applied
Brake Motor Forward
Brake = 881
Decreasing Value, Brake not applied
Brake Motor Forward
Brake = 860
Decreasing Value, Brake not applied
Brake Motor Forward
Brake = 843
Decreasing Value, Brake not applied
Brake Motor Forward
Brake = 824
Decreasing Value, Brake not applied
Brake Motor Forward
Brake = 805
Decreasing Value, Brake not applied
Brake Motor Forward
Brake = 783
Decreasing Value, Brake not applied
Brake Motor Forward
Brake = 767

Seeing your picture, it is not surprising you are getting a lot of noise. Your low-voltage analog lines are running between your power lines. Also your power lines are long and not twisted together.

There are several things you can do to limit your system’s noise:

  1. reduce the length of your power supply lines
  2. twist your power pairs together
  3. route low-voltage analog signals away from high-power lines
  4. convert analog signals to digital signals closer to their origin

By the way, I also noticed one of your Simple Motor Controllers is missing its USB connector. Have you verified that it is still working the way you expect it to independent of the rest of the system?

- Ryan

Thank you. I will try those methods but my question is why is it just interference when I press the brake? I don’t get it with steering pot and that runs along the same path. Only get it when brake is pressed.I will apply those methods you mentioned.

And yes, the usb connector came off. I have it set the way I need it for now but is there a way to attach it back on? I see it has 2 pin holes for the bottom of usb two dots. Can it be soldered back on?

Maybe the power lines for the brake motor controller travel closer to the steering pot wires, so when you start braking current is flowing through those wires and causing noise. It should be easy to test this idea.

It might be possible to put it back on. The two big pins are just for mechanical alignment. You are going to have to use a microscope, magnifying glass or look very closely at the 4 leads that come out of the connector, and reconnect them to the four corresponding pads on the board. I imagine the pads on the board might also be damaged, so you would have to repair those.

- Ryan

Well, we have resolved the issue now. We wrapped most of the wire with metallic tape and it seemed to have solved the problem. Now, I am having another problem with the motor controller and motor. It was working well about a week ago. I have changed the code up slightly but the output of the serial monitor shows it should be working perfect but it is obviously not sending a signal to the motor controller. I have checked the wiring and it is great. Checked to make sure the 36V was being supplied to the motor controlled at it is. Using a 36v20. Measured the voltage being sent to the motor when I press the gas pedal and it is 0V. Do you know of anything else I could check to try to see what the problem might be…that is if it is not my code.

Code

typedef enum {
  NONE, GOT_B, GOT_G, GOT_S, GOT_W} 
states;

#include <SoftwareSerial.h>

#define errorPin 4 //pin for error, high or low
#define PWML    10 //PWM pin for Low, do not need to direction of motor.
#define PWMH    11 //PWM pin for High, needed for direction of motor
#define DIR    12 //non PWM pin for direction control
//#define SWTCH   8; //switch enable for forward/reverse

states state = NONE;
// current partial number
unsigned int currentValue;

void setup ()
{
  Serial.begin (9600);
  pinMode(PWML,OUTPUT);
  pinMode(PWMH,OUTPUT);
  
  state = NONE;
  exitSafeStart();
}  // end of setup

void exitSafeStart()
{
  brake.write(0x83);
}

int processBrake (const unsigned int value)
{
  // do something with brake 
  Serial.print ("Brake = ");
  Serial.println (value);
}
/****END BRAKE******/

/******START GAS*****/
int processGas (const unsigned int value)
{
  // do something with gas 
  Serial.print ("Gas = ");
  Serial.println (value);
  static int previousGas = 0;
  //map down to 1/3
  int PWMval = map(value, 0, 1023, 0, 78);
  //int PWMval = value;
  motorForward(PWMval);

  if(PWMval > 2)
  {
    Serial.print("PWMval: ");
    Serial.println(PWMval);
    
   if(PWMval > 75)
    {
      Serial.println("Max speed");
      motorForward(78); 
    }
    else if(value > previousGas)
    {
      Serial.println("Motor accelerating");
      motorForward(PWMval);
    }
    else if(previousGas > value)
    {
      Serial.println("Motor decelerating");
      motorForward(PWMval);  
    }
  }
  
    previousGas = value;
    return value;
}

//Motor stop
void stopFunction()
{
  analogWrite(PWML, 0);
  analogWrite(PWMH, 0);
}

//Forard of the motor
void motorForward(int PWMforward)
{
  Serial.print("Entered motorForward: ");
  Serial.println(PWMforward);
  digitalWrite(DIR, LOW); 
  digitalWrite(PWML, HIGH);
  analogWrite(PWMH, PWMforward);
  Serial.println("Leaving motorForward");
  delay(5);
}
//Reverse of the motor
void motorReverse(int PWMreverse)
{
  digitalWrite(DIR, HIGH);
  digitalWrite(PWML, HIGH);
  analogWrite(PWMH, PWMreverse);
}
/**********END GAS*********/

/**********START STEERING***********/
void processSteer (const unsigned int value)
{
  // do something with steer
  Serial.print ("Steer = ");
  Serial.println (value); 
} // end of processGear

void processWheel(const unsigned int value)
{
  Serial.print("Wheel = ");
  Serial.println(value);
}

void handlePreviousState ()
{
  switch (state)
  {
  case GOT_B:
    processBrake(currentValue);  
    break;
    
  case GOT_G:
    static int checkGas = 0;

    if(abs(currentValue - checkGas) > 150)
      break;
    else
      checkGas = processGas(currentValue);
    break;

  case GOT_S: //processes first part of Sxxx,xxx
    processSteer (currentValue);
    break;
    
  case GOT_W:
    processWheel(currentValue);
    break;
  }  // end of switch  

  currentValue = 0; 
}  // end of handlePreviousState

void processIncomingByte (const byte c)
{
  if (isdigit (c))
  {
    currentValue *= 10;
    currentValue += c - '0';
  }  // end of digit

  else 
  {

    // The end of the number signals a state change
    handlePreviousState ();

    // set the new state, if we recognize it
    switch (c)
    {
    case 'B':
      state = GOT_B;
      break;
    case 'G':
      state = GOT_G;
      break;
    case 'S':
      state = GOT_S;
      break;
    case 'W':
      state = GOT_W;
      break;
    default:
      state = NONE;
      break;
    }  // end of switch on incoming byte
  } // end of not digit  

} // end of processIncomingByte

void loop ()
{
  if (Serial.available ())
    processIncomingByte (Serial.read ());

  //if error is stopping motor, try to re-enable the motor

}  // end of loop

Output that looks great

Gas = 252
PWMval: 19
Motor accelerating
Entered motorForward: 19
Leaving motorForward
Gas = 268
PWMval: 20
Motor accelerating
Entered motorForward: 20
Leaving motorForward
Gas = 285
PWMval: 21
Motor accelerating
Entered motorForward: 21
Leaving motorForward
Gas = 427
PWMval: 32
Motor accelerating
Entered motorForward: 32
Leaving motorForward
Gas = 462
PWMval: 35
Motor accelerating
Entered motorForward: 35
Leaving motorForward
Gas = 609
PWMval: 46
Motor accelerating
Entered motorForward: 46
Leaving motorForward
Gas = 591
PWMval: 45
Motor decelerating
Entered motorForward: 45
Leaving motorForward
Gas = 575
PWMval: 43
Motor decelerating
Entered motorForward: 43
Leaving motorForward
Gas = 559
PWMval: 42
Motor decelerating
Entered motorForward: 42
Leaving motorForward
Gas = 543
PWMval: 41
Motor decelerating
Entered motorForward: 41
Leaving motorForward
Gas = 527
PWMval: 40
Motor decelerating
Entered motorForward: 40
Leaving motorForward
Gas = 511
PWMval: 38
Motor decelerating
Entered motorForward: 38
Leaving motorForward
Gas = 495
PWMval: 37
Motor decelerating
Entered motorForward: 37
Leaving motorForward
Gas = 479
PWMval: 36
Motor decelerating
Entered motorForward: 36
Leaving motorForward
Gas = 463
PWMval: 35
Motor decelerating
Entered motorForward: 35
Leaving motorForward

Does it work when you don’t use PWM and just set PWMH to a logical high? It is possible that your motors do not start spinning at lower duty cycles.

If you are still having trouble, I would recommend simplifying your system. For example, take the Arduino out of the system and just see if you can make the motor driver drive the motor by wiring its inputs to values that should make it go.

- Ryan

No, it doesn’t. Just tried to set it to either HIGH or LOW and here is my code I used and output. Thing is, when we were testing about a week ago, I had set the PWMval to map from 0-255 and would only send PWMval/4 to the motor. We never ran it at it’s max speed to draw max current. So, I do not see why the motor controller would be damaged at all. I have checked the wiring and all seems good with the arduino pins. I checked and see that 36V is being supplied to the motor controller but when I press the gas pot, 0V are being supplied to the actual motor through the OUTA/OUTB pins. Is there anyway we can check others things related to the motor controller to see if it is functioning correctly?

Code

typedef enum {
  NONE, GOT_B, GOT_G, GOT_S, GOT_W} 
states;

#include <SoftwareSerial.h>

#define rxBrake 3 //not used
#define txBrake 5 //pin5 connects to RX motor controller
SoftwareSerial brake = SoftwareSerial(rxBrake, txBrake);

#define errorPin 4 //pin for error, high or low
#define PWML    10 //PWM pin for Low, do not need to direction of motor.
#define PWMH    11 //PWM pin for High, needed for direction of motor
#define DIR     3 
//#define SWTCH   8; //switch enable for forward/reverse

states state = NONE;
// current partial number
unsigned int currentValue;

void setup ()
{
  Serial.begin (9600);
  brake.begin(9600);
  brake.write(0xAA);
  pinMode(PWML,OUTPUT);
  pinMode(PWMH,OUTPUT);
  pinMode(DIR,OUTPUT);
  
  state = NONE;
}  // end of setup

/******START BRAKE******/
int processBrake (const unsigned int value)
{
  // do something with brake 
  Serial.print ("Brake = ");
  Serial.println (value);
}
/****END BRAKE******/

/******START GAS*****/
int processGas (const unsigned int value)
{
  // do something with gas 
  Serial.print ("Gas = ");
  Serial.println (value);
  static int previousGas = 0;
  //map down to 1/3
  int PWMval = map(value, 0, 1023, 0, 255);
  Serial.print("PWMval: ");
  Serial.println(PWMval);
  //int PWMval = value;
 
  if(PWMval > 150)
  {
    Serial.println("Forward");
    digitalWrite(DIR, LOW);
    digitalWrite(PWMH, HIGH);
  }
  else if(PWMval < 150)
  {
    Serial.println("Off");
    digitalWrite(DIR,LOW);
    digitalWrite(PWMH, LOW);
  }
  return value;
}

void handlePreviousState ()
{
  switch (state)
  {
  case GOT_B:
    static int checkBrake = 0;

    if(abs(currentValue-checkBrake) > 150)
      break;
    else
      checkBrake = processBrake(currentValue);  
    break;
    
  case GOT_G:
    static int checkGas = 0;

    if(abs(currentValue - checkGas) > 150)
      break;
    else
      checkGas = processGas(currentValue);
    //processGas(currentValue);
    break;
  }  // end of switch  

  currentValue = 0; 
}  // end of handlePreviousState

void processIncomingByte (const byte c)
{
  if (isdigit (c))
  {
    currentValue *= 10;
    currentValue += c - '0';
  }  // end of digit

  else 
  {

    // The end of the number signals a state change
    handlePreviousState ();

    // set the new state, if we recognize it
    switch (c)
    {
    case 'B':
      state = GOT_B;
      break;
    case 'G':
      state = GOT_G;
      break;
    default:
      state = NONE;
      break;
    }  // end of switch on incoming byte
  } // end of not digit  

} // end of processIncomingByte

void loop ()
{
  if (Serial.available ())
    processIncomingByte (Serial.read ());

}  // end of loop

Output

Gas = 306
PWMval: 76
Off
Steer = 736
Wheel = 439
Gas = 324
PWMval: 80
Off
Gas = 340
PWMval: 84
Off
Gas = 356
PWMval: 88
Off
Gas = 372
PWMval: 92
Off
Gas = 388
PWMval: 96
Off
Gas = 404
PWMval: 100
Off
Gas = 420
PWMval: 104
Off
Gas = 436
PWMval: 108
Off
Gas = 452
PWMval: 112
Off
Gas = 484
PWMval: 120
Off
Gas = 500
PWMval: 124
Off
Gas = 516
PWMval: 128
Off
Gas = 532
PWMval: 132
Off
Gas = 565
PWMval: 140
Off
Gas = 630
PWMval: 157
Forward
Gas = 647
PWMval: 161
Forward
Gas = 711
PWMval: 177
Forward
Gas = 776
PWMval: 193
Forward
Gas = 792
PWMval: 197
Forward
Gas = 808
PWMval: 201
Forward
Gas = 840
PWMval: 209
Forward
Gas = 888
PWMval: 221
Forward
Gas = 921
PWMval: 229
Forward
Gas = 969
PWMval: 241
Forward
Gas = 1018
PWMval: 253
Forward
Gas = 1002
PWMval: 249
Forward
Gas = 980
PWMval: 244
Forward
Gas = 964
PWMval: 240
Forward
Gas = 947
PWMval: 236
Forward
Gas = 929
PWMval: 231
Forward
Gas = 910
PWMval: 226
Forward
Gas = 894
PWMval: 222
Forward
Gas = 877
PWMval: 218
Forward
Gas = 861
PWMval: 214
Forward
Gas = 844
PWMval: 210
Forward
Gas = 812
PWMval: 202
Forward
Gas = 795
PWMval: 198
Forward
Gas = 777
PWMval: 193
Forward
Gas = 760
PWMval: 189
Forward
Gas = 743
PWMval: 185
Forward
Gas = 726
PWMval: 180
Forward
Gas = 709
PWMval: 176
Forward
Gas = 690
PWMval: 171
Forward
Gas = 640
PWMval: 159
Forward
Gas = 621
PWMval: 154
Forward
Gas = 522
PWMval: 130
Off
Gas = 387
PWMval: 96
Off
Gas = 403
PWMval: 100
Off
Gas = 419
PWMval: 104
Off
Gas = 435
PWMval: 108
Off
Gas = 451
PWMval: 112
Off
Gas = 467
PWMval: 116
Off
Gas = 483
PWMval: 120
Off
Gas = 499
PWMval: 124
Off
Gas = 515
PWMval: 128
Off
Gas = 531
PWMval: 132
Off
Gas = 547
PWMval: 136
Off
Gas = 563
PWMval: 140
Off
Gas = 579
PWMval: 144
Off
Gas = 595
PWMval: 148
Off
Gas = 611
PWMval: 152
Forward
Gas = 627
PWMval: 156
Forward
Gas = 643
PWMval: 160
Forward
Gas = 660
PWMval: 164
Forward
Gas = 676
PWMval: 168
Forward
Gas = 692
PWMval: 172
Forward
Gas = 740
PWMval: 184
Forward
Gas = 756
PWMval: 188
Forward
Gas = 773
PWMval: 192
Forward
Gas = 789
PWMval: 196
Forward
Gas = 805
PWMval: 200
Forward
Gas = 821
PWMval: 204
Forward
Gas = 838
PWMval: 208
Forward
Gas = 854
PWMval: 212
Forward
Gas = 871
PWMval: 217
Forward
Gas = 919
PWMval: 229
Forward
Gas = 952
PWMval: 237
Forward
Gas = 1000
PWMval: 249
Forward
Gas = 983
PWMval: 245
Forward
Gas = 967
PWMval: 241
Forward
Gas = 951
PWMval: 237
Forward
Gas = 935
PWMval: 233
Forward
Gas = 918
PWMval: 228
Forward
Gas = 902
PWMval: 224
Forward
Gas = 886
PWMval: 220
Forward
Gas = 870
PWMval: 216
Forward
Gas = 853
PWMval: 212
Forward
Gas = 837
PWMval: 208
Forward
Gas = 821
PWMval: 204
Forward
Gas = 805
PWMval: 200
Forward
Gas = 789
PWMval: 196
Forward
Gas = 772
PWMval: 192
Forward
Gas = 756
PWMval: 188
Forward
Gas = 724
PWMval: 180
Forward
Gas = 708
PWMval: 176
Forward
Gas = 692
PWMval: 172
Forward
Gas = 660
PWMval: 164
Forward
Gas = 644
PWMval: 160
Forward
Gas = 627
PWMval: 156
Forward
Gas = 611
PWMval: 152
Forward
Gas = 578
PWMval: 144
Off
Gas = 562
PWMval: 140
Off
Gas = 545
PWMval: 135
Off
Gas = 529
PWMval: 131
Off
Gas = 513
PWMval: 127
Off
Gas = 497
PWMval: 123
Off
Gas = 480
PWMval: 119
Off
Gas = 464
PWMval: 115
Off
Gas = 447
PWMval: 111
Off
Gas = 431
PWMval: 107
Off
Gas = 414
PWMval: 103
Off
Gas = 398
PWMval: 99
Off

Well, I am not even getting the 5V from the 5Vout pin either. I do get the 36V from the v+ on the logic side. We have a 20A fuse between the motor controller and that is still good. I tried connecting 5V to the VCS separately and no luck either. Seems like the motor controller is damaged somehow and I have no clue how that would have happened honestly.

Your situation sounds remarkably similar to someone I helped on the phone this morning. Did you or someone working with you call us this morning?

- Ryan