Sabertooth Motor Controller
Adds support for various motor controllers from Dimension Engineering.
Namely the Sabertooth 2 x 5 Amp controller, the SyRen10 and SyRen25 boards.
These controllers require a UART port where the Gnd and Transmit pins are connected to each board on the 0V and S1 inputs respectively.
These boards can be driven in a number of different modes but we will use only two of these modes namely:
- Packetized serial (mode 4)
- Simplified serial mode (mode 3)
Each board can drive up to two motors, called motors 1 and 2.
Simplified Serial Mode
Simplified serial mode can only be used to control one board (so a maximum of 2 motors) - but has the advantage that it only has to send one byte for each motor and the baud rate can be set via the DIP switches to select either 2400, 9600, 19200 or 38400 baud.
Packetized Serial Mode
Packetized serial mode has the advantage that multiple boards (up to 8 i.e. 16 motors) can be placed on the same serial line - each board has a unique address set via the DIP switches. This combination of address and motor number is therefore unique for each motor. The advantage of this mode is the ability to control multiple boards but the disadvantage is that we need to send 4 bytes for each motor compare with one for simplified serial mode. However: the greatest disadvantage is that packetized mode uses an 'auto baud rate' detection algorithm with valid baud rates of 2400, 9600, 19200 and 38400 baud. This detection is based on the first byte that it is automatically sent by this library. Although this 'sounds' easy the practical issue is that your main controller board 'may' suffer from contact bounce on its power switch - the end result being that one or more spurious characters may be sent over the UART and confuse the Sabertooth board as to what the actual baud rate should be. If you are using separate power supplies for the Sabertooth and your micro-controller board then this also means that you need to 'turn on' the Sabertooth card before, or at the same time, as your micro-controller. When using this mode the library will wait for 2 seconds before sending the automatic baud detection character.
When adding the motors in Project Designer take careful note of the DIP switch settings and set up your board accordingly.
- connect - Connect the actuator to the drive system.
- disconnect - Disconnect the actuator from the drive system. Once an actuator is disconnected it will stop responding to other commands until it is connected once again.
- getSpeed - Returns the value you specified in your previous call to setSpeed.
- isConnected - Test if an actuator is connected
- isInverted - Test if an actuator is inverted
- setConnected - Connect or disconnect the actuator from the drive system.
- setSpeed - Set the required speed to a value between DRIVE_SPEED_MIN and DRIVE_SPEED_MAX.