Dec 282013
 

The IBT-2 H-bridge module from wingxin is an inexpensive, high power motor driver based on two BTS7960 chips and is readily available from various ebay vendors; see e.g. here.

IBT-2Module

The link provides more details but here are a few key parameters.

  • Input voltage : 6V-27V
  • Maximum Current : 43A
  • Input level : 3.3V-5V

I am not sure whether the heat sink is sufficient for handling 43A but even if one does not drive the unit to its limits the specifications are still impressive given the typical price point of this module (currently between $13 and $17 including free shipping from China). There is relatively little information available about how to hook up the module with an Arduino controller. This thread on the Arduino forum was useful but the solution wastes a few pins and does not demonstrate bidirectional motor control. In this post I describe a slightly more complete solution that uses an Arduino controller with connected potentiometer to drive a motor via the IBT-2 module from full reverse speed to full forward speed.

For reference here is the description of the input ports and the two supported usage modes (image taken from one of the ebay postings). In this post I leverage usage mode one.

IBT-2-Input-Ports

Here is the associated Arduino sketch:

/*
IBT-2 Motor Control Board driven by Arduino.

Speed and direction controlled by a potentiometer attached to analog input 0.
One side pin of the potentiometer (either one) to ground; the other side pin to +5V

Connection to the IBT-2 board:
IBT-2 pin 1 (RPWM) to Arduino pin 5(PWM)
IBT-2 pin 2 (LPWM) to Arduino pin 6(PWM)
IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin
IBT-2 pin 8 (GND) to Arduino GND
IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected
*/

int SENSOR_PIN = 0; // center pin of the potentiometer

int RPWM_Output = 5; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM)
int LPWM_Output = 6; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM)

void setup()
{
  pinMode(RPWM_Output, OUTPUT);
  pinMode(LPWM_Output, OUTPUT);
}

void loop()
{
  int sensorValue = analogRead(SENSOR_PIN);

  // sensor value is in the range 0 to 1023
  // the lower half of it we use for reverse rotation; the upper half for forward rotation
  if (sensorValue < 512)
  {
    // reverse rotation
    int reversePWM = -(sensorValue - 511) / 2;
    analogWrite(LPWM_Output, 0);
    analogWrite(RPWM_Output, reversePWM);
  }
  else
  {
    // forward rotation
    int forwardPWM = (sensorValue - 512) / 2;
    analogWrite(LPWM_Output, forwardPWM);
    analogWrite(RPWM_Output, 0);
  }
}

The following Fritzing diagram illustrates the wiring. B+ and B- at the top of the diagram represent the power supply for the motor. A 5k or 10k potentiometer is used to control the speed.

IBT-2-with-Arduino_bb

 

  41 Responses to “IBT-2 H-Bridge with Arduino”

  1. Hi, do you know if it is possible to control 3 motors with only one Arduino Uno board? Thanks!

  2. each h-bridge needs 2 pwm ports, and an arduino uno has 6, so yes

  3. Thank you very much, Dr. Hessmer!

  4. Is there any reason why the two sides require a dedicated PWM pin? Could you tie those together to the one PWM output from the Arduino and use R_EN and L_EN to select direction? Even better, if one is always the inversion of the other, could a NOT gate be used so that to drive a motor forward and reverse, only one PWM pin and one non-PWM pin are required? (Possibly meaning as many as 6 motors could be driven from the one Arduino)

    … Actually, writing that gives me an inkling as to why two PWM inputs are available…

    Similarly, could two of these bridges be used to drive a high current stepper motor?

  5. is it possible to ad a feedback potentiometer to the dc motor. and code in arduino so it will act like 180 degree servo.
    Kind regards
    Tom Jensen

  6. Dr. Hessmer,
    I plan to use a similar (higher power) single H bridge to control a DC brushed motor.
    The bridge has a similar connection schema, including an ENABLE and LPWM and RPWM.
    I am worried about cross-conduction (shoot-through) protection when changing direction. My guess is that the bridge does not provide it.
    In that case, would such protection not be provided by always taking the xPWM pin that was fed until now to zero and ONLY THEN feeding the other?
    In other words, in the code above, have the “forward rotation” coded thus:
    // forward rotation
    int forwardPWM = (sensorValue – 512) / 2;
    analogWrite(RPWM_Output, 0);
    analogWrite(LPWM_Output, forwardPWM);
    Many thanks for your opinions and advice,
    Ilan

  7. Hi Thanks for the post. Very useful.
    May I know IBT-2 can control the Bipolar Stepper Motor, if so, how to connect the motor.

  8. Hi,
    i what to ask why some time they connect R_EN and L_EN to a digital pin
    thanks ^^

  9. Dr. Hessmer, thanks for sharing! Very informative and useful…I always learn something new and useful every time I visit your blog. Thx!

  10. Good morning
    This is exactly what I was looking for but would like to add rpm measurement via a slotted optical sensor board based on an LM393 chip and also an LCD display showing the measured rpm. Would you be able to provide some guidance on how to wire and program this additional equipment?
    Thanks a lot
    Chris

    • LA Q TAL SI ES POSIBLE VER TUSA RPM HE IR CONTROLANDOLAS ASTA INALAMBRICAMENTE X BLUETOOTH PERO RECUERDA Q ESTE MODULO SOLO ES DE POTENCIA NESESITAS TU ENCODER Q TE DARA TUS RPM AHI ENCODER YA COMERCIALES MUY FACIL DE USAR EFECTIVAMENTE SON SENSORES OPTICOS LO Q TE PUEDO RECOMERDAR ES Q TRATES DE UTILIZAR AL IGUAL UN MOTOR CON ENCODER YA INCLUIDO Y UN LCD CON SU PUERTO I2C Y LISTO.

  11. Thanks for the great info!! I thought I would share how I controlled this with one PWM pin. I “drove” both the enables with one PWM pin (Pin 44 goes to R_EN and L_EN). I then used the LPWM and RPWM pins to set the direction. I also use some digital pins to power/ground the logic of the IBT-2’s (46,47,52, 53).

    The following code is for the Mega-2560 and can control two IBT-2’s

    int pwmpin1=44; // 8-bit pwm 0-255 timer 5 for motor 1
    int pwmpin2=45; // 8-bit pwm 0-255 for motor 2
    int mcgnd1=46; // ground for motor control 1
    int mcpwr1=47; // power for motor control 1
    int pwmdirection2r=48; // digital motor control direction 2
    int pwmdirection2l=49; // digital motor control direction 2
    int pwmdirection1r=50; // digital motor control direction 1
    int pwmdirection1l=51; // digital motor control direction 1
    int mcgnd2=52; // ground for motor control 2
    int mcpwr2=53; // power for motor control 2

    //Code snippet for two motors on 2 IBT-2’s using just two pwm pins.

    //set h-bridge to reverse or CCW
    digitalWrite(pwmdirection1r,HIGH);
    digitalWrite(pwmdirection1l,LOW);
    analogWrite(pwmpin1,128);

    delay(5000);

    //else CW
    digitalWrite(pwmdirection1r,LOW);
    digitalWrite(pwmdirection1l,HIGH);
    analogWrite(pwmpin1,128);

    delay(5000);
    //set h-bridge to reverse or CCW motor 2
    digitalWrite(pwmdirection2r,HIGH);
    digitalWrite(pwmdirection2l,LOW);
    analogWrite(pwmpin2,128);

    delay(5000);

    //else CW
    digitalWrite(pwmdirection2r,LOW);
    digitalWrite(pwmdirection2l,HIGH);
    analogWrite(pwmpin2,128);

    Jim K says:
    November 30, 2014 at 4:51 pm
    Could you share the fritzing part for the IBT-2?

    Thanks,

    Jim

  12. Hej dr.Hessmer do you now if its possible to run a segway on two ibt2 motor controller instead
    Of the sabertooth motor controller with arduino.i am a newbee to arduino. if you can run it on
    Ibt2 do you then got some exsampel code for that.
    Kind Regards
    Tom jensen

  13. hey guys im looking for a arduino code to control a dc motor using an analogue stick controller

  14. Hola.
    Estoy buscando un código de Arduino para controlar un motor de corriente continua utilizando un puente, H 43 A BTS 7960B,

  15. Hola,
    Estoy intentando programar,ARDUINO UNO,con el puente H 43A BTS 7960 B, y no consigo que funcione el motor,estoy, con el código, IBT-2, el código me lo acepta bien pero no funciona el motor,agradecería que alguien me pasara un código.
    Saludos…Juan….

  16. HELLO SIR:
    I CANNOT GET THIS PROGRAM TO VERIFY IN LINE 32.
    if (sensorValue < 512)
    I CAN GET THIS PROGRAM TO VERIFY IN LINE 32 WHEN I CHANGE IT TO THIS.
    if (sensorValue = 512)
    WHAT IS THE CORRECT LINE 32 STATEMENT.
    I WILL BE LOOKING FOR YOUR REPLY.
    THANK YOU
    LINTON BROWN

    • HELLO AGAIN:
      PLEASE LOOK AT LINE 32 ABOVE .WHEN I EMAILED YOU AND I HIT THE
      SUBMIT COMMENT AND MY EMAIL QUESTION CHANGED FROM &lt to <.PLEASE HELP ME
      ON THIS. I HOPE YOU CAN UNDERSTAND ME.
      LINTON BROWN

  17. Can you please upload the fritzing file component for the IBT-2 driver ?

    Thank you Dr. Hessmer

    Mohamed Ehab

  18. Hi Dr. Rainer,

    I used these motor drivers and your recommendation to run a golf cart.

    After nine holes, the cart reduced in power. It seems the battery running out of juice. Yet when I measured the voltage of the battery, it is at 13v. And the heat sink is not even warm.

    Yet, when I get home, it was running fine again.

    Can you offer some insight to solve this problem?

    Thank you,
    Donald

  19. This chip won’t switch higher than 40Hz. Just tried using it as the DC->AC component in a step up transformer and it can’t handle signals over 40Hz and still deliver the power it claims to deliver.

  20. I need the foot print of this driver i cant find its dimmension

  21. @hassan:
    In this Zip-file you can also find the size of the IBT-2
    http://www.uctronics.com/download/U3537-BTS7960.zip

    @Hessmer
    Are you sure about the B+ and B-?
    According to the pdf and all images, the pin assignment is B-,B+,M+,M- (from left to right)
    According to your drawing, -M,M+,B+,B-

    Or does this depends on the version of the IBT-2?

  22. Hi.
    I used the same drivers with electrical model cars – wondering if anyone has an idea how to get it in wifi version?

  23. hi.
    How much voltaje is the maximum for the VCC pin in the IBT-2 H-BRIDGE because i have been connecting 9V to that pin and the IBT2 stop working, I am not sure if I burn it or the arduino is the one damage.

  24. hi
    How can I get the Transfer Function of the driver (IBT-2 H-bridge module)? please.

  25. @swante
    the motor goes in next to the IBT-2 text
    power source goes in the middle of the board and polarity matters

    so the drawing above is wrong,
    very funny when i was pwm’ing my power source

    here is the right drawing
    http://www.homofaciens.de/bilder/technik/rotary-encoder_010.htm

  26. I too connected 12V to M+ , M-. My driver not work. If I burn it driver?

  27. Dear Mr
    Dr Rainer Hessmer
    I want to make a sun tracker dual axis
    * I have arduino mega 2560 R3
    * I have 2 pcs BTS7960 (my motors are 24Vdc power suplly)
    * Analog sensors 4 photodiots array ( 4 serial for east-4 serial for west- 4 serial up -4 serial down)
    * 4 push button for manuel control (east-west-up-down)
    * 1 pcs wind speed sensor (output 0-5Vdc)
    * when sun set sistem will park in EAST
    need your help for codes
    Best regards

  28. Amazing and informative stuff. Is it work with 3D printer? I am working on an arduino 3D printer project.

  29. Dear Dr Rainer Hessmer,
    Can you please kindly help me for my project?
    Especially I would like to drive peltier with this motor driver. I only need to control voltage of peltier from 0 to 12 volts. What should be the pins (input pins) wiring. I dont need any reverse current. I would like to only give some pwm signals from raspberry pi with python and control output voltage. Thanks for your kind help.

  30. Good morning Mr Hessmer

    I have a strong doubt on the IBT-2, that is:

    I have a 12V DC motor which absorbs a current of 30A in S1 service (max 38A in S2 service).
    Can I safely use IBT-2 to operate the motor 30A?
    Someone said that IBT-2 is small for this use.

    I would use Arduino + potentiometer for feedback control.

    Thanks in advance and waiting for your answer
    Christian

  31. Hi

    Im using the Motor Driver BTS7960 43A for a 24v dc motor 200watt, im using a raspberry pi to control the pwm. When I first set up I was using a frequency of 100htz, but when running the motor and motor controller got extremely hot!. So I change the frequency to 800htz. Its now running cool and smooth but could anyone tell me if this a good setting please?.

    Many thanks

    Andy

  32. […] On the wiring side, I connected the VCC, R_EN, and L_EN pins to the 5V from the arduino. This powers the motor driver and permanently enables both directions on the motor. Ultimately, I will most likely disable one of the two directions, however while I am testing there is no reason to do so. I connected the LPWM and RPWM to PWM capable pins on the arduino and then the positive and negative leads from the motor and the battery to the larger wire receptacles on the motor driver (Battery to B, motor to W). Everything seemed pretty self explanatory, and no research I have found so far uses the two _IS pins. More information can be found in this instructable and on this blog. […]

  33. Thanks ! Can you give a clue on using the IS pin for current limiting/monitoring ?
    I don’t understand the datasheet for that pin.
    Thanks in advance

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)