Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: TB6612FNG motor driver not working (Teensy3.6)

  1. #1

    TB6612FNG motor driver not working (Teensy3.6)

    Hi everyone,

    I have a motor driver (Pololu TB6612FNG) on my robot and it's actually not working. But when I connect PWM_A and AIN_2 the motor runs.
    On this page (, they say that you need a transistor. Is this also when you have a motor driver?

    This is my code:
    void setup() {
      // put your setup code here, to run once:
      pinMode(2, OUTPUT); // pin 2 is AIN_2
      pinMode(3, OUTPUT); // pin 3 is AIN_1
      pinMode(4, OUTPUT); // pin 4 is STBY
      pinMode(5, OUTPUT); // pin 5 is BIN_1
      pinMode(6, OUTPUT); // pin 6 is BIN_2
    void loop() {
      // put your main code here, to run repeatedly:
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      analogWrite(30, 255); // pin 30 is PWM_A
      analogWrite(29, 255); // pin 29 is PWM_B
    I can post a photo of the wiring if you want, but it's in my robot and it will not be clear at all. I checked it many times, so I know it's correct.

    Thanks in advance.

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    Normally, you should test everything before assembling the robot...

    I have no idea about that specific motor driver, but your code looks very strange! In the loop, there is absolutely nothing happening, the same commands are issued repeatedly without ever changing the state of whatever pin... And the standby pin is always driven high, so I think that the motor can't start with these commands...

  3. #3
    On this page (, they say that you need a transistor. Is this also when you have a motor driver?
    They are talking about building your own motor driver, which is what you would do with one or more transistors. You have a motor driver, you do need any more transistors. There are already 8 transistors (MOSFETS actually) inside the B6612FNG.

    Your code matches what the truth table on page 4 of the B6612FNG datasheet says, so the motors should be moving. STBY has to be high for the motors to move, and A01/A02 or B01/B02 have to be come combination of high and low, not both high.

    So, your code looks OK-- except what Theremingenieur says about it code being weird is right. Those lines in the main loop are going to get executed millions of times a second! Maybe you're in the testing phase, but at bare minimum you should put a delay (100); in there at the end of the loop to slow things down.

    Also, yes, post a pic. it's way easier for an uninvolved person to see errors than for someone who has been slaving over a project for months. I'm betting it is a hardare problem.

  4. #4
    Still have the same with a delay.

    here is my wiring, its the best I can make of it.
    Click image for larger version. 

Name:	robot motor.jpeg 
Views:	60 
Size:	110.2 KB 
ID:	11963

  5. #5
    Ah, it's a bit like vero board... It's pretty difficult to see what is going on in the pic, as for some reason you have run all the wiring on the bottom side, and the components are on the other side. Not sure what the black strips are around the motor driver-- sockets or header strips? they should be on the component side.

    I would get a magnifying glass and look for shorts. And then I would double check the wiring, first with a continuity tester and also against the schematic.

    Cleaning the board with a tiny bit of rubbing alcohol and a toothbrush would not hurt either, as this will remove solder flux and allow you to see the connections more clearly.
    Last edited by Daniel-J; 11-02-2017 at 09:29 PM.

  6. #6
    All the components are on the other side of the board, which is the bottom of my robot, apart of the motor driver, because if I want to add a heat sink it will touch the ground. So what you see are male headers.

    I checked all my wiring with a multimeter, and there are no shortcuts.

  7. #7
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    I really don't want to do a lecture about systematic hardware and software design and debugging...

    But first, one would need a complete schematic of your circuit, perhaps a link towards the motor driver's technical specs, and the complete flow diagram of your control software, so that in a first step, one could check if there are no design errors before you blame the motor driver.

    Second, you did hopefully not assemble everything without having thoroughly checked every circuit element or subsystem apart? This would have helped to solve the current problem before everything is squeezed together...

    But obviously, the baby has already fallen in the pit. So, what I'd do in such a case is ordering a second Teensy, a second motor controller and a second motor as reference elements and try to get everything working on a breadboard and from that deduce the problem in your robot.

    I guess that there is rather some logic problem. Your sketch loop() (with delays or without) doesn't change anything, so it makes absolutely no sense to run it repeatedly, with or without delays. If the motor is controlled by static signals, everything would go into setup(). The loop is there to do repeated code in order to react on external events or changes, only.

    Did you at least check with an oscilloscope if the 5 digital and the 2 PWM signals come out correctly of the Teensy and if these arrive correctly at your motor driver?

  8. #8
    1. Nothing is soldered definitely on the pcb: I soldered female pin headers on the pcb, so I can remove all the components easily.
    2. I just tested the same motor driver with an Arduino mega, and it worked fine (same code, same wiring).
    3. I don't have an oscilloscope.

    So my conclusion is that the problem is on the teensy. But the teensy works fine, because it works with all my other components.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts