Hooking up deadbolt motor to TB6612FNG Stepper Motor Controller

Discussion in 'General Electronics Chat' started by StealthRT, Nov 5, 2016.

  1. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
    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:

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    And the TB6612FNG is this:
    [​IMG]

    Back of the board
    [​IMG]

    Each pin and its function is covered in the table below.
    Code (Text):
    1.  
    2.      Pin        Label                      Function    Power/Input/Output Notes
    3.      VM         Motor Voltage              Power       This is where you provide power for the motors (2.2V to 13.5V)
    4.      VCC        Logic Voltage              Power       This is the voltage to power the chip and talk to the microcontroller (2.7V to 5.5V)
    5.      GND        Ground                     Power       Common Ground for both motor voltage and logic voltage (all GND pins are connected)
    6.      STBY       Standby                    Input       Allows the H-bridges to work when high (has a pulldown resistor so it must actively pulled high)
    7.      AIN1/BIN1  Input 1 for channels A/B   Input       One of the two inputs that determines the direction.
    8.      AIN2/BIN2  Input 2 for channels A/B   Input       One of the two inputs that determines the direction.
    9.      PWMA/PWMB  PWM input for channels A/B Input       PWM input that controls the speed
    10.      A01/B01    Output 1 for channels A/B  Output      One of the two outputs to connect the motor
    11.      A02/B02    Output 2 for channels A/B  Output      One of the two outputs to connect the motor
    12.  
    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 (Text):
    1.  
    2.     In1  In2 PWM Out1 Out2 Mode
    3.     H    H   H/L L    L    Short brake
    4.     L    H   H   L    H    CCW
    5.     L    H   L   L    L    Short brake
    6.     H    L   H   H    L    CW
    7.     H    L   L   L    L    Short brake
    8.     L    L   H   OFF  OFF  Stop
    9.  
    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!
     
  2. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
  3. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    7,572
    1,644
    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.
     
  4. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
    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.
     
  5. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    7,572
    1,644
    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: Nov 7, 2016
  6. StealthRT

    Thread Starter Senior Member

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

    Code (Text):
    1.  
    2. //motor A connected between A01 and A02
    3.     //motor B connected between B01 and B02
    4.     int STBY = 6; //standby
    5.     //Motor A
    6.     int PWMA = 3; //Speed control
    7.     int AIN1 = 4; //Direction
    8.     int AIN2 = 5; //Direction
    9.     //Motor B
    10.     int PWMB = 3; //Speed control
    11.     int BIN1 = 4; //Direction
    12.     int BIN2 = 5; //Direction
    13.     void setup(){
    14.       pinMode(STBY, OUTPUT);
    15.       pinMode(PWMA, OUTPUT);
    16.       pinMode(AIN1, OUTPUT);
    17.       pinMode(AIN2, OUTPUT);
    18.       pinMode(PWMB, OUTPUT);
    19.       pinMode(BIN1, OUTPUT);
    20.       pinMode(BIN2, OUTPUT);
    21.     }
    22.     void loop(){
    23.       move(1, 50, 1); //motor 1, full speed, left
    24.       move(2, 50, 1); //motor 2, full speed, left
    25.       delay(1000); //go for 1 second
    26.       stop(); //stop
    27.       delay(250); //hold for 250ms until move again
    28.       move(1, 50, 0); //motor 1, half speed, right
    29.       move(2, 50, 0); //motor 2, half speed, right
    30.       delay(1000);
    31.       stop();
    32.       delay(250);
    33.     }
    34.     void move(int motor, int speed, int direction){
    35.     //Move specific motor at speed and direction
    36.     //motor: 0 for B 1 for A
    37.     //speed: 0 is off, and 255 is full speed
    38.     //direction: 0 clockwise, 1 counter-clockwise
    39.       digitalWrite(STBY, HIGH); //disable standby
    40.       boolean inPin1 = LOW;
    41.       boolean inPin2 = HIGH;
    42.       if(direction == 1){
    43.         inPin1 = HIGH;
    44.         inPin2 = LOW;
    45.       }
    46.       if(motor == 1){
    47.         digitalWrite(AIN1, inPin1);
    48.         digitalWrite(AIN2, inPin2);
    49.         analogWrite(PWMA, speed);
    50.       }else{
    51.         digitalWrite(BIN1, inPin1);
    52.         digitalWrite(BIN2, inPin2);
    53.         analogWrite(PWMB, speed);
    54.       }
    55.     }
    56.     void stop(){
    57.     //enable standby
    58.       digitalWrite(STBY, LOW);
    59.     }
    60.  
    [​IMG]
    [​IMG]
    [​IMG]
     
  7. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
    Should the motor turn when i apply 5vdc to the red wire and gnd for the black wire? It does nothing when doing that.
     
  8. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
    This is how I did my layout:
    [​IMG]
     
  9. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    7,572
    1,644
    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.
     
  10. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
    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?
     
  11. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
    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 (Text):
    1.  
    2.  
    3.  
    4. floatvoltage=limitSwitchValue*(3.3/1023.0); //Using 3.3v for max limit switch voltage
    5.  
    What would be the best resistor to use to make sure it pulls all the way down to 0vdc?
     
  12. StealthRT

    Thread Starter Senior Member

    Mar 20, 2009
    240
    0
    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:

    [​IMG]
     
  13. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    3,496
    1,254
    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.
     
    Robert Murphy likes this.
  14. rav527

    New Member

    Saturday
    1
    0
    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: Jan 13, 2018 at 2:59 AM
Loading...