Shop OBEX P1 Docs P2 Docs Learn Events
H-Bridge & prop questions — Parallax Forums

H-Bridge & prop questions

TrezitorulTrezitorul Posts: 68
edited 2008-03-23 05:54 in Robotics
I am currently working on my first robot. It is simply a hacked toy car with differential drive and am in the process of building an H-Bridge. The problem is that the motors stall even with no load? A turn of the motor by hand gets it started but even then it is really slow. I am using radio shack transistors to build the H-Bridge(serial number 2N4401052) and the propeller chip for control any suggestions would be appreciated.

Comments

  • ercoerco Posts: 20,256
    edited 2008-03-19 02:22
    The 2N4401 a bad transistor for use in an H-bridge; you're losing at least 0.5 volts per conducting transistor, so you're losing a volt or more. Your choices are:

    1) Increase your supply voltage (more batteries)
    2) Change to low-loss MOSFETs or equivalent
    3) Use two SPDT relays like Radio Shack 275-240

    I prefer to use relays in my Basic Stamp projects. They're bulletproof, zero loss, and you can switch them perfectly with the 2N4401 transistor you're using (or the Shack's bulk pack of NPN transistors). Additionally, you'll get dynamic braking for free when you switch your relays off, so your drive wheels will STOP instead of spooling down slowly. Keep the relays on the opposite side of the circuit board·from your Prop chip, use filter caps, and put a spike diode across each relay coil, and you can run everything (motors, too) from a single supply.

    Post Edited (erco) : 3/19/2008 6:16:45 AM GMT
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-19 04:10
    I figured out why it has to do with the power supply I was using(9V battery) it just was not producing the amps I needed. So I switched over to 4 D size batteries. Now I am having fun toasting transistors. Is there any reason the transistors only fry on the negative part of the H-Bridge(after the motor lower part of bridge). The upper part works just fine. Any reasons for this and anything I can do to prevent more burns, magic smoke, etc. Right now I am just using transistors with a 6V input for testing and no resistors or diodes.

    Thank you for the information on the transistors erco.

    Post Edited (Trezitorul) : 3/19/2008 4:16:09 AM GMT
  • ercoerco Posts: 20,256
    edited 2008-03-19 06:22
    Yep, 9-volt batteries won't power a motor well, no current capacity there. If you're smoking those little transistors, use·a trusty TIP31 NPN power transistor (even the Shack has 'em). They'll get warm, so heat sink them if they get·too hot to touch. Not sure why you're only burning one. Post a circuit diagram and someone here will figure it out. Cheers.
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-19 06:39
    Well I think I figured out why only one transistor was burning idea.gif . I believe that I installed some of my transistors in backwards. Is that even possible? Well now I have half the H-bridge working just fine but the Bridge will not respond to the small signal the propeller is giving(3.3 V) so I had to use my 9V battery with a transistor to amp the signal to power the motors. Now that I have installed the transistors the right way they seem to be doing much better. What are the rules on transistors for hook up. I know it has a base, emitter, and collector but how do I know where each pin goes. I know that the center pin on my transistors is the signal pin but that is about it. I theorized that they were reversible because they simply open and close but this is not the case. Here is a diagram of the setup that successfully fried transistors(note the transistor shown might have been reversed in reality). I was just testing part of the H-Bridge so the diagram is incomplete. My current setup is also attached it works though the transistors do get kind of hot but not too bad.It is also half an H-Bridge. Pardon the awful drawings.

    Sorry the transistor part number I gave you was only partially correct for some reason radio shack included 2N3904 transistors and 2N2220 transistors in the pack I got.

    Post Edited (Trezitorul) : 3/19/2008 7:07:08 AM GMT
  • ercoerco Posts: 20,256
    edited 2008-03-19 15:38
    No bias resistors? Always put at least a 220 or 330 ohm resistor on the base. Sounds like you need a primer. See http://www.rason.org/Projects/transwit/transwit.htm for starters.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-20 03:30
    Well I put a 220 resistor on my pnp transistor(3906) and the transistor works a bit then heats up and melts. Any suggestions would be appreciated. The motor has a resistance of .007 Kohms and the base voltage is 3.3 with a 220 ohm resistor on it. The incoming power is 6V.

    Post Edited (Trezitorul) : 3/20/2008 4:16:19 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-20 03:39
    Main suggestion is to read about H-bridges and understand first how they work. You can melt a lot of transistors otherwise. A neat, clear, and current schematic helps in conversations with others.

    Another good reference is the Wikipedia. Google search for "wiki h-bridge".
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-20 04:20
    Trezitorul,

    There are several things that you need to take into consideration to get the results that you are looking for. From my own experience, "trial by fire" is not always the best approach. First thing I would do, is determine how much current the motor requires. Does the motor have any kind of markings or anything that indicates at least an operating voltage of the motor? How many volts are you trying to drive the motor with? <-- Does it seem comfortable at that voltage when directly driven from your power supply? If so measure the resistance across the motor terminals with a meter without anything else connected to the motor. If you don't have a meter, I would suggest getting one. Meters are relatively cheap these days... nothing fancy, just voltage, resistance, etc. (a diode check would be a bonus in this case).

    To get a good Ball-park figure as to what kind of current your motor is demanding....

    Current = {Supply Voltage} / {Motor resistance}

    Do this and check back with us.


    I'm guessing that since the motors are from a "hacked toy car" they will be rated for 3V, 4.5V, 7.2V or 9V ...·· How many batteries (and what kind) did the toy car require?


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/20/2008 4:27:30 AM GMT
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-20 04:38
    The toy car had a 6V battery in it so I assumed it required 6V. Currently for the power supply I am using a 6V battery pack made of 4 D size batteries. When I took the measure of the resistance on the motor it turned out that the motor had a .006 K Ohm resistance so 6 ohms resistance then I ran ohms formula on it and got 6V/6 Ohms is equal to one amp that is being drawn by the motor.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-20 05:30
    Trezitorul,

    With 6V (assuming 4 cells) are you sure that the toy car did not use a center tap on the power supply to drive a HALF-BRIDGE instead of a full H-Bridge ? ...Actually 3V to the motor?

    Even so, 1Amp is too much for the 2n3906 (or 2n3904 counter part) to properly handle. You need to increase your transistor drive strength with a larger transistor. (...or smaller motor)

    As a rule of thumb, I usually double the current requirement when selecting the transistor. So I would be looking for something that can at least handle 2 Amps at my 6V supply.

    Also, you need to consider how much Gain (Hfe) the transistor has.· Typically for the 2n3906 and 2n3904 this is 200, but I have measured it as low as 20, and as high as 400. The Gain can be a bit
    tricky, but you need to be aware of it so that you can properly select the proper value for the current limiting resistor on the transistor Base connection. Always error on the lowest Hfe value.

    Suppose that the Hfe was 20 and you need to drive 2 Amps. The "Base" current drive would be the 2 Amps divided by the Hfe, SO the Base current drive would be 100mA. If you are using
    the Propeller or any of the Stamps, there is a problem.... The Propeller is only rated at a maximum of 50mA per pin.· The Stamps even less.

    Hmmm... what to do? You can find a transistor with a higher gain, or you can configure two transistors in a Darlington arrangement to "multiply" the gain of the two transistors. More on that later.
    There is also a potential problem of powering the H-Bridge with a different voltage level from the micro. In this case 3.3V for the Propeller vs. 6V for the motor. More on that later as well.

    Right now you need a transistor capable of delivering 2 Amps or more at 6V.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/20/2008 5:36:25 AM GMT
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-20 05:50
    Thank you for the suggestion on looking at the motor current. Sorry I did not do this earlier I guess I got a bit excited. Also I asked the people at radio shack if these transistors were good for a six volt motor and I got the A-okay from them. This was really my first time out in circuitry and I have learned a lot about motors, current, and transistors. Number one lesson always perform calculations before buying partstongue.gif Thankfully these were 16 cent transistors, excellent place to make a mistake.
    So when I read the specs I want to look at the Hfe or the current gain so I can select a good resistor. Also I want to make sure that the transistor is rated about double the current coming int to the collector so I can avoid burned fingers, melted plastic, and horrible smells. Now I just have to get the new transistors when I do get them I will post right away.

    If I am understanding correctly the transistors worked but I tried to force too much power through them and so they heated up and melted. Why does it matter which way you install the transistor since it simply turns on and off.

    I also do not believe it used Half bridges because the previous circuit had 8 transistors larger square transistors(2SD2166) along with two transistors for control also this toy car was an RC car capable of forwards and backwards motion. As for the center tap I have never encountered one and do not know what to look for.

    Post Edited (Trezitorul) : 3/20/2008 6:09:13 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-20 06:20
    Trezitorul,

    If you look at the datasheet for the 2SD2166, it is rated at 4A with a minimum Hfe of 120
    http://www.tranzistoare.ro/datasheets/166/240614_DS.pdf

    "the specs I want to look at the Hfe or the current gain so I can select a good resistor" sort of... You may not find it directly on the package, but if you Google the transistor number with the keyword "Datasheet" included, you can find the information easily.

    "Also I want to make sure that the transistor is rated about double the current" This is just a good rule of thumb.

    "also this toy car was an RC car capable of forwards and backwards motion." You can get forwards and backwards motion with a HALF-BRIDGE if the power supply is split.



    "If I am understanding correctly the transistors worked but I tried to force too much power through them and so they heated up and melted" -·Yes and No ... The motors required more power than·the transistors could deliver, and with an input to the Base of 3.3V (from Propeller) through a 220 Ohm resistor, you were only providing 15mA of Base current. (3.3V / 220Ohm = 15mA)· If the Hfe is only 20, then the transistor was only capable of providing 300mA to the motor. (15mA X 20 = 300mA)



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/20/2008 6:46:49 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-20 12:11
    "Why does it matter which way you install the transistor since it simply turns on and off"

    If you read a theoretical description of the way a transistor works, the emitter and collector of a transistor should be interchangable. In practice, a transistor is not built symmetrically. The specs for the transistor are based on the device being connected a particular way, so you have no idea (without testing it yourself) of the gain or other factors when it's connected in reverse.

    Some MOSFETs are built symmetrically and will actually function identically with the source and drain interchanged, but not all MOSFETS. Junction transistors are not built symmetrically.
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-20 16:20
    Is there any particular transistor that would be the best for this application that I could get locally at radio shack.

    I performed the calculation for minimum base current using the formula of load/hfe = min base current and with an hfe of 20 I got 50mA as the minimum base current. 300 mA would be more than enough to drive the transistors.

    Post Edited (Trezitorul) : 3/20/2008 4:39:07 PM GMT
  • ercoerco Posts: 20,256
    edited 2008-03-20 16:50
    Your original 6 volt toy had a working H-bridge with properly-rated switching transistors. Your best bet is to use that portion of the circuit. Find the 4 transistors that make up the H-bridge and study the electrical circuit board traces. Find the bases of those transistors, cut the connections to the rest of the circuit board, and attach your Prop outputs to those 4 bases through 220 ohm resistors.

    That's the great advantage of modifying an existing toy, much of the driver circuitry is already there.

    But if you still want to build your own H-bridge, use power transistors with heat sinks: TIP31 or TIP120 for NPN, TIP42 PNP, all at the Shack. See http://www.blogcadre.com/blog/jason_striegel/howto_make_a_robot_car_-_part_2_h-bridge_details_2005_11_10_23_18_10 for specifics.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-20 18:07
    Trezitorul,
    "I performed the calculation for minimum base current using the formula of load/hfe = min base current and with an hfe of 20 I got 50mA as the minimum base current. 300 mA would be more than enough to drive the transistors."
    Don't worry about the required base current right now, find a transistor capable of driving the right amount of current to your motor first.
    Erco·is correct, if you can, use the transistors already selected for the motor.· Depending on how comfortable you are with a soldering iron, you could even desolder the transistors from the toy and re-use them else ware.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-20 18:16
    I was thinking about doing this but unfortunately the H-Bridge part of the circuit is under a layer of white rubber that would be very messy to desolder this white rubber covers everything in that region including the base pin inputs and the circuit traces. Also the reason I am using this particular toy is because it does not work. It looks like the bridge is burned on this particular circuit. Sorry about my calculation I misinterpreted your results. If I understand correctly the gain is the amount that the transistor is amplifying off the base current?

    Post Edited (Trezitorul) : 3/20/2008 6:43:33 PM GMT
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-20 23:29
    I now have sufficiently rated transistors the TIP3055 for the NPN transistors and the TIP42 for the PNP transistors. They don't even heat up when running
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-21 05:46
    Trezitorul,

    H-Bridge Primer

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/21/2008 6:00:15 AM GMT
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-21 07:15
    I performed some simple tests and I found that when the base pin resistance was less than the emitter resistance the base pin would accept all of the power from the batteries. Now when the base pin had more resistance all the power went to the emitter.
    If my tests were correct then the transistors Q5 & Q6 would have to be rated to handle the same number of amps as is needed to saturate transistors Q1 & Q2. So my 3904's should do the job well enough

    Thank you so much for the primer. It all makes sense now. Your schematic with its arrangement of pnp transistors made me look them up further. I had always though that they were the same thing as npn transistors and had the same mode of operation. That you apply voltage and they allow current to pass thru them well I was wrong.

    So on the pnp transistors when they are on they ground thru the base providing they have resistance well more resistance than the emitteridea.gif


    Below are some simple circuits that I have built for testing these are my versions of how the two different types of transistors work.

    Post Edited (Trezitorul) : 3/21/2008 7:53:08 AM GMT
    720 x 450 - 25K
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-21 16:24
    Trezitorul,

    "If my tests were correct then the transistors Q5 & Q6 would have to be rated to handle the same number of amps as is needed to saturate transistors Q1 & Q2. So my 3904's should do the job well enough"

    That is correct... also keep in mind that Q5 and Q6 also need to saturate Q4 and Q3.

    "So on the pnp transistors when they are on they ground thru the base providing they have resistance well more resistance than the emitter"

    Transistors are current devices, within the operating range of the transistor, the voltage·remains fairly constant (about 0.6V).· This voltage exists across the B-E (Base-Emitter) junction and is the main reason you need a current limiting resistor in series with this location as to not exceed this voltage.· The current is then amplified across the C-E (Collector-Emitter) junction by a ratio of the·Hfe·value.

    In general the Emitter is·tied to the Source.· With NPN's the Source is the Ground connection, with PNP's the Source is the Voltage Supply connection.· The Collector is usually considered the drive and what connects to one side of the device you want to control.· The other side of the device you want to control·goes to the Voltage Supply connection·(with a NPN) or to the Ground connection (with a PNP).· The Base voltage potential of the transistor needs to be less than the Emitter potential·if it is a PNP by about 0.6V, and greater than the Emitter potential if it is a NPN by about 0.6V·to turn "ON" the transistor,·otherwise the transistor is considered "OFF".










    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/21/2008 6:08:43 PM GMT
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-21 17:49
    My calculations for my setup; which has a 6V power supply and my transistors have a hfe of 20 and the motors need one amp to operate.

    From my calculations I am planning to get.

    a pack of 84 ohm resistors for R1&R2 or close to this value
    a pack of 840 ohm resistors for R3&R4 or close to this value
    Some more TIP3055 and TIP42 transistors.
    Attached is the schematic with all of the parts labeled verification would be greatly appreciated.
    One question about the whole drive set up; will the two H-Bridges I will eventually have simply be connected in parallel to one power supply or will I have to split my battery pack in two or get another battery pack with each one going to a separate motor. I would prefer having 6V to each motor and having only one battery pack.

    Then with the propeller what is the best way to have it connected to a mobile power supply.

    Post Edited (Trezitorul) : 3/21/2008 6:08:36 PM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-21 20:06
    Trezitorul,

    You’re not figuring in any current overhead or buffering for R1 and R2.··Even though your transistors might be able to handle the current, if you don't supply an adequate drive, the transistors are at risk for operating in the linear region.· In some applications this is ok, in fact you design specifically around this operating range, but for a motor driver it is not where you want to be.

    Take your 1A stall current and double it at least... use 2A in the equation instead of 1A.· R1 and R2 become 42 Ohms· (A standard 47 Ohm resistor would be fine)

    For Q5 and Q6, since the hfe is 200 and the current needed to pass through Q5 and Q6 is 100mA (2A / 20 Hfe = 100mA) you need a Base drive current of only 0.5mA ... (100ma / 200 Hfe = 0.5mA)

    To deliver 0.5mA from a 3.3V I/O, R3 and R4 would need to be 4200 Ohms ... (3.3V - 1.2V)/0.5mA = 4200 Ohms ( A standard 3.9K or 4.7K resistor would be fine)


    Also.... to save a trip to Radio Shack... pick up two bridge rectifiers (Model: 276-1152· Catalog #: 276-1152 ) ... These will add protection to your transistors by reducing back-EMF spikes generated from your motor.·· Easy hookup... the "~" or AC inputs go to your motor, the "+" goes to the Supply Voltage positive (6V), and the "-" goes to GND or Vss.· This will direct any spike generated by the motor greater than 0.6V back into the power supply.

    BTW) in answer to your post.... you can use the same supply for more than one H-Bridge, as long as your supply can provide adequate power to both motors.

    i.e. a 4AH (Amp Hour) battery will provide 2 Hours of continuous use....· 4AH / (2Amps <- total motor current) = 2 Hours

    "Then with the propeller what is the best way to have it connected to a mobile power supply."
    You can use a·voltage regulator like that used in the Propeller Demo board (LM2937ET-3.3) to bring the 6V down·to 3.3V for the Propeller.
    ·




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/21/2008 8:18:44 PM GMT
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-22 15:31
    I have a demo board could I just find an old transformer cut the circular plug off and wire it into my battery supply.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-22 22:20
    Trezitorul,

    The words "old transformer" would definitely persuade me to find a "new" one with the correct voltage ratings... Power Supply

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-22 23:21
    Sorry that I was not clear but what I meant was can I simply cut the circular plug that goes into the propeller off a transformer and then wire the plug minus the transformer into my 6V battery supply safely. Then using the plug could I connect a 9V square battery to the wall wart female input on the propeller demo board rev c. Is there any danger in doing this.

    Post Edited (Trezitorul) : 3/23/2008 1:59:53 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-23 04:21
    Trezitorul,

    If you observe the proper polarity on the plug, then that solution should be fine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • TrezitorulTrezitorul Posts: 68
    edited 2008-03-23 04:49
    Since 9V batteries some times go over nine volts by .5 volt or more should I add a resistor to bring down the voltage below 9 volts before it reaches the prop or is the demo board capable of going over 9V by possibly up to one volt.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-03-23 05:54
    Trezitorul,

    I missed the part about the 9V battery in your last post... up until this point we had been taking 6V.· Using a 9V battery would not be an optimal power supply considering that a 9V battery only has about 450mAH of storage to begin with and your wasting a lot of that though the process of regulating the 9V down to 3.3V for the Propeller. Even a 4 pack (or 5 pack if using rechargeable batteries) of AA batteries would provide 2500mAH of storage capacity, and you would be closer to your target voltage of 3.3V which would end up wasting less energy in the long run.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
Sign In or Register to comment.