Dual DC H-Bridge on Jetson Nano GPIO

Greetings!

Is it possible to use this H-Bridge ([url]https://www.bananarobotics.com/shop/HG7881-(L9110)-Dual-Channel-Motor-Driver-Module[/url]) to control two 3.3v vibration motors (or just two vibracall motors) through Nano’s GPIO pins? I really new to GPIO/I2C stuff so I’m not sure which pin should I connect to etc.

Thank you so much.

Yes, that looks like it will work.

If you just want the vibration motors to “go” then that should be simple – you could do this from Python using the GPIO module, or from a shell script using the /sys/class/gpio files, even.

If you want to use PWM to control how fast/hard the motors go, then you’ll have to enable PWM for the GPIO pins for the Jetson, which requires configuring the output pins/modules correctly and installing a new device tree (update a dts file and build a new dtb file and flash it to the appropriate place) – there are other threads on this forum about this process, which is not entirely trivial.

You would pick four available GPIO pins on the 40-pin expansion header, and wire those to the [AB]-I[AB] pins. You would also wire GND from the 40-pin expansion header to GND on the board. Then you’d wire a sold 3.3V power supply to the VCC in on the board. You may wish to use a separate 3.3V power rail, no the one available on the 40-pin GPIO header, if your motors are at all strong/noisy, to avoid emitting motor EMI back into the Jetson module. Make sure to tie GND of your power supply to GND of the module, too (which ties GND of power and Jetson together.)

Then, screw in the motor terminals. Open the GPIO pins; set the “IA” pins to “high” (on, 1) to make them “go” and choose direction with the “IA” pins (“high” or “low”)

  1. By “board” you mean the H-Bridge?

  2. How can I use a separate 3.3V power rail?

  3. Is there some kind of 3.3V holder for 3.3V batteries if I won’t power motors using jetson nano power?

  4. Vibration motors consume from 2.5V to 4V up to 90mA at 9000rpm avg.

Sorry if some of these questions are naive. I’m really an outsider in terms of electronics.

Yes, by “board” i mean the H-bridge carrier board you linked to.

If they only draw 90 mA, they may be low-power enough that you may be able to power them directly from the Jetson. Hook 'em up and see how it goes; if you get software instability when activating the motors, you know that you need a separate power rail.

Generally, you generate a separate power rail from the main power source using some kind of regulator. A LM7803 would work fine for these, as would any of the four-dollar “buck dc dc” converters on Amazon/eBay/Aliexpress, assuming they are OK with whatever voltage you can put in (5V from the Jetson 40-pin header, or direct from your battery) and are set to, or can be adjusted to, the 2.5-4V range you need.

A third option for cleaning up the power is to put a capacitor in parallel with the VCC – i e, get a 100 uF calacitor and solder it in the same pins you put VCC and GND. Again, this might let you drive it straight from the Jetson 3V rail. (And when I say 3V, I really mean “3.3V”)

I will test it and report back in a few days.

Note that when I say that, I mean the 3.3V rail, through the H-bridge board you’re suggesting, btw.
I don’t mean that you would be able to drive the motors straight from a Jetson GPIO – those only do a few milliamps at most!
This was hopefully clear, but making sure I don’t lead some reader into a trap of frying GPIO pins.

You mean: I plug both motors on H-Bridge and then plug the H-Bridge VCC into Jetson GPIO 3.3V pin, right? The same for GND from H-Bridge to Jetson GND and all A/B IA/IB pins to avaiable Jetson GPIO general usage pins? When my parts arrive, I’ll draw a scheme to confirm before testing it.

Correct.

Alright, my parts arrived and I wired 'em as follows:

1-H-Bridge VCC to 3.3V on Jetson GPIO
2-H-Bridge GND to GND on Jetson GPIO
3-H-BRIDGE IA1 to pin 21 on Jetson GPIO
4-H-BRIDGE IA2 to pin 22 on Jetson GPIO
5-H-BRIDGE IB1 to pin 23 on Jetson GPIO
6-H-BRIDGE IB2 to pin 24 on Jetson GPIO

I didn’t power on jetson yet.

Both motors are 3V (3.3) and 58mA.

Is it correct? Btw. I’m powering Nano through MicroUSB.

Here are some pics:

I connected a vibration motor to IA1 and IB1 (21 and 23), then I ran the following jetson-gpio code sample to turn HIGH and LOW on those pins (17 and 18 according to jetsonhacks table).

It wasn’t working. I plugged my VCC in pin 2 (5V) and tried to run the code above but it still didn’t work. For curiosity, I changed the jumper from pin 23 to GND and it started vibrating on contact (without even run the code).

How should I proceed?

The vibration motors go to the green connectors; those are the outputs.

I rearranged them like this

IA2 - Pin 21
IB2 - Pin 23
VCC and GND remains the same (under pin 15 and 18 respectively).

I tried to run the following code and it didn’t work:

import RPi.GPIO as GPIO
import time

output_pin = 17  # BOARD pin 21, sys pin 17
output_pin1 = 18 # BOARD pin 23, sys pin 18

def main():
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.HIGH)
    GPIO.setup(output_pin1, GPIO.OUT, initial=GPIO.HIGH)
    print("Starting demo now! Press CTRL+C to exit")
    curr_value = GPIO.HIGH
    try:
        while True:
            GPIO.output(output_pin, curr_value)
            GPIO.output(output_pin1, curr_value)
            curr_value ^= GPIO.HIGH
    finally:
        GPIO.cleanup()

if __name__ == '__main__':
    main()

Here are the new pics:

Do you have an oscilloscope or volt meter?

You could look at the voltage on the IA2/IB2 pins (compared to GND) to see whether your GPIO code actually changes the output values.

Also, make sure that the output port you’re using matches the input pins – the output ports don’t have an obviously readable label in the picture so it’s possible you hooked the motors to “out 1” but the inputs to “in 2.”

I solved the problem by connecting the “B” input of motors (IB1 and IB2) to GND pins over GPIO.

I’m planning to use 3 to 5 vibration motors now. Is it safe to attach many (at least 2) board GNDs to the same Jetson GPIO pin (like Y cables)?

The motors should go between the two screw terminals on the same green connector.

Anyway, if the motors draw 90 mA, and the controller is rated up to 800 mA, you should be able to just parallel more motors into the same green connectors. I e, you should be able to use three motors to output A1/A2, and three motors to output B1/B2, within the driver rating.

I made some illustrations to examplify.
The first figure is how it is working currently. This was the only way I managed to make both motors to work.
The second and third figures are about my doubt on multi wires connected to a single GPIO pin. If it is possible, I can even connect four motors if their GND can share the same pin.
No more than TWO motors will be on simultaneously and I’ll add a 5th motor as well (maybe get another bridge if I can support 4 motors like figure 3).

So, will I fry my Jetson Nano if I solder 4 GND wires into one and connect this one to Jetson GPIO pin?

Image 1:

Image 2:

Image 3:

1 Like

The third option should theoretically work, assuming that your driver chip is OK with there being more current through one half of its H-bridge than the other. (Some drivers detect this as an error condition and shut down.)

I imagine your desire is to control the four motors separately? Then you’d tell “motor B forward” to activate motor 3, but “motor B backward” to activate motor 4. Important to note is that you could never make motor 3 and motor 4 active at the same time in that situation.

2 Likes