H-Bridge Motor Control for DIY Servo

YG_H-Bridge1.jpg (20178Bytes)
YG_Servo_Controller1.jpg (12257Bytes)

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.

H-Bridge

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.

YG_Servo_Driver_003.jpg

YG_H-Bridge_01.jpg

(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? 

YG_Servo_Controller1.jpg

(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.

https://www.youtube.com/watch?v=6P3HSpfZHJs

After some more testing, I

After some more testing, I found that as soon as I connect the 6V batteries to the circuit, it drags the 16V supply down to 3-4V. I think I need a way to interface the two circuits. I’m thinking optoisolator.

Voltage drop

Without a circuit diagram it’s ahrd to figure out why your 16V drops to 3V. Seems to me this could be easily prevented with a clever diode somehwere.

OK, I added dagrams for the

OK, I added dagrams for the H-bridge and servo controller. To keep it simple, they are separate diagrams, but the inputs/outputs are labeled. The grounds of the two circuits are connected.

When power from the 6V battery is applied to the R/C receiver and servo, the 16V supply for the H-bridge drops down to about 3.4V. While I’m causing the motor to turn via the R/C transmitter, I monitored the voltage on one of the outputs of the servo board that is now driving the H-bridge. The voltage was a bit over 5V and the 16V supply goes up to about 10V.

You can see on the video that initially the multimeter is reading almost 16V, but after I connect the 6V battery you will see (at about 1 min 50 seconds) that the supply has been dragged down to between 3 and 4 volts. Then when I use the R/C transmitter you will see the supply voltage jump briefly up to about 10V

My thinking is that the 0-5V range of the servo board drag the supply down through the voltage drops of the transistors. When the servo outputs are at 0, the supply is dragged down to 3.4V. Turning the output high to drive the motor, the supply is not dragged down nearly as far.

This is why I’m considering an optoisolator. I can keep the power supplies and signal levels for the two circuits completely isolated.

Hmmm, study your bridge some more

I always find it much more educational to strip my circuit ad test it in all feasible modes. How about you remove the servo board and replace those signals with plain pullup (to 5V) / pulldown resistors. Measure your 16 V supply and make sure to also measure the current drawn.

My suspicion is that current (and lots of it) is flowing out the inputs, or at least somewhere in your bridge. Find the flow and you’ll find the flaw. What happens when you increase the 1k resistors to 10k or 100k? Does the current draw plummet? Proportionally?

Side note: An optoisolator is basically a photo transistor actuated by a built in led. You could probably use them to replace the input transistor (pn2222). If the isolator happens to be NPN.

Excellent points, rik and I

Excellent points, rik and I agree with your approach.  I already tested the motor with the H-bridge alone as you suggested before hooking it up to the servo board, and it works perfectly with no voltage drop and no jittering of the motor.

I will try adjusting the resistor values and see if that helps. Good thought. If not, it’s off to find some optocouplers!

I tried a quick test

I tried a quick test replacing the 1k resistors on the bases of the PN2222A transistors with 10k, 100k, and then 1M and measuring the voltage put out by the supply.

Increasing the resistor values did not seem to have an appreciable effect. The voltage still dropped to about 3.4V at the supply, and rose to around 10V when the motor was running.

I do agree that a lot of current is probably flowing into the inputs of the servo board. Since my bench power supply cannot support a lot of current, it is pulling the voltage down. If I was connected to my 24V battery, it might keep the voltage up, but I think I need to fix the current drain/voltage drop problem before moving forward.

I think my next step is the optcouplers. Thanks for the idea of using the output stage to replace the PN2222A transistors, I’ll try that. My only concern on using optocouplers is ensuring they are fast enough to respond to the output of the servo board. If they introduce a lot of delay, it could make steering sloppy or worsen my jitter problem instead of solving it.

According to your circuit

According to your circuit diagram the TIP127s are connected with the Collector and Emitter reversed, might want to double check that one =)

Good catch, TeleFox. I have

Good catch, TeleFox. I have corrected the diagram. Thankfully my circuit building is more accurate than my drawing. ; j

 Any thoughts on the cause of my problem?

Hmm, the only things I can

Hmm, the only things I can think of are that your power supply isn’t enough to handle the current drawn by your motor, or that there’s some shoot-through happening on one or both sides of the driver bridge.
Maybe you should disconnect the servo controller and test the driver with one input turned on to check that current is only flowing through the motor as it should.

Hmm, indeed. I don’t think

Hmm, indeed. I don’t think the h-bridge itself is the issue. I’ve already tested it in isolation and it seems to work fine.

In theory, I shouldn’t be getting any shoot through. Unless the servo board is trying to switch the motor between forward and backward so quickly that I’m briefly seeing both legs of the H turn on at the same time. That is something I had not considered. Is there any reason a servo controller board would apply +V to both motor leads at the same time?

I just had another thought. Maybe the servo electronics are so nicely matched to the motor they are designed to work with that it doesn’t work so well with another? I could try connecting the output of the H-bridge to the original servo motor. Like so:

Servo Controller (including internal h-bridge) -> External H-bridge -> Servo motor

Thanks for giving me some fuel for thought.

Can’t say I know too much

Can’t say I know too much about servo controller standards, but there’s a possibility both outputs would be active at the same time.
Do you have a logic analyser, oscilloscope, or anything similar you could use to check out the signals?

Unfortunately, no. I really

Unfortunately, no. I really would love to have an o-scope one day.

I’ll do some research on how servo controllers work. Maybe I’ll find some answers.

Research: potentiometer failure

I’m posting some of my reasearch here for my own reference. Hopefully it will be helpful to others as well.

The potentiometer is the feedback device and often the first thing to fail in servos. If it gets dirty, or the contacts get oxidized, the servo will fail to work properly, sometimes by “jittering or hunting” since the feedback is inaccurate, or turning completely to one side and drawing lots of current since the servo doesn’t know where its output shaft is pointing. More expensive servos have “sealed” potentiometers, cheaper ones do not. 

From PC in Control tutorial on Servo Control

 

Research: servo tuning

This could be my problem. The servo controller is not tuned for this motor, so the position is always slighly wrong. Consequently the motor twitches because the controller is trying to correct the position slightly.

There are three different factors to set when tuning the servo motor: its called a PID algorithm, or something like that. This is an acronym for Proportional, Integral, and Derivative gain. You might try googling PID loop and check out some of the articles that come up.

By carefully adjusting each of these three parameters, you can observe the effect that this has on the controller’s control of the servo motor.

The “I” and “D” factors control the resetting and damping of the controller servo loop. It helps to “calm down” the harshest responses that are technically possible, as the controller monitors the encoder position and tries to make it obey the “prime directive”, which is always to have a difference of zero between the commanded and actual encoder position.

Imagine an example: the encoder is only one count off of commanded position: should the controller command a huge current to move the motor that last count, or should it be a small current? It depends on the load. That’s why the tuning has to be done in real life, on the real load, so that it can be judged when the controller response is adequately proportioned. This keeps the motor from getting into a “buzzy state” where it continuously overshoots both directions from zero, because the applied minimum correction is too large.

From CNCZone website forum question How do Servo Motors Work?

More Experimentation

After some further experimentation with the servo and h-bridge, I think I’m going to try a slightly different approach.

I tried running the original servo motor, but with my H-bridge circuit in between. My thought was that the servo controller was tuned for this motor. Unfortunately, I saw similar behavior to the other motor: too much jitter. 

Since my new 24V motor had arrived. I replaced the temporary gear motor I was using with the new 24V one. I had similar results. Actually, I think the jittering was even worse.

Now the coils for my new motor measure at 70 ohms. So I figure the stall current at various voltages:

  • @ 6V: 6 / 70 = 85.7 mA
  • @ 24V: 24 / 70 = 342.8 mA
  • @ 28V (maximum battery voltage): 28 / 70 =400 mA 

By comparison, the original motor from the servo has a coil measuring 17 ohms:

  • @ 6V: 6 / 17 = 352.9 mA

Based on this, I decided it would be safe to try to drive the new motor directly from the servo controller, without my H-bridge in between.  The motor ran fine, but far too slowly. Since the motor is rated at 30 rpm at 24V, it is very slow at 6V. The good news is I learned the servo controller could drive this motor without jitter.

So I think I will abandon the idea of an H-bridge in between the servo controller and the motor. I had originally thought about placing some optocouplers in between the controller output and the H-bridge to eliminate any interference. Since I have already ordered the optocouplers, I think I will try using them to interface to the new motor, only with no H-bridge.

Servo controller -> Optocouplers -> High voltage transistor (possibly) -> Motor

My thinking is that with an open collector optocoupler, I can simply translate the output of the internal servo controller’s H-bridge to a higher voltage to drive the motor. As long as I can source 400 mA (the motor’s stall current at 28V), I think this may work. Hopefully the simplicity of this design will allow the servo controller to drive the new motor with enough speed and torque, and without introducing the jitter.

It is possible the jitter will return when I drive the motor at higher voltages. Only time will tell.

Optocoupler works…

the same as without them.

My optocouplers came in yesterday. I tried replacing the PN2222A transistors that drive the H-bridge in the schematic above with optocouplers. The good news, it works. The bad news, the motor still has a major case of the delirium tremens.

I may keep the optocouplers in the design, since I still haven’t tried the circuit at the nominal 24VDC from the batteries. However, jittery motor remains a problem. Grrrrr.

User Jerry asked via PM

User Jerry asked via PM about my H-Bridge. I thought I’d answer in the forums rather than directly.

Jerry asked:

Did you get the jitter out of the motor?  I am trying to hook up a motor
using this simple H-Bridge design, bought the parts, but it seems like
maybe I am missing something.  As I look closely at the photo of the
breadboard, I was wondering if the NPN 2222s are supposed to be reversed,
or maybe I have the wrong Tip connected.  I can not seem to get the motor
to reverse when I use my throttle control.
Looking for a suggestion.
Jerry

I’m still dealing with the jitter for now. But keep in mind this was an H-Bridge being fed by the electronics of a servo I tore apart. The servo already has an H-Bridge, but it won’t handle the voltage I want to drive this motor at. So I’m dealing with a servo PID algorithm designed for a different motor, driven through the original servo h-bridge, then driven through my own h-bridge. Not ideal.

If all you are trying to do is drive a motor with the h-bridge above, it should work fine with no jitter at all. See my comment above.

My advice is to double-check the datasheets for all of your transitors and be sure you have them all wired correctly. Then try setting one of the inputs to the h-bridge (the base of one 2222A transistor) high. Now use a multimeter and test what is happening. Did the 2222A transistor turn on? Is it triggering the PNP and NPN power transistors to turn on the motor in one direction? Verify each component is working.

H-Bridge

After further investigation, I did have the 2222s reversed.  I forgot the pin out is reversed from the bottom of the transistor

Thanks a lot.

Anyway, the great news is, it works perfectly with a 9 v battery I used for a supply for my motor.

I decided to increase the voltage so I got a 12v lawn/tractor battery.  That is my objective.  Then, the TIPs started smoking and got very  hot.  It really made the motor run as fast as I wanted, but after a few times, I think they fried because the circuit won’t work anymore even on the 9v battery I started with.

The motor only draws less than 200mA when put directly on the 12V battery.  It does not seem like that is too much.

Could you offer a suggestion?

 

H-Bridge

I forgot to mention.  I am using a servo motor output  like you have on the schematic to drive my motor.

My motor does not jitter but it is a DC brushed type, and like I said it works great on 9v.  Just not the supply I need