Hooking up deadbolt motor to TB6612FNG Stepper Motor Controller

Thread Starter

StealthRT

Joined Mar 20, 2009
303
Hey all I am in need of some help with hooking up this little motor to the TB6612FNG Stepper Motor Drive Controller that I purchased. I am wanting some feedback on how to go about hooking it up to this deadbolt motor so that I dont mess up the motor. This board will be controlled by an Arduino.

The deadbolt insides look like this:









And the TB6612FNG is this:


Back of the board


Each pin and its function is covered in the table below.
Code:
     Pin        Label                      Function    Power/Input/Output Notes
     VM         Motor Voltage              Power       This is where you provide power for the motors (2.2V to 13.5V)
     VCC        Logic Voltage              Power       This is the voltage to power the chip and talk to the microcontroller (2.7V to 5.5V)
     GND        Ground                     Power       Common Ground for both motor voltage and logic voltage (all GND pins are connected)
     STBY       Standby                    Input       Allows the H-bridges to work when high (has a pulldown resistor so it must actively pulled high)
     AIN1/BIN1  Input 1 for channels A/B   Input       One of the two inputs that determines the direction.
     AIN2/BIN2  Input 2 for channels A/B   Input       One of the two inputs that determines the direction.
     PWMA/PWMB  PWM input for channels A/B Input       PWM input that controls the speed
     A01/B01    Output 1 for channels A/B  Output      One of the two outputs to connect the motor
     A02/B02    Output 2 for channels A/B  Output      One of the two outputs to connect the motor
Now, for a quick overview of how to control each of the channels. If you are using an Arduino, don’t worry about this too much as the library takes care of all of this for you. If you are using a different control platform, pay attention. When the outputs are set to High/Low your motor will run. When they are set to Low/High the motor will run in the opposite direction. In both cases, the speed is controlled by the PWM input.
Code:
    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
Don’t forget STBY must be high for the motors to drive.

And the data sheet on the TB6612FNG is http://www.sparkfun.com/datasheets/Robotics/TB6612FNG.pdf.


I found a great tutorial http://bildr.org/2012/04/tb6612fng-arduino/ but want to make sure I hook up the wires correctly for this deadbolt motor and thats why I ask someone whos more knowledgeable about these types of things to help me out.


Thanks!
 

Alec_t

Joined Sep 17, 2013
14,280
If you are not going to use the old control board then you will need to:
1) disconnect the motor and the limit switches from the old board,
2) connect the two motor terminals to AO1 and AO2 respectively (assuming you use channel A of the new breakout board),
3) connect the other breakout board terminals to approprite I/O terminals of the Arduino as required by the Arduino software,
4) connect the two limit switches to the Arduino inputs as required by the Arduino software.
5) ensure that you have the correct supply voltages for the motor and the breakout board chip, consistent with the Arduino's input/output voltage ratings.
 

Thread Starter

StealthRT

Joined Mar 20, 2009
303
I'm going to still use the board for the buttons and such. Just want to manually open and close the lock when I want too without the key code.
 

Alec_t

Joined Sep 17, 2013
14,280
In that case you really need the schematic of the existing controller, to work out how to interface with it, and the new breakout board seems superfluous. Alternatively a DPDT switch could perhaps be used to select whether the motor connects to the controller or to the breakout board; but you would then be unable to use the existing buttons for the manual operation and would need alternative limit switches (unless you were prepared to use more DPDT switches to re-route the existing limit switch connections).
 
Last edited:

Thread Starter

StealthRT

Joined Mar 20, 2009
303
Well i hooked it up to the TB6612FNG and the Arduino and i got....nothing.

Code:
//motor A connected between A01 and A02
    //motor B connected between B01 and B02
    int STBY = 6; //standby
    //Motor A
    int PWMA = 3; //Speed control
    int AIN1 = 4; //Direction
    int AIN2 = 5; //Direction
    //Motor B
    int PWMB = 3; //Speed control
    int BIN1 = 4; //Direction
    int BIN2 = 5; //Direction
    void setup(){
      pinMode(STBY, OUTPUT);
      pinMode(PWMA, OUTPUT);
      pinMode(AIN1, OUTPUT);
      pinMode(AIN2, OUTPUT);
      pinMode(PWMB, OUTPUT);
      pinMode(BIN1, OUTPUT);
      pinMode(BIN2, OUTPUT);
    }
    void loop(){
      move(1, 50, 1); //motor 1, full speed, left
      move(2, 50, 1); //motor 2, full speed, left
      delay(1000); //go for 1 second
      stop(); //stop
      delay(250); //hold for 250ms until move again
      move(1, 50, 0); //motor 1, half speed, right
      move(2, 50, 0); //motor 2, half speed, right
      delay(1000);
      stop();
      delay(250);
    }
    void move(int motor, int speed, int direction){
    //Move specific motor at speed and direction
    //motor: 0 for B 1 for A
    //speed: 0 is off, and 255 is full speed
    //direction: 0 clockwise, 1 counter-clockwise
      digitalWrite(STBY, HIGH); //disable standby
      boolean inPin1 = LOW;
      boolean inPin2 = HIGH;
      if(direction == 1){
        inPin1 = HIGH;
        inPin2 = LOW;
      }
      if(motor == 1){
        digitalWrite(AIN1, inPin1);
        digitalWrite(AIN2, inPin2);
        analogWrite(PWMA, speed);
      }else{
        digitalWrite(BIN1, inPin1);
        digitalWrite(BIN2, inPin2);
        analogWrite(PWMB, speed);
      }
    }
    void stop(){
    //enable standby 
      digitalWrite(STBY, LOW);
    }


 

Alec_t

Joined Sep 17, 2013
14,280
The wiring looks right, so the problem presumably is software-related.
Should the unused inputs of the breakout board be terminated? Floating inputs are usually a no-no.
 

Thread Starter

StealthRT

Joined Mar 20, 2009
303
Ah it seems to be working now. YAY! :)

Just need to tweak the code a little and hook up the limit switches to the analog inputs and see if i get readings from them. That would just consist of grounding one side and running the other to the arduino analog pin, correct?
 

Thread Starter

StealthRT

Joined Mar 20, 2009
303
Alright so I finally got around to testing out the limit switch. Seems the Left pin is Gnd and the middle pen is voltage and the right pin is na.

Measuring the limit switch its 0vdc when not engaged and 3.3v when it is engaged.

So knowing that, wouldn't it be best to use an Analog input for measuring the voltage?
Code:
floatvoltage=limitSwitchValue*(3.3/1023.0); //Using 3.3v for max limit switch voltage
What would be the best resistor to use to make sure it pulls all the way down to 0vdc?
 

Thread Starter

StealthRT

Joined Mar 20, 2009
303
is this the correct way of doing it? of course it would be an esp8266 and not an Arduino board and using 3.3v instead of 5v:

 

djsfantasi

Joined Apr 11, 2010
9,156
Generally looks good. I am assuming the PWM pin in your diagram is intended to represent an amplifier input pin. You know, you don't need to use an analog pin? For this application a digital input could work as well.
 

rav527

Joined Jan 13, 2018
1
Did you get anywhere with this kwikset powerbolt 2? I have the same lock and i want to keep manual control of entering code via keypad but at the same time hook up wemos d1 mini to control the lock via app. please share any headway in the project.

MOD NOTE: Moved new content outside of quote (which is now empty but refers to original post).
 
Last edited by a moderator:
Top