[Solved ] BTS7960 based H-Bridge (IBT_2) behaviing strangely

Updated 6/8/15 - I've now confirmed this was a hardware issue

Hi all,

I have been using variuos codes (most recently the code from here: IBT-2 H-Bridge with Arduino – Dr Rainer Hessmer) to test out my new motor driver with my UNO clone.

I connected it to my motor (B+ and B- to 12v SMPS - M+ and M- to the Motor).

I also connected it to the Arduino as per isntructions (VCC, R_EN and L_EN to Arduino 5v - Pin 8 (GND) to Arduino GND, and LPWM + RPWM pins to Arduino D5 and D6).

The only hardware difference is that I used an LDR instead of a 10k pot for the analog input, because that's what I had handy. I took that out of the code and used the value 127 to simplify.

At firs, with any test code, I could only get it to rotate the motor one way (let's call this forwards) - by experimentation, I could achieve reverse rotation if I unplugged the wire connecting pin 8 (GND) with Arduino GND, however, with the GND wire disconnected it would then blow the motor fuse on the next FW cycle.

I realised that if I set the PWM values to 0 between direction switches, then no fuse is blown. So now I have rotation both ways, but the GND cannot be connected or I lose REV rotation.

I'm now using the code below (a heavily cut down version of the Dr Rainer code) to get rotation both ways (only works with GND disconnected).

/*
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);
 Serial.begin (9600);
}

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

 Serial.println (sensorValue);
  
  //if (sensorValue > 511)
 
    // reverse rotation
    int reversePWM = 127;
    analogWrite(RPWM_Output, 0);
    analogWrite(LPWM_Output, reversePWM);

 
  
  delay(5000);
 
    analogWrite(RPWM_Output, 0);
    analogWrite(LPWM_Output, 0);

 
  //forward rotation
  int forwardPWM = (127);
  analogWrite(LPWM_Output, 0);
  analogWrite(RPWM_Output, forwardPWM);

  delay(5000);
 
    analogWrite(RPWM_Output, 0);
    analogWrite(LPWM_Output, 0);

  
}

Is there anything obvious I'm doing wrong - I'm very confused as to why:

(a) it works perfectly with the IBT_2 GND disconnected from the Arduino GND and
(b) it would not work in both directions when GND was connected.

Thanks for any help you can give me.

Steve

Hi,

Can you please post a copy of your complete circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Please include your power supply and load.

Thanks ..Tom.... :slight_smile:

Thanks for the reply Tom,

I'm stuck in the office late tonight but will try to draw something out by hand

I have no CAD software and I tried Fritzing yesterday but it has no IBT_2 module that I'm aware of.

Steve

Hi,

You can download for free, no attachments and a nice easy CAD from.

It has a image export facility to, so you can post images of your circuit.

Tom.... :slight_smile:

Hi Tom, I attach 2 drawings of the setup both:

(1) with GND connected between the IBT_2 and Uno - which allows one way rotation; and

(2) With GND disconnected which allows 2 way rotation but blows a fuse (on "m+" not pictured) when rotation goes to FW without an analogWrite of 0 to the opposite PWM pin.

The project is a Bus destination sign (I'm motorising the blind roller) - there is an unused 7805-based 5v regulator in the diagrams. That is to connect the Uno to when I"m done coding.

Steve

and diagram 2

You must have ground connected, or you could easily damage something.

Why are you enabling left and right simultaneously, that sounds wrong...

Enable only one direction and a time...

Mark, that's what I thought. I'm starting to think the Motor Driver module is faulty.

I've enabled both as both the example sketches used either called for them to be connected to +5v (presumably to save pins) or enabled them together (via digitalWrite).

I have unplugged them one at a time with the same code and the motor does not move. I wonder if that's because one _EN pin is floating, perhaps it needs to be written LOW to connect it to GND?

The code which digitalWrite's them both high I mention is the code at step 2 of this instructable

I used that code for initial tests and the motor worked well in the one direction. It was only when I wanted to reverse the direction I couldn't get the motor working.

I have one of those H-bridges, but haven't used it yet. Below is a previous discussion that had success. The BTS7960 data sheet have some additional info of interest. You might go by radio shack and get a pot to see if that gets things back on track. If you don't have the arduino ground and H-bridge grounds connected, what is the PWM current flow path? I think with the EN pins perform the enable function, but they also cause motor breaking when high and the PWM pin is low. I'd try connecting the grounds together, tie the LPWM and L_EN together, and tie the RPWM and R_EN pins together. This should allow the motor to free wheel when the PWM pin is low. Bottom is the schematic from the instructable just for reference.

http://forum.arduino.cc/index.php?topic=148482.0

Hi,
Can you connect LEDs with their series resistors to each of the four control outputs and gnd of the arduino.
This is so you can see the signals that are being sent to control the H-Bridge.

Tom.... :slight_smile:

Good idea Tom,

I will get LED's hooked up (I already thought of this on the FW side, but not the REV side).

Next chance to look at this will be Friday eve, so will have a play then.

Steve

I think I'm going to also change my code so as to:

(1) simplify it as much as possible; and
(2) change the way the unused x_PWM pin is written.

It seems from other answers on this forum that an analogWrite of 0 is not enough and I need to digitalWrite the pin LOW.

This seems to be confirmed by the general info on analogWrite for pins 5 and 6 of the UNO:

"The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6."

That high duty cycle of pins 5 and 6 may be causing my short when GND is connected and I am essentially running +v and +v through both sides of the (fused) motor.

Perhaps I need to also move my fuse to one of the battery (powered by the SMPS) lines. The fuse itself is really an artefact from an earlier version which just switched 2 relays to get instant full speed control in either direction.

Tom,

I've connected LED's to the LPWM and RPWM outputs and the Arduino is producing the correct signals.

I'm using the basic "Fade" sketch to produce a rising / falling PWM signal which work well on RPWM.

The H-Bridge seems to be faulty as signal to the LPWM pin doesn't cause the motor to spin. The LED fades as it should, but nothing happens. i've reversed my motor leads and the motor is not the issue (it spins both ways fine using the RPWM signal.

I'll return the H-bridge to the vendor. I have a spare L298 H-bridge, but the Motor's stall current is 11A, so the L298 will probably fry.

Steve

Thanks all for your help - I've now received my new controllers and can confirm the issue was a fault with the old controller. Everything works as expected now.

It may have been a returns / repair part as it had one BTS7960 on board and one of the replacement component (the name of which I forget - BTN7961n?).

My new controllers have 2x matching BTS7960's.