Need help interfacing Arduino with Motor Controller

Hi,

I am relatively new to Arduino. I am currently in the process of building a robot, and I am using an Arduino Uno to control my sensors and also send commands to a motor controller.

At the moment I am having issues sending commands to the motor controller.

This is the motor controller I am using :

The issue is, the motor controller seems to operate the wheels without the Arduino. I.e. When the Arduino is off and the motor controller is on, the wheels are still moving, and no amount of code I load onto the Arduino seems to have an effect..

At the moment the Arduino and the Motor Controller are running off seperate power sources, and when the Arduino is disconnected 2 out of the 4 motors move in a forward direction, and once the Arduino is hooked up the same still occurs.

This is the code I am using:

#include <Servo.h>
Servo myservo;

void setup () {
  myservo.attach(9); // Use PWM pin 9 to control Sabertooth.
}

void loop() {  
  // 0 means full power in one direction.
  // Actually the minimum value for me is around 30.
  // A smaller value won't drive the motor.
  myservo.write(30);
  delay(2000);
 
  // 90 means stopping the motor.
  myservo.write(90);
  delay(2000);  
   
  // 180 means full power in the other direction.
  // Actually the maximum value for me is around 160.
  // A larger value won't drive the motor either.
  myservo.write(160);
  delay(2000);
}

I need to know why I am unable to control this motor controller, and why it is not responding to the code I load onto the Arduino.

Thanks

Please post a circuit diagram. Have you connected the grounds together?

Hi,

I really don't know how to make a digital circuit diagram, so I'll just explain.

There are 2 red, 2 orange and 2 brown wires on the motor controller.

I have the 2 orange wires connected to PWM pins 5 and 6

I have 1 brown wire connected to Ground

And None of the red wires are connected.

I was told to wire it this way by this website:
http://www.robotshop.com/forum/arduino-mega-adk-and-sabertooth-12a-r-c-t11651

Thanks

Hi redmug,
Do you really need 12A? (if not you wasted a lot of money!!) they must be some motors. That link tells us nothing about the driver PCB and does'nt show us the full board contacts, etc. The two leads have 3 wires coded for servos?? (Red=5v, Brown=Gnd and Orange=control signal). Are you using DC motors or servos??

What are the lables printed near the 6 screw terminal block, are they the motor outputs and power in?

You code is for servos, not DC motors!!!

As JR says we need to see your schematic and perhaps a picture of your setup. Until then we can't help much, help us to help you.

From the second link:

As for the connection, you have to use PWM capable pins on your Arduino Mega for the signal (Orange Wire).
You need to hook one of the GND wire between the motor controller and the Arduino (Brown Wire) on the "GND" pins.

The Red wire is leave alone as it is use to power the receiver with the internal BEC of the Motor Controller.

Don't connect it to the Arduino. NO CONNECT IT TO THE MOTOR SUPPLY POS! SURELY?

Is this a RC project? if not again you purchased the wrong thing??

Are your Gnd's tied together??

Regards

Mel.

Hi,

Firstly, let me clarify, I didn't buy these parts, I am taking part in a special project and was only given these parts to work with unfortunately...

This isn't an R/C project, and I was told to program these like they were servos not DC motors. Also, I think I may have found the reason as to why the motor controller is not responding to my Arduino, however I am not exactly sure how to go about fixing it.

Basically this is an R/C motor controller and I am aiming to build an autonomous robot. If its an R/C controller, I think to control the motors I need to make my Arduino produce a pulse between 1 - 2 ms.

If someone could show me how to get the Arduino to produce these pulses that would be much appreciated.

Thanks

You code is for servos, not DC motors!!!

In the link for the motor controller provided, the motor controller appears to be made for being controlled using servo position commands. Below is some servo test code that could be used to check the calibration of the motor controller foward/stop/reverse command values.

// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a 
// to decrease) and enter to change servo position 
// (two hands required, one for letter entry and one for enter key)
// use strings like 90x or 1500x for new servo position 
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continous rotation servo
//int pos=90;

void setup()
{
  myservo.attach(7, 400, 2600); //servo control pin, and range if desired
  Serial.begin(9600);
  Serial.println("serial servo incremental test code");
  Serial.println("type a character (s to increase or a to decrease)");
  Serial.println("and enter to change servo position");
  Serial.println("use strings like 90x or 1500x for new servo position");
  Serial.println();
}

void loop()
{
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }
  if (readString.length() >0) {
    if(readString.indexOf('x') >0) { 
      pos = readString.toInt();
    }

    if(readString =="a"){
      (pos=pos-1); //use larger numbers for larger increments
      if(pos<0) (pos=0); //prevent negative number
    }
    if (readString =="s"){
      (pos=pos+1);
    }

    if(pos >= 400) //determine servo write method
    {
      Serial.println(pos);
      myservo.writeMicroseconds(pos);
    }
    else
    {   
      Serial.println(pos);
      myservo.write(pos); 
    }
  }
  readString=""; //empty for next input
}

Hi,

Sorry for the late response.

Are your Gnd's tied together??

Yes my grounds are tied together.

Also, In relation to the code you provided zoomkat, it still doesnt seem to have any effect on the operation of the motors, even after changing the servo position, the 2 left wheels still move at the same speed, and nothing happens with the right wheels.

This is the closest forum post I have found on what I think I need to do to solve this issue: Making My Arduino produce 1-2ms pulses - Troubleshooting - Arduino Forum

I need to make my arduino produce the pulses, as I am trying to control this R/C motor controller without a remote.

Also,
just thought I may add, there are switches on the motor controller itself, and these change some of the settings. Currently my configuration is:

1: Down 2: Up 3: Down 4: Down 5: Up 6: Down

Also, the 4 terminals that cannot be clearly seen on the board are:

0V, 5V, S1 and S2

Finally,

Upon turning on this controller, its now stopped displaying any status leds, even the one indicating that power is running to the controller..

Thanks

You might consider contacting Robot Shop or Dimension Engineering about your issue and they might help ensure your controller is setup correctly.

https://www.dimensionengineering.com/

I think to control the motors I need to make my Arduino produce a pulse between 1 - 2 ms.

If someone could show me how to get the Arduino to produce these pulses that would be much appreciated.

Lines like this do exactly that....

  myservo.write(90);

..... except that example sends degrees not ms, and 90 degrees is 1.5ms (the mid-point).

So you can send degrees of 0 for 1ms, 90 for 1.5ms and 180 for 2ms. Or, if you need to be more specific, use the writeMicroseconds():

myservo.writeMicroseconds(1000);
//or
myservo.writeMicroseconds(1500);
//or
myservo.writeMicroseconds(2000);
// or any value between 1000 and 2000

Hi,

I did end up contacting Dimension Engineering, and turns out that either the processor or the internal BEC on my motor controller may be damaged, as no Status Lights turn on when 12v are supplied to the controller, and this is probably why I am struggling to control these motors with an Arduino.

Thanks

I've never used a bec but read about them here: they need a very careful arming sequence don't they? Is that what you're doing?

I did end up contacting Dimension Engineering, and turns out that either the processor or the internal BEC on my motor controller may be damaged, as no Status Lights turn on when 12v are supplied to the controller, and this is probably why I am struggling to control these motors with an Arduino.

That is strange sounding as the sabertooth is for brushed motors and a BEC is normally for brushless motors (there are brushed motor BECs).