Difference between revisions of "TB6612 Motor Driver"

From Interaction Station Wiki
Jump to navigation Jump to search
(Created page with "==With a TB6612 Motor Driver== 500px|frameless|none [https://learn.adafruit.com/adafruit-tb6612-h-bridge-dc-stepper-motor-driver-breakout/overview Here is...")
 
Line 1: Line 1:
==With a TB6612 Motor Driver==
+
 
 
[[File:TB6612.jpg|500px|frameless|none]]
 
[[File:TB6612.jpg|500px|frameless|none]]
 
[https://learn.adafruit.com/adafruit-tb6612-h-bridge-dc-stepper-motor-driver-breakout/overview Here is an overview of this driver :)]
 
[https://learn.adafruit.com/adafruit-tb6612-h-bridge-dc-stepper-motor-driver-breakout/overview Here is an overview of this driver :)]
 +
 +
==Stepper Motors==
 
===Components===
 
===Components===
 
*Arduino board (we are using the Uno in this example)<br>
 
*Arduino board (we are using the Uno in this example)<br>
Line 71: Line 73:
  
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
==DC Motors==

Revision as of 14:25, 10 October 2024

TB6612.jpg

Here is an overview of this driver :)

Stepper Motors

Components

  • Arduino board (we are using the Uno in this example)
  • TB6612 Motor Driver
  • Breadboard
  • Jumper Wires
  • External Power Supply

The amount of power depends on the specifcs of your motor. At the station we have switching power supplies for this purpose.

Wiring

TB6612wiring.jpg
  • Place your motor driver on the breadboard
  • Connect the Pins of the Motor Driver to the ones on the Arduino:
-->VM to Vin Pin 
-->Vcc to 5V 
-->GND to ground
-->AIN2 to Digital 4
-->AIN1 to Digital 5
-->BIN1 to Digital 6
-->BIN2 to Digital 7
-->PWMA and PWMB to 5V

In this case we are powering the motor with the Vin Pin of the Arduino. The pin is connected to the DC connector. You can supply the eternal 12 volt power here form your power supply. This will be used to power the Arduino as well. Alternatively, you can connect your external power supply to the green screw terminals on the Motor Driver. They have a + and - connection that can go directly to your power supply.

PowerMotorDriver.jpg
  • Connect the Motor to the Motor Driver

Your stepper motor, accordingly to the type, will most likely have 4 wires. Some of them can also have 5 or 6. On the motor driver you see that you have 2 pin conenctions for Motor A and two for Motor B. To figure out which one of the wires of the motor goes where you need to understand which one of the pair of wires is coil A and coil B of the motor.
If you don't know you can check this with a multimeter. Follow this video to see how. If you are working with a stepper motor with more than 4 wires you will see that it will have still two pair of wires that are the two coils. The extra wire(s) can be ignored.
Here's a scheme of common wire connections id you don't have a multimeter to check the coils.

Motor wires scheme-02 copy.jpg

You have now determined the two pairs of wire to connect to the motor driver. Each pair will be connected to the Motor A and Motor B pins on the driver.

-->Motor A to one of the coils 
-->Motor B to the other coil

Coding

  • Open the Arduino IDE on your computer
  • Make sure your board is connected and the right port is selected
  • Upload the code

For this basic test we are using the in build Arduino Stepper library.

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 200

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 4, 5, 6, 7);


void setup()
{
  Serial.begin(9600);
  Serial.println("Stepper test!");
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(60);
}

void loop()
{
  Serial.println("Forward");
  stepper.step(STEPS);
  Serial.println("Backward");
  stepper.step(-STEPS);
}

DC Motors