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


Adds support for various motor controllers from Pololu.
Namely the following:-
These controllers require a UART port where the Gnd and Transmit pins are connected to each board. Each motor has a unique number which can be set by sending it a 'one-off' sequence of characters - see the datasheets. Avoid motor numbers 0 and 1 if you have more than one board since all boards will re-act to these numbers. The UART sends a 4 byte sequence to set the speed of a motor as follows:- 0x80, 0x00, b0mmmmmmd, b0sssssss where 'mmmmmm' is the motor number, 'd' is the direction 1=fwd 0=rev and 'sssssss' is the speed.
In order to use the boards you must first create each motor by using 'MAKE_POLOLU_DS_MOTOR' and then combine them all into a driver using 'MAKE_POLOLU_DS_DRIVER'.
The driver is then passed to 'pololuDualSerialInit' when your application is initialising (in appInitHardware). Your main program can then set the speed of each motor using act_setSpeed in the same way as for any other servo or motor.
Here is a small example for the Axon that makes the motors spin forward and backward at different speeds:-
#include "sys/axon.h" // We are using the Axon
// Include files
#include "uart.h"
#include "Motors/Pololu/DualSerial.h"
// Create two motors
// Create a driver that includes them both and uses UART0 at 19200 baud.
// The list of motors starts at motor number '2'
POLOLU_DS_MOTOR_LIST PROGMEM motors[] = {&motor1,&motor2};
POLOLU_DS_DRIVER driver = MAKE_POLOLU_DS_DRIVER(motors, UART0, 19200, 2);
// Initialise the hardware driver in my start up code
void appInitHardware(void){
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    return 0;
// Move the motors back and forth
int dir=1;
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
    // Get the current speed of motor 2
    DRIVE_SPEED speed = act_getSpeed(&motor2);
    // Increase or decrease it
    speed += dir;
    // Change direction if we've hit the end stop
    if(speed == DRIVE_SPEED_MAX){
        dir = -1;
    }else if(speed == DRIVE_SPEED_MIN){
        dir = 1;
    // Set the speed of both motors
    return 40000; // only call me every 40ms

Valid XHTML 1.0 Transitional