Motor Driver BTS7960 43A

237K12164

Intro: Motor Driver BTS7960 43A

When you Build Your project , Sometimes you faced some issue with Motor driving Control , Specially if you want to control High Power Motor , I want to write about a nice Motor driver Module , it's BTS7960 half bridge motor controller .

The BTS 7960 is a fully integrated high current half , bridge for motor drive applications , comes with Two package as in pictures .

The Operating Voltage of 24V And Continuous current of 43A Max  , PWM capability of up to 25 kHz combined with active freewheeling 

In this artical I want to show you How we can use it with arduino and control High power Motor , And change The PWM Frequency of the arduino .

STEP 1: Inside the Datasheet

The datasheet for this IC Give us useful data 

this IC Have a good protection  circuit such as :

1) Undervoltage Shut Down: To avoid uncontrolled motion of the driven motor at low voltages the device shuts off . 
if the Supply voltage VUV(OFF) droped under 5.4V , The Motor driver will switched Off , And won't turned on untill the Supply voltage increased to 5.5V Or more .

2)Overtemperature Protection: The BTS 7960 is protected against overtemperature by an integrated temperature
sensor. Overtemperature leads to a shut down of both output stages.

3)Current Limitation : The current in the bridge is measured in both switches, High and Low side ,if The current reaching the limit current (Iclx)  the switch is deactivated and the other switch is activated for a certain time(Tcls).

You can read The datasheet for more info 

STEP 2: Connect It to the Arduino

The connection of  this module to Arduino Board is shown in schematic Below , 2 PWM Pin must connected to PWM Pin on the arduino , EN pin connected to digital pin on the arduino , The motor driver channel Will be disable if EN Pin is LOW .

Simple code for arduino below .

/*........................
BTS7960 Motor Driver Test
Written By : Mohannad Rawashdeh
Code for :
https://www.instructables.com/member/Mohannad+Rawashdeh/
*/
int RPWM=5;
int LPWM=6;
// timer 0
int L_EN=7;
int R_EN=8;

void setup() {
  // put your setup code here, to run once:
  for(int i=5;i<9;i++){
   pinMode(i,OUTPUT);
  }
   for(int i=5;i<9;i++){
   digitalWrite(i,LOW);
  }
   delay(1000);
    Serial.begin(9600);
  }



void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("EN High");
  digitalWrite(R_EN,HIGH);
  digitalWrite(L_EN,HIGH);
delay(1000);
for(int i=0;i<256;i++){
  analogWrite(RPWM,i);
//  analogWrite(LPWM,255-i);
  delay(100);
}
delay(500);
for(int i=255;i>0;i--){
  analogWrite(RPWM,i);
// analogWrite(LPWM,255-i);
  delay(100);
}
delay(500);
Serial.println("EN LOW");
digitalWrite(R_EN,LOW);
  digitalWrite(L_EN,LOW);
delay(1000);
for(int i=0;i<256;i++){
  analogWrite(RPWM,i);
  delay(100);
}
delay(500);
for(int i=255;i>0;i--){
  analogWrite(RPWM,i);
  delay(100);
}
delay(500);
}

And this is a video to show how this code works 

the PWM Frequency on the arduino UNO Atmega328p - Timer0 is 970Hz , This is a low PWM Frequency , in the next step we want to increase PWM Frequency .

STEP 3: PWM ... Arduino Timer

arduino Uno atmega 328p MCU has 3 timers , Time0,,Time2 8 Bit and Time1 16Bit  

Timer0 is connected to pin D5 , D6  , we want to increase the frequency "More smoothly control " 

Note That Timer0 is control the  (delay , millis ) on the arduino , so any change on the prescale of this timer will change the delay and millis time .

int RPWM=5;
int LPWM=6;
int L_EN=7;
int R_EN=8;

  void setPWMfrequency(int freq){
   TCCR0B = TCCR0B & 0b11111000 | freq ;
  }

  void MotorActiveStatus(char Side,boolean s){
    boolean state=s;
    if(Side=='R'){
    digitalWrite(R_EN,s);
    }
    if(Side=='L'){
    digitalWrite(L_EN,s);
    }    
  }
  void setMotor(char side,byte pwm){
   if(side=='R'){
    analogWrite(RPWM,pwm);
   }
    if(side=='L'){
    analogWrite(LPWM,pwm);
   }
  }
  void closeMotor(char side){
     if(side=='R'){
    digitalWrite(RPWM,LOW);
     }
     if(side=='L'){
    digitalWrite(LPWM,LOW);
     }

     }
void setup() {
  // put your setup code here, to run once:
  setPWMfrequency(0x02);// timer 0 , 3.92KHz
  for(int i=5;i<9;i++){
   pinMode(i,OUTPUT);
  }
   for(int i=5;i<9;i++){
   digitalWrite(i,LOW);
  }
   delay(1000);
   MotorActiveStatus('R',true);
   MotorActiveStatus('L',true);
    Serial.begin(9600);
  }

void loop() {
  // put your main code here, to run repeatedly:
for(int i=0;i<256;i++){
  setMotor('R',i);
  delay(500);
}
delay(1000);
closeMotor('R');
delay(1000);
  for(int i=0;i<256;i++){
  setMotor('L',i);
  delay(500);
}
delay(1000);
closeMotor('L');
delay(1000);
}

if we want to use this code with another timer " timer 2 " just change  D5 , D6 To pin D3 , D11 Respectively

int RPWM=3;
int LPWM=11;
int L_EN=7;
int R_EN=8;

  void setPWMfrequency(int freq){
   TCCR2B = TCCR2B & 0b11111000 | freq ;
  }

  void MotorActiveStatus(char Side,boolean s){
    boolean state=s;
    if(Side=='R'){
    digitalWrite(R_EN,s);
    }
    if(Side=='L'){
    digitalWrite(L_EN,s);
    }    
  }
  void setMotor(char side,byte pwm){
   if(side=='R'){
    analogWrite(RPWM,pwm);
   }
    if(side=='L'){
    analogWrite(LPWM,pwm);
   }
  }
  void closeMotor(char side){
     if(side=='R'){
    digitalWrite(RPWM,LOW);
     }
     if(side=='L'){
    digitalWrite(LPWM,LOW);
     }

     }
void setup() {
  // put your setup code here, to run once:
  setPWMfrequency(0x02);// timer 2 , 3.92KHz
  for(int i=5;i<9;i++){
   pinMode(i,OUTPUT);
  }
   for(int i=5;i<9;i++){
   digitalWrite(i,LOW);
  }
   delay(1000);
   MotorActiveStatus('R',true);
   MotorActiveStatus('L',true);
    Serial.begin(9600);
  }

void loop() {
  // put your main code here, to run repeatedly:
for(int i=0;i<256;i++){
  setMotor('R',i);
  delay(50);
}
delay(500);
closeMotor('R');
delay(1000);
  for(int i=0;i<256;i++){
  setMotor('L',i);
  delay(50);
}
delay(500);
closeMotor('L');
delay(1000);
}

STEP 4: Arduino Mega Timer

For arduino MEGA 2560 ,  it has 5 timers  : 

timer 0 (controls pin 13, 4)
timer 1 (controls pin 12, 11)
timer 2 (controls pin 10, 9)
timer 3 (controls pin 5, 3, 2)
timer 4 (controls pin 8, 7, 6)

This code For arduino mega with Timer 1 and 3  :

// code for Arduino Mega2560 and BTS7960 Motor driver
// written by : Mohannad Rawashdeh

int RPWM=3;
int LPWM=11;
int L_EN=7;
int R_EN=8;

  void setPWMfrequency(int freq){
    TCCR1B = TCCR2B & 0b11111000 | freq ;
    TCCR3B = TCCR2B & 0b11111000 | freq ;
  }

  void MotorActiveStatus(char Side,boolean s){
    boolean state=s;
    if(Side=='R'){
    digitalWrite(R_EN,s);
    }
    if(Side=='L'){
    digitalWrite(L_EN,s);
    }    
  }
  void setMotor(char side,byte pwm){
   if(side=='R'){
    analogWrite(RPWM,pwm);
   }
    if(side=='L'){
    analogWrite(LPWM,pwm);
   }
  }
  void closeMotor(char side){
     if(side=='R'){
    digitalWrite(RPWM,LOW);
     }
     if(side=='L'){
    digitalWrite(LPWM,LOW);
     }

     }
void setup() {
  // put your setup code here, to run once:
  setPWMfrequency(0x02);// timer 2 , 3.92KHz
  for(int i=5;i<9;i++){
   pinMode(i,OUTPUT);
  }
   for(int i=5;i<9;i++){
   digitalWrite(i,LOW);
  }
   delay(1000);
   MotorActiveStatus('R',true);
   MotorActiveStatus('L',true);
    Serial.begin(9600);
  }

void loop() {
  // put your main code here, to run repeatedly:
for(int i=0;i<256;i++){
  setMotor('R',i);
  delay(50);
}
delay(500);
closeMotor('R');
delay(1000);
  for(int i=0;i<256;i++){
  setMotor('L',i);
  delay(50);
}
delay(500);
closeMotor('L');
delay(1000);
}

45 Comments

Hello, Thank you for the post.
Now how can I add a ACS758LCB-050B to measure voltage and current?

Thanks again!!!! :)
Hi,
I need to run a DC motor (2750 RPM, 250 W) with variable speed, maybe quite half of nominal speed (some 1400 RPM), but mechanical power of the motor have to not drop too much.
How will be the mechanical power of the motor at low speed? Is this driver suitable for my application?
Can I use the module of bts with esp32? If possible then what will be the change in code?
Can this project be powered by 18v cordless drill battery?
I was working with bts7960 for fuel injection using proximity sensor connecting vcc and grnd in bts7960 i have one digital input pin 2 where should i connect in bts , its the analog pin of sensor which will provide output. Bt i connect that pin in all slot it doesn't provide output for injector?plz hlp
I suppose, you need to supply power to arduino seperately?
Can I connect 2 bts 7960 drivers parallaly and drive two motors?
Hi,
I've built my board like what you shared here. It can drive my motor with different speed but only on one direction, Do you know why does it act like this?
Hello
Thanks for nice tutorial.
I have a question about BTS7960. I'm using BTS7960 for control motor dc 24v 90W. Voltage supply is 24v 15A. When the pwm is 255, output voltage from BTS7960 about 14,5v. Why output voltage BTS7960 not 24v, whether the maximum voltage is 14.5 volts?
Hi my teacher,

I am using the BTS7960 DC motor
driver in a mobile robot project. However, I have a
problem with this driver. For example, if the motor is
locked or overloaded in any way, these drives burn out immediately. So I burned a lot of drivers. Can I protect the
drive with a current limitation? In practice, I put a
SIMENS fuse between the DC source and this driver, but this failed to protect
this driver. Can you make any suggestion about the
protection of the driver? How to limit to the maximum current
of the driver by additional module? Can you give me some
information about this subject?
Hi, I wish the photos showed a Red wire for +Motor Power and a Black or Green wire for -Motor Power and a Red for +5V from Arduino and Black or Green wire for Arduino GND and it would be nice if there were labels on the photos labeling the wires too (+MPower, -MPower, +5V, GND, Motor+ and Motor-) ... even the schematic is lacking complete information to describe which connectors are which on the motor driver.

Who's the manufacturer? How about a link to the data sheet.
Hello Mohannad,

You write in your 1st lines about an "half bridge" - what do you mean with an "half..."?

Here these lines:
"I want to write about a nice Motor driver Module , it's BTS7960 half bridge motor controller .

The BTS 7960 is a fully integrated high current half , bridge for motor drive applications , comes with Two package as in pictures ."

Is n't it this that you mean with "half" the H of H-bridge?

With regards,

Jop
Sorry sir can you help me, if the wiring in the connector is the output that is supposed to run the motor, can it be used to supply the battery with a constant voltage of 14 volts?
Hi!! Thanks for this tutorial, it really helps me. But I'm still confused. How to make a Simulink code with this driver, because it have 2 PWM Pin? Before use this driver, i use a L298N motor driver, and the simulink code works very well. But with the same code, and this driver, it does nothing. Oh i use Arduino Nano and a 12V DC motor on my project. Thanks for your help.
Hi
One could run this driver chip without any pwm signal, I've found a very simple way to drive this chip if required without the need for pwm, just by using diodes, by making the enable pins high/low to drive the motor forward or reverse direction, with only 2 control pins to be used.(with certain combination of diodes and the pmw and enable pins)
Also if required to have the speed control, then just add two pots to make the out put variable.
I've made a wire cutter and used bts 7960 to driver a wiper motor for the cutter unit.
Let me know if any is interested to know more about this method.

Darryl
hi! do you have any tutorial?

hey can you help me? i have a problem with this driver. i have 2 motor DC 12V 5A, then i have a supply (accu) 12V 20AH. when i plug the wire into one of this driver, the output voltage from this driver only 5V and actually motor can't move. why? thanks for your attentions

check your connection first , then check if your battery is in good condition.

It's possible to use only one PWM to pwm pins (1and 2) so do the direct control (left, right) using the enables pins?

Thanks,

More Comments