Controls a Sabertooth or SyRen motor driver running in Packet Serial mode.
More...
|
static void | autobaud (SabertoothStream &port, boolean dontWait=false) |
|
Controls a Sabertooth or SyRen motor driver running in Packet Serial mode.
- Examples:
- 1.Basics/Jolty/Jolty.ino, 1.Basics/Sweep/Sweep.ino, 1.Basics/TankStyleSweep/TankStyleSweep.ino, 2.Settings/MinVoltage/MinVoltage.ino, 2.Settings/Persistent/BaudRate/BaudRate.ino, 2.Settings/Persistent/Deadband/Deadband.ino, 2.Settings/Persistent/MaxVoltage/MaxVoltage.ino, 2.Settings/Persistent/Ramping/Ramping.ino, 2.Settings/SerialTimeout/SerialTimeout.ino, 3.Advanced/SharedLine/SharedLine.ino, and 3.Advanced/SoftwareSerial/SoftwareSerial.ino.
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
-
address | The 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
-
address | The driver address. |
port | The port to use. |
byte Sabertooth::address |
( |
| ) |
const |
|
inline |
Gets the driver address.
- Returns
- The driver address.
void Sabertooth::autobaud |
( |
boolean |
dontWait = false | ) |
const |
void Sabertooth::autobaud |
( |
SabertoothStream & |
port, |
|
|
boolean |
dontWait = false |
|
) |
| |
|
static |
Sends the autobaud character.
- Parameters
-
port | The port to use. |
dontWait | If 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
-
command | The number of the command. |
value | The command's value. |
void Sabertooth::drive |
( |
int |
power | ) |
const |
Sets the driving power.
- Parameters
-
power | The power, between -127 and 127. |
void Sabertooth::motor |
( |
int |
power | ) |
const |
void Sabertooth::motor |
( |
byte |
motor, |
|
|
int |
power |
|
) |
| const |
Sets the power of the specified motor.
- Parameters
-
motor | The motor number, 1 or 2. |
power | The 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
-
baudRate | The 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
-
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. |
void Sabertooth::setMaxVoltage |
( |
byte |
value | ) |
const |
Sets the maximum voltage. Maximum voltage is stored in EEPROM, so changes persist between power cycles.
- Parameters
-
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. |
void Sabertooth::setMinVoltage |
( |
byte |
value | ) |
const |
Sets the minimum voltage.
- Parameters
-
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. |
void Sabertooth::setRamping |
( |
byte |
value | ) |
const |
Sets the ramping. Ramping is stored in EEPROM, so changes persist between power cycles.
- Parameters
-
value | The ramping value. Consult the user manual for possible values. |
void Sabertooth::setTimeout |
( |
int |
milliseconds | ) |
const |
Sets the serial timeout.
- Parameters
-
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. |
void Sabertooth::stop |
( |
| ) |
const |
void Sabertooth::turn |
( |
int |
power | ) |
const |
Sets the turning power.
- Parameters
-
power | The power, between -127 and 127. |