One thing I see is that you don’t have a ground wire running between the Sabertooth and the Arduino, so the signals may not work properly. I believe it is marked on the Sabertooth as 0v.
I just got done trying that as well and all it will get me is a blinking error LED.
When I power on the sabertooth the error led will light up then turn off ( normal operations I am guessing ). When I turn on the Arduino the error LED will turn on solid for ~3 seconds then start blinking rapidly.
Sorry, but don’t know much more what to advise you. It may easily be that the Sabertooth detects that you don’t have any motors connected and shuts off the system or the like.
Also I am not familiar enough with the Arduino 2009, but you appear to be trying to hook it up to the hardware serial port, which is also used by the USB port. So having them both connected may not work here. I have only used Arduino Megas which have 4 hardware serial ports.
My guess is that you will need to connect the sabertooth up to a different digital IO pin and then use the software serial library, which I believe has a max speed of 9600.
That’s an interesting observation on the RX/TX ports. A Sparkfun tutorial describes connecting the LAN board up (the RX/TX pins are on the header), and says nothing about disabling the output of the USB chip.
You caught the ground connection before I could reply!
I don’t see any jumpers on my UNO.
Probably OK to just output to both Sabertooth and USB chip.
I tried to use the Softserial library of the arduino and still get no results at the motor terminals. I used pin digital pin 12 on the ardunio as my TX pin so all I have done was to move the green wire to pin 12 and still have the arduino gnd to 0V on the sabertooth.
With the software serial library did you initialize the IO pins to be input/output. I found when I did a simple test that I did not get any output until I did so. Here is the quick and dirty version of your stuff…
[code]#include <SoftwareSerial.h>
const int BAUDRATE = 9600;
const byte ADDRESS = 131;
SoftwareSerial mySerial = SoftwareSerial(2, 3);
void setup()
{
//Hardware Serial
mySerial.begin(BAUDRATE);
pinMode(2, INPUT);
pinMode(3, OUTPUT);
Serial.begin(38400);
delay(2000); //mySerial.print(170, BYTE); //bauding character to Sabertooth
//delay(200);
}
void loop()
{
int speed = 127;
int direction_m1 = 0;
int direction_m2 = 4;
the FTDI TX goes to RX of UNO, and the RX goes to the TX of UNO (NOT parallel).
But I see Kurt is using SoftwareSerial, using pins 2 & 3, so no conflict.
Connecting the NET card (via stacking pins) STILL would be parallel to the FTDI (prewired on UNO), and I can see no way to prevent a contention (cut a trace??).
Kurt,
Can’t you just do a #define the baudrate? Or is that what Arduino is actually doing? Does it reserve a ram byte? I know for const or initialization of a variable, you get a ROM table to initialize the RAM. I don’t know what Arduino is doing…
With the code you provided I get the error led to go solid for ~3 seconds then it starts a rapid blink. This is the same behavior I get when I use the hardware serial.
#include <SoftwareSerial.h>
/*****************************************************
* DIP Switches as per the wized:
* - NiMh Battery
* - TTL RS232
* - Simplified Serial Mode
* - Just one Sabertooth conected
* - 9600 baudrate
*
* Pin 1 - OFF
* Pin 2 - ON
* Pin 3 - ON
* Pin 4 - ON
* Pin 5 - OFF
* Pin 6 - OFF
****************************************************/
// Labels for use with the Sabertooth 2x12 motor controller
// Digital pin 13 is the serial transmit pin to the
// Sabertooth 2x12
#define SABER_TX_PIN 13
// NOT USED (but still init'd)
// Digital pin 12 is the serial receive pin from the
// Sabertooth 2x12
#define SABER_RX_PIN 12
// Set to 9600 through Sabertooth dip switches
#define SABER_BAUDRATE 9600
// Simplified serial Limits for each motor
#define SABER_MOTOR1_FULL_FORWARD 127
#define SABER_MOTOR1_FULL_REVERSE 1
#define SABER_MOTOR2_FULL_FORWARD 255
#define SABER_MOTOR2_FULL_REVERSE 128
// Motor level to send when issuing the full stop command
#define SABER_ALL_STOP 0
SoftwareSerial SaberSerial = SoftwareSerial( SABER_RX_PIN,
SABER_TX_PIN );
void initSabertooth( void )
{
// Init software UART to communicate
// with the Sabertooth 2x12
pinMode( SABER_TX_PIN, OUTPUT );
SaberSerial.begin( SABER_BAUDRATE );
// 2 second time delay for the Sabertooth to init
delay( 2000 );
// Send full stop command
setEngineSpeed( SABER_ALL_STOP );
}
/*****************************************************
* setEngineSpeed
*
* Inputs - cSpeed_Motor1 - Input a percentage of full
* speed, from -100 to +100
*
*****************************************************/
void setEngineSpeed( signed char cNewMotorSpeed )
{
unsigned char cSpeedVal_Motor1 = 0;
unsigned char cSpeedVal_Motor2 = 0;
// Check for full stop command
if( cNewMotorSpeed == 0 )
{
// Send full stop command for both motors
SaberSerial.print( 0, BYTE );
return;
}
// Calculate the speed value for motor 1
if( cNewMotorSpeed >= 100 )
{
cSpeedVal_Motor1 = SABER_MOTOR1_FULL_FORWARD;
cSpeedVal_Motor2 = SABER_MOTOR2_FULL_FORWARD;
}
else if( cNewMotorSpeed <= -100 )
{
cSpeedVal_Motor1 = SABER_MOTOR1_FULL_REVERSE;
cSpeedVal_Motor2 = SABER_MOTOR2_FULL_REVERSE;
}
else
{
// Calc motor 1 speed (Final value ranges from 1 to 127)
cSpeedVal_Motor1 = map( cNewMotorSpeed,
-100,
100,
SABER_MOTOR1_FULL_REVERSE,
SABER_MOTOR1_FULL_FORWARD );
// Calc motor 2 speed (Final value ranges from 128 to 255)
cSpeedVal_Motor2 = map( cNewMotorSpeed,
-100,
100,
SABER_MOTOR2_FULL_REVERSE,
SABER_MOTOR2_FULL_FORWARD );
}
// Fire the values off to the Sabertooth motor controller
SaberSerial.print( cSpeedVal_Motor1, BYTE );
SaberSerial.print( cSpeedVal_Motor2, BYTE );
}
void setup( )
{
initSabertooth( );
}
void loop ( )
{
/*
// Full stop
setEngineSpeed( 0 );
// Half reverse
setEngineSpeed( -50 );
// Full reverse
setEngineSpeed( -100 );
// Half forward
setEngineSpeed( 50 );
*/
// Full forward
setEngineSpeed( 100 );
}
Have you hooked any motor up to the Sabertooth? It probably will detect that there is no motor and not be happy. I can not directly test your setup as again I have arduino Mega and my Sabertooth is an older 2x10, which looks like it is reasonably compatible, but looking it it’s instructions I see the information about auto baud rate detection and why you have to send an 0xaa (170) to it as the first character…
Yes, what he said. The idea I have is that if one wants to send serial data straight from the arduino IDE serial monitor to the sabertooth for testing, one could connect the sabertooth rx to the arduino rx pin, basically placing the arduino and sabertooth in parallel for receiving data from the serial monitor. There may need to be code running on the arduino to place the arduino rx pin in a a condition that would not impact the sabertooth ability to receive the serial data.
Yes, you can have the monitor TX going to both Arduino and sabertooth RX. You can also use a extra PC serial port to “white rat” the commands to the 'tooth.
I connected the motors to the sabertooth but still no luck. I tested the motors by connecting a 7.4v battery to them. Everything seems to work but the sabertooth.
Alan and zoomkat,
I have tried monitoring the RX commands and it appears the commands are being sent correctly. This can be done when using the arduino hardware serial. I don’t have a ftdi cable to see if the software serial is doing the same.
I played around with this. Again I have the old Sabertooth (2x10) and I cheated and used TX3 to connect to Sabertooth and first made sure things worked with simple serial as you specify which baud rate you are using. I remember from before that in packet mode it was sometimes tricky with the timings to get it to recognize the correct baud rate. but I got that working as well and have the motor spinning up from slow to fast back to slow… I have it hooked up with 12v Lynxmotion NIMH battery and old 12v motor I replaced when I fried the one on the other side of the rover and ordered two newer ones to have a matched set… So only M1 hooked up.
If you tried with a 7.4v battery was it also lithium… if not did you disable the check (switch 3)…
For what it is worth here is the program that now appears to work for me…
P.S. - The newer Sabertooth 2x12 manual no longer talks about the special character that must be sent at the beginning to have it detect which baud rate. Instead It says defaults to 9600… If it were me, I would try the code out at all of the different baud rates specified in the manual to verify that the default value was not changed…
I went through each baud rate listed in the manual and I either get the red error led at 9600 or nothing at all. At this point I am starting to lean towards a bad board.
I noticed that for the 2x12 there is a command set. I have changed up my code to use the command set but still no luck. I even put the arduino gnd to the B- and still got nothing.
One thing I did notice is that if I use my meter and check all of the terminals at the battery and motor side I see:
Red probe on m1a black on B-: 3.69V
Red probe on m1b black on B-: 16.69V
Red probe on m2a black on B-: 0.0V
Red probe on m2b black on B-: 3.64V
Red probe on B+ black on B-: 16.69V
Red probe on m1a black on m1b: 0.0V
Red probe on m2a black on m2b: 0.0V
This seems a bit strange to me.
const int BAUDRATE = 19200;
const int ADDRESS = 135;
void setup()
{
//Hardware Serial
Serial.begin(BAUDRATE);
delay(2000);
// send the baud rate
/*
15: Baud Rate (decimal 15, binary 0b00001111, hex 0h0f)
This value remains until it is changed and does persist through a power cycle. The values are:
1: 2400 baud
2: 9600 baud (default)
3: 19200 baud
4: 38400 baud
*/
send(15, BAUDRATE);
//send(2, (12-6)*5); // min voltage
delay(2000);
}
/*
Send a command based on:
Void DriveForward(char address, char speed)
{
Putc(address);
Putc(0);
Putc(speed);
Putc((address + 0 + speed) & 0b01111111);
}
*/
void send(int command, int data)
{
Serial.print(ADDRESS, BYTE);
Serial.print(command, BYTE);
Serial.print(data, BYTE);
Serial.print ( ((ADDRESS + command + data) & 0b01111111), BYTE); //checksum
}
void loop()
{
int speed = 127;
int direction_m1 = 0; // command for motor 1 to go forward
int direction_m2 = 4; // command for motor 2 to go forward
send(direction_m1, speed);
send(direction_m2, speed);
digitalWrite(13, HIGH);
delay(10000);
digitalWrite(13, LOW);
delay(500);
}
Have you tried to contact DimensionEngineering? I believe one email address is: [email protected]
They may have a better idea what is going on.
From your last message it sort-of sounds like it is probably running at 9600 baud and when it gets you command, it does not like something on board, so hence the error light. At other baud rates, it does not see a valid command so it ignores it…
I did contact DimensionEngineering and had them take a look at this thread to see if they could figure out what the problem is. They said that they will look into the problem and will try to replicate what I am seeing.