WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

Generic/Serial Servo Controller

A generic solution for using various different serial servo controllers.
Currently this driver supports the following serial protocols:-
Check the data sheet of your servo controller to see if it supports any of these protocols and, if so, whether you need to configure it in any way to support the required protocol.
The Mini SSC protocol only sends 3 bytes to move a servo whereas the Pololu Compact protocol requires 4. If your robot has lots of servos, such as a humanoid, then you want to send the message for all of the servos as quickly as possible. So the protocol requiring the fewest bytes is normally the best choice and you should use the fastest possible baud rate.
The only 'disadvantage' of the Mini SSC protocol is that you cannot change the center and range positions of the servo. However: some controllers such as the Pololu Maestro series have an application to allow you to do this.
This driver only requires two wires between the micro controller and the servo controller. You must connect the Ground supply from your micro controller to the Ground supply on the servo controller as well as the Transmit pin from your micro controller UART to the receive pin of the servo controller. This allows you to connect multiple servo controller boards to the same UART - often referred to as 'daisy chaining'.
If your board supports daisy chaining then you normally have to configure each board to respond to a different starting number for the servos. For example: if you have 16 servos and 2 controller boards that support 8 servos each then configure one board to start at servo 0 (so it controls servos 0 to 7) and configure the other board to start at servo 8 (so it controls servos 8 to 15).
To use the controller(s) you will need to define the servos in the standard way other than using MAKE_REMOTE_SERVO rather than MAKE_SERVO because no IO pin needs to be specified :-
#include "servos.h"
SERVO left = MAKE_REMOTE_SERVO(FALSE, 1500, 500);
SERVO right = MAKE_REMOTE_SERVO(TRUE , 1500, 500);
// Create a single list of the servos
// The first entry is servo 0
SERVO* PROGMEM servos[] = {&left,&right};
// Create a driver and give it the list of servos
SERVO_DRIVER driver = MAKE_SERVO_DRIVER(servos);
In appInitHardware you will need to initialise the driver:-
// Initialise the servo controller specifying the UART
// baud rate, and protocol
servoSerialInit(&driver,UART0,19200,POLOLU_COMPACT);
The protocol parameter must be either MINI_SSC or POLOLU_COMPACT
You may then move the servos using the functions in actuators.h

Valid XHTML 1.0 Transitional