EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: tehtehteh on December 22, 2016, 12:44:40 am

Title: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 12:44:40 am
hello, I am new here

I am trying to make a fan controller for a 4 pin PWM computer fan

this is the best I could find regarding a proper specification: http://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdf (http://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdf)

the fan has an internal pullup resistor so needs to connect to an open drain / open collector style output

I have attached my circuit diagram including a simplified circuit for the fan to help show what is happening

(http://i.imgur.com/dYRmVexs.jpg) (http://i.imgur.com/dYRmVex.jpg)

now the problem I am having is this, if I measure at the gate of the MOSFET I get the expected 25kHz square wave:

(http://i.imgur.com/0Zmkb4Qs.jpg) (http://i.imgur.com/0Zmkb4Q.jpg)

......but if I measure at the drain I get this ugly sawtooth wave which does not control the fan properly:

(http://i.imgur.com/02yKqGOs.jpg) (http://i.imgur.com/02yKqGO.jpg)

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 pullup

so 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?
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 01:12:16 pm
nobody? if I need to give more information I will, just say the word
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 03:31:17 pm
nobody? if I need to give more information I will, just say the word

The 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?
Title: Re: MOSFET problem in PWM fan controller
Post by: leeatljs on December 22, 2016, 03:41:34 pm
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.
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 03:54:24 pm
The 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?
the 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 change

the 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 it

I've measured it both at the gate and at the ic pin and it's the same, it looks ok at these points
Title: Re: MOSFET problem in PWM fan controller
Post by: Zero999 on December 22, 2016, 03:57:30 pm
It doubt the gate resistor is responsible for this.

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.

Yes. 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 (https://www.eevblog.com/forum/beginners/why-is-mosfet-turning-off-slowly/msg1096628/#msg1096628)
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 03:59:29 pm
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.
the 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 anyway

your 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
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 04:02:04 pm
Yes. 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 (https://www.eevblog.com/forum/beginners/why-is-mosfet-turning-off-slowly/msg1096628/#msg1096628)
I'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?
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 04:04:55 pm
the 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 anyway

Why don't you try with our ol' friend the BJT... ;)
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 04:09:41 pm
the 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 anyway

Why don't you try with our ol' friend the BJT... ;)
didn'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
Title: Re: MOSFET problem in PWM fan controller
Post by: Zero999 on December 22, 2016, 04:14:24 pm
Yes. 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 (https://www.eevblog.com/forum/beginners/why-is-mosfet-turning-off-slowly/msg1096628/#msg1096628)
I'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?
The BS170 is one of the lowest capacitance MOSFETs out there.

the 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 anyway

Why don't you try with our ol' friend the BJT... ;)
BJTs 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.
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 04:15:11 pm
didn't have one, but I'll get one, did you have anything specific in mind?

not 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 ...

Title: Re: MOSFET problem in PWM fan controller
Post by: Zero999 on December 22, 2016, 04:23:20 pm
didn't have one, but I'll get one, did you have anything specific in mind?

not 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 ...
Looking 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.pdf (http://www.logosfoundation.org/instrum_gwr/display/BS170.pdf)
http://www.farnell.com/datasheets/296640.pdf (http://www.farnell.com/datasheets/296640.pdf)
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 04:26:13 pm
Looking 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.

Speaking 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?
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 04:33:00 pm
The BS170 is one of the lowest capacitance MOSFETs out there.
doh!

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?
Title: Re: MOSFET problem in PWM fan controller
Post by: Zero999 on December 22, 2016, 04:41:09 pm
Looking 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.

Speaking 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?
The 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=5546d462533600a4015357444e913f4f (http://www.infineon.com/dgdl/mosfet.pdf?fileId=5546d462533600a4015357444e913f4f)

The BS170 is one of the lowest capacitance MOSFETs out there.
doh!

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?
I 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.

Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 04:48:16 pm
The BS170 is one of the lowest capacitance MOSFETs out there.
doh!

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?

Why 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.
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 04:50:04 pm
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.
all I have to go on is this

http://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdf (http://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdf)

which says no pullup on the motherboard, only the pullup internal to the fan

the 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
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 04:52:14 pm
Why 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.
already done, 1k to 5v gave me a square wave, 100k to 5v gave me a similar sawtooth wave like having the fan connected
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 05:02:10 pm
Why 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.
already done, 1k to 5v gave me a square wave, 100k to 5v gave me a similar sawtooth wave like having the fan connected

Can 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...
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 05:07:14 pm
Can 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...
this is the fan

http://noctua.at/en/products/product-line-industrial/nf-a14-industrialppc-3000-pwm (http://noctua.at/en/products/product-line-industrial/nf-a14-industrialppc-3000-pwm)
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 05:11:33 pm
Can 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...
this is the fan

http://noctua.at/en/products/product-line-industrial/nf-a14-industrialppc-3000-pwm (http://noctua.at/en/products/product-line-industrial/nf-a14-industrialppc-3000-pwm)
OK, 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...
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 05:21:14 pm
OK, 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...
alas no, my component box is rather basic
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 05:32:08 pm
OK, 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...
alas no, my component box is rather basic

The 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 for
(http://geoffg.net/Downloads/FanController/Schematic.jpg)


He 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 here http://geoffg.net/fancontroller.html (http://geoffg.net/fancontroller.html)


Not sure if those PWM pin outputs of the PIC18F are open drain though!
Title: Re: MOSFET problem in PWM fan controller
Post by: Zero999 on December 22, 2016, 06:11:20 pm
OK, 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...
alas no, my component box is rather basic

The 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 for
(http://geoffg.net/Downloads/FanController/Schematic.jpg)


He 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 here http://geoffg.net/fancontroller.html (http://geoffg.net/fancontroller.html)


Not sure if those PWM pin outputs of the PIC18F are open drain though!
That 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.

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.
all I have to go on is this

http://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdf (http://formfactors.org/developer%5Cspecs%5C4_Wire_PWM_Spec.pdf)

which says no pullup on the motherboard, only the pullup internal to the fan

the 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
It 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.
Title: Re: MOSFET problem in PWM fan controller
Post by: ZeroResistance on December 22, 2016, 06:16:49 pm
That 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.

That 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.

It 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.
That's a brilliant idea Hero999 that should work out for the OP...
Title: Re: MOSFET problem in PWM fan controller
Post by: Zero999 on December 22, 2016, 06:21:47 pm
That 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.

That 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.
I 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.
Title: Re: MOSFET problem in PWM fan controller
Post by: tehtehteh on December 22, 2016, 08:38:03 pm
It 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.
sounds promising! I don't have any suitable diodes, but I might be able to get a 1n4148 or a 1n4448 tomorrow
Title: Re: MOSFET problem in PWM fan controller
Post by: 97hilfel on December 26, 2016, 07:16:31 pm
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)