SyRen/Sabertooth Packet Serial Library for Arduino: Sabertooth Class Reference

SyRen/Sabertooth Packet Serial Library for Arduino

SyRen/Sabertooth Packet Serial Library for Arduino
Control your SyRen or Sabertooth with reliable Packet Serial.

Controls a Sabertooth or SyRen motor driver running in Packet Serial mode. More...

Public Member Functions

 Sabertooth (byte address)
 
 Sabertooth (byte address, SabertoothStream &port)
 
byte address () const
 
SabertoothStream & port () const
 
void autobaud (boolean dontWait=false) const
 
void command (byte command, byte value) const
 
void motor (int power) const
 
void motor (byte motor, int power) const
 
void drive (int power) const
 
void turn (int power) const
 
void stop () const
 
void setMinVoltage (byte value) const
 
void setMaxVoltage (byte value) const
 
void setBaudRate (long baudRate) const
 
void setDeadband (byte value) const
 
void setRamping (byte value) const
 
void setTimeout (int milliseconds) const
 

Static Public Member Functions

static void autobaud (SabertoothStream &port, boolean dontWait=false)
 

Detailed Description

Constructor & Destructor Documentation

Sabertooth::Sabertooth ( byte  address)

Initializes a new instance of the Sabertooth class. The driver address is set to the value given, and the Arduino TX serial port is used.

Parameters
addressThe driver address.
Sabertooth::Sabertooth ( byte  address,
SabertoothStream &  port 
)

Initializes a new instance of the Sabertooth class. The driver address is set to the value given, and the specified serial port is used.

Parameters
addressThe driver address.
portThe port to use.

Member Function Documentation

byte Sabertooth::address ( ) const
inline

Gets the driver address.

Returns
The driver address.
void Sabertooth::autobaud ( boolean  dontWait = false) const

Sends the autobaud character.

Parameters
dontWaitIf false, a delay is added to give the driver time to start up.
Examples:
3.Advanced/SharedLine/SharedLine.ino.
void Sabertooth::autobaud ( SabertoothStream &  port,
boolean  dontWait = false 
)
static

Sends the autobaud character.

Parameters
portThe port to use.
dontWaitIf false, a delay is added to give the driver time to start up.
void Sabertooth::command ( byte  command,
byte  value 
) const

Sends a packet serial command to the motor driver.

Parameters
commandThe number of the command.
valueThe command's value.
void Sabertooth::drive ( int  power) const

Sets the driving power.

Parameters
powerThe power, between -127 and 127.
void Sabertooth::motor ( int  power) const

Sets the power of motor 1.

Parameters
powerThe power, between -127 and 127.
Examples:
3.Advanced/SharedLine/SharedLine.ino.
void Sabertooth::motor ( byte  motor,
int  power 
) const

Sets the power of the specified motor.

Parameters
motorThe motor number, 1 or 2.
powerThe power, between -127 and 127.
SabertoothStream& Sabertooth::port ( ) const
inline

Gets the serial port.

Returns
The serial port.
void Sabertooth::setBaudRate ( long  baudRate) const

Sets the baud rate. Baud rate is stored in EEPROM, so changes persist between power cycles.

Parameters
baudRateThe baud rate. This can be 2400, 9600, 19200, 38400, or on some drivers 115200.
void Sabertooth::setDeadband ( byte  value) const

Sets the deadband. Deadband is stored in EEPROM, so changes persist between power cycles.

Parameters
valueThe deadband value. Motor powers in the range [-deadband, deadband] will be considered in the deadband, and will not prevent the driver from entering nor cause the driver to leave an idle brake state. 0 resets to the default, which is 3.
void Sabertooth::setMaxVoltage ( byte  value) const

Sets the maximum voltage. Maximum voltage is stored in EEPROM, so changes persist between power cycles.

Parameters
valueThe voltage. The units of this value are driver-specific and are specified in the Packet Serial chapter of the driver's user manual.
void Sabertooth::setMinVoltage ( byte  value) const

Sets the minimum voltage.

Parameters
valueThe voltage. The units of this value are driver-specific and are specified in the Packet Serial chapter of the driver's user manual.
void Sabertooth::setRamping ( byte  value) const

Sets the ramping. Ramping is stored in EEPROM, so changes persist between power cycles.

Parameters
valueThe ramping value. Consult the user manual for possible values.
void Sabertooth::setTimeout ( int  milliseconds) const

Sets the serial timeout.

Parameters
millisecondsThe maximum time in milliseconds between packets. If this time is exceeded, the driver will stop the motors. This value is rounded up to the nearest 100 milliseconds. This library assumes the command value is in units of 100 milliseconds. This is true for most drivers, but not all. Check the packet serial chapter of the driver's user manual to make sure.
void Sabertooth::stop ( ) const

Stops.

void Sabertooth::turn ( int  power) const

Sets the turning power.

Parameters
powerThe power, between -127 and 127.