0

Using TB6612 motor controller to PWM LEDs
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Using TB6612 motor controller to PWM LEDs

by gr8flux on Tue Aug 06, 2019 8:31 pm

Hello All,

I'm trying to control LEDs using a pulse width modulation that can handle ~1A. As such, I chose to use the TB6612 motor controller as it allows 1.2A per motor (iirc). Now I'm trying to figure out how to wire it up. The Stepper code used in an example for it doesn't give me a clear idea of what the inputs are doing and I don't want to fry anything.

Also, is there a way to send a PWM signal to the controller directly? Or am I going to need to write something that pulses a signal (power?) to be replicated at the motor? It looks like the stepper code for Arduino just pulses an on-off signal but, I'm not sure.

Thanks in advance!

gr8flux
 
Posts: 26
Joined: Fri Feb 17, 2017 2:14 am

Re: Using TB6612 motor controller to PWM LEDs

by adafruit_support_mike on Tue Aug 06, 2019 10:29 pm

The TB6612 is a quad half-bridge, meaning it has four outputs that can source or sink up to 1.2A.

Each output is controlled by one of the four input pins: AIN1, AIN2, BIN1, and BIN2. When you control them that way, all four are independent of each other. Using PWM to control AIN1 will only control current flowing into and out of the corresponding output pin.

Half-bridges are usually arranged in pairs, with one going high any time the other goes low. When they're connected to opposite ends of a motor coil, the motor runs one direction when AIN1 is high and AIN2 is low, and the other direction when AIN1 is low and AIN2 is high.

To make it easier to control motor speed that way, both output pins in set A can be enabled or disabled by the PWMA pin. Both outputs in set B are controlled by the PWMB pin. When one of the PWM pins is low, both outputs it controls go low and are essentially shorted to GND.

That gives you two options for controlling power to the LEDs, and two options for control:

- You can connect the positive side of the LED to the TB6612 and connect the negative end of the LED to GND.
- You can connect the positive side of the LED to VCC and connect the negative end of the LED to the TB6612.

- You can use PWM to control AIN1, AIN2, BIN1, and BIN2 individually.
- You can use PWM to control both outputs in set A with PWMA, and both outputs in set B with PWMB.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: Using TB6612 motor controller to PWM LEDs

by gr8flux on Tue Aug 06, 2019 11:08 pm

Thanks Mike! That clears up a lot!

Just to clarify, the TB6612 can manage 1.2A per each of the four outputs?

Does VM need to be 12v? I tried 5V and can't get the chip to work.

gr8flux
 
Posts: 26
Joined: Fri Feb 17, 2017 2:14 am

Re: Using TB6612 motor controller to PWM LEDs

by adafruit_support_bill on Wed Aug 07, 2019 6:21 am

Each of the 4 half-bridge outputs can handle up to 1.2A. If you will be driving all of them to the max, you should add a heat-sink to the chip.

VM between 5v and 12v should be fine. http://www.ti.com/lit/ds/symlink/ads1115.pdf

If you post some photos showing your soldering and connections, we can take a look.

adafruit_support_bill
 
Posts: 74647
Joined: Sat Feb 07, 2009 10:11 am

Re: Using TB6612 motor controller to PWM LEDs

by gr8flux on Wed Aug 07, 2019 5:08 pm

My soldering:
Image

I connected:
Vcc to Arduino 5V
Vm to Arduino 5V
GND to Arduino GND

I've tried connecting a pwm signal wire to all the inputs and subsequently tried each output, I can't get a signal. Testing the signal wire to the LED directly and it works fine - analogWrite and digitalWrite.

Not sure if there's some code in the Stepper file that tells the chip what to do that I need? I haven't opened that code up yet to examine it closely.

gr8flux
 
Posts: 26
Joined: Fri Feb 17, 2017 2:14 am

Re: Using TB6612 motor controller to PWM LEDs

by adafruit_support_bill on Wed Aug 07, 2019 5:19 pm

Soldering looks fine. But we can't see any connections.

I connected:
Vcc to Arduino 5V
Vm to Arduino 5V
GND to Arduino GND

You didn't mention the 'sleep' pin (SLP). You need to pull that HIGH to enable the outputs. It is LOW by default.
https://learn.adafruit.com/adafruit-drv ... n-pins-2-3

adafruit_support_bill
 
Posts: 74647
Joined: Sat Feb 07, 2009 10:11 am

Re: Using TB6612 motor controller to PWM LEDs

by gr8flux on Wed Aug 07, 2019 5:30 pm

adafruit_support_bill wrote:You didn't mention the 'sleep' pin (SLP). You need to pull that HIGH to enable the outputs. It is LOW by default.
https://learn.adafruit.com/adafruit-drv ... n-pins-2-3


My board is different, it doesn't have a SLP pin. All the pins it has are shown in the photo above.

gr8flux
 
Posts: 26
Joined: Fri Feb 17, 2017 2:14 am

Re: Using TB6612 motor controller to PWM LEDs

by adafruit_support_bill on Wed Aug 07, 2019 5:44 pm

Sorry, that was for the DRV8833. Here is the TB6612 pinout: https://learn.adafruit.com/adafruit-tb6 ... n-pins-2-4

You need at least two signal connections to enable an output. If you pull PWMA HIGH, you should be able to control the MotorA pins with AIN1 and AIN2. Similarly, you need to pull PWMB HIGH to control the B channels.

adafruit_support_bill
 
Posts: 74647
Joined: Sat Feb 07, 2009 10:11 am

Re: Using TB6612 motor controller to PWM LEDs

by gr8flux on Thu Aug 08, 2019 1:49 am

adafruit_support_bill wrote:Sorry, that was for the DRV8833. Here is the TB6612 pinout: https://learn.adafruit.com/adafruit-tb6 ... n-pins-2-4

You need at least two signal connections to enable an output. If you pull PWMA HIGH, you should be able to control the MotorA pins with AIN1 and AIN2. Similarly, you need to pull PWMB HIGH to control the B channels.


Good catch! That was the missing link. Pulling PWMA High solved my problem. Thanks!

gr8flux
 
Posts: 26
Joined: Fri Feb 17, 2017 2:14 am

Re: Using TB6612 motor controller to PWM LEDs

by adafruit_support_bill on Thu Aug 08, 2019 5:45 am

Good to hear that's working for you . Thanks for the follow-up.

adafruit_support_bill
 
Posts: 74647
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.