Let's Make Robots!

Help with H-Bridge

brunoxyz's picture
 Hello, I need some help to reduce the chances of burning my precious Arduino/apartment.
 
I managed to build and test this H-bridge made out of transistors on a breadboard, and to my surprise everything worked perfect, I was able to use PWM to adjust speed and drive the motor back and forth.
 
 My question is, will I create a short if the two inputs receive signal at the same time?  right now they alternate between HIGH and LOW or  0 and higher numbers with the analogWrite or digitalWrite functions.  I ask because I might want to vary speeds according to a sensor or similar and at some point current could flow through both inputs?
 
Also I want to build a  shield with two of these H-bridges to control two motors,  what other considerations should I have?
 
 
Thanks! 
 
note: this diagram shows the transistors from below. 
 
first two are PNP, the other four are NPN 

 driver2.jpg
 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
amando96's picture
can make the code like if(input1 && input 2, HIGH) input1(or 2), LOW } else{ ^^ its not excatly like that i think i'm missing some punctuation...
brunoxyz's picture

can somebody check to see if the diodes I added here will prevent a possible short circuit?

 Also, what diodes  should I get?

 do I have to add something else to the circuit? like a voltage regulator or more resistors somewhere? I am really new to all this so any help would be greatly appreciated.

 driver2a.jpg

thanks

 

 

TeleFox's picture

The added diodes won't stop a short from occuring when both inputs are high; here's a diagram showing the short circuit paths in red:
driver2a_short.jpg

Try the following circuit instead - when one of the inputs goes high it effectively disables the other input by forcing it to be low. I've also added 2 more resistors between the middle NPN collectors and the PNP bases. These resistors will reduce the excess power wasted by the circuit, and help protect the transistors. If your supply voltage is around 3-6V I suggest using 200Ω for the new resistors. You don't strictly need a regulator for this circuit, it's pretty resilient, but in the end it depends on your power supply.
driver2b.jpg

brunoxyz's picture

Thanks a lot man, I integrated them to the shield I'm planing to make, though I am not sure how the diodes are going to force the other line to shut down, is it because the input creates a flow or something?. t. I will try not to screw up with the code anyway.

circ.jpg 

 

 

TeleFox's picture
The way it works is like this: if the left input is set high, then the left-middle NPN is turned on. This also turns on the top-left PNP and the lower-right NPN. The collector of the bottom right NPN is pulled down to almost ground when it is on, which also pulls the cathode of the right diode towards ground.
If the right input is now set high, the diode will pull the voltage at the base of the right-middle NPN down towards ground, preventing it from activating.
brunoxyz's picture

makes a lot of sense now, I had the impression it was something like what you explained, but I couldn't really see it.

 

thanks once more! lets see how this goes.

TeleFox's picture

I strongly recommend you avoid turning both inputs on at the same time - doing so will switch on the middle 2 NPNs, which in turn will switch on the other 4 transistors, creating a short between the upper and lower transistors on the left and right sides. Since there are no resistors or anything to limit the current, the short created will drain your batteries and/or destroy your transistors due to overcurrent.

If you're concerned you might accidentally set both inputs high through a glitch or coding error, you can add a basic diode to one/both side of the H-bridge that will 'lock out' one half of the bridge when the other half is activated, thus ensuring you can't get a short circuit condition.

brunoxyz's picture

thanks telefox, that's what I was afraid would happen, through a coding error or glitch.     let me see if I can figure out the diode problem without calling Huston :D 

brunoxyz's picture

thank you, that's good to know,,   I thought that it would create a short for sure, I tried to figure it out by looking at the diagram but transistors are still a bit confusing to me. need to research some more :)

 

I will be making small robots with small? motors for now.. like two 5.9v DC motors and a 9V or similar battery.  will those transistors handle that load?    I'll try to find a way to measure current consumption in google, as the motors only say the voltage.

 

 

ignoblegnome's picture

Well, since you have already tried your circuit out on a motor, you can just feel the transistors while they are running the motor. Are they getting hot? If so, you are overloading them. If not, they are probably fine.

Keep in mind your motor will work harder, and draw more current, when it is under load. However, if the transistors stay completely cool during testing, you will probably be OK.

Also, a 9V battery does not supply much current. You might be better off with 3 or 4 AA batteries.