H-bridge for two DC motors

Status
Not open for further replies.

escallic

New member
Hey all!

I am new to microcontrollers and transistors, so any help is valuable to me. Here's my scenario:

I have a Teensy 2.0 with which I want to drive two 9V DC motors in both directions (cw and ccw). Each motor draws a maximum of 780mA when stalled. The external power supply (a Lego Mindstorms NXT microcontroller) I have for the Teensy supplies both 4.3V and 9V simultaneously. I want to use I2C to feed the Teensy instructions for motor control from the NXT's 'sensor' port. I need two extra EV3-medium-motors (in addition to 3 NXT motors) for my Lego Mindstorms robot but can't afford the extra weight from another set of 6 AA batteries for a second NXT.

I know I need some kind of H-bridge to drive the motors, but I don't know which H-bridge is appropriate for this as there are many variations of H-bridges. Should I build one out of NPN, PNP, FET, etc transistors? I found the L298N, a dual H-bridge integrated circuit. Is this what I need? What additional resistors, capacitors, diodes, and other components would I need and how would they appear in a circuit with the L298N and Teensy? If on the datasheet for L298N it requires 4.5V - 7V for a logical supply, but the NXT only supplies either 4.3V or 9V, does this mean that I would need a voltage regulator somewhere?

I'm hoping for a low-volume (small) and cheap solution--emphasis on the latter since I am a cheap person. :)

Any insight on which software libraries I will need then would be helpful, too.

I know I am ignorant and have so many doubts about this. Please, I'd really appreciate any help.

Thanks in advance! :)
 
Just kidding; I actually need 3 additional motors for my Lego robot now, not 2. There are (just) enough pins on the Teensy 2.0 for 3 motors (2 PWM pins and 1 analog pin for "ENA," "IN1," and "IN2" on the L298 per motor) plus each of the Lego motors' two tachometer leads (2 analog pins) plus SDA and SCL for I2C. So I know this is possible.

I ordered two L298 ICs--one for two motors and one for one motor. I'm worried that this won't work because this L298-based circuit utilizes so many large and apparently essential components in conjunction with the L298; a large construction might compromise the robot's function. I read somewhere that L298 may work with even 3.3V, so I'll try to make it work without a voltage regulator. I read somewhere else that Current Sensing A&B can be grounded directly without the 0.5 Ohm resistors. I assume the capacitors aren't totally necessary. I think I may have trouble with L298's infamous voltage spikes if I don't have the eight diodes. I hope to get by without the heat sink. I'm not totally aware of the consequences of excluding these components. I might just order a motor multiplexer from Mindsensors and derive power from the NXT's motor port A if I can't get this to work. It still would have been fun to learn about what's possible with the Teensy.

Is there a Teensyduino library for I2C communication? If not, are there tutorials for programming the Atmel processors/Teensy in C language, specifically with PWM, I2C and the C equivalent of analogRead(), analogWrite(), micros(), and Serial.print() from Teensyduino? I looked at the Blinky source code but that was way over my head. Is there a way to either understand or automatically generate the contents of a Makefile? BTW, I'm using Ubuntu 14.04.

Any help is still appreciated! :)
 
I designed a couple of DC motor drivers on small add-on boards for the Teensy 3.1 (see here and here). Maybe these would work for you.

I also plan to design another board using the TI DRV8833 motor driver which allows even larger drive currents but haven't got around to it yet.

Use the i2c_t3.h I2C library for the Teensy 3.x.
 
Last edited:
I use an L293DD (might not fit your requirements exactly). I'm building mine directly onto a PCB alongside the two Teensy processor chips, so I have a bit more control over various things as well - I give it supply voltage direct from 'USB' voltage (or external voltage). It's got enough range that the 3.3v Logic High coming from the teensy is enough to toggle it. I put 9V in at VS, and 5v at VSS, and can use logic from 0-3.3v to control it.

But, it's got a maximum current output of about 600mA per output, so probably not the best fit for your needs.
 
Thanks @onehorse & @MuShoo! I'll look into these motor drivers and the i2c_t3.h library and report back soon.
 
So after a few months, I decided my best solution was to make a Mindstorms breakout board w/ DRV8833. It seats two Mindstorms ports on the top and a Pololu DRV8833 breakout board underneath. The Pololu board is what connects it to the Teensy 3 via 4 contiguous PWM pins. This intermediate board seems redundant, but it was the only thing I could think up that minimizes volume on-board the robot. What actually is more redundant is my time and effort spent on implementing a proprietary RJ12-like jack that ends up being the largest and most expensive component of this project. I should have just cut open a cable lol.
 
Status
Not open for further replies.
Back
Top