Project

Building an RC Robot Using a Wheelchair Base—Part 2

July 13, 2016 by Mark Hughes

The Sabertooth 2x32 motor controller can be used to create a robust drive platform for your next robotic endeavour. This article uses an Arduino Uno to communicate with the Sabertooth 2x32 controller.

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.

 

Wearable Game Controller by Nintendo

Wearable game controller by Nintendo

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 2x25 Sabertooth 2x32
Cost $124.99 $124.99
Average Current Per Channel 25 Amps 32 Amps
Peak Current Per Channel 50 Amps 64 Amps
Inputs RC, Analog, TTL Serial RC, Analog, TTL Serial, USB
Brake Control No Yes
Steering Independent and Mixed Mode Independent and Mixed Mode
Programming USB-Serial converter required Micro-USB on board
Arduino Libraries Yes Yes
Input Voltage 6-30V nominal; 33.6V max 6-33.6V max
Designed for Ease of Use Maximum Configurability

Parts Needed

Part Description Example Cost Notes
Jumper Wires Various F/F, F/M, and M/M terminal wires Link $10 Standard DuPont connectors on multi-strand wire
Sabertooth Dual 32A Motor Controller Link $125  
Electric Wheelchair Merits P101 Folding Power Chair Link $1400 new (<$150 used) If more than $150, consider buying motors and batteries online.
E-stop switch Push Down, Twist Release Switch Link $4  
Arduino Uno R3 Any Arduino compatible board should work Link $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.

 

Sabretooth 2x32

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.  

Sabertooth 2x32 User Guide & Joystick Holder Files

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()
{
  ForeAft_Input = analogRead(ForeAft_Pin) ;
  LeftRight_Input = analogRead(LeftRight_Pin) ;

  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.
Wheelchair Sabertooth Arduino Joystick
L Motor + M1A    
L Motor - M1B    
L Brake + Bat +    
L Brake - P1    
R Motor + M2A    
R Motor - M2B    
R Brake + Bat +    
R Brake - P2    
  S2 Digital 3  
  S1 Digital 2  
  5V 5 V 5 V
  0V Gnd Gnd
    Analog input 0 ForeAft
    Analog input 1 LeftRight

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.
  2. Connect the Arduino and download the code.
  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
// See license.txt for license details.

#include 
#include 

// 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
{
// Read the joystick values
  ForeAft_Input = analogRead(ForeAft_Pin) ;              // Read the Fore/Aft joystick value
  LeftRight_Input = analogRead(LeftRight_Pin) ;          // Read the Left/Right joystick value

// 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
  
}

Wheelchair_Sabretooth.mp4

Next Steps

  1. Test your e-stops!
  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(){
if(digitalRead(inPin)==High){
  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
  2. Head tracking cameras
  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

Give this project a try for yourself! Get the BOM.

35 Comments
  • Cecil Clontz July 22, 2016

    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?

    Like. Reply
    • Mark Hughes July 22, 2016
      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?
      Like. Reply
      • Cecil Clontz July 27, 2016
        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.
        Like. Reply