Electronics > Electronics

[SOLVED] Switch positive and negative (Choosing/Building an H-bridge)

(1/4) > >>

    I'm designing a new setup for my son's HO train set. I've built the $50 robot, and want some more circuitry experience, so I'm including some automation. I wanted my son to be able to reach all points, so instead of setting up on a table, I'm putting it together on shelves along 2 walls of his room.

    My goal is to have the train reverse before it reaches the end of the track without any input to do so. I have my detection idea pretty solid. I always try to do things as inexpensive as possible, so I'm planning on using a photosensor, like those on the $50 robot, watching an LED on the opposite side of the track to detect when the train crosses track towards either end.

    When the train reaches this point, I want to power down the track over the course of about one second, wait about one second, then increase the power, but with opposite polarity on the tracks, so that the train takes off in the opposite direction.

    Before putting the concept down on paper, I thought I could pull off switching the polarity with a couple transistors, but when I started trying to build the circuit (on paper), I realized it would end up having to be an H-bridge, since the rails are essentially motor leads. (I don't have any experience with H-Bridges or transistors other than reading about them on this site and wikipedia when I got curious about controlling larger motors with an MCU)

    I thought that I simply needed to find an H-bridge online that could handle the 18V 25W circuit and receive the 5V gate voltage from my atmega328 board originally built for the $50 bot. However, after searching through Digikey for an hour or so, I'm not sure I know what I'm looking for anymore.

    Does anyone have any suggestions on finding a suitable H-Bridge for this project, or suggestions on any simpler path to take? I also thought of making the H-Bridge described by admin, but I run into the same kinds of confusion with looking for MOSFETS.

////////////BASICALLY THE END OF MY QUESTION, BUT I'M ADDING ADDITIONAL INFO BELOW.(Thank you and you're welcome, Soeren. :D ) ///////////

    Specifically, I now understand that Vgs is the voltage that would turn a MOSFET "on" all the way and get the smallest resistance, the gate to source voltage. I'm a little confused about Vdss though. I've seen the definition. It's the Voltage between drain and source. This makes sense in a circuit -in mine this would be 18V, right? But what does this mean in the specs of an H-Bridge or MOSFET: maximum, minimum, recommended voltage, or what? Can I use an H-bridge with 30V Vdss in the specs for my 18V circuit?

    Should I be looking for a motor controller, rather than an H-Bridge? I understand the idea of how an H-bridge works to control the voltage going to leads. What else does a motor controller do? I just looked them up and they seem to have varying numbers of pins, all more than an H-bridge though.

    Also, I really can't wrap my head around N-type, P-type, NPN, and PNP. What are the these?

    Thanks in advance for any info!


That's the only motor controller I've found on Digikey that I'm pretty absolutely sure would work for what I'm trying to do. They don't have any, but hopefully this can give someone an idea of where I'm going wrong/right.


These products are also confusing me. They would seem to work, until you get to the max power, which is not above 2.5W, but they all suggest higher voltages than I'm using, so the amperage is in the right range.

What is meant by "Voltage - Supply" and "Voltage - Load" on Digikey?  I'm guessing that "supply" is the gate voltage range and "load" is the voltage range of what is being controlled...?

Am I getting close? Even if I'm right about any of these working, please let me know. Even if I guess right, I won't know that I've guessed right, right?


So, this is what I would get if I didn't have the great members of Society of Robots to tell me exactly how wrong I am. So, how wrong am I?

First question - will an H bridge work for this application? Many HO trains run on AC power and just switching the two leads via an H bridge will do nothing.  Have you tried switching the wires manually to see if it will, in fact, run backwards?

Oh - back to your questions. An L298N should have enough poop to run your train and can be controlled via 5 volt logic from a micro controller.  Assuming an H bridge will work.

--- Quote ---Also, I really can't wrap my head around N-type, P-type, NPN, and PNP. What are the these?
--- End quote ---

Different ways the internals in a FET (N, P type) or bipolar transistor (NPN, PNP) are arranged.  The primary difference is wether you pull the gate/base high or low to turn the transistor on.

I agree with jkerns: Back when I had HO scale toys (30+ years ago) the command to switch direction was twisting the AC transformer all the way to the bottom, which sent a special voltage spike. The direction wasn't controlled by polarity.

If an H-bridge will work, the I suggest buying an existing motor controller on a circuit board, rather than trying to build your own from scratch. Pololu.com has several varieties with various levels of capability in voltage and current, you can find something reasonably priced that does 18V 2A -- again, assuming you're talking about DC here.

Then it comes to finding parts on Digi-Key, most motor controllers do not do the actual switching of the current themselves; instead, they are intended to drive four MOSFET transistors that actually implement the H-bridge. The controller chip takes care of things like preventing cross-conduction, charging the gate for high-side N-channel MOSFETs, etc.

PNP and NPN are bipolar transistors. These let a amount of current through their collector/emitter junction proportional to the amount of current they let through the base. What proportion that is is measured through the hFE of the transistor. For high-current transistors, it may be as low as 10x. For signal transistors, it's often 100x. So, to let 2A through a bipolar power transistor, you may need to let 200 mA through the base. This is both hard to do from a microcontroller (where allowable currents are in the 2-20 mA range) and pretty wasteful. To drive 200 mA through the base, you will want a buffering transistor that takes 2 mA in and lets 200 mA through.

N-channel and P-channel are MOSFET transistors. These let current through their drain/source junction proportional to the charge at the gate. Actually, the proportional range is very small -- typically, these are either considered "on" or "off." An N-channel needs a voltage higher at the gate than at the source; a P-channel needs a voltage lower at the gate than the source. There are "logic level" MOSFETs that work fine with + (or -) 5V; however, really high-power MOSFETs will want 10 V differential to perform well. MOSFETs also work as a diode in the reverse direction; they will always conduct (but with a diode voltage drop) in the reverse direction. Once switched "on" by charging a gate, a MOSFET will draw very little current on the gate, and the conduction resistance will be very small for a power MOSFET, so they won't heat up very much. The problem is that the resistance is higher in the "transition" region, which means if you stay in the transition region (not fully charging the gate) for too long, it will develop too much heat, and blow up. Thus, you typically use buffer transistors or MOSFET gate driver chips. Motor controllers are a special form of MOSFET gate driver chips.


[0] Message Index

[#] Next page

Go to full version