Connecting Pololu Dual Motor Controller to FEZ Domino

Connecting the Pololu to an MCU is not at all obvious at first (at least for me), and the directions did not help in that regard (unless you already did it once).  So here is a step-by-step recipe.

 

Recipe #1

1) Connect motors to M1 and M2 as shown. The +/- does not matter.  Your default direction rotation will dictate that. But you can change that in software.

2) Connect PWM10 and PWM9 to M2-IN1 and M2-IN2 respectively. Unless your using a Domino, your pins will different, but pick two PWM pins.  Hardware PWM pins if possible.

3) Connect PWM8 and PWM7 to M1-IN1 and M1-IN2 respectively.

4) Connect VDD on controller to 3.3v output on MCU. If you have another regulated supply rail, you can use that.  VDD is used the power the jumpers.   If you had a need, you could instead drive the same pins HIGH/LOW from the MCU.  However, using jumpers and 1 VDD saves MCU pins and needless wire connections.

5) Connect 12V supply and GND to VIN on MCU.

6) Connect Jumpers to controller to tie down required defaults.  Jumper (EN)able pin. This will enable controller. Jumper both sets of D1/D2 pins to disable all four.

7) It is recommended to use separate power sources. This helps isolate the MCU power rail from motor power rail.  Switching directions, braking, stalling and starting a DC motor causes high power draw (which can reset your MCU) and motor noise.  You can use the same supply for all and regulate 5V for the Fez/MCU supply if you need to leverage the same battery.  However, I have seen my MCU restart when going from forward to reverse in quick succession because the added motor amp draw with no motor load. It is not something that may happen, it will happen.  And this happened using a 12v 1.5amp wall wart.  So I am guessing using a battery would only make it happen more.  Two ways to head some of this off is in software.  Add at least a short delay between direction changes.  You may have to experiment with the delay time.  Also, use PWM and a timer to “Ramp” your speed up and down.  That code could be worthy of a separate post. 

8) Also add caps to your motors to help reduce noise. I would consider this step *required.

With this configuration, we can control each motor with only 2 PWM pins.  Signal 1 line and it goes one direction, signal other line and it goes the other direction.  Do not signal both at same time.  You can just set line High or Low to achieve full speed or stop.  PWM is used to control speed in respective direction.

Software

static PWM pwm9;
static PWM pwm10;
public static void Main()
{      
    // Pins for single motor.
    pwm9 = new PWM((PWM.Pin)FEZ_Pin.PWM.Di9);
    pwm10 = new PWM((PWM.Pin)FEZ_Pin.PWM.Di10);

    Debug.Print("Forward");
    pwm9.Set(5000, 50); // 50% speed.
    Thread.Sleep(4000);
    pwm9.Set(false);

    // Pause to prevent sudden power draw to reverse.
    Thread.Sleep(500);

    // Reverse.
    Debug.Print("Reverse");
    pwm10.Set(5000, 50); // 50% speed.
    Thread.Sleep(4000);
    pwm10.Set(false);

    Debug.Print("Dispose.");
    pwm9.Dispose();
    pwm10.Dispose();
}
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.