Instructables

P-Channel MOSFET woes - anyone know how to drive one of these things with Arduino?

Hi all, I’m a hobbyist trying to build a digital controller / power monitor for a green power generator project built from an auto alternator. Hoping to use an arduino microprocessor & some simple transistor circuits to power an alternator’s field coil which at 13v can draw up to 10amps of power. From what I’ve read I think I need high side PWM switching because the alternator shares a common ground with its other electrical connections preventing me from using my usual novice NPN based bag-of-tricks. From my reading I assume some sort of PNP or P-Channel MOSFET is in order (components I sadly have no prior experience with). Alternativly I've read about using fancy high side controller ICs to drive regular NPNs but don't want to go that route.

So far everything seems to work except I clearly can’t figure this P-channel MOSFET out (IRF6540)!  No matter what I try I always get a high voltage at the drain pin (full-on condition) regardless of what I do to the gate pin. I uploaded a portion of my schematic as a test circuit I think should work from my limited understanding and online tutorials: http://www.curtismasonjohnson.com/sandbox/ProblemCircuit.JPG
  - The NPN driver in the drawing (2N3904) by itself works when tested with a voltmeter and toggling the input
  - If I replace the p-channel mosfet with a PNP transistor it work as expected. Shouldn’t this mosfet work pretty much the same? My puny TIP127 PNP can't handle the current if I were to hook up the load.
  - I’ve tried several IRF6540 components
  - I’ve tried connecting the MOSFET’s ground pin via a current limiting resistor directly to ground. Also via the resistor to 13v. No voltage change on the drain pin in either case.

Clearly I’m missing something embarrassing and fundamental. I mentioned I’m a hobbiest, right - my day job is managing global marketing programs for fortune 500s and don't know anyone that knows anything about electronics! After years of electronics & robotics projects I’ve yet to be stumped to the point of needing help til now - amazing how much you can self-teach via google and such. This one has me beat – hope someone can help as I have no idea what to do next! Truely appreciated...

Picture of P-Channel MOSFET woes - anyone know how to drive one of these things with Arduino?
Full curcuit so far - work in progress.JPG
The NPN transistor is wired backwards !

I'd like to see a resistor in the base of the NPN too, to stop you punching a hole in it

Connect the emitter to ground. put the resistor from +12 to the collector, connect the collector to the gate of the MOSFET. Field wiring is JUST like a solenoid, you HAVE to put a diode across it to freewheel the current when the mosfet's off.

Put a 10K resistor from 12V to the gate.

...on reflection, make that 10K 100K.
cmjstealth (author)  steveastrouk1 year ago
Woops - yeah my schematic was wrong (I keep forgetting what part of the symbol is the collector vs emmitter). Luckily I've been connecting the NPN properly on my breadboard, however (like I said the NPN part has always seemed to work when testing with a multimeter). I've been essentially trying to follow this circuit I found on http://digital-diy.com/general-electronics/67-tip-logic-level-fets-p-channel.html (also added as picture here).

To simplify, however: Even if I set aside everything except just the MOSFET with:
     - the emmitter connected directly to 13v
     - a 10k resistor connecting the base to 13V
     - no load

I still get 13v at the collector when read with a multimeter. Is there a reason this is happening? Shouldn't I get 0v in this condition?

And yeah, interesting you note the blocking diode. While I have actually been using one like you suggest out of fear (my original schematic sucked apparently) I've read a few places that it isn't nessisary for MOSFETs because they act as diodes themselves. Is this true? Seems like I always find conflicting info on that point. The field coil certainly behaves like a pretty massive inductor like you point out.
P-Channel%20FET.gif
cmjstealth (author)  cmjstealth1 year ago
On reflection... I also tried the following: I set aside everything except just the MOSFET with:
- the emmitter connected directly to 13v
- base connected to 13v with a 100k resistor like I belive you were suggesting
- small load on collector (used a 2k resistor to ground)

Still get 13v at the collector when read with a multimeter. Is there a reason this is happening? Shouldn't I get 0v in this condition?
Got a load on it ? No load - no voltage drop.
cmjstealth (author)  steveastrouk1 year ago
I tried connecting one of my MOSFETs the field coil and it didn't work (ie: delivered lots of power to the field but wouldn't turn off). The MOSFET I used, however, I had earlier in frustration tried connecting the gate directly to gound without a current limited resistor - later wondered if this could have burned it out.

Also tried a fresh MOSFET with a 2k resistor from the drain to ground to similate a load in place of the field coil... you think this was enough to be a good test?
Keep the gate tied to the source with a high value resistor. Use a more realistic load, like 200 Ohm. 6 mA isn't realistic !

cmjstealth (author)  steveastrouk1 year ago
Got a brand new IRF9540 mosfet today and tried this again using the suggestions from Steve. I created a new schematic drawing below showing exactly how I hooked it up from my understanding of your feedback. Also added a picture of my breadboard; I quadruple checked everything before adding power.

Exactly the same problems as before - the MOSFET won't turn off. I get 2.5 amps of current flowing through the field coil regardless of whether the arduino PWM pin is "on" or "off".  With 12v I would expect to only get this in a full "on" state (the field coil is about 5 ohms). The collector of the npn transistor reads 12v when "off" and 0.3v when "on" (which seems correct).

Ideas?
IRF9540 arduino circuit.JPGp-channel test breadboard picture with comments.jpg
Does it start "off" and turns on once ?
cmjstealth (author)  steveastrouk1 year ago
Seems to be "on" from the beginning.
Measure Vgs directly, on the pins of the mosfet.
cmjstealth (author)  steveastrouk1 year ago
In case you are interested in the final resolution on this...

To date I've spent hours, hours, and even more hours burning through tons of IRF9540's purchased from my local electronics shop. Normally local parts make sense for prototypes but at $9 a pop but it was adding up to a fortune. I finally ordered a whole bag of these things on ebay for $0.60 a piece and waited 4 weeks for them to be shipped from Hong Kong. Finally tried one of them last night.

Pretty sure I did nothing that I hadn’t tried at least 5 times since the beginning and guess what.... IT WORKS PERFECTLY!!! Has my local shop been selling me bad parts this whole time?

Steve - REALLY appreciate your help and patience through this nightmare. Was making no sense whatsoever and was nice to know I wasn't completely insane. If you weren’t a 9+ hour flight away I'd invite you over to share the bottle of Champaign I'm about to open!
Weird one that. Not impossible that the devices were stocked faulty
Your still mixing names
Bipolar-Transistors.jpg
I think you are confused (and confusing.....) about emitters etc. Only bipolar transistors have emitters and collectors and bases. Fets have drains, sources and gates.

I wouldn't trust the body diode for the field of a motor, and besides, that energy has to go somewhere. You don't want it pumped onto your supply rails, or you could blow everything. Put the flywheel diode in.
cmjstealth (author)  steveastrouk1 year ago
I'll use the terms drain/source/gate rather than collector/emmitter/base from now on then - thanks for the correction. Guess I was kinda equating them as similar things in my head and got sloppy with the names (base/gate, collector/drain, and emmiter/source).

I'll keep using the protection diodes then. Does the phrase "flywheel diode" imply using a diode specifically in a configuration like in the digital-diy schematic I uploaded above (in parallel with load)? Would the phrase "blocking diode" instead imply that it is used in series with the load? Does the parallel configuration provide better protection (I've been using in series).
You've got to remember FETS are different working principles from BJTS, they have three wires, and control currents and voltages, but there the similarities end.

YES. the diode MUST be in parallel with the load. Yes, it provides better protection, and protection in the right way.

Steve