MOSFET problem in PWM fan controller - Page 1
Forum section: electronics / beginners

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 12:44:40 am
content: hello, I am new hereI am trying to make a fan controller for a 4 pin PWM computer fanthis is the best I could find regarding a proper specification:http://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdfthe fan has an internal pullup resistor so needs to connect to an open drain / open collector style outputI have attached my circuit diagram including a simplified circuit for the fan to help show what is happeningnow the problem I am having is this, if I measure at the gate of the MOSFET I get the expected 25kHz square wave:......but if I measure at the drain I get this ugly sawtooth wave which does not control the fan properly:I disconnected the fan and took readings from the signal pin, I get a constant 4.25 volts and current between it and ground is 58uA, this would suggest to me a pullup in the region of 80k, also if I ground the pin the fan shuts off, and if I leave it floating it spins up to full speed, all this is consistent with an internal pullupso I disconnect the fan from drain and put a 100k resistor to 5v instead, I get the same ugly wave, if I swap the resistor for a 1k I get a nice square wave, if I connect the fan with this 1k pullup in place I also get the square wave and the fan responds correctly, this and the sawtooth on the oscilloscope leads me to believe that the MOSFET is being very slow to switch off when the drain to source current is low, am I correct? will a different MOSFET respond better?

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 01:12:16 pm
content: nobody? if I need to give more information I will, just say the word

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 03:31:17 pm
content: Quote from: tehtehteh on December 22, 2016, 01:12:16 pmThe gate resistor of 300ohm for the BS170 mosfet seems too high try with 22ohm.Also have you checked the fan does it run full speed when you give steady 5V to the PWM input.Have you measured the gate waveform directly at the gate or before the 300ohm resistor?

author: leeatljs
author_rank: Contributor
timestamp: December 22, 2016, 03:41:34 pm
content: As you have correctly worked out, that 80k pullup is too high when you are running at 25khz.Stick your own 1k pullup in and everything will be ok.That 80k pullup has to charge the capacitance of that mosfet and any other capacitance that might be on that line.

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 03:54:24 pm
content: Quote from: ZeroResistance on December 22, 2016, 03:31:17 pmthe gate resistor was a concern, I don't want to go too low because the picaxe will only support 20mA per pin, I started with 1k and took it down to 300ohms and the signal didn't changethe fan has its own pullup internally so if I disconnect it it runs full speed, if I put 5v into the pin it probably would run full speed also but I don't want to try this in case I damage itI've measured it both at the gate and at the ic pin and it's the same, it looks ok at these points

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2016, 03:57:30 pm
content: It doubt the gate resistor is responsible for this.Quote from: leeatljs on December 22, 2016, 03:41:34 pmYes. It's the same problem as discussed in the other thread. The drain-source capacitance is being charged, via the pull-up. 1k will probably be fine here, since the BS170 is much smaller and therefore has less capacitance, than a high power MOSFET does.https://www.eevblog.com/forum/beginners/why-is-mosfet-turning-off-slowly/msg1096628/#msg1096628

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 03:59:29 pm
content: Quote from: leeatljs on December 22, 2016, 03:41:34 pmthe problem with using my own 1k pullup is some fans work internally on 3.3v logic, I am measuring this one at 4.25v, so I don't know if putting 5v into that pin would cause current to flow in the wrong direction in some part, also the pullup prevents the fan from turning off completely, if I ground the signal pin the fan will stop rotating, but with the pullup and 0% duty cycle the fan still spins at a low RPM, for reasons I can't really work out, but it's wrong anywayyour last sentence is interesting, as this is all currently on a breadboard, so I wonder how much of an effect this has on the capacitance

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 04:02:04 pm
content: Quote from: Hero999 on December 22, 2016, 03:57:30 pmI'm only using the BS170 because it was the only one I had in my box of things, would a different MOSFET or BJT work at these frequencies without the need for the pullup?

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 04:04:55 pm
content: Quote from: tehtehteh on December 22, 2016, 04:02:04 pmWhy don't you try with our ol' friend the BJT...

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 04:09:41 pm
content: Quote from: ZeroResistance on December 22, 2016, 04:04:55 pmdidn't have one, but I'll get one, did you have anything specific in mind? I only got the BS170 because I thought it would be good for many situations, I didn't really have PWM in mind at the time

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2016, 04:14:24 pm
content: Quote from: tehtehteh on December 22, 2016, 04:02:04 pmThe BS170 is one of the lowest capacitance MOSFETs out there.Quote from: ZeroResistance on December 22, 2016, 04:04:55 pmBJTs still have a collector-emitter capacitance to charge. They also can be difficult to turn off quickly: due to the storage time and a emitter-base capacitance discharging.

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 04:15:11 pm
content: Quote from: tehtehteh on December 22, 2016, 04:09:41 pmnot really I'm just going in for "don't think but change and check" method ..I thought you might have a few lying around in your kit box, the evergreen 2N2222 .. or something or those lines... but if its going to take some time ordering it .. then persist with the mosfet .. I'm sure the experts here will have something to say about that and get your circuit up and running ...

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2016, 04:23:20 pm
content: Quote from: ZeroResistance on December 22, 2016, 04:15:11 pmLooking at it again, the 2N2222 might be better than the BS170. Its maximum output capacitance is 8pF vs the 30pF of the MOSFET. You will probably need to add a Baker clamp (base-collector Schottky diode which prevents it saturating) and a base resistor bypass capacitor, to provide a negative pulse to the base, to discharge the base-emitter capacitance.http://www.logosfoundation.org/instrum_gwr/display/BS170.pdfhttp://www.farnell.com/datasheets/296640.pdf

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 04:26:13 pm
content: Quote from: Hero999 on December 22, 2016, 04:23:20 pmSpeaking about output capacitance the datasheet talks about it as the Collector to Base capacitance and that's mentioned as 8pF ... haven't read anything about Collector to Emitter capacitance ... or isn't there one like that?

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 04:33:00 pm
content: Quote from: Hero999 on December 22, 2016, 04:14:24 pmdoh!there must be a way as these things seem to work on computer motherboards just fine, would a gate driver help do you think? without the current limit of the picaxe maybe it would switch better?

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2016, 04:41:09 pm
content: Quote from: ZeroResistance on December 22, 2016, 04:26:13 pmThe output capacitance is the sum of the base or gate to collector capacitance and source or emitter to drain or collector capacitances.http://www.infineon.com/dgdl/mosfet.pdf?fileId=5546d462533600a4015357444e913f4fQuote from: tehtehteh on December 22, 2016, 04:33:00 pmI doubt a gate driver would make any difference because the waveform on the gate is fine.I haven't seen the schematic for the fan control circuit in a computer mother board but would presume it has a pull-up resistor or a push-pull output.

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 04:48:16 pm
content: Quote from: tehtehteh on December 22, 2016, 04:33:00 pmWhy don't you first take the fan out of the equation and just get a clean signal on the drain of the mosfet, as Hero999 says connect a 1k load to the drain and tie the other end to +12 or whatever your supply is and disconnect the fan you should now see a clean square wave when you scope the drain.

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 04:50:04 pm
content: Quote from: Hero999 on December 22, 2016, 04:41:09 pmall I have to go on is thishttp://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdfwhich says no pullup on the motherboard, only the pullup internal to the fanthe pullup is sorting out the signal but it is having some undesirable effects with the fan not being able to turn off even at 0% duty cycle

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 04:52:14 pm
content: Quote from: ZeroResistance on December 22, 2016, 04:48:16 pmalready done, 1k to 5v gave me a square wave, 100k to 5v gave me a similar sawtooth wave like having the fan connected

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 05:02:10 pm
content: Quote from: tehtehteh on December 22, 2016, 04:52:14 pmCan you post a pic of your fan, do you have any brand name or model no. written on it ? It's a 4 wire fan right? Any more clues would help us getting more data on the fan...

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 05:07:14 pm
content: Quote from: ZeroResistance on December 22, 2016, 05:02:10 pmthis is the fanhttp://noctua.at/en/products/product-line-industrial/nf-a14-industrialppc-3000-pwm

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 05:11:33 pm
content: Quote from: tehtehteh on December 22, 2016, 05:07:14 pmOK, that's good, another quick idea do you have a LM339 comparator lying around its a open collector output and may just do the job...

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 05:21:14 pm
content: Quote from: ZeroResistance on December 22, 2016, 05:11:33 pmalas no, my component box is rather basic

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 05:32:08 pm
content: Quote from: tehtehteh on December 22, 2016, 05:21:14 pmThe fan link you provided doesn't mention anything about how to drive the fan.This guy seems to have made the same thing that you are looking forHe is driving the PWM to the fan directly no mosfets not BJT's etc.. he just connects the MCU pin to the fan. Take a look at the bottom 2 4pin connectors.The link to the article is herehttp://geoffg.net/fancontroller.htmlNot sure if those PWM pin outputs of the PIC18F are open drain though!

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2016, 06:11:20 pm
content: Quote from: ZeroResistance on December 22, 2016, 05:32:08 pmThat circuit doesn't use the fan's PWM pin. It's a buck converter which varies the fan's supply voltage, which may not work well with four wire fans.Quote from: tehtehteh on December 22, 2016, 04:50:04 pmIt seems like you're overcomplicating things.You don't need a MOSFET or any other switching transistor because MCU is more than capable of driving the current/voltage on the fan's PWM input. All you need is a small signal diode (1N4148 (silicon) or BAT54 (Schottky whcih should be even better)), connected positive side to the fan's PWM input and negative side to the MCU output. This will convert the MCU output to an open drain output. There may be some tiny spikes when switching but the fan should be able to cope with them.

author: ZeroResistance
author_rank: Frequent Contributor
timestamp: December 22, 2016, 06:16:49 pm
content: Quote from: Hero999 on December 22, 2016, 06:11:20 pmThat circuit uses 2 modes of operation for 4 wire fan it goes into PWM mode where the PWM signal is provided by the PIC18F, for other type of fans it goes into buck converter mode.Quote from: Hero999 on December 22, 2016, 06:11:20 pmThat's a brilliant idea Hero999 that should work out for the OP...

author: Zero999
author_rank: Super Contributor
timestamp: December 22, 2016, 06:21:47 pm
content: Quote from: ZeroResistance on December 22, 2016, 06:16:49 pmI see it now. Pins 12 & 13 are PWM outputs. It will work if the fan has a 5V tolerant input, otherwise it may damage the fan. A diode or perhaps even a current limiting resistor should enable it to drive a fan with a 3V input safely.

author: tehtehteh
author_rank: Regular Contributor
timestamp: December 22, 2016, 08:38:03 pm
content: Quote from: Hero999 on December 22, 2016, 06:11:20 pmsounds promising! I don't have any suitable diodes, but I might be able to get a 1n4148 or a 1n4448 tomorrow

author: 97hilfel
author_rank: Regular Contributor
timestamp: December 26, 2016, 07:16:31 pm
content: Well I just wire the MCU 25kHz output to the fan, also currently building a fan controller, you dont really need a driver between because 4 pin fans should already have that build in and the PWM has ro provide only the signal. (I use a 5V MCU and everything works fine)