# How to control a motor driver (BTS7960) without PWM

Using a Raspberry Pi 3B+, I need to control a motor which works in 12V and can draw up to 2A. It doesn't use PWM. It just goes in one direction or the other (reverse/forward) when interchanging the +/-.

Since the Raspberry Pi can't do that alone, I bought an external 12V/10A power supply and a motor controller called BTS7960 (datasheet: here, image below).

What I did:

1. Connect the external power supply +/- to the numbers 2 and 1 respectively (see the image below for the numbers). It works: I measured the voltage with a voltmeter between 2 and 1, and it shows 12V.
2. Connect the Raspberry Pi PINs 2 and 6 (i.e. 5V and GND) to the letters B and A respectively (again, see the image below for the letters). It also works: I measure 3.3V between B and A.
3. Connect the motor +/- to the numbers 3 and 4 respectively.
4. Connect the Raspberry Pi PINs 36 and 38 (i.e. GPIO 16 and GPIO 20) to the letters E and F respectively. I assumed that setting HIGH these PINs would "enable" the corresponding voltage (+12V/-12V) between numbers 3 and 4 so I can control the motor in both directions. Is this true? Should it work like that?.

However, when I set HIGH one of these PINs (GPIO 16 or GPIO 20), I measure a voltage of +/- 0.01V between numbers 3 and 4 instead of the expected +/- 12V. So it seems to work a little because the voltage switches from positive to negative correctly (and becomes 0V when both GPIO PINs are LOW), but the value is totally wrong (0.01V instead of 12V).

What did I do wrong?

• Is that 2A rated current? or surge current? i.e. what is the motor DCR? Then how do you plan to limit motor power dissipation? THe logic is the easy part/ Sep 29, 2018 at 15:43
• The board documentation clearly says the Controller power supply needs to be 5V ….so trying to operate the board at 3.3V is probably the major problem. Sep 29, 2018 at 16:46
• @JackCreasey You were right, thank you! C.F. my answer below. Sep 29, 2018 at 17:18
• @JackCreasey what do you think?? Noise immunity? Sep 29, 2018 at 23:44

I surmise that the board you have bought was not designed be driven by a 3.3V MCU. It may work, but depending on your MCU may not. But there may be a couple of solutions to your problems.

The likely schematic for this board is here:

The various boards from different suppliers may differ in the selection of the components but you should note that THIS BOARD AS SHOWN IS NOT 3.3V compatible due to the high current input requirements. Your board picture shows the same value of pulldown resistors. The 1k OHM pulldown resistors result in a lot of current being required with the input high, and this may well pull the outputs of a 3.3V MCU out of spec.

The datasheet for the (Phillips) 74HC244 shows the following:

While the datasheet does not show the Vin(high) value for a 3.3V supply we can extrapolate that it is likely to be a minimum of about 2.4V to register a high. This requires the Raspberry PI I/O pin to source at least 2.4mA at 2.4V. It may not be capable of that. (There is no problem for the Vin(low) since the 1k Ohm resistors pull down the input).

You can check by simply looking at the IN and INH voltages from the 'PI when driving the board.

Counterintuitively you might be able to sort your drive problem by actually reducing the VCC for the 74HC244.

The datasheet for the BTS7960 shows the IN and INH signal voltage levels with a worst case voltage of 2 and 2.15V.

If you were to reduce the 74HC244 VCC to say 2.5V you would still meet this requirement, but the input high voltage levels from the Raspberry PI would drop to around 1.8V worst case. This does not reduce the load on the Raspberry PI I/O pin, but will tolerate an out of spec Vout(High) from the 'PI much better.

As another solution you could perhaps replace the 1k Ohm resistors with say 10k Ohm, this would reduce the current supplied by the Raspberry PI I/O pin and increase the voltage applied to the 74HC244 inputs.

UPDATE:

For those that doubt the Raspberry PI DIO current could be a problem, here are a couple of pointers. The DC characteristics of the chips used in the 'Pi are poorly documented, but the DIO structure can actually be programmed to supply different levels of source current. First link, second link

I have no idea what DIO current levels are set for the different models of Pi but it is operating system dependent.

The I/O structure for each DIO pin looks like this:

UPDATE_1:

I finally pulled a 'PI 3B out of a project to test the GPIO ports. It is running the current Debian(Jessie) release.

The differences between GPIOs when you have a 1K Ohm pulldown is quite profound.

I did not have a 74HC244 so worked from what the datasheet presented as the Vin(High) voltage that would be required and measured the GPIO voltage with a multimeter.
The GPIOS seem to fall into two groups, those which have a single output pin configuration as a GPIO and those that have dual function (GPIO and some other function selected by configuration).
The group that are just GPIO (GPIO 5,6,13,19,26,40,38,36,32) have excellent characteristics with Vout(High) dropping only 0.05-0.1 with a 1K Ohm pulldown load. At a 412 Ohm load, this group dropped around 0.25-0.3V, but none were under 3.0V.

The dual function group of pins showed a much worse current source capability, with one of this group (GPIO 11) much worse than all the others.
Most of this group had a Vout(high) of less than 3.2V with a 1K Ohm (the actual value was 1100 Ohms) load. GPIO 11 was the worst with 3.14V. At 412 Ohm load most were 2.95V or above while GPIO 11 was 2.9V. (Please note here that the GPIO 11 pin source current is only 7mA, I did measure this further and at 10mA, this port collapsed to 2.6V)

From the above numbers we can say that the 'Pi (at least my sample of one) would be incapable of driving a worst case 74HC244 using a VCC at 4-5V (Vin(high) of 3.14V or greater). For a 74HC244 VCC of 3.3V, all of my ports would successfully drive a high signal for a 1K Ohm pulldown. Given I had one port that was significantly worse than the other, I would surmise this may occur with other 'Pis too. I therefore stand by the assertion that reducing the VCC for the 74HC244 provides better margin for error, though it's clear that reducing the VCC value to around 3V would be all that is required.

If anyone would like to use the same software and test configuration I'm happy to post.

• This theory is not all that likely - 3.3 mA is really not much load. But fortunately it's also something readily visible to direct measurement - simply measure the input voltages while connected to the relay board. If they have not sagged, then that is not the problem. Sep 30, 2018 at 4:57
• The 74HC244 is not a Schmitt trigger, read your own data sheet link. Your theory has a low likelyhood of being the problem, but it can be measured. If the measurement does not confirm sag to a questionable voltage, it's a distraction and the poster should look elsewhere for the actual problem. For that matter, they can even measure the output of the buffer with care. Sep 30, 2018 at 17:20
• @ChrisStratton You are right the 74HC244 is not Schmidt trigger ...it's the BTS7960 that is. But you are wrong about the Raspberry Pi (it being theory about not delivering the current). I've added some documentation to the answer. Sep 30, 2018 at 18:04
• You have a question asker ready to blame suspicions without evidence, so the situation calls for reliable facts and evidence. Remove the comments related to the (now admittedly) false claim of the 74HC244 being a Schmidt trigger, and I'll remove the downvote putting you back at the situation of having a plausible but unproven idea. Find or conduct a documented experiment confirming substantial voltage drop on a pi output loaded by 1K with default settings of a major distribution, and I'll give you an upvote. Sep 30, 2018 at 18:17
• @ChrisStratton Of course I said that the OP could measure the voltage. However measuring the input from the 'PI is only one part of the problem, you have no idea what the trigger level is on the 74HC244 at any given VCC. The trigger level (Vin(high)) for the device is approximately 0.7 -0.75 VCC. Sep 30, 2018 at 18:24

You need to drive one of the direction lines (E or F) high at the same time that you drive the corresponding PWM line (G or H, repsectively) high. These two signals are effectively ANDed together by how the driver chips are wired together. My guess would be that E and F control the two high-side switches (one on each chip) and that G and H control the two low-side switches.

• I tried to set E (i.e. forward enable) HIGH and send a PWM signal on G (i.e. forward PWM) with a value of 50% (I set the other two to LOW). I checked with a voltmeter that everything was correct (measuring voltage at E shows 3.3V so it's HIGH, measuring voltage at G shows 1.6V so it's 50%, measuring voltage at F and H show 0V so it's LOW). However, the voltage between 3 and 4 is still very small (0.01V). Again, when I set all PINs to LOW, the voltage between 3 and 4 is absolute 0. What can be wrong? Sep 29, 2018 at 16:22
• I thought you said you didn't need PWM. In any case, you gave us the datasheet for the chip, but we know nothing about the board. Can you provide a link or a schematic, or anything? Sep 29, 2018 at 16:33
• @GuiTeK: The correct designation for the board seems to be IBT 2. A search brings up various 3rd party descriptions and examples of use, but I found no detailed information from the manufacturer of the board.
– user80875
Sep 29, 2018 at 17:14
• There are supposedly two modes of operation.
– mirh
Apr 16, 2023 at 22:55

On the website where I bought the board and on several other websites, it was explicitly written that the "input level" could be 3.3-5V, while some other websites only read 5V.

As the RPi GPIO PINs can deliver only 3.3V, I decided to use 3.3V. It didn't work. As a commenter on my OP emphasized on the fact that it needed 5V to work, I decided to try it out. Guess what!? It worked.

In order to make it work, you need to:

1. Connect the external power supply +/- to the numbers 2 and 1 respectively
2. Connect the motor +/- to the numbers 3 and 4 respectively
3. Connect both E and F letters (respectively reverse enable and forward enable) to 5V
4. Send 5V to either G or H letter: sending 5V to G (i.e. reverse PWM) will cause the board to send -12V to the motor, and sending 5V to H (i.e. forward PWM) will send +12V

Despite the fact that many sources say that this board works with 3.3V, it seems completely false. It needs 5V to work properly.

• While it's nice that you got things working, your conclusion would appear to be incorrect. There is nothing evident in the picture your provided of the board that should not work at 3v3 for the logic side. If powered from 5v, the 74HC244's input threshold might be marginal for a 3v3 signal, but if powered from 3v3 it will be fine. However you generally should not power external motor-related devices from the pi's delicate 3v3 rail. Sep 29, 2018 at 19:00
• @ChrisStratton The only device powered by the 'Pi 3v3 is the 74HC244 and I would assume this is quite ok. Total current for the devices is going to be only a hundred uA or so. Hardly a problem for the 'Pi onboard 3v3 regulator. Sep 30, 2018 at 22:42
• While that's true in a steady state condition, experientially even something like a power supply rail capacitor in a low-draw accessory can cause a pi to reboot if hot plugged (either intentionally or via intermittent wiring). It may work in this case, but in general one should be extremely cautious about adding loads to the 3v3 rail of a pi; the 5v rail is upstream of the regulator is much more resilient. But if it's just the HC244, then it might be okay; hopefully we agree the HC244 needs a 3v3 supply from some source if it is to receive 3v3 inputs. Sep 30, 2018 at 22:54
• It's now become clear that this answer is incorrect. In fact, the design is compatible with 3v3 usage, when the 74HC244 is also powered with 3v3 on pin B. You should measure the control input voltages to the board. If they are above say 2.5 volts even when loaded by those 1K resistors, it should work and your problem is elsewhere. Close to 2.5v it might be flaky, but your described failure sounds much more persistent than that would cause, given that this is a continuous circuit rather than one with flip-flops that could "remember" an ill-timed glitch. Oct 4, 2018 at 17:00

There seems to be some misinformation or lack of information regarding this board.

If the interface uses the BTS7960 IC then from 4.4.6 in the datasheet
Vin(H) is 1.6V typ 2V max over temp
i.e. 3V compatible

The input threshold is in between 1.4 and 1.6V (@30uA typ, 150uA max @5.3V)

This is exactly the same input threshold as RS232 Rx, TTL input and 74HCTxxx CMOS logic.

If the input pins are directly connected to the inputs on board, it must comply to meet spec.

The reason for logic higher logic levels is higher stray motor current noise immunity. This tells me your shielding and immunity is less than optimal.

• The input is not to the BTS7960 but to a 74HC244 supplied at whatever voltage is wired to pin "B". Oct 4, 2018 at 16:59
• Are you sure it is 74HC and not 74HCT? To make meet 3 to 5V range Oct 4, 2018 at 17:25
• An HCT would indeed be better. But the picture shows an HC, which is a more challenging case. The pictured 74HC244 should work if supplied at 3v3 and driven by something that can maintain say 2.5 volts measured at the control inputs under the load of the pulldown resistors the board apparently puts on them. Supplied at 5v it might well not. But it sounds like 3v3 supply was tried. If not, it should have been (with due care to or better avoidance of loading the pi's own delicate 3v3 rail) Oct 4, 2018 at 17:27
• I see it now yes I agree. The Vt =Vcc/2 +/- temp tolerance for Vcc=5V makes a Vt=2.5V very marginal without a pull-up R of say 220R to 3.3V for noise immunity or Low activated Diode switch with 5V R pull-up to 5V to make it work. Oct 4, 2018 at 17:31

Your Control Table is a little wrong, it should be -

A - Ground | B - Logic +V

[for output 3] | [for output 4]

C - Error sig | D - error sig

E - Enable | F - Enable

G - Set Hi/Lo | H - Set Hi/Lo