Shop OBEX P1 Docs P2 Docs Learn Events
Hbridge Confusion... — Parallax Forums

Hbridge Confusion...

Technic-R-CTechnic-R-C Posts: 117
edited 2010-07-26 17:37 in Propeller 1
Hello,

I'm wiring an hbridge to my propeller·but have come across a problem that I cannot resolve.· it makes absolutely no sense...

my hbridge circuit·is shown below

31232_1468221344739_1209732695_1295091_1001970_n.jpg

The problem is that when I send a high signal to transistors 1 and 3 (which makes the·motor move in one·direction)·then transistor #2 acts as if a signal was sent to·its base terminal·in effect shorting the collector and emmiter terminals.... I figured out why this short is occuring, it is because the collector terminals on 1 and 2 are connected, but this is how an hbridge is built which makes no sense. Either I am missing something big or don't understand what I am doing.

Any insight would be much appreciated

Thank you

Technic-R-C

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-18 23:09
    Look at the Wikipedia article on H-Bridges or other articles like www.dprg.org/tutorials/1998-04a/. You'll see the the upper transistors are PNP type while the lower transistors are NPN type. The Propeller or Stamp ground is connected to the (-) terminal of the battery and not to the emitters of the transistors. You need the diodes to protect the transistors, not the battery, from the back current from the motor.

    Depending on the motor battery voltage, you may need some further amplification for the transistor bases. You'll need to give more information.
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-19 00:25
    Thanks Mike,

    I read through the article and understand more about H-Bridges, esp. when it comes to differentiating between the NPN and PNP transistors.· However I still do not understand why transistor #2 in my circuit shorts the collector and emitter terminals when I never saturate the base pin???· How does connecting the collector pins (1 and 2)·turn on a transistor that has not yet been turned·on with a high signal to the base pin??· Shouldn't the collector and emitter pins ONLY short when the base pin gets a high signal?

    Technic-R-C
  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-19 01:23
    The problem with the circuit you've posted is that all the emitters are tied together and to the Stamp's Vss (ground). You haven't said whether the transistors are PNP or NPN or a mixture and that affects which ones are turned on by default.

    I can't answer your question for the incomplete circuit you've posted. Remember that NPN transistors normallly have the collector connected to a more positive potential than the emitter and will conduct when the base conducts current from a more positive potential relative to the emitter. For a PNP transistor, the collector has to be connected to a more negative potential than the emitter and will conduct when the base conducts current from a more negative potential relative to the emitter. In a proper H-bridge, the NPN transistors have their emitters connected to the negative power supply terminal while the PNP transistors have their emitters connected to the positive power supply terminal. The negative power supply terminal is usually considered ground because that's how the logic circuits are designed.
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-20 17:55
    Ok so initially all of the transistors I used in my circuit were NPN TIP31, however·I bought some TIP42 PNP transistors and made the following circuit below.

    BipolarHBridgeSchematic.gif

    I used an external power supply (9V battery) to power my motor.· I did as Mike suggested, connected the Propeller's ground directly to the battery's ground.· When I hooked everything up and had all the transistors recieving no signal, I checked and confirmed that the PNP transistors collector and emitter terminals were shorting for some reason.... I can't figure out why.· Any suggestions?

    Technic-R-C
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-07-20 18:48
    An NPN is "on" when its base is more positive than its emitter.· A PNP is "on" when its base is more negative (less positive) than its emitter.

    Q1 and Q4 must turn·On at the same time·and, not concomitantly, Q2 and·Q4 must be Off (and vice versa.)

    The PNP (in) should be pulled high and a NPN (in) should be pulled low, not be left to float.

    Why don't you try building one half of it, the Q1 and Q4 section/s?

    [noparse][[/noparse]No offence, but I think that you are in past your ken.]
  • T ChapT Chap Posts: 4,223
    edited 2010-07-20 18:52
    "When I hooked everything up and had all the transistors recieving no signal"

    Do you mean the inputs are floating?

    If I were you, I would start out simpler, get an NPN, put an ohm meter across E and C, hardwire the base to GND and see the result on the meter. Then hardwire the base to +V and see the result. Do the same with PNP, then you will get a better understanding of how the transistors and circuits should work before you start trying the more complex process of designing an Hbridge. If you are floating inputs, see what that reaction is also on the meter. When the microprocessor is not turned on or has no program or is in between turning on or changing programs, your inputs to the transistors will float, that is not good because you are going to be producing smoke after a while. You should figure out whether you need to pull up or down the base inputs with a higher value pullup/pulldown resistor like 10k or higher, to avoid problems when the bases are floating. Use the pullups connected directly to the base.

    Post Edited (T Chap) : 7/20/2010 7:03:40 PM GMT
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-20 19:57
    T Chap:

    I meant that all the transistor bases were recieving a low signal from the propeller.
    If I were you, I would start out simpler, get an NPN, put an ohm meter across E and C, hardwire the base to GND and see the result on the meter. Then hardwire the base to +V and see the result. Do the same with PNP, then you will get a better understanding of how the transistors and circuits should work before you start trying the more complex process of designing an Hbridge.· If you are floating inputs, see what that reaction is also on the meter. When the microprocessor is not turned on or has no program or is in between turning on or changing programs, your inputs to the transistors will float, that is not good because you are going to be producing smoke after a while. You should figure out whether you need to pull up or down the base inputs with a higher value pullup/pulldown resistor like 10k or higher, to avoid problems when the bases are floating. Use the pullups connected directly to the base.
    Thank you, my ohm meter isn't in the best working condition but I will give it a go.

    PJ Allen:· I did try one part of the circuit (only Q1 and Q4) and I was able to control the motor in one direction.· However immediatly when I hooked up the other two transistors the motor wouldn't budge.· In your previous post you mentioned that Q1 and Q4 must turn on at the same time, so·I set the propeller pins connected to the transistor bases (Q1 and Q4) high.

    What I don't understand is that you mentioned that:

    "A PNP is "on" when its base is more negative (less positive) than its emitter".

    How then would·I turn the PNP,·Q2,·"off" if the emitter (seeing 9.6 volts) is always more positive than the base (seeing 3.3 volts).· Wouldn't it be always "on" which explains why the collector and emitter terminals of Q2 are shorting no matter what signal (high or low) i send to Q2's base?

    Technic-R-C
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-07-20 20:57
    You must provide a LO to the PNP to turn it on·AND·a HI to the NPN to turn it on.·
    They cannot share the same I/O pin.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-07-20 21:34
    This thread might help ...

    http://forums.parallax.com/showthread.php?p=538764

    ..regardless if the I/O is even defined as an OUTPUT or an INPUT you will still have problems driving a HIGH-SIDE transistor when the supply voltage to the H-Bridge is higher than the I/O voltage can provide.

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

    IC Layout Engineer
    Parallax, Inc.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-20 23:00
    This reminds me a circuit I just made (a few days back). It is essentially an H-bridge controlled by 1 IO. It can handle almost any input voltage below the 555's limit (15V) and the current is limited only by the N-Channel MOSFETs (16A is readily available in tiny SMT packages).

    This is a bit more complicated than what you have, but it can do more, with less IOs.

    Of course there are always H-bridge ICs out there that will give you low IO count and low part count, but where is the education (?fun?) in that?

    Keep up the learning with the discrete components. Once you understand it, you can do all kinds of fun stuff. It also helps you understand the limitations of the hardware you are using. Just some advice, I didn't quite understand NPN/PNP thing for a while, you are dealing with voltage and amperage on the base. MOSFETs simplify that by only (for most purposes) caring about voltage on the gate. They waste less power, and allow more through, and they generate a significant amount less heat.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!

    Post Edited (Bobb Fwed) : 7/21/2010 12:56:26 AM GMT
    976 x 747 - 60K
  • FaubFaub Posts: 6
    edited 2010-07-21 00:00
    I am doing an RC tank project / research on the prop. I am going to build my own dc motor controller since my wheelchair motors pull a lot more amps than most small robotics motor controllers provide. I am looking at this IC that would do half (one side) of your H bridge. This takes care of the bootstrapping problem mentioned earlier. So it looks like i can just use this IC and put whatever size mosfets are best for my application. Depending on size your may or may not have to heat sink the mosfets. I am looking for something to drive IGBT's as I do industrial automation and happen to have a big supply of used IGBT's that can carry way more amps than I need.

    Mouser Part #: 511-L6393D
    Manufacturer Part #: L6393D
    Manufacturer: STMicroelectronics

    Hope this helps,

    Brian
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-23 21:01
    I think I almost have logic control of a PNP transistor figured out with all your folks help.· Basically first off, I need to place a high value resistor between the logic pin and base of the transistor, so the logic board (in this case a bs2px) can sink the current.·
    The next thing I need to do is place a resistor between the base and emitter so they assume a close potential and keep the transistor turned off when I send a high (5V) signal through the basic stamp pin.· I know I need to select the values of the resistor so that when the logic is high the base coltage is less than .5v lower than the emitter and when the logic is low it is more than .6v lower than the emitter.· But I do not know how to figure this value out? can somebody explain this to me please?· Schematic below.

    Edit: will·connecting the emitter and base pins with a resistor·ruin·the transistor?




    37575_1556104701768_1209732695_1515952_8012392_n.jpg

    Technic-R-C

    Post Edited (Technic-R-C) : 7/23/2010 9:11:49 PM GMT
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-23 21:18
    You can't do that quite so easily. The stamp (and pretty much every IC) has diodes that slough of anything higher than a fraction of a volt above the Vdd. So what will happen in the diagram you gave us is the resistors will always have power flowing through them. You would have to know precisely when the transistor starts conducting and what voltage (12V) would be supplied.

    I think a solution that is almost as simple, won't waste nearly as much power, and won't require quite so much precision is to put a NPN between the black resistor and the red one.

    Like this:
    attachment.php?attachmentid=71948

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
    876 x 381 - 30K
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-23 21:24
    Great, thank you Bobb!

    I will try it out now

    Technic-R-C
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-23 21:30
    If it were me, I would actually do this (below). You can drive a very high power motor with very little heat generated (thus little power lost).
    attachment.php?attachmentid=71949

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
    613 x 346 - 21K
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-23 21:51
    That one looks pretty good too.· What took place of the TIP42 PNP transistor? btw it does work and now onto building the full h-bridge.

    Technic-R-C
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-23 22:35
    It is a p-channel mosfet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-23 23:21
    The H-Bridge Works!!! however for some reason or another the motor is not getting enough current.. it seems that the Hbridge itself is limiting current to my motor which is rated at 12V and 3A max current pull.· Is the following h-bridge causing this??

    Another question: If i switched my Hbridge power supply to 16 volts would I have to change the resistor values?

    edit (don't mind the <6amps part, that was with 6 7812 regulators)

    38357_1556262225706_1209732695_1516424_17090_n.jpg

    Post Edited (Technic-R-C) : 7/23/2010 11:33:43 PM GMT
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-23 23:45
    I just spiced the NPN/PNP H-bridge...with lower value resistors (more current allowed) I can only get about 550mA across the coil.
    On the other hand, an identical H-Bridge built with MOSFETs will go to about 19A. I think that is the direction you need to go.

    With 16V input, you do not need to change anything. And you may get a slight boost in current, but probably not. Try changing the 1K resistor on Q1-Q4 to a 520 or less. That may help you some.

    What are those transistors rated for current-wise?

    EDIT: it is most likely the Q1 and Q4 transistors that are limiting you. The PNP transistors get a good amount of current on the base because of the higher voltage, but the NPN on Q1 and Q4 are getting the same resistance with a lower voltage, thus less power is allowed to flow.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!

    Post Edited (Bobb Fwed) : 7/23/2010 11:52:41 PM GMT
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-23 23:50
    Uh oh, so basically in my current configuration the motor is seeing only about 550mA of current?· If this is the case then I will definately be needing to switch over to mosfets... is there anything else besides mosfets that would make this current setup work?

    All of the transistors, TIP31 and TIP42, are rated for 10A continuous current.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-23 23:54
    It really depends on the gain of those transistors, but somewhere around there. Lowering the resistance on the base will help you get closer to your goal, but at some point you will be sinking more power than the IOs are allowed to handle. And you will likely hit that before you hit 3A.

    With MOSFETs you will be drawing less than 1mA on all your IOs and you will have the option to power much more powerful motors than your 3A one.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-23 23:59
    Try this first, this won't put you over your limit as long as each transistor is powered by a separate IO. If you put a 100-ohm resistor on Q1 and Q3, and a 220-ohm resistor on Q2 and Q4. This will get you darn close to 3A, and push you right up against your 40mA limit on the IOs (that's what it is on BS2s right?). Pushing the limit the rating of parts is never a great idea, but it should work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-24 00:06
    Talk about pushing it to the limit,·but that would most definately work. However, I have switched on over back to the propeller.· Can I try out these values with the prop?

    From the manual the:· Current Source/Sink per 8 pins is 100 mA

    So I can afford to use even smaller resistor values I believe.

    Real quick math overview:

    Wouldn't 4 I/O pins connected to 100 and 220 ohm resistors give you:

    V = IR

    5v / 100 ohms = 0.05 Amps * 2 = .1A
    5V / 220 ohms =·0.02 Amps·* 2 = 0.045A
    added together gives you .1045amps aka 104.5mA which is way to much. Is this correct?

    Post Edited (Technic-R-C) : 7/24/2010 12:24:57 AM GMT
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-24 00:33
    No matter what you do, using the BJT transistors will push the limits. The math is a little off. First of all, the Propeller runs at 3.3V. Second, there is a threshold voltage that the transistors won't conduct at. I think they are usually around 0.6V. So if we do this: 3.3V - 0.6V = 2.7V / 100-ohms = 0.027A * 4 = 0.108. Or to be safe, you could do three I/Os which would put you at 81mA into the bases. This is probably about enough to get you to over 3A.

    If you added a second transistor (an NPN as a darlington pair, or a PNP --it has a name, but I can't remember what--) to the Q1 and Q3, you could increase the limit without stressing the IOs.

    EDIT: I don't know why I didn't think of the darlington pair earlier...I guess I wanted to keep it simple. But a darlington pair with 2.2K resistor would allow the transistor to sink more than 6A.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!

    Post Edited (Bobb Fwed) : 7/24/2010 12:43:33 AM GMT
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-24 00:51
    My suggestions: darlington pair, better yet: MOSFETs
    Great place to mess with everything without purchasing parts: LTspice IV. It's not perfect, but it gets you really close. Usually the problem is that the program doesn't have the parts you have on hand.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
  • Technic-R-CTechnic-R-C Posts: 117
    edited 2010-07-24 01:24
    Ok, a lot of great suggestions that I will look into as soon as I get a chance.

    Thank you for all your help Bobb! I understand the concepts 100x more than I did when I initially started.

    Thanks again to everyone,

    Technic-R-C
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-07-26 17:37
    I was bored, so I made this in spice (attached). On the left you have your BJT setup, on the right you have the MOSFET setup.
    On both I am using just 1 I/O for each half of the H-bridge.

    BJT: I am controlling the PNP transistor's base current with NPN which is being controlled by R1 (no need for the resistor in between the NPN and PNP). At 3.3V, the controlling I/O will only need to source a maximum of 1.4mA (assuming your BJT's are the same as the default spice ones). Q2 and Q3 will have to be heatsinked to be able to dissipate the (minimum of) 36W of power going through them. R1 and R3 should be changed when the controlling voltages change (3.3V vs. 5V).

    MOSFET: This is my suggested circuit. It uses one less part than the BJT. No heatsinking is necessary if the ambient temperature is below 40C or so. At 3A there will only be 1.5W of power that will need dissipation. The MOSFETs I chose I use every day, they are rated for 3.4A and 2W. So this one SOIC part could be both your power FETs (but it would be better to split them up). Really, R5 should be a 1K or less. The higher value will cause the P-channel MOSFET to take a while to turn off, thus dissipating a lot of power while doing so. If you will be switching it on/off a lot (more than a couple times per second), put a 470 or less. This circuit would work for an I/O as low as 2.8V and as high as 20V. The I/O pin will only have to source 0.4mA (max).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
    1403 x 680 - 55K
Sign In or Register to comment.