Connecting an IBT-2 driver (BTS7960) to an Arduino

Thread Starter

mikeoz

Joined Sep 25, 2017
86
Hi,

I'm aiming to control the speed of a 12V DC motor using PWM via an IBT-2 (BTS7960) driver connected to an Arduino Uno and potentiometer. For my project I only need the motor to turn in one direction. Having researched this, I'm still slightly unsure how I need to connect the Arduino and driver for my requirements. Specifically, it's the RPWM, LPWM, R_EN and L_EN pins I'm struggling to understand.

To drive the motor in a single direction, would I connect L_EN and R_EN to digital pins and write them HIGH. Then connect the LPWM and RPWM to PWM pins on the Arduino - writing a PWM value of 0 to one and a value between 0 - 255 for the other?

Any help would be greatly appreciated.

Thanks

Michael
 

philba

Joined Aug 17, 2017
959
That's what various examples out there show. Google brought up a fair number of examples.

By the way, the IBT-2 maker claims it uses a line driver chip for "isolation" it but that really is weak at best. I wouldn't let that stop me from using it, though.
 

Reloadron

Joined Jan 15, 2015
7,501
I would use this tutorial and just modify the code and the connections. RPWM and LPWM are the directions. Which ever you don't use I would tie to ground since they are active high. The code sample gives a good idea of what is going on. Note how they use the pot and the PWM out. You will change that so a single PWM out will be 0 to 1023. There won't be an If, Else.You could tie the unused direction to an Arduino pin and just hold the pin low but I would just use a single PWM Out pin from your Arduino and tie the unused LPWM or RPWM low on the motor driver board.

Ron
 

Thread Starter

mikeoz

Joined Sep 25, 2017
86
Thanks a lot for the replies.

Ron, the only bit I don't fully understand is the last part of your post 'tie the unused LPWM or RPWM low on the motor driver board.'

Would connecting the direction I don't need (either RPWM or LPWM) to a GND pin on the Arduino also work - like you mentioned? Will this mean I don't even reference it in the code - no setup pin as an OUTPUT like in the link you provided?

In order to connect L_EN, R_EN and VCC of the driver to the 5v pin of the Arduino, would it be best to solder the 3 jumper wires to make a single pin connection?

Apologies for all the questions, looking at different examples of how to connect the driver has confused me!

Thanks

Michael
 

Reloadron

Joined Jan 15, 2015
7,501
The link I provided was aimed at running a motor one way and then the other way. The code was bi-directional. However, you only want one direction of rotation. So lets look at your motor driver inputs:
Motor Driver.png

This is a link to the data sheet for the IBT-2 (BTS7960) driver.

Now if we look at the code in the sample link I posted they use a pot for an analog input which is typically done to get a PWM output but there is a twist in the code. The Arduino uses 10 bit Analog to Digital conversion. In this case that means 0 to 5 volts analog input, from a pot would equal 0 to 1023 bits or 1024 quantization levels.The center pin of the pot will output a voltage of 0 to 5 volts.
C:
{
  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);
  }
}
Notice how the 512 is used, right in the center of 0 to 1024 bits. Since you don't want or need bi-directional rotation and only want either left or right rotation.

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

So if for example I only want Right rotation I can just tie pin #2 LPWM of the driver board low to ground. I also tie pin 4 the Left Enable to low or ground. Since these pins will always be logic low there really is no need to use two Digital Out Arduino pins held low. Note in the code how the pins are toggled for Right and Left. Your code would look similar to this sample and the sample code is taken from here.
C:
int analogInPin = A0;

int sensorValue = 0;

int outputValue = 0;

int transistorPin = 3;

void setup()

{

Serial.begin(9600);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(transistorPin, OUTPUT);

}

void loop()

{

sensorValue = analogRead(analogInPin)/4;

outputValue = map(sensorValue, 0, 1023, 0, 255);

analogWrite(transistorPin, sensorValue);

if (sensorValue >= 160)

{

//example

digitalWrite(8, HIGH);

digitalWrite(9, LOW);

}

else

{ digitalWrite(9, HIGH);

digitalWrite(8, LOW);

}

delay(10); }
You will need to write a High to enable the Right Enable in my example.

Ron
 

Thread Starter

mikeoz

Joined Sep 25, 2017
86
Thanks Ron, that's really helpful.

So as an example of the connections:

RPWM to a PWM pin
LPWM to a GND pin
R_EN to 5v pin or digital pin written HIGH
L_EN to a GND pin
GND to Arduino GND pin
VCC to Arduino 5v pin

The driver has various protection features including over-current and short circuit. Would I need to connect the IS pins for this protection to work? If it's any help, I've attached the datasheet for the BTS7960. Page 13 describes the protection functions - no doubt you'll understand this better than I do!

Thanks again for your help.

Michael
 

Attachments

Thread Starter

mikeoz

Joined Sep 25, 2017
86
Hi,

I'm having real trouble with this. The motor doesn't respond - regardless of the code I use. In the end I've resorted to the H bridge connections described in Reloadron's earlier post and used this exact code here: http://www.hessmer.org/blog/2013/12/28/ibt-2-h-bridge-with-arduino/
All I get is an audible ringing sound from the motor as I turn the pot, but no movement from the motor.

The basic setup of my circuit is as follows:

IBT-2 H bridge is connected to a 12v SLA battery with a 15A fuse inline and SPST switch.
Arduino Uno is connected to 10K potentiometer and is using the USB power supply.

Using my DMM, I get 13v from the fully charged 12v battery where it inputs the IBT-2 module. Yet when I measure the voltage at the motor, the highest reading I get turning the pot is 0.78v. Can anyone help with what might be going wrong here?

Thanks

Michael
 

philba

Joined Aug 17, 2017
959
Try running it first without PWM. Maybe use LEDs instead of the pump. Make two sets of LED+resistor and then connect them so one is reversed. Have one red LED and one green so you can tell which polarity is active. That's always my first step when I start testing motor drivers.

Your DMM will have strange readings with PWM, by the way.
 

Thread Starter

mikeoz

Joined Sep 25, 2017
86
Thanks philba,

I'll have to get hold of some LED's to try that. I tested the H bridge with the DMM as it's currently connected and the module is receiving 5V, so too are it's 2 EN pins. Does that tell us anything? The only other 2 connected pins are the LPWM and RPWM attached to the Arduino PWM pins, not sure how to test those with the DMM.

Michael
 

philba

Joined Aug 17, 2017
959
In the code, change the PWM ports output to just standard digital. Then you should be able to measure 0 or +5V. Though, if you have an O'scope you can look at the waveform.
 

Thread Starter

mikeoz

Joined Sep 25, 2017
86
I adjusted the PWM pins from analog to digital outputs and tested them using the DMM - they measured 0 or 5V, so no obvious problems there. Sadly I don't have an Oscilloscope. At the moment, would the most likely scenario be that the IBT-2 H bridge is causing the problem?

Michael
 

philba

Joined Aug 17, 2017
959
Well, it looks like your code and arduino are working. Now, take the arduino out of the equation. Jumper the inputs to the driver board - verify all your connections and if no joy then it's likely a dead board.
 
Top