NPN transistor to switch on and off a MOSFET - Page 1
Forum section: electronics / beginners

author: yash101
author_rank: Contributor
timestamp: May 02, 2015, 05:17:31 pm
content: We ordered our MOSFETs for our project, which requires an H-Bridge motor driver. Here's the datasheet:http://www.st.com/web/en/resource/technical/document/datasheet/DM00071594.pdf. They do not seem to turn on at 3.3v because they aren't TTL-rated.Because of this, I bought a bunch of NPN transistors (2N3904). I would like to know how I can use 3.3v to turn on the 2N3904 and use that to switch 12v to the MOSFET. The only parts I have available are a bunch of 2N3904s and 100k ohm resistors.

author: oPossum
author_rank: Super Contributor
timestamp: May 02, 2015, 05:40:05 pm
content: What you really need is a proper MOSFET driver like a TC4468 (and many others).http://ww1.microchip.com/downloads/en/DeviceDoc/21425b.pdfA discrete bipolar transistor driver is certainly possible, but will require quite a few parts and probably not perform as well.As a practical matter, it would also require some PNP transistors in addition to NPN. Using all NPN would be really ugly.

author: Zero999
author_rank: Super Contributor
timestamp: May 02, 2015, 06:08:58 pm
content: The easiest way to use a MOSFET driver IC.If you really want discrete, NPN only, try this.

author: oPossum
author_rank: Super Contributor
timestamp: May 02, 2015, 06:09:36 pm
content: I really don't recommend this...Resistors values must be close to what is show - 100k will not work!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 02, 2015, 06:19:45 pm
content: If you add PNPs to the mix,Better saturation towards +V, faster risetime, and better (and symmetrical) current output.Input can be a resistor divider (see above), or part of an extended circuit, like a differential amplifier or level shifter. Or you could use a 2N7000 and logic level input.If you're wasting all that current capacity with a 100 ohm gate resistor anyway, choice is hardly critical. Just drive it straight from the logic pin! (5V HC CMOS type logic is good for about 50-100 ohms output resistance as it is, so a little damping resistance is all that's needed to keep things quiet.)None of the above circuits will forcefully pull gate voltage to 0V (stopping around 0.7V), so I would not recommend using a "logic level" FET with them (which typically have Vgs(th) min around 0.8V).Tim

author: Zero999
author_rank: Super Contributor
timestamp: May 02, 2015, 06:32:14 pm
content: Quote from: oPossum on May 02, 2015, 06:09:36 pmIs that comment referring to my circuit? Yes, it will work with R1 = 100k but it'll slow things down. For more speed, add a capacitor (try 1nF) with 100R series resistor, in parallel with R1.

author: oPossum
author_rank: Super Contributor
timestamp: May 02, 2015, 06:36:22 pm
content: No, it was referring to the circuit I posted. Not enough base current if all those resistors where 100k. It would be horribly slow and weak.

author: Zero999
author_rank: Super Contributor
timestamp: May 02, 2015, 07:00:53 pm
content: A Schottky diode could be used for D1 to pull the gate nearer to 0V. I also added some more speed-up capacitors to help with turn-off time.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 02, 2015, 10:48:35 pm
content: 1n (C1) is pretty large for the amount of charge storage typical of something like 2N3904; I recall using more like 100-470pF like that. Excess doesn't really matter much, as long as you aren't trying to push it to crazy rep rates (i.e., >500kHz or so?).The series resistor (R4) isn't really necessary but can be used, and will be more desirable if the source has a wide swing (>5V?). If the source doesn't pull down very far itself (e.g., TTL, or CMOS with some load?), it's mandatory. Ideally, the source should be like 1.4V CMOS, and the charge/discharge current through R1 will be symmetrical. If the source is higher than that, then it should be effectively divided down to that, for the same reason.The "transistor with a pullup directly driving the next transistor base" (TR1-TR2, R2) is a nice motif and works particularly well. (You can make TTL logic this way, with few transistors, low thresholds, and quite reasonable speed!) R2 can be quite large, since it only ever needs to supply TR2 base current, and TR1's collector voltage hardly slews at all (it's clamped by the B-E). You'll notice by inspection that adding anything inbetween (i.e., C2-R5) can only slow it down (by making more voltage swing), not speed it up (well, maybe turn-off, very slightly, but not enough to matter).If you wanted to continue making "variations on a riff", you could, say...- Add a second TR2 that drives the output directly (not via schottky) -- true to-the-rail drive- Replace R3 with a PNP current source (faster, more steady rise)- Add an inverted and complementary TR2 (you'll need some extra inverters and logic hanging off TR1 to implement this), and replace R3 with an active PNP- Replace TR3/D1 with a complementary emitter follower (sacrifices some saturation voltage)- Go with the PNP pullup, but beef it up so it drives the output directly (but be careful that its switching is delayed just enough against TR2 so as to avoid shoot-through!)- Need more speed? Tack on more stages! You can take advantage of the voltage swing at the output, by driving a MOSFET pair (e.g., 2N7002 + BSS84 -- they're about as "complementary" as MOSFETs get). Then amplify *that* output with a complementary emitter follower. That looks likehttp://seventransistorlabs.com/Images/GD9.jpgandhttp://seventransistorlabs.com/Images/GD8.jpg. Chain more MOS stages, of tapered, increasing dimensions, to push it into the 1ns range!- Need more PSRR? Making a bootstrapped high side driver? Add differential drive, using mirrors, diff pairs, inverters, etc. Get really fancy and use differential pulse modulation (supposedly what's used in the HVIC types).The lovely thing about BJTs is there's so damn many things you can do with themTim

author: Yansi
author_rank: Super Contributor
timestamp: May 03, 2015, 11:15:33 am
content: They will not snap anything, the mosfet is avalanche rated - it will clamp the voltage like zener. But it is NOT recommended to use that as an excuse to not putting there a freewheeling diode.For PWM operation, proper frequency selection and use of the fw diode is mandatory!The PWM frequency can be chosen as fPWMmin >> Usupply / (4*Lmotor*Imotor*0,1)PS: This is not empirical formula. The only empirics here is that the motor current ripple should be lower than 10% of its rated current.

author: Zero999
author_rank: Super Contributor
timestamp: May 03, 2015, 03:29:12 pm
content: Here's a design which will be able to go very near 0V.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 03, 2015, 06:40:42 pm
content: Hmm, TR2 and TR3 bases in parallel is a bad idea, actually, even if the transistors are matched: as one saturates, it pulls Vbe lower (in effect, the B-C junction is being forward biased), which will tend to desaturate the other. Both in saturation, I think, would be kind of a see-saw situation, where it could be unstable towards one or the other leaving saturation. They might both be deep enough in saturation anyway, not to matter; I don't know offhand how strong this effect is.The solution, of course, is a modest series base resistor, maybe 100 ohms, for each base. This increases the collector swing on TR1, but not by too much.Speaking of additional protection:When MOSFETs die, they frequently "go out with a bang". That's the sound of plasma expanding and cracking the plastic case. Needless to say, the plasma unites all three terminals in an orgy of conduction. The gate typically gets connected to some fraction of the drain voltage.The best solution is beefy schottky diodes from GND to G to +12V, on the driver side of the gate resistor. (If the gate resistor blows out, it can be easily repaired; not so much the rest.)D-S avalanche is okay, once in a while, but it really screws up switching (free charge carriers -- transistor doesn't simply shut off after the event, it keeps conducting for a while). The continuous repetitive rating is very small, and should be considered incrementally damaging. If you're getting spikes, you should add a snubber circuit: this can be anything from an R+C, to an RCD snubber (dV/dt or peak clamp type), to more involved methods (quasi-resonant or switched energy-recovery types, etc.). The freewheeling diode (specifically for inductive loads where you want a buck converter behavior) is a natural.But mind that the diode must be placed as close to the transistor as possible, and the supply bypass capacitor must be similarly close to them. The AC ground return path from switching transistor to diode to capacitor is what counts. Very often you'll see people just throwing catch diodes on relays,at the relay coil, which iswrong. Fortunately, it doesn't matter for teeny little relays. You'll go through a lot of transistors, trying to do that with a big stinkin' motor!Tim

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 01:16:30 am
content: What are the diodes on some of those MOSFET schematic diagrams? I think mine has built-in diodes. Otherwise, I was able to spare a couple of TO-247 40A @ 170v high voltage schottky's from ST! They are humongous (http://www.st.com/web/en/resource/technical/document/datasheet/CD00067836.pdf)!I'm sure that the internal diodes in these MOSFETs should be enough! However, there's going to be a ton of momentum.I think it might be more feasible to program the craft so that it doesn't abruptly change directions but instead has a dead-zone timer where it is in brake mode.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 04, 2015, 03:25:27 am
content: So, you're doing motor control?That should always be continuous mode, done gradually to avoid sudden acceleration and breaking or burning of things, and preferably with a current mode controller (which gets you two things for free -- relative freedom from burning, and proportional torque control!). You NEVER want to just throw a motor across an H-bridge and wave your hands "it'll be OK"!Tim

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 04:23:41 am
content: Well I'm sorry about what what happened! I guess I can claim that extreme stupidity is one way to blow things up! It's a bad idea to suddenly switch directions on an H-Bridge especially with a lot of momentum. When I got my first motor driver to work, that's exactly what I did. It didn't go poof because there was no load. However, it got a bit hot!This makes me think! Maybe that might be why our robotics team keeps blowing up motor controllers every once in a while! They are force-air-cooled. However, when we suddenly switch the direction of the motor, voltage should be generated backwards. This voltage is very high and destructive!EMF is like that scary police dog. Obey it or it will come and bite you!

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 04:59:57 am
content: Quote from: Mechatrommer on May 04, 2015, 04:54:45 amIt couldn't be better statedI guess that could summarize when I pressed both buttons at the same time and got myself a blister when trying to rearrange the transistors

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 07:33:21 pm
content: I rebuilt my H-Bridge driver and got rid of the 2N3904 transistors.It kindaish works!The MOSFETs are getting extremely hot extremely quickly even when the motor is having no load and finished ramping. The motors are not getting even close to the expected speed. I have a sad feeling that there is some small short somewhere. Everything works perfectly when none of the buttons are pressed. The transistors are cool to the touch when nothing's active.I know, for sure that I'm not getting even close to the max power of these MOSFETs. They are rated for 80 volts and I'm running them at 12-14v.They are rated at 180A and I would be surprised if the motors were pulling more than an amp or two.Attached are a ton of pictures of everything electronic.Update:I cannot upload all the pictures to this board so I uploaded them to my server.http://cdn.devyashis.me/?path=%2FPictures%2FHBRIDGEIMG1

author: oPossum
author_rank: Super Contributor
timestamp: May 04, 2015, 07:41:33 pm
content: Quote from: yash101 on May 04, 2015, 07:33:21 pmHow are you driving it? The MOSFETs you are using need Vgs of at least 7 volts, preferably 9 to 12. See figure 7 in the spec sheet.

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 07:44:03 pm
content: I'm driving it off VCC which should be about 12v.

author: oPossum
author_rank: Super Contributor
timestamp: May 04, 2015, 07:48:35 pm
content: The high side MOSFETs would require at least 19 volts (12 + 7) assuming the drain is connected to 12 volts.

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 07:50:01 pm
content: Its an h bridge.I've gotten it to work in the past -- then it stopped working

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 07:50:01 pm
content: Its an h bridge.I've gotten it to work in the past -- then it stopped working.I rebuilt it.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 04, 2015, 07:52:04 pm
content: You need PMOS...Andmuchbetter layout! Even as breadboard goes, you aren't doing yourself any favors with long wires strewn about -- easily half a microhenry per connection -- just imagine how much voltage spike or oscillation takes place around switching edges, or on the gates because of natural instability!Tim

author: Zero999
author_rank: Super Contributor
timestamp: May 04, 2015, 07:55:55 pm
content: That breadboard won't be able to take more than a couple Amps anyway before melting.

author: oPossum
author_rank: Super Contributor
timestamp: May 04, 2015, 07:58:22 pm
content: With gate and drain both connected to +12V the MOSFET will turn on, but there will be several volts across the source and drain. This will make a TO220 without a heatsink get hot even at a few hundred mA.If you are going to use all N channel, then you must have a higher voltage supply for the gate drive of the high side MOSFETs.

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 09:22:04 pm
content: Here's the schematic I followed (attached).I can't seem to find what's wrong! I know it works because I have gotten it to work beautifully. It before got the motor to full speed and was cool to the touch.I'm sure that I won't need a heat sink for such a small load! It's gotten an internal resistance of like 0.0025 ohms! That's less than the jumper wires' resistance.The problem I have is wiring somewhere. Currently, I could care less of inductance because it's not even running high frequency! It's merely, press one button, forward, other -- backwards. Or if you want, both buttons -> self destruct.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 05, 2015, 12:25:52 am
content: The high side gates have to be driven to (V+) + Vgs(on).Tim

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 12:28:57 am
content: Quote from: T3sl4co1l on May 05, 2015, 12:25:52 amI know. The push buttons in my breadboarded circuit are connected to +12v (VCC) or the drain on the upper transistors. The gates of all the MOSFETs are pulled low using 100k resistors (as suggested by my DE teacher).

author: Monkeh
author_rank: Super Contributor
timestamp: May 05, 2015, 01:09:33 am
content: Quote from: yash101 on May 05, 2015, 12:28:57 amYour supply is 12V, and your FETs require Vgs 10V to switch on fully. That is the gate being 10V above the source.How can your Vgs be 10V on the high side FET if you're only applying 12V?

author: Monkeh
author_rank: Super Contributor
timestamp: May 05, 2015, 02:18:06 am
content: Quote from: Mechatrommer on May 05, 2015, 02:16:53 amI was hoping he might have some neurons fire.It's already been said pretty plainly on the last page.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 02:26:27 am
content: I'm sorry, I'm unable to understand what issue you are seeing. I am feeding in between 12 and 14v to the gate, so I'm sure that it is saturating.I think I may have possibly worked out a solution. Basically, I'm now using an NPN transistor set up in the following way:The collector is connected to VCC. The base is connected to the source via a 100k resistor (which can be omitted). The emitter is connected to ground via a 100k resistor. Before the resistor, connected to the emitter, the Vout pin exists.I've attached the schematic below.Before I build this, please, someone, let me know if this will work!.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 02:27:35 am
content: Quote from: Monkeh on May 05, 2015, 02:18:06 amYeah. I understand what you are saying, but I can't change my power source. I need to do something else!

author: Monkeh
author_rank: Super Contributor
timestamp: May 05, 2015, 02:30:04 am
content: Quote from: yash101 on May 05, 2015, 02:26:27 amThe gate must be 10Vabove the source. If the FET is fully on, the drain is at the same potential as the source,12V. You must feed a voltagegreaterthan present at the drain pin into the gate of an N-channel FET on the high side.Quote from: yash101 on May 05, 2015, 02:27:35 amUse a FET driver capable of taking the gate above the drain, or use a P-channel FET.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 02:32:47 am
content: My project is due in this week so all I have to work with is what I have currently. After the due date, I can pursue it further and improve it.Currently, my goal is to get it to work with the least resources possible.I would preferably be able to build the H-Bridge with my MOSFETs and NPN transistors.I don't have an easy source for PNP transistors and I'm already exceeding my budget.I'm sorry if you think I'm just ignoring what you are saying. I'm not. It's just the problem that it's too late for me to do that. I designed this H-Bridge driver from my electronics experience from when I was young and had time. I CADed everything and then ordered all the parts together. Something might look perfect on paper but not work in real practice.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 02:40:35 am
content: The battery would take another week to arrive.We would need to change out our motors for 24 volt ones.We would need to change our control logic voltage regulators because they are currently tiny LDO chips; they would die at that voltage.Adding another battery is simply not a solution. Not to say, these high quality, high-discharge (65C) LiPos are quite expensive!This is only practical after my project is over, if I choose to spend time and improve it. I would need to start a new fundraiser, which would be successful due to an actual physical prototype as well as experience from what we are currently facing.

author: Monkeh
author_rank: Super Contributor
timestamp: May 05, 2015, 02:44:32 am
content: Quote from: yash101 on May 05, 2015, 02:40:35 amIf you change your motors for 24V, and supply 24V to the drain pin, where does that leave your gate voltage?QuoteUse a 9V battery over the existing one. Hey presto, you're probably enough above the source to get away with it.Got a 555? Build a charge pump. Probably take similar area with rough construction.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 02:47:32 am
content: Monkeh, that charge pump idea is actually one I'm considering. It's quite complicated for something so simple, but I have a bunch of 555 chips and the current requirement is quite low!We are using a pretty high quality LiPo from HobbyKing. It would be difficult to source something that can output almost 150 amps continuous that small!Also, why do I need that? I've gotten my circuit to work. I'm just wondering why it isn't working now! When I got it working perfectly, the MOSFETs were fully saturating and running cold. The motor was running at close to full speed at the voltage being provided.UPDATE:Maybe I should read a bit slower"GATES"A charge pump seems pretty simple to make. I attached a schematic to make sure it's right!

author: Monkeh
author_rank: Super Contributor
timestamp: May 05, 2015, 02:54:48 am
content: Quote from: yash101 on May 05, 2015, 02:47:32 amYou don't need to put out 150A, you're only charging the gate of a FET! A 9V battery would do the trick.QuoteBecause the gate must be raised above the source.. If the FET were fully turned on, the source pin would beat 12V. An unloaded motor might well get up to speed despite a partially turned on high side FET. Load it down and you'll have a lot of smoke in short order.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 02:57:01 am
content: "You don't need to put out 150A, you're only charging the gate of a FET!"I got that. Now I see what you are trying to say. It seems like quite a simple change! Thanks, guys!Now, my new question is how to wire that up? I've never done that.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 05, 2015, 03:01:40 am
content: Also, be extremely careful that the gates of a common side aren't turned on at the same time (i.e., both left transistors, or both right transistors). Add some delay, 100ns minimum. You might have very low resistance transistors, but if they touch any teensy little bit, RIP your power supply (and probably the transistors with it).The pulses overlapping is kind of like this, so don't do it.http://roflposters.com/wp-content/uploads/2013/02/1212811803369.jpg.rofl.posters.jpgTim

author: Monkeh
author_rank: Super Contributor
timestamp: May 05, 2015, 03:05:04 am
content: Quote from: yash101 on May 05, 2015, 02:57:01 amIn series. Negative terminal of the 9V to positive of your main battery, positive of the 9V to your gate drive. This will net you 8-9V above the main battery, which should adequately turn the FET on.And as above, make damned sure you never end up with both transistors on a side turned on with a battery like that. Small wires become explosive fuses.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 03:07:49 am
content: Yeah! I remember when I was playing with my initial iteration of this H-Bridge. It worked really well. It became really hot when I pressed both buttons simultaneously to see what happens. I did have some current limiting so nothing died, but it was fungerous

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 03:59:14 am
content: I came across this article:http://www.neufeld.newton.ks.us/electronics/?p=133I think that transistor is acting like an invertor. That means that when the circuit is turned on, everthing will be shorted out until the microcontroller can bring the input high.To fix that issue, I could use a typical hex invertor. The fix will be really simplistic.I guess that I should place either the charge pump or 9v battery between +12v and that 10k resistor.Do you guys think I'm heading in the right direction now?

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2015, 08:18:59 am
content: Quote from: yash101 on May 05, 2015, 02:26:27 amAll voltages are relative.The MOSFET will not conduct until its threshold voltage is exceeded.A BJT will not turn on until the voltage between the base and emitter exceed 0.6VIf the voltage on the MOSFET's source needs to be 12V relative to 0V, then the gate voltage needs to be 12V plus the gate-source voltage required for it to pass the desired current.Attached is an estimate of the voltages in your circuit.

author: yash101
author_rank: Contributor
timestamp: May 05, 2015, 11:04:06 pm
content: Thanks! Do you use DipTrace? It looks like you completely redid that schematic! Thanks for the time!I am going to use the suggestion which includes the 9V battery.Do you by chance have a schematic for an all-N-Channel H-Bridge which possible won't need that?Also, for my future reference, should I not use a MOSFET? I don't know if a BJT can handle high current without getting hot.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 06, 2015, 12:28:06 am
content: You need a bootstrap gate driver, or a higher supply like the charge pump circuits shown earlier.See how this uses +18V supply on the logic side, to drive only +12V in the all-N-channel bridge:http://seventransistorlabs.com/PWM_Generator.pdfNote that no time delay is provided, so the supply will be shorted out briefly during switching. This was OK because the application had a current limited or constant current supply (simulated by the 1 ohm resistor).Tim

author: yash101
author_rank: Contributor
timestamp: May 06, 2015, 12:30:42 am
content: Thank You. I just rebuilt my H-Bridge driver. It works cool to the touch with a 6 amp inductive load. As you guys have mentioned, it's not a very good idea. This is just for a display model at the moment. I'll be fixing the parts which you all are saying may not work properly.Again, Thanks for all the time, guys!

author: yash101
author_rank: Contributor
timestamp: May 07, 2015, 01:29:24 am
content: I got some good P-Channel MOSFETs to use for the high side. Now, the circuit is working fantastically. It's taking 40A without much of an issue. There is no heat sink on the MOSFETs and they are connected to a loaded motor. The MOSFETs are barely warm after 30 seconds of use! I guess I could afford to use a small heat sink, just to be on the safe side!