Connecting the Pololu TB6612FNG Dual motor driver to FEZ

Not a lot to say here.  It seems like a great little controller for $8.50 bucks.  Now wondering why I also bought a $45 controller.  This thing will handle up to 3A per channel (1amp continuous) and 13.5V.  Stout little bugger. Sometimes its just good to see a picture and some code and not a lot of talk.  So here it is.

private static void TB6612FNGController()
{
    PWM speedA = new PWM((PWM.Pin)FEZ_Pin.PWM.Di8); // MotorA Speed control.
    OutputPort in1 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.An0, false);
    OutputPort in2 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.An1, false); // L/H forward

    for (int i = 0; i < 2; i++)
    {
        // Forward
        Debug.Print("Forward");
        in1.Write(false);
        in2.Write(true);
        speedA.Set(10000, 70);
        Thread.Sleep(2000); // Let run for 2 sec.
        speedA.Set(false);
        Thread.Sleep(100); // Min 100 required to prevent amp draw reboot.

        // Reverse
        Debug.Print("Reverse");
        in1.Write(true);
        in2.Write(false);
        speedA.Set(10000, 70);
        Thread.Sleep(2000);
        speedA.Set(false);
        Thread.Sleep(100);
    }

    // Done
    speedA.Dispose();
    in1.Dispose();
    in2.Dispose();
    Debug.Print("Done");
}
Advertisements
This entry was posted in .Net Micro Framework, C#, FEZ, Motors, Robotics and tagged , , , , . Bookmark the permalink.