Sabertooth and SoftwareSerial library

I have been using a Sabertooth and Syren motor controllers for awhile with the hardware tx pin. I want to be able to use the SoftwareSerial library so I can use the hardware serial lines for the serial monitor.

This code works with the hardware serial:

#include <Sabertooth.h>


Sabertooth DriveControl(128);
Sabertooth CutControl(129);

void setup()
{
	Serial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial.
	Sabertooth::autobaud(Serial);

	DriveControl.drive(0); // The Sabertooth won't act on mixed mode packet serial commands until
	DriveControl.turn(0);  // it has received power levels for BOTH throttle and turning, since it mixes the two together to get diff-drive power levels for both motors.
	CutControl.motor(1, 0);

	delay(3000);
}

After including the SoftwareSerail library I tried this but can’t seem to get the Sabertooth or Syren to acknowledge.

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

SoftwareSerial swSerial(NOT_A_PIN,3);
Sabertooth DriveControl(128, swSerial);
Sabertooth CutControl(129, swSerial);


void setup()
{
	swSerial.begin(9600);
	Serial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial.
	Sabertooth::autobaud(swSerial);

	DriveControl.drive(0); // The Sabertooth won't act on mixed mode packet serial commands until
	DriveControl.turn(0);  // it has received power levels for BOTH throttle and turning, since it mixes the two together to get diff-drive power levels for both motors.
	CutControl.motor(1, 0);

	delay(3000);
}

Has anyone been successful with this combination?

It is entirely possible that the Sabertooth library conflicts with the SoftwareSerial library

What does this line mean

SoftwareSerial swSerial(NOT_A_PIN,3);

Where is NOT_A_PIN defined ? and what value does it have ?

...R

As far as I can tell, not_a_pin is a constant in the core arduino library set to 0.

I doubt there is a conflict in the libraries since there is sample code here to use them together.
I have tried that sample code but no joy so far.

http://www.dimensionengineering.com/software/SabertoothArduinoLibrary/html/3_8_advanced_2_software_serial_2_software_serial_8ino-example.html

rbtgeek:
As far as I can tell, not_a_pin is a constant in the core arduino library set to 0.

'0' would cause a problem because that is a Pin that is used by HardwareSerial.

...R

Yes but the sample code shows that and also I don’t think it matters since the motor controller shouldn’t need to send anything to arduino so we only need tx.The orininal code with hardware only used pin 1 and it worked. The issue could be if softwareserial needs rx connected.

rbtgeek:
I don't think it matters since the motor controller shouldn't need to send anything to arduino

In that case why use SoftwareSerial at all - just use HardwareSerial ?

...R

Like I said iny initial post I want to be able to use the hardware port with the serial monitor for future work.

rbtgeek:
Like I said iny initial post I want to be able to use the hardware port with the serial monitor for future work.

Which means SoftwareSerial cannot use pin 0

This is getting very circular.

...R

I just tried

SoftwareSerial swSerial(12,11);

and it still doesn’t work.

rbtgeek:
and it still doesn't work.

I said earlier that it is possible the two libraries conflict with each other.

You could examine the code in the libraries to see what Arduino resources they each use.

You could also try a different software serial library - there is AltSoftserial or you could try my yet another software serial. However if Sabertooth itself needs to use the software serial library then my code almost certainly will not work.

Perhaps the answer is to use a Mega which has 4 hardware serial ports or a Leonardo which has 1 spare hardware serial port.

What does the Sabertooth documentation say about its essential requirements ?

...R

This issue turned out to be a firmware issue with the Syren controller. Dimension Engineering sent me an updated controller which works great.

rbtgeek:
This issue turned out to be a firmware issue with the Syren controller. Dimension Engineering sent me an updated controller which works great.

That's good news.

It would be helpful for others if you could post a short demo working program.

...R

This code snippet is for a robot lawnmower and shows the SaberTooth motor controller and the Syren motor controller using the software serial library.

The address on the controllers needs to be set to 128 and 129 for this code and the software serial pin both use is 9. The controllers are set to packet serial mode. Modify as necessary.

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

SoftwareSerial swSerial(NOT_A_PIN,9);
Sabertooth DriveControl(128, swSerial);
Sabertooth CutControl(129, swSerial);


void setup()
{
	swSerial.begin(9600);
	Serial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial.
	Sabertooth::autobaud(swSerial);
	DriveControl.drive(0); // The Sabertooth won't act on mixed mode packet serial commands until
	DriveControl.turn(0);  // it has received power levels for BOTH throttle and turning, since it mixes the two together to get diff-drive power levels for both motors.
	CutControl.motor(1, 0);
	delay(3000);
}

void loop()
{
	CutRampUp();
	delay(4000);
	ForwardFromStop(40);
	delay(5000);
}


void ForwardFromStop(int drivePower)
{
  Serial.println(drivePower);
  int i;
	for (i = 0; i >= -drivePower; i--)
	{
		DriveControl.drive(i);
		delay(32);
	}
}

void CutRampUp()
{
	int power;
	for (power = 0; power >= -40; power--)
	{
		CutControl.motor(1, power);
		delay(40);
	}
}