Categories

Arduino motor control with TB6612 module

 

Arduino control DC motor

supports dual channel H bridge TB6612

1. The engines TB6612 driver module

 

Dual-channel driver can control two DC motors. Continuous current to a single engine may not exceed 1A, 3A temporary. The maximum supply voltage of 12V. These options allow for maintenance, for example, micro-motors, Pololu or HL149.


The module includes the necessary condensers, filter and power protection from reverse power connection.

 

To facilitate the installation of the module was equipped with standard output goldpin (pitch 2.54 mm). The system can be installed in prototype pin Board or connect to the Arduino with wires.

 

 

2. The module is connected

 

Food

VCC - power logic

UMOT - powered engines

GND - weight - keep in mind that all ground should be connected to each other

STBY - low state causes a transition to the sleep state, that is, low power consumption (stand-by) to the bridge was attached, you must specify the condition of high

 

Outputs - conclusions, which should connect the motors

AO1, AO2 - output channel A - output that must be connected the first motor

BO1, BO2 - output channel B - output to which you must connect the second motor

Engine controls

PWMA - PWM signal channel A is used to adjust the speed of rotation of the motor connected to channel A

AIN1 AIN2 output used for determining the direction of rotation of the motor connected to the outputs of the channel And

PWMB - PWM signal B - channel is used to adjust the speed of rotation of the motor connected to channel B

BIN1, BIN2 - output, used to determine the direction of rotation of the motor connected to the outputs of channel B

 

 

Table - service bridge TB6612 (x - means that the corresponding channel A or B)

x IN1

x IN2

PWM x

STBY

The output of the channel x

lowhighPWMhighThe motor rotates at the maximum given speed using PWM (different from 0) in a clockwise direction.
highlowPWMhighThe motor rotates at the maximum given speed using PWM (not equal to 0) in a counterclockwise direction.
anyanylowhighSudden braking (so-called hard-stop).
lowlowanyhighGentle braking.
highhighanyhighGentle braking.
anyanyanylowThe bridge in standby - low power state.

 

 

 

 

The figure shows an example of connecting the controller module with Arduino Uno.

 

 

 

3. Approximate program

 

Programme overview the module supports TB6612. The layout should be connected in accordance with drawing:

 

 

The result of the program will be a rotating shaft of the engine. Two seconds will be a change of direction of rotation. After two the engine will stop.

 

Program:

 

pwmMotorA int=5; 
InMotorA1 int=4; 
InMotorA2 int=3; 

void setup() { 

 //PWM output channel, And 
 pinMode(pwmMotorA, OUTPUT); 

 //Digital output AIN1 
 pinMode(InMotorA1, OUTPUT); 
 //Digital output AIN2 
 pinMode(InMotorA2, OUTPUT); 

} 

// Nieskonczona cycle 
void loop() { 

 //Channel, And 

 //Setting the direction of rotation 
 digitalWrite(InMotorA1, LOW); 
 digitalWrite(InMotorA2, HIGH); 

 //Setting the speed to 50% (range PWM: 8bitów i.e. 0-255) 
 analogWrite(pwmMotorA,128); 

 //Delay 2s 
 delay(2000); 

 //Change the direction of rotation 
 digitalWrite(InMotorA1, HIGH); 
 digitalWrite(InMotorA2, LOW); 

 //Delay 2s 
 delay(2000); 

 //Stop engine - installation wspołczynnika performance PWM to 0 
 analogWrite(pwmMotorA,0); 

 //Delay 2s 
 delay(2000); 

}