Arduino + Sabertooth problem

Hi,
Me and some friends are trying to make a segaway as a school projekt. However we got some problem while testing it, we only get one motor to work, the motor that are connected to m1 but we can’t get the m2 terminal to work. Any ideas?

Products:
Motors - two 500 watt dc brushed, from a permobile
Arduino uno
Sabertooth 2x25 v2
Deadman switch
Two 12v 17ah lead-acid gel battery connected in series

Sabertooth simplified serial mode

Code:

#include <SoftwareSerial.h>

//Digital pin 13 is serial transmit pin to sabertooth
#define SABER_TX_PIN 13
//Not used but still initialised, Digital pin 12 is serial receive from Sabertooth
#define SABER_RX_PIN 12

//set baudrate to match sabertooth dip settings
#define SABER_BAUDRATE 9600

#define SABER_MOTOR1_FULL_FORWARD 127
#define SABER_MOTOR1_FULL_REVERSE 1

#define SABER_MOTOR2_FULL_FORWARD 255
#define SABER_MOTOR2_FULL_REVERSE 128

SoftwareSerial SaberSerial = SoftwareSerial (SABER_RX_PIN, SABER_TX_PIN );

void initSabertooth (void) {
//initialise software to communicate with sabertooth
pinMode ( SABER_TX_PIN, OUTPUT );

SaberSerial.begin( SABER_BAUDRATE );
//2 sec delay to let it settle
delay (2000);
}

float level = 0;

int u;

signed char Motor1percent;
signed char Motor2percent;

void setup() // run once, when the sketch starts
{
initSabertooth();
//analogINPUTS

Serial.begin(9600);

}

void set_motor() {
unsigned char cSpeedVal_Motor1 = 0;
unsigned char cSpeedVal_Motor2 = 0;

Motor1percent = (signed char) level;
Motor2percent = (signed char) level;

Serial.print("level ");
Serial.println(level);

if (Motor1percent > 100) Motor1percent = 100;
if (Motor1percent < -100) Motor1percent = -100;
if (Motor2percent > 100) Motor2percent = 100;
if (Motor2percent < -100) Motor2percent = -100;

cSpeedVal_Motor1 = map (Motor1percent,
-100,
100,
SABER_MOTOR1_FULL_REVERSE,
SABER_MOTOR1_FULL_FORWARD);

cSpeedVal_Motor2 = map (Motor2percent,
-100,
100,
SABER_MOTOR2_FULL_REVERSE,
SABER_MOTOR2_FULL_FORWARD);

SaberSerial.print (cSpeedVal_Motor1, BYTE);
SaberSerial.print (cSpeedVal_Motor2, BYTE);

delay(5000);
}

void loop () {

level = 20;
set_motor();

} // end loop

What happens if you remove all the code from loop and put this at the end of setup?

SaberSerial.print (SABER_MOTOR2_FULL_FORWARD, BYTE);

What happens if you swap the motors around?

Is the saber baudrate right? The datasheet I saw mentioned 38400 for simplified serial.

You just get a printout in the serial monitor with that line of code.

When we switch the motors around, the motor connected to the first channel is still the powered one.

We are using the Sabertooth in 9600 baud mode so that is not the issue.

Thank you for the fast reply :slight_smile:

You just get a printout in the serial monitor with that line of code.

How so? That line, as I understand it is supposed to send a motor2 command to the sabertooth. There should be no serial output unless the sabertooth library is echoing to serial. Does it?

wildbill:

You just get a printout in the serial monitor with that line of code.

How so? That line, as I understand it is supposed to send a motor2 command to the sabertooth. There should be no serial output unless the sabertooth library is echoing to serial. Does it?

Yy, sorry, I'll rephrase :slight_smile: We get no reaction from motor two just the simple feedback in the serial monitor about which level and speed it is running on. :slight_smile:

Have yuo tried using the sabertooth in the rc mode using the arduino servo code?

Did you ever resolve this? I have the same problem.