Pages

Friday, April 2, 2021

TB6612FNG AVR motor driver


The + is an H-Bridge driver IC that can drive up to 2 motors.
This IC as a maximum power supply voltage of 15V, with an output current of 1.2A average and 3.2A peak.





It's pretty simple to drive this chip. For each motor it has 3 input, 2 digital ones used to select the direction, the other is the PWM input.

Find below the control table for this IC, IN1 and IN2 are the two digital input that defines the direction and in conjuction with the PWM one, the Mode of operation of the OUT1 and OUT2 pin, that are connected to the motor.

IN1 IN2 PWM OUT1 OUT2 Mode
H H H/L L L Short brake
L H H L H CCW
L H L L L Short brake
H L H H L CW
H L L L L Short brake
L L H OFF OFF Stop

This driver is based on my DC Motor PWM driver you can find it here http://davidegironi.blogspot.com/2015/02/driving-dc-motor-using-pwm-with-avr.html

It use the PWM output pins of the microcontroller, it means that no software resources are used to generate the PWM needed to drive the motors in speed.

This driver is built to control one IC, it means 2 motors independently in speed and direction.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz but can easly be ported to other microcontroller.



All the parameters can be changed in the dcmotortb6612.h.
The drive can even run on a single motor output, we just need to change the macro DCMOTORTB6612_SINGLEMOTOR.


Changelog
  • v01: minor fix to motor stop macro
  • v01b: first version

Code

Notes
  • read risk disclaimer
  • excuse my bad english