Pololu Micro Dual Serial Motor Controller

TheCowGod's picture
Price: 
$22.95 USD

This tiny module can control two motors, 1 A peak each, and you can daisy-chain multiple units to control up to 62 motors with a single serial line. The new version provides up to 2 A to a single motor, or 1 A each to two motors. The motor supply can be as low as 2 V, making the unit a perfect match for small DC motors. Using one serial output from your microcontroller, you can independently set each motor to go forward or backward at any of 127 speeds, coast, and brake.

The controller takes up almost no space on a breadboard or PCB:

07.jpg

 


 

Sample control code for Arduino:

 

#include <softwareserial.h>

#define LEFT_MOTOR 2
#define RIGHT_MOTOR 3

#define FORWARD 1
#define REVERSE 0


byte motor_controller_pin = 3;
byte motor_controller_reset_pin = 4;

// for rx on all unidirectional software serial objects
byte unused_pin = 10;


unsigned char mc_command[4];

SoftwareSerial motor_controller = SoftwareSerial(unused_pin, motor_controller_pin);


//==========================================================================================

void setup()
{
pinMode(motor_controller_pin, OUTPUT);
pinMode(motor_controller_reset_pin, OUTPUT);
pinMode(unused_pin, INPUT);

motor_controller.begin(9600);

mc_init();
}

//==========================================================================================

void loop()
{
// accelerate forward
for(int i = 0; i <= 130; i += 10)
{
mc_send_command(LEFT_MOTOR, FORWARD, i);
mc_send_command(RIGHT_MOTOR, FORWARD, i);

delay(250);
}

delay(3000);

// decelerate
for(int i = 130; i >= 0; i -= 10)
{
mc_send_command(LEFT_MOTOR, FORWARD, i);
mc_send_command(RIGHT_MOTOR, FORWARD, i);

delay(250);
}

delay(3000);

// accelerate backward
for(int i = 0; i <= 130; i += 10)
{
mc_send_command(LEFT_MOTOR, REVERSE, i);
mc_send_command(RIGHT_MOTOR, REVERSE, i);

delay(250);
}

delay(3000);

// decelerate
for(int i = 130; i >= 0; i -= 10)
{
mc_send_command(LEFT_MOTOR, REVERSE, i);
mc_send_command(RIGHT_MOTOR, REVERSE, i);

delay(250);
}

delay(3000);
}


//==========================================================================================


void mc_init()
{
// start up motor controller
digitalWrite(motor_controller_reset_pin, HIGH);

// let motor controller wake up
delay(100);
}


void mc_send_command(byte motor, byte direction, byte speed)
{
direction = constrain(direction, 0, 1);
speed = constrain(speed, 0, 127);

mc_command[0] = 0x80; // start byte
mc_command[1] = 0x00; // Device type byte
mc_command[2] = (2 * motor) + (direction == FORWARD ? FORWARD : REVERSE); // Motor number and direction byte
mc_command[3] = speed; // Motor speed (0 to 127)

// send data
for(int i = 0; i < 4; i++)
{ motor_controller.print(mc_command[i], BYTE); }
}

 

Your rating: None

This looks really nice &

This looks really nice & cool. I think I will have to invest in some :-)
TheOther1's picture

I bought one of these from

I bought one of these from Polou.  I have not hooked it up yet, but they had amazingly fast shipping.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.