RSeries astromech firmware
SabertoothDriver Class Reference

#include <motor/SabertoothDriver.h>

+ Inheritance diagram for SabertoothDriver:

Public Member Functions

 SabertoothDriver (byte address, Stream &port)
 
byte address () const
 
void setAddress (byte addr)
 
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 (Stream &port, boolean dontWait=false)
 

Constructor & Destructor Documentation

◆ SabertoothDriver()

SabertoothDriver::SabertoothDriver ( byte  address,
Stream &  port 
)
inline

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

◆ address()

byte SabertoothDriver::address ( ) const
inline

Gets the driver address.

Returns
The driver address.

◆ autobaud() [1/2]

void SabertoothDriver::autobaud ( boolean  dontWait = false) const
inline

Sends the autobaud character.

Parameters
dontWaitIf false, a delay is added to give the driver time to start up.

◆ autobaud() [2/2]

static void SabertoothDriver::autobaud ( Stream &  port,
boolean  dontWait = false 
)
inlinestatic

Sends the autobaud character.

Parameters
portThe port to use.
dontWaitIf false, a delay is added to give the driver time to start up.

◆ command()

void SabertoothDriver::command ( byte  command,
byte  value 
) const
inline

Sends a packet serial command to the motor driver.

Parameters
commandThe number of the command.
valueThe command's value.

◆ drive()

void SabertoothDriver::drive ( int  power) const
inline

Sets the driving power.

Parameters
powerThe power, between -127 and 127.

◆ motor() [1/2]

void SabertoothDriver::motor ( byte  motor,
int  power 
) const
inline

Sets the power of the specified motor.

Parameters
motorThe motor number, 1 or 2.
powerThe power, between -127 and 127.

◆ motor() [2/2]

void SabertoothDriver::motor ( int  power) const
inline

Sets the power of motor 1.

Parameters
powerThe power, between -127 and 127.

◆ setAddress()

void SabertoothDriver::setAddress ( byte  addr)
inline

Sets the driver address.

Returns
The driver address.

◆ setBaudRate()

void SabertoothDriver::setBaudRate ( long  baudRate) const
inline

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.

◆ setDeadband()

void SabertoothDriver::setDeadband ( byte  value) const
inline

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.

◆ setMaxVoltage()

void SabertoothDriver::setMaxVoltage ( byte  value) const
inline

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.

◆ setMinVoltage()

void SabertoothDriver::setMinVoltage ( byte  value) const
inline

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.

◆ setRamping()

void SabertoothDriver::setRamping ( byte  value) const
inline

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.

◆ setTimeout()

void SabertoothDriver::setTimeout ( int  milliseconds) const
inline

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.

◆ stop()

void SabertoothDriver::stop ( ) const
inline

Stops.

◆ turn()

void SabertoothDriver::turn ( int  power) const
inline

Sets the turning power.

Parameters
powerThe power, between -127 and 127.

The documentation for this class was generated from the following file: