Controls a Sabertooth or SyRen motor driver running in Packet Serial mode. More...
#include <Sabertooth.h>
Public Member Functions | |
byte | address () const |
void | autobaud (boolean dontWait=false) const |
void | command (byte command, byte value) const |
void | drive (int power) const |
void | motor (int power) const |
void | motor (byte motor, int power) const |
SabertoothStream & | port () const |
Sabertooth (byte address) | |
Sabertooth (byte address, SabertoothStream &port) | |
void | setBaudRate (long baudRate) const |
void | setDeadband (byte value) const |
void | setMaxVoltage (byte value) const |
void | setMinVoltage (byte value) const |
void | setRamping (byte value) const |
void | setTimeout (int milliseconds) const |
void | stop () const |
void | turn (int power) const |
Static Public Member Functions | |
static void | autobaud (SabertoothStream &port, boolean dontWait=false) |
Private Member Functions | |
void | throttleCommand (byte command, int power) const |
Private Attributes | |
const byte | _address |
SabertoothStream & | _port |
Controls a Sabertooth or SyRen motor driver running in Packet Serial mode.
Definition at line 41 of file Sabertooth.h.
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.
address | The driver address. |
Definition at line 21 of file Sabertooth.cpp.
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.
address | The driver address. |
port | The port to use. |
Definition at line 27 of file Sabertooth.cpp.
byte Sabertooth::address | ( | ) | const [inline] |
void Sabertooth::autobaud | ( | boolean | dontWait = false | ) | const |
Sends the autobaud character.
dontWait | If false, a delay is added to give the driver time to start up. |
Definition at line 33 of file Sabertooth.cpp.
void Sabertooth::autobaud | ( | SabertoothStream & | port, |
boolean | dontWait = false |
||
) | [static] |
Sends the autobaud character.
port | The port to use. |
dontWait | If false, a delay is added to give the driver time to start up. |
Definition at line 38 of file Sabertooth.cpp.
void Sabertooth::command | ( | byte | command, |
byte | value | ||
) | const |
Sends a packet serial command to the motor driver.
command | The number of the command. |
value | The command's value. |
Definition at line 48 of file Sabertooth.cpp.
void Sabertooth::drive | ( | int | power | ) | const |
Sets the driving power.
power | The power, between -127 and 127. |
Definition at line 73 of file Sabertooth.cpp.
void Sabertooth::motor | ( | int | power | ) | const |
Sets the power of motor 1.
power | The power, between -127 and 127. |
Definition at line 62 of file Sabertooth.cpp.
void Sabertooth::motor | ( | byte | motor, |
int | power | ||
) | const |
Sets the power of the specified motor.
motor | The motor number, 1 or 2. |
power | The power, between -127 and 127. |
Definition at line 67 of file Sabertooth.cpp.
SabertoothStream& Sabertooth::port | ( | ) | const [inline] |
void Sabertooth::setBaudRate | ( | long | baudRate | ) | const |
Sets the baud rate. Baud rate is stored in EEPROM, so changes persist between power cycles.
baudRate | The baud rate. This can be 2400, 9600, 19200, 38400, or on some drivers 115200. |
Definition at line 99 of file Sabertooth.cpp.
void Sabertooth::setDeadband | ( | byte | value | ) | const |
Sets the deadband. Deadband is stored in EEPROM, so changes persist between power cycles.
value | The 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. |
Definition at line 129 of file Sabertooth.cpp.
void Sabertooth::setMaxVoltage | ( | byte | value | ) | const |
Sets the maximum voltage. Maximum voltage is stored in EEPROM, so changes persist between power cycles.
value | The voltage. The units of this value are driver-specific and are specified in the Packet Serial chapter of the driver's user manual. |
Definition at line 94 of file Sabertooth.cpp.
void Sabertooth::setMinVoltage | ( | byte | value | ) | const |
Sets the minimum voltage.
value | The voltage. The units of this value are driver-specific and are specified in the Packet Serial chapter of the driver's user manual. |
Definition at line 89 of file Sabertooth.cpp.
void Sabertooth::setRamping | ( | byte | value | ) | const |
Sets the ramping. Ramping is stored in EEPROM, so changes persist between power cycles.
value | The ramping value. Consult the user manual for possible values. |
Definition at line 134 of file Sabertooth.cpp.
void Sabertooth::setTimeout | ( | int | milliseconds | ) | const |
Sets the serial timeout.
milliseconds | The 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. |
Definition at line 139 of file Sabertooth.cpp.
void Sabertooth::stop | ( | ) | const |
Stops.
Definition at line 83 of file Sabertooth.cpp.
void Sabertooth::throttleCommand | ( | byte | command, |
int | power | ||
) | const [private] |
Definition at line 56 of file Sabertooth.cpp.
void Sabertooth::turn | ( | int | power | ) | const |
Sets the turning power.
power | The power, between -127 and 127. |
Definition at line 78 of file Sabertooth.cpp.
const byte Sabertooth::_address [private] |
Definition at line 175 of file Sabertooth.h.
SabertoothStream& Sabertooth::_port [private] |
Definition at line 176 of file Sabertooth.h.