In Part 2 of building our RC robot, we'll learn how to use a Sabertooth 2x32 motor controller and Arduino to modify an electric wheelchair into an RC robot.

In my first article, we used a Sabertooth 2x25 to create a functioning RC robot base. In this article, we'll configure joystick control, create a kill switch, and connect an Arduino and you can customize to your heart's content.  You can use any microcontroller-compatible analog or digital sensor to send information to your microcontroller, and have the microcontroller send information to the Sabertooth to control your robot's motion.

### Parts Required

Note that instead of the Sabertooth 2x25 motor controller we worked with in Part 1, this time we will use a Sabertooth 2x32.

Sabertooth 2x25Sabertooth 2x32
Cost$124.99$124.99
Average Current Per Channel25 Amps32 Amps
Peak Current Per Channel50 Amps64 Amps
InputsRC, Analog, TTL SerialRC, Analog, TTL Serial, USB
Brake ControlNoYes
SteeringIndependent and Mixed ModeIndependent and Mixed Mode
ProgrammingUSB-Serial converter requiredMicro-USB on board
Arduino LibrariesYesYes
Input Voltage6-30V nominal; 33.6V max6-33.6V max
Designed forEase of UseMaximum Configurability

### Parts Needed

PartDescriptionExampleCostNotes
Jumper WiresVarious F/F, F/M, and M/M terminal wiresLink$10Standard DuPont connectors on multi-strand wire SabertoothDual 32A Motor ControllerLink$125
Electric WheelchairMerits P101 Folding Power ChairLink$1400 new (<$150 used)If more than $150, consider buying motors and batteries online. E-stop switchPush Down, Twist Release SwitchLink$4
Arduino Uno R3Any Arduino compatible board should workLink\$15

Purchase the Sabertooth motor controller from Dimension Engineering and try to find the electric wheelchair from the local used market. You do not need the entire chair—just the motors, wheels, batteries, and harness. If you cannot find a chair on the local used market, you can usually find the parts you need on eBay.

### Creating a Kill Switch

When creating controls, make your first design consideration a way to safely bring the robot base to a stop. The preferred way to do this is with an e-stop switch. E-stops (emergency stops) are switches that typically have one normally-open and one normally-closed contact. These switches can be pushed closed, but must be twisted to reopen.

Sometimes reaching a single switch on a misbehaving robot can be difficult, so you'll have to introduce other mechanical means to activate it.

##### Two designs for an e-stop switch: pull style (left) and kick-bar style (right)

That might be a kick bar, or a fabric rope someone pulls or steps on. It is important to incorporate an actual e-stop switch in your design, though, because they are readily identified in case of emergencies.

If you come up with an idea that is too clever or takes any amount of time at all to figure out, there is a good chance that when your robot has you pinned on the edge of a cliff with its running buzz-saw, or in another emergency situation, someone in a panic will not know how to shut it off.

### The Sabertooth 2x32

The Sabertooth 2x32 is slightly larger than the Sabertooth 2x25 used in the first part of the project for a robot controller. Both controllers are excellently designed and can be user programmed with Dimension Engineering's DEScribe software. Both controllers also accept analog, RC, and TTL serial input. The changes between the two come with the advanced configurability and additional outputs of the 2x32.

##### The Sabertooth 2x25 (left) and the Sabertooth 2x32 (right)

Along with greater current capacity, the Sabertooth 2x32 can be controlled directly by a computer or Raspberry Pi with the micro-USB connector or a combination of the previously mentioned inputs. Additionally, it can be programmed to activate the brakes on an electric wheelchair and respond to e-stops. Both options must be configured using the DEScribe software.

##### The Sabertooth 2x32 motor controller

If you can imagine a remote control robot or wheelchair design, you can likely find a way to bring it to life with the Sabertooth 2x32.

For the Sabertooth to work in the mode that you want, you must set the DIP switches correctly. Use this tool to choose the correct settings.

### Repurposing the Joystick

We will reuse the joystick included in the wheelchair controller—it should be salvaged and used for future projects if you don't use it here. But note that you can create any analog or digital signal to feed into the Arduino and then interpret it for use in the Sabertooth.

The headers on the wheelchair joysticks are quite small and something you might not want to work with without converting it into a larger pitch. The quickest way I found to move to a larger pitch is to simply clip the end off of the connector and crimp an RJ45 connector on the end of the wire, then from the RJ45 connector to either an RJ45 breakout or RJ45 Punchdown. The first four pins are all that are required for the easiest implementation.

If you are fortunate enough to have access to a laser-cutter/engraver, I have included a simple joystick holder you can cut out of 1/8" plywood that you can use for experimenting or as a jumping off point for further design in the attached .zip.

Pin IO / Ref Description Notes
1 In $$V_{s}=5 VDC$$ Connect to Arduino 5V
2 Out Left / Right 1 Connect to Arduino A1
3 Ref Gnd Connect to Arduino Gnd
4 Out Fore / Aft 1 Connect to Arduino A0
5 Out Fore / Aft 2 Unused in the sample program
6 Ref $$\frac{V_{s}}{2}$$
7 Out Left / Right 2
8 Unused

##### The joystick hooked up to the Arduino

                    //  Code to read contactless joystick outputs via Arduino.
int ForeAft_Pin = 1;        //Fore/Aft input is Arduino pin A1
int LeftRight_Pin = 0;     //Left/Right input is Arduino pin A0

float ForeAft_Input ;       // Expected Range 220-800
float LeftRight_Input ;    // Expected Range 220-800

void setup()               // Main Program Initialization
{
Serial.begin(9600);      // Prepare debug information
}

void loop()
{

Serial.print(LeftRight_Input);
Serial.print("\t");
Serial.print(ForeAft_Input);

Serial.println();
delay( 100 );           // Just to slow down the output for debug
}


### Hooking Up the Sabertooth

First, here are a couple of resources that you might find useful for these next sections:

Here's your checklist for connecting everything:

1. Disconnect all power to all controllers and disconnect motors.
2. Connect the Left Motor + and - wires to the M1A and M1B on the Sabertooth.
3. Connect the Right Motor + and - wires to the M2A and M2B on the Sabertooth.
4. Connect the positive brake lines from the left and right wheels to Battery + on the Sabertooth.
5. Connect the battery wires to the Sabertooth (make sure the harness is not connected to the battery).
6. Connect L Brake - to P1 and R Brake - to P2.
7. Connect the Sabertooth S1 line to Arduino Digital pin 2.
8. Connect the Sabertooth S2 line to Arduino Digital pin 3.
9. Connect the Sabertooth 5V and 0V line to the Arduino 5V and Gnd lines.
10. Connect the joystick's 5V and Gnd lines to the Arduino 5V and Gnd lines.
11. Connect the joystick's output pins, Fore/Aft & Left/Right to Arduino analog 0 and 1.

##### Connection diagram. Click to enlarge.

WheelchairSabertoothArduinoJoystick
L Motor +M1A
L Motor -M1B
L Brake +Bat +
L Brake -P1
R Motor +M2A
R Motor -M2B
R Brake +Bat +
R Brake -P2
S2Digital 3
S1Digital 2
5V5 V5 V
0VGndGnd

## Using the Sabertooth with Arduino

Libraries and installers for Arduino can be found here.

Click here for the Sabertooth "DIP switch wizard." DIP switch settings depend on the mode you wish to use. We will be starting with packetized serial mode and setting the Sabertooth to receive at address 128

 1 2 3 4 5 6 On █ █ █ █ Off █ █

##### Top row: joystick and e-stop Bottom row: voltage regulators (left over from development), Arduino Uno clone, Sabertooth 2x32, and cable harness
1. Connect the Sabertooth to the computer and download settings from DEScribe software.
3. Raise the wheels off the ground and connect the batteries—test it out.

                    // Software Serial Sample for Packet Serial
// Copyright (c) 2012 Dimension Engineering LLC
// Edited by Mark J. Hughes for AllAboutCircuits

#include <SoftwareSerial.h>
#include <Sabertooth.h>

// Decide where you are going to plug the joystick into the circuitboard.
int ForeAft_Pin = 0;        // Plug Joystick Fore/Aft into Analog pin 1
int LeftRight_Pin = 1;      // Plug Joystick Left/Right into Analog pin 0

//Decide where you are going to plug in the Arduino
int Tx_pin = 2;             // Arduino Transmit Pin to Sabertooth S1
int Rx_pin = 3;             // Arduino Receive Pin to Sabertooth S2

// Create variables to read joystick values
float ForeAft_Input ;       // Variable to store data for Fore/Aft input from joystick
float LeftRight_Input ;     // Variable to store data for Left/Right input from joystick

// These variables allow for math conversions and later error checking as the program evolves.
int Fore_Limit = 800;       // High ADC Range of Joystick ForeAft
int Aft_Limit = 220;        // Low ADC Range of Joystick ForeAft
int Right_Limit = 800;      // High ADC Range of Joystick LeftRight
int Left_Limit = 226;       // Low ADC Range of Joystick LeftRight

// Create variables for Sabertooth
int ForwardReverse_power = 0; // -127 for full reverse, 0 for stop, +127 for full forward.
int LeftRight_power = 0;      // -127 for full CounterClockwise, 0 for stop, +127 for full Clockwise

SoftwareSerial SWSerial(Rx_pin, Tx_pin); // RX, TX on pin 2 (to S1).
Sabertooth ST(128, SWSerial); // Address 128, and use SWSerial as the serial port.

/*  Sabertooth can be used in independent or mixed mode.  We're using mixed mode which controls the motion
of both motors with a single command.  Independent mode controls one motor with one command */

void setup()
{
ST.drive(0);              // Send command to stop transldational motion
ST.turn(0);               // Send command to stop rotational motion
SWSerial.begin(9600);     // Establish serial connection to Sabertooth
Serial.begin(9600);       // Establish serial connection back to computer for debugging
}

void loop()                 // Main program loop
{

// Convert the joystick values to Sabertooth values
ForwardReverse_power=map(ForeAft_Input,Fore_Limit, Aft_Limit, 127,-127);  // Translate and scale joystick values to Sabertooth values
LeftRight_power=map(LeftRight_Input,Left_Limit, Right_Limit, 127,-127);  // Translate and scale joystick values to Sabertooth values

// Command the Sabertooth to drive the motors.
ST.drive(ForwardReverse_power);  //Command the Sabertooth translational motion
ST.turn(LeftRight_power);        //Command the Sabertooth rotational motion

// Create debug information

Serial.print(ForwardReverse_power); Serial.print("\t"); Serial.println(LeftRight_power);  //Debug

}


### Next Steps

2. Open the example files that come with the Sabertooth software and test the various transmit/receive functions available to use.
3. Create a wireless controller with an nRF24L01+.
4. Mount your hardware in an enclosure for extended use.
5. Create a speed setting by adjusting the limits of the map function. Instead of typing 127, create a variable that can be adjusted to change the speed.  Also note that you can create code to eliminate reverse by replacing the map function with an equivalent.

                    /* Code to control speed */
//Decide what speeds to use with 127 maximum

int fast = 127;
int slow = 40;
int inPin= 5; // toggle switch on pin5 between gnd/5V

// Create code to change speed with SPDT toggle input
void setup(){
pinMode(inPin, INPUT);
speed = slow;
}
// Map
void loop(){
speed=fast
} else {
speed = slow
}

map(x, Left_Limit, Right_Limit, -speed, speed);
}
/* End Code to control speed */


                    /* Code to customize controller mapping */
// Map truncates data -- if you need a bit more control ,or for some reason
// need to eliminate reverse, these functions should give it to you.

float convertForeAftToServo(float y) {                         // take joystick input
float result;                                                // create output variable
result = ((y - Aft_Limit) / (Fore_Limit - Aft_Limit) * 180); // adjust equation to adjust output
return result;
}

float convertLeftRightToServo(float x) {
float result;
result = ((x - Left_Limit) / (Right_Limit - Left_Limit) * 180);
return result;
}

/* End Code to customize controller mapping */


Here's a video of me testing my directional controls:

### It Works! Now What?

Several hundred dollars and several hours later, you have now created a new Sabertooth-powered, Arduino-controlled robot via the joystick that came with it.  Are you pondering what I'm pondering?  Now instead of using just a joystick from an old wheelchair to control the robot, we need to get a bit more creative with our controllers:

1. Makey Makey can be used to create very novel controllers
3. Voice recognition controllers
4. Muscle sensors
5. Brainwave scanners
6. Surface sensors
7. Flex sensors
8. Object tracking sensors
9. Break beam sensors
10. Accelerometer/compass sensors
11. Single-channel or multiple-channel capacitive touch functionality
12. Gesture sensors
13. 9-DOF sensors

• Cecil Clontz 2016-07-22

Thanks for the excellent tutorials. I have a Power chair capable of transporting 300lbs. I’m about to build a self balancing scooter and I’m curious why you are using the Sabertooth instead of the motor controller that came with the wheel chair. Was it not beefy enough. I have to assume that mine is as it has massive motors and dual 35Ah batteries. Am I missing something?

• Mark Hughes 2016-07-22

Hi Cecil, it really comes down to the fact that the Sabertooth is much easier to interface with a microcontroller.  The default programming that comes with the powerchairs I’ve played with all have exponential response curves that build to maximum speed over time, which means that by the time a self-balancing robot’s gyro indicated rotation and commanded the wheelchair’s motors to turn on to compensate, and the wheels began to move, the robot would have already fallen over.  This is great if you’re a user with a tremor, as quick hand movements don’t become quick chair movements.  Now sure you could reverse engineer and repurpose the circuitry that’s in the chair, whether it has mosfets or igbts, but how much time and money do you want to spend re-engineering something you can buy?

• Cecil Clontz 2016-07-27

Thanks for the reply. This makes sense. I was really hoping not to have to buy a Sabertooth and make something out of the parts that I have but maybe I need to re-think what I make from this mobility chair.

• LebEngineer 2016-11-30

Thanks for this excellent tutorial , i was looking for something like this ,i just want to ask if all this can be converted to a PCB , my target is to minimize the size of all this in a single board with predefined inputs outputs. thank you

• Mark Hughes 2016-11-30

Hi @LebEngineer,
Yes, everything can be simplified for whatever purpose you desire.  Usually, though, the cost of miniaturization is overwhelming for all but large-scale projects.  What did you have in mind?
Mark

• LebEngineer 2016-12-02

hello , well i have a member in my family that is on wheel chair so i want to convert your project into a pcb and embed it in the wheel chair we have , i don’t care about the cost since it will be less than a new electric wheel chair in my country and it is fun to do (want to learn new stuff also). anyway i am familiar with arduino but never did a pcb before.
1-Now i am trying to connect all the parts and make sure that everything is working.
2- i have to draw the schematics of the connections in order to convert to pcb
since i am never did it before i am finding some difculties and i am using fritzing software but could find the sabertooth component.

Any help how can i start implementing the final pcb , thanks a lot

• Mark Hughes 2016-12-02

Hi @LebEngineer.  I don’t think there’s a need for you to create circuitboard for this project.  Get an aluminum project case large enough for the sabertooth and a cable gland(start searching for boxes herehere.  Drill a hole for the cable gland and feed through the cable harness from the wheelchair.  Once the wires have made their way inside the project case, terminate them with fork terminal flanged spade connectors.  Then attach and drill and tap holes to hold the Sabertooth 2x32 directly against the outside case (so it can dissipate its heat).  Add another, much smaller wire harness for your control mechanics.

The only reason to create a circuitboard for this project, would be to combine the arduino and the sabertooth onto a single board, and you’d still have to find a way to feed the wires into and out of the case, and there are heat dissipation issues that arise with the Sabertooth that the Fritzting software will not be able to model.

The smallest metal container I can easily secure the Sabertooth 2x25 in (based on things already in my shop) is the Hammond 1590BB  You’ll want to use the Sabertooth 2x32, which just barely won’t fit.  And if you want to use an Arduino, you’ll need to go a size up from there.

We’re getting into technical aspects that are better discussed in the forums.  Please start a project there and ping me and I’ll try to assist as best I can.

Thanks,
Mark

• Mister Dude 2016-11-30

Does your code make use of a wireless controller or just the old joystick wired directly to the robot? I’d like to use your tutorial to build a remote control lawnmower.

• Mark Hughes 2016-11-30

Hi @Mister Dude—If you look around, you’ll find an article where I remoted the wheelchair with an nRF24L01.  However, I’d recommend that you use the Sabertooth with another transceiver I wrote about, the HC12 Transceiver

On the transmitter side of things, you’ll interpret the signal from the joystick with a microcontroller and transmit with the HC12.  On the receiver, you might be able to wire the HC12 directly to the Sabertooth 2x32.

If you post your project in the Forums Ping me and I’ll help out best I can.

Thanks,
Mark

• captclearleft 2017-08-04

Hello and Great Tutorial!
I am working on a similar project, and am stuck on the “E-Brake”

How did you program the DEScribe software to stop the robot when Sabertooth A1 or A2 was High.???

Can you post an image of the DEScribe program.  Thanks!

• Mark Hughes 2017-08-04

Hi @captclearleft,
Unfortunately, I cannot post images in article comments—but if you want to create a post in our forums http://forum.allaboutcircuits.com, I can post photographs there.
First, I want to double check that you are using the Sabertooth 2x32 motor controller, and have selected the same in the DEScribe software (drop down is between the Disconnect and Undo buttons).
The software GUI will reconfigure itself after you select the proper controller and present additional options.  Select the “Power Outputs” tab.  And change “Mode” to “Brakes” for P1 and P2.  Select your other settings and then “Upload Settings to Device.”
Double check your brake electrical connections—the positive side of each brake should connect to the positive battery terminal (or the B+ connector).  The negative wire from each brake connects to P1 and P2 screw terminals.

If you still have issues, create a forum post and ping me and I’ll post the screenshots or a video walkthrough for you.

Mark

• Marian Maxim 2017-09-15

Plnning to use this in combination to an EMOTIV to provide Brainwave control based wheel chair for the most unfortunate. Thanks alot.

• Mark Hughes 2017-09-16

@Marian Maxim,
Sounds like you’re doing someone a great service.  I wish you the best of luck.
Mark

• Great Tutorial!  I am a tinkerer but never messed with Arduino or Sabertooth stuff.  And I really need my project RC wheelchair base (Invacare Pronto M41).  I will mount a 3’ pole on top of the seat mount and then have a gimbal and 360 camera on top of that.  So here is my question.  I ordered the 2x32 and other parts listed.  But I need (want) to use an RC controller.  For Tutorial #1 that you did using the 2x25, does it not have any brakes at all and just comes to a coasting stop?  I am trying to figure out if I am able to get everything programmed properly using my Flysky RC controller?  I feel confident on following your tutorials but tutorial #2 is using a joystick setup and not an RC setup.  Any advice and help will be greatly appreciated.  Thanks again.

• Mark Hughes 2018-02-23

Hi @timmyd-in-mississippi,
You should be fine.  The 2x32 has much more flexibility than the 2x25—it can do everything the 2x25 can do and more.  Use the Describe software to program it however you wish.
As for the brakes—you can program the 2x32 to use the brakes and your rc controller.  The Sabertooth will brake the motors electronically regardless, and only engages the “brakes” on the motor housing after the wheelchair has completely stopped, and disengages them before the wheelchair wheels start.
Good luck!  Create a forum post if you need assistance once they arrive—there we can share photographs and code/whatnot to help get you going.
Mark

• Sweet!  Thank you very much.  As soon as everything is in I will take some photographs and create a post to show the project from beginning to end (and get some help if I need it

• Mark, I have all my stuff in.  I am going to get everything laid out and then take some pictures and do a post as you have suggested.  But I have a quick question.  Do I have to use the Arduino?  If I am going to use an RC can I just run that straight into the 2x32 and still have braking?  I am not 100% clear on the brake difference between the 2x25 and the 2x32.  Does the 2x25 have no braking at all and just keeps free rolling where the 2x32 controller will apply the electical brakes to slow the unit down?  I don’t need anything fancy.  Just something that will go and stop accordingly when I use my FLYsky controller.  I am also going to get a FPV camera to put on the front (and maybe rear).  Thanks again!  Looking forward to getting this bad boy up and running to do some video tours.

• It won’t let me edit a comment (should have got it right the first time!).  Anyway, I reread your response and it seems pretty clear that for my purposes I can do without the Arduino??  As I put in just previous post, I simply want it to go and stop using the RC controller.  So I assume that if I let off the joy stick on my RC then it applies the electric brake at that time to top the unit.  Can the sensitivity of brakes be programmed or is that a simple on/off with power/current?

• Mark Hughes 2018-02-27

Hi @timmyd-in-mississippi,
Yeah, the comment section is pretty limited in functionality—that’s why we always push people to create forum posts for help (hint…hint).  You are correct.  You do not need an Arduino.
The Describe software by Dimension Engineering is used to program the Sabertooth.  It should allow you to specify the ramp-up/ramp-down for your situation.  Electric wheelchair brakes aren’t like any brake that you’re thinking of.  On every model I’ve seen, they only engage once the wheelchair has already stopped or in an emergency to cause an abrupt halt.  The braking that you’re thinking of is done electronically through the Sabertooth connection to the motors—and that can be programmed to suit your purposes.

To get an idea of how that is possible take a motor and spin it gently by hand.  Then while it is spinning, short the two power leads from the motor together.  Then do it again with a small resistor between the power leads.

• m_oal 2018-02-27

thank you for this tutorial!!  just to make sure, can I control the SPEED and direction of a two LARGE DC MOTORS ( 500W) by using Sabertooth 2x32 ?

• Mark Hughes 2018-02-27

I believe that those motors will exceed the specifications of the Sabertooth 2x32.  You might want to upgrade to the 2x60.

• m_oal 2018-03-01

Thank you for replying and quick question , how much weight (2X60) can handle ? Cuz I’m supposed to build something that can carry Almost 300kg and I don’t know which motor driver should i use. I tried Relays but I can’t Control their speed programmatically plus Relays will make things way more complicated. Please help me !

• Mark Hughes 2018-03-01

@m_oal,
You might wan to check with the makers of the product for that question.  https://www.dimensionengineering.com/products/sabertooth2x60  The product webpage says it’s good for robots up to 1000 lbs or battlebots up to 120 lbs.  Your 200 kg robot is easily a factor of ten heavier than anything I’ve ever moved with a Sabertooth, so I’m afraid that I can’t answer the question with any authority.

• Mark, last question I promise.  If I am going to connect my RC receiver directly to the 2x32, do you have a newbie guide for programming the 2x32 with Describe?  I would assume that programming will allow me to change parameters such as acceleration rate, top speed, braking power, etc?  I could not find any good videos that teach this to someone who has never used this stuff.  Again, THANK YOU for this tutorial.  Without it I would not even be able do this.  Any direction in the programming will be appreciated.  I did create a project post as you suggested.  Have a super duper day!