Let's Make Robots!

H-Bridge Motor Control for DIY Servo

I'm building a DIY servo for steering Yard Gnome. I'm testing some things out while I wait for the 24VDC 30 rpm 41 in-lbs gearmotor I ordered to arrive.

I'd like some advice on my controller.


I'm designing a fairly straightforward H-bridge like the one Weiss posted here. I'll be using two TIP127 PNP transistors and two TIP120 NPN transistors for the main H-bridge. For interacing to the drive signals, I'll using a pair of PN2222A NPN transistors, because I have a bunch of them. My test circuit right now is using 1N4004 diodes like in Weiss' design, but I will substitute some 3A 1N5402 transistors for the final implementation.

(click for larger image)

I have successfully tested the H-bridge running at 16VDC (the limit of my bench power supply) driven by 6V from 4xAA batteries.

I'm hoping this H-Bridge will have plenty of current handling capacity at the nominal 24VDC from the batteries to drive the motor mentioned above, I don't have the motor stall current specs, but I'll take some measurements when it arrives.

Servo Controller

My biggest question right now is how to drive the H-bridge above from the servo controller. I was planning to either buy a controller that is designed to work with a standard DC motor and potentiometer, or rip a controller out of an existing servo. The key point is that I need the high current and 24V capabilities of the H-bridge to interface between the motor and the servo controller. My question is, how do hook them up?

If I use a servo controller out of an existing servo, can I simply disconnect the servo's own motor, and use those leads to drive the H-bridge above? 

(click for larger image)

Update 2010-06-05

I decided to go ahead and try driving the H-bridge from a servo. It worked! I desoldered the servo motor and hooked the leads to the two input signals for the H-bridge. Now if I either manually move the potentiometer on the servo, or use my R/C controller to tell the servo to move, it drives the motor through my H-bridge.

However, when the motor is not moving, it continuously jitters. I'v'e tried slightly adjusting the servo potentiometer and using the trim controls on the R/C transmitter, but nothing helps. Maybe some capacitors on the driven motor will smooth things out.

I posted a video so you can see what I'm talking about.

YG_H-Bridge1.jpg24.55 KB
YG_Servo_Controller1.jpg14.87 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I know exactly what your problem is because I've done this exact thing already. The problem is with your servo outputs, ACTUALLY you can NOT directly connect your servo motor leads to your H-bridge. Here's why, if you connect the servo motor leads to an o-scope, you'll see that the pulses not only change polarity depending on the direction it needs to turn the motor, but at rest (when the pot exactly matches the PWM) it sits both motor leads outputs at 2.5 volts, NOT at ground. Now lets look at just one side of your H-bridge, and lets assume your driving it at just 5v, its got a PNP and NPN transister. The NPN is turned "on" when it gets anything above 0, the PNP is backwards, it is turned on with ANYTHING below 5, so, if you give your H-bridge 2.5 volts, BOTH the PNP and NPN are on at the same time! Thats a direct short to ground, no wonder you keep frying your power transisters! You need to connect the motor leads to a schmitt trigger or comparitor first to ensure that your h-bridge gets a control signal of exactly 0 or Vmot (24 in your case I think). Hope this helps!

Thanks for the comment. I appreciate the input, though this project is on near-permanent hold.

I hear what you are saying about the h-bridge design. Though the problem I experienced was merely jitter. I never had an issue with shorting the transistors to ground and frying them.

I was using a low current bench supply, which probably can't put out enough current to fry those power transistors. So it is possible that I was seeing the h-bridge short you describe, but never fried anything due to the current limitations of my supply. Had I been working with the two 12V DC batteries this driver was intended for, things may have been very different.

In any case, this is an abandoned design for the foreseeable future. 

I understand this thread is “permanently benched” but I would like to put this issue to rest  for other readers who stumble onto it (like I did :-)


Yeah, I see now the “fryed and smoking” issues were not your comments but others, it’s good you had a current limiting PowerSupply.


The jitter problem is because even when the motor is stopped, all 4 transistors are still turned on allowing all available current to flow around the motor, not through it. The jitter is actually the result of the 2 sides of the H-bridge passing the current unevenly (because they are pegged) and the resulting tiny variations in voltage cause the motor to twitch. LOL, I feel so strongly on this matter I even drew you a diagram. Please see it here: http://letsmakerobots.com/node/34692

Yeah, I agree the topic is worth discussing for posterity. Thanks for taking the time to put this together. I've re-posted your picture below for reference.
















I was not aware that the servo's control outputs (going into it's internal h-bridge) worked that way. Edit: I meant the servo's internal h-bridge output going to the motor. Duh.

Anyway, what you say makes sense. Some day I will get around to trying this out. I'm sure I'll need a big, honking sized servo one day for something!

Question: If I use a Schmitt trigger on the outputs, won't I run into a situation where I cannot really achieve the 'virtual zero' case you illustrate in your diagram?

Consider signal A in your top-left diagram. As the signal drops from 5V towards 2.5V, the hysteresis of the Schmitt trigger may keep the signal high, instead of allowing it to drop to zero.

Similarly, signal B will be approaching 2.5V from 0V. If it doesn't quite hit the threshold, the signal will never go high.

Even if signal A or B do hit their threshold, if one or the other does not, you will get unwanted results. Say in your 'Stopped' diagram (2nd from the right along the top), if signal A doesn't quite reach the Schmitt trigger threshold, it will stay high, and the servo motor will be turned on at half the normal voltage.

So I think you are on to something here, but the exact way to fix it may need some more thought. Maybe I can find a schematic for the h-bridge used in an actual hobby servo. The way they interface their h-bridge to the control circuit should already solve this problem.

Edit: Wait, maybe I get it. If I used a couple of comparitors, and set the threshold lower than 2.5V, let's say 2V, Then the outputs will either be 0 or 5V. If the inputs are both around 2.5V, I'll get both outputs at 5V. So I'd have to design a 'smoke proof' h-bridge for the final output stage. 

A comparator is a better choice here because it has a clear on/off point, but if you used a Schmitt trigger then it would need a very narrow hysteresis, so long as the drop out is till above 2.5 it would work the same. Either way, only the tops of square waves will trigger an output.


You don’t want the virtual zero, you only ever want to output a 0 or 5, so you really only care when the input signals are high, because the one that is high tells you which direction to turn, so when B is toggling between 2.5 and 0, you couldn’t care less, its not above 3 so leave it’s output at 0.


But turn the POT the other way will cause A and B to switch, now B goes between 2.5 and 5, so the output is 5, but now A is toggling between 0 and 2.5, but that’s not high enough so the output stays at 0.


I went ahead and made a video showing all these principals, please watch!


Have you had any luck with the servo and hbridge issues? I am having the same problem as you with my set up of two hbridges side by side controled by two servo . Did you go with the optocouplers? What was your solution?

Never got this working, and it's tabled for the long term.

ignoblegnome, you mentioned the pot in the servo controller. Have you thought about replacing it with a pair of resistors as they sometimes do when converting a servo to full rotation?

This would not help as I do need position feedback from the potentiometer.

Currently the motor in the servo case is not moving, so, neither is the pot. Could the pot be rotated slightly to get the servo board to think the servo is in the deadband?