The darn H-bridge

I just want to be able to reverse a current. How hard can it be?

I just want to be able to decide direction of the motor to my pic, why does it have to be so complicated?

Well - perhjaps it doesnt! Jip / Jimmy, the most clever guy in here just drew me this and send it to me.


The smallest and most-likely-to-burn-something H-bridge in the world!

If it works, I will make a full walkthrough about it.

If it burns my robot.. well.. he did warn me ;)




Transistors are seen from top (usually you see them drawn from below)


Motor will turn one way when


A = low, B = low, C = high, D = high

Other way when A = high, B = high, C = low, D = low


Motor will halt if A = high, B = high, C = high, D = high


... shortcut and smoke if A = low og B = high or C = low and D = high




You could contruct it so

You could contruct it so that you only need 2 inputs. Also, if you do that it would be preferable to use MOSFET transistors instead as they work for both directions. If you use an combination between NPN and PNP transistors you’ll have to use a total of 6 transistors.

Societyofrobots has a really good tutorial that covers H-bridges though it only covers it with MOSFET transistors:

No, it did not work!

No rotation, nothing, does not work, something is wrong.

Will try to just use a L293D

Hate this ■■■■■■


Thanks, Fredrik, but I am too stupid for this, and I just want to make robots, hate electronics, am too stupid ;/

/ Frits

L293D Did the job!!

Yes, there is a 1.5V voltage drop within the L293D, and yes, it can only take so much of a load… But it is simple, and it works.

I am going to make a L293D walkthrough for dummies - I have so far only used it in the picaxe 28 project board… But it is actually very nice as a quick stand alone-fix!

More later,

/ Frits

Frits I did warn you about

Frits I did warn you about not putting the darn thing online before you tested if it worked :-). I’m no electronics wizard so things that I conjure up are bound to be broken from the start :smiley:

A little note on the above H-bridge: it is not recommended for use by others than Frits who apparently wants to burn his transistors and chips :-). I think the design is correct but I didn’t really test it :-D. At the very least there should be some schottky diodes for transistor protection and capacitors on the motor for spike protection (I think that’s how it works anyway).

Fredrik you’re quite right in that MOSFETs should be used instead of BJTs and if you really want a good and effective H-bridge you should use only N-channel MOSFETs since these have a lower internal resistance than P-channel (this does impose some requirements on your supply voltages though). Looks like a nice tutorial you found but the design it shows doesn’t allow for electronic braking.

It would be nice to see some different motor controller designs. I was thinking of building something which works kind of like L293 with having a voltage for the motor and still being able to control it from TTL voltage levels directly from the picaxe. I think maybe this can be done by using an op-amp to drive each transistor (and you can get four op-amps in one chip with the LM339)… I should make a drawing so you guys can see and tell me if it is crap and not working :-).

- Jimmy

There is also an L298 chip

There is also an L298 chip that can handle more current and can sense the motor voltage (this can be used for telling how fast the motor is running - I think :-))

- Jimmy


I just saw that I turned the NPN transistors in the wrong direction on the picture! They should be rotated 180 degrees… The collector pins from PNP and NPN are supposed to be connected.

- Jimmy

There are two problems with this design. 1 is the transistors. the 547 and 557 are designed for low current. I doubt you can drive a motor with it. 2 is that if you turn on A+B and/or C+D then yes, the motor will halt, but you will most likely see the whole thing go up in a puff of smoke. If you open both transistors in either side, you create a short between Vmotor and GND…

There is an error in the pin description. To turn the motor one way, open C+B. The other way is A+D. Think of the transistors as a switch and follow the power from Vmotor, through the open transistor (A or C), through the motor and through the other open transistor (B or D)

Yes it’s true that the

Yes it’s true that the transistors are only rated for about 100 mA of current which I also pointed out to Frits in the mail I sent him. I guess he left that bit of information out when putting the thing online :-).

Aren’t motor drivers supposed to go up in a puff of smoke? :-D… I’m going for drama and not movement ;-).

- Jimmy


I think the pin description

I think the pin description is right. Remember that PNP transistors turn on when input is low and not high. NPN transistors are the other way around. Did I miss something else?

- Jimmy

Well, I missed the PNP/NPN

Well, I missed the PNP/NPN part. :slight_smile: But why use NPN and PNP? Why not NPN all the way? And connect A&D and B&C in your drawing to get 2 control lines instead of 4.

Also, remember to put protection diodes on the transistors. Put them across collector/emitter against the current direction.

The voltage at the base pin

The voltage at the base pin must be higher than the voltage at the emitter to turn an NPN on. If you put in an NPN where there are PNPs you would need the base-pin to go beyond the voltage supply for the motor. Of course this is possible either using voltage doublers or just keeping the motor voltage lower than the supply voltage.

Actually the h-bridge shown above was never meant to be in this forum. Frits asked me to show him the simplest possible (no protection or anything) h-bridge using the transistors he had (BC547 and BC557) and so I did :-). If I were to build an H-bridge myself I would start off by using my HEXFETs (rated for around 20 A) instead of the BJTs in this design and I would add protection schottky diodes like you describe (although the HEXFETs have built-in body diodes for protection) and I would add filtering capacitors to absorb voltage spikes from the motor. I think I would also use some bridge driver chip to drive the HEXFETs instead of interfacing them directly from the microcontroller.

If you connect A&D and B&C you limit you modes of operation. With a full bridge you get CW rotation, CCW rotation, brake and coast (and of course melt-down :-)). You will have to limit yourself to three of these if you do the connection. As previosly said this is a simple bridge not really meant for others than dare-devils like Frits :-).

- Jimmy

Dang I keep forgetting to

Dang I keep forgetting to click "reply" on the right comment… look below somewhere to find a comment to your comment :slight_smile:

- Jimmy

You are right, of course. I
You are right, of course. I just thought i remembered a design with only NPN transistors. I’ll see if I can dig it up somwhere and see how it works (if it works at all…)


"The voltage at the base pin must be higher than the voltage at the emitter to turn an NPN on."

Erh… of course I meant that the voltage at the base pin must be higher than the voltage at the COLLECTOR to turn an NPN on :slight_smile:

- Jimmy

I have now tested the

I have now tested the h-bridge design (where the NPN are connected correctly) and it seems to work. I used LEDs instead of a motor: green is one direction and red is the other. I guess it’s not so easy to see what the heck is on the breadboard but the camera couldn’t go any closer without blurring the whole thing up… The resistors used in series with the base-pins are 2.2K


And the other direction:


Please note that the green LED in the middle is just the power indicator connected to the voltage regulator (an 7805 in this case). Also you can see my picaxe setup on the right side of the breadboard with my homemade programming circuit for use in a breadboard - nice and handy!

- Jimmy

Nice, Jimbo!

I am not getting anything of this, so I can only say this rather off-topic:

Hey JIP, you can get 9V as rechargables, at the same price as one new Duracell (10USD in Denmark, Harald Nyborg)

/ Frits

Thanks for the tip! I just

Thanks for the tip! I just read the description from the batteries you pointed me to… “High capacity which makes them suitable for devices with high current demands”… I don’t think any 9V can deliver high current :-). Since both the charger and the battery are so cheap (the charger is about 15 USD) - and since I live really close to that store - I definitely think I will go get some!

The alkaline ones that I have now I bought from and I think it was 12 batteries for 250 DKK (which is about 50 USD).

- Jimmy

David Cook shows an H-bridge for BJTs

David Cook has written a nice and short introduction to H-bridges using bipolar junction transistors here

- Jimmy