TL;DR: Anyone know why my 4-pin PWM fan doesn't turn off when the PWM pin is set to duty cycle 0, or arduino PWM bypassed and the pin just tied to ground?
Hi, I've found a lot of help in this forum when trying to get my Arduino Pro Micro 3.3V set up to output a PWM signal to control a 4-wire PWM 120mm case fan.
However, of the articles I've read and datasheets I've seen, they all suggest that setting a duty cycle of 0, or just flat out grounding the PWM pin should stop the fan. I'd like to build a control circuit with my arduino that can control the speed with a potentiometer, but at the last few analog values I want it to set the duty cycle to zero to turn the fan off.
I've tried manually hard-coding in a duty cycle value of 0. Then to ensure it wasn't some issue with the PWM setup, I removed the PWM and just tied the fan PWM pin to ground. However, it still spins (albeit very slowly). Sometime it spins down to a stop, but after 5 or 6 seconds it will spin up again to about 120rpm.
I know I could add another GPIO output to an NPN transistor and just switch the 12V input to the fan, but it just seems like unnecessary extra circuitry if PWM control is working as it should do.
Any ideas why this is happening?
Noctua's datasheet suggests that zero should turn the fan off:
My fan is an Arctic F12 PWM. I can't find anything as detailed as the noctua white paper on controlling its operation, but as it is designed to be a motherboard controlled fan I would assume it should obey the same operation.
By the way, my PWM control is working fine (except for completely off as discussed), I can dial it up to 1800rpm and down to about 100rpm in as many steps as I want using the TCCR1A TCCR1B registers for timer1. Thanks to many on the forums here for those instructions
I hadn't seen that datasheet graph before. Thank you for sharing.
I did spot this sentence in the Noctua white paper:
"Operation below 20% PWM duty-cycle is not officially supported in the Intel specification
(undefined behaviour). However, most Noctua PWM fans can be operated at below 20%
and will stop at 0% duty-cycle"
So I guess other manufacturers are free to implement whatever behaviour they want at below 20% PWM.
I'll be going back to the NPN transistor to switch the 12V line to the fan then
I would consider using a PNP transistor to switch the high side instead. An FET would be better but those suitable for high side switching with logic level signals are in short supply. Just make sure you bias the BJT into saturation to reduce the power consumed by it.
Y has to take fan V drop into bias consideration, other then that npn "valve" is fine, whats pnp benefit in this case? Imho it can be pulled either way as long as bias is correct.
different story for amps or inverters when you want 2 for 1 action...
Can you explain further? By control signal do you mean the PWM signal? Are there implications if the PWM signal is still running while the NPN transistor is off (and presumably the GND pin of the fan will be high as a result)?
I've just checked the datasheet for a typical 2n3904 (have plenty of them on hand) and it probably needs 5mA+ base current to allow the fan to draw its full 100mA@12V, but that shouldn't be an issue for the micro.
Yes, thePWM signal. Presumably you have the fan ground attached to your Arduino ground. If you insert an NPN transistor between fan ground and Arduino ground, when the transistor is ON, there will be a voltage drop across it. If you drive the transistor hard enough, into saturation, that drop will be on the order of 0.5V. Then, ground for the fan, which is the reference point for the PWM input signal will be 0.5V above ground for the Arduino PWM output. That means that the logic high from the Arduino might not be enough to satisfy the requirement of the fan which is now 0.5V more than normal. If you don’t saturate the NPN transistor, the conditions are even worse.
Now, you might get lucky and it will work but it’s bad design practice. If you use an N-channel logic FET, that has an extremely low ON resistance, you would be okay but you specified an NPN BJT. The correct approach would be to use a PNP transistor with, say, a 250mA collector current rating and drive the base hard enough to saturate it at the current for your fan which is about 120mA. You want to saturate it to keep the voltage drop across it when it is conducting as low as possible so as not to overheat and provide ample voltage for your fan.
I understand now, thanks for the detailed explanation.
Your assumption is correct, fan GND is connected to arduino GND. However, the fan PWM doesn't actually require an arduino logic-high signal. The fan has its own pull-up on the PWM input (presumably to fan's 12V); so I am using the arduino PWM to toggle the base of a separate NPN, connected between fan PWM input and GND to pull the fan PWM input low when arduino PWM is high, and let it be pulled back up high when arduino PWM output is low (and therefore NPN is in cut-off). I've read that I could probably just connect arduino straight to the fan PWM and then I wouldn't have inverted PWM logic, but I wasn't sure about connecting the 3.3V GPIO directly to the fan PWM which is supplied at 12V, even if it is acting as input rather than an output. Then I guess there would also be the matter of if the arduino high logic signal would be high enough above the fan's GND reference point.
I'll try with the NPN between fan output and GND for the time being. I'll be interested to see if the ~0.5V drop affects the top speed of the fan even when on the maximum duty cycle. I've got the tacho reading set up for that so I should be able to compare easily.
Ps. I know i was talking about duty cycle of 0 before, but in reality it was a duty-cylce of 100 in my attempt to turn the fan off via PWM due to the inverted output because of the NPN transistor. I thought that was probably unnecessary detail at the time.
Thx, been driving fets mostly, with optos, ignores much of the ground problems, forgot , but Isn't it best to tie PNP base to Vcc with a current limiting pull-up resistor, and then put a NPN to ground the base when you want it on, that way almost no current goes thru arduino and the logic is non inverting, I'm not entirely sure, as I haven't bjt in some time.
High side control is only good if you have other common grounded electronics in the load, or if its unavoidable. Maybe RPM sensor(not even sure), but you wont need inbuilt pwm, bc you are going to drive it externally, I mean its designed to avoid using this whole circuit, stupid they wouldn't let it go to 0rpm, it may be some kind of a safety feature...
Other option is to use only Q2 and tie fan gnd to the collector...
Also maybe good idea to tie a 10k pulldown between Q2 base and gnd
Thanks for the ideas Semtex. I think i'll start with your second option and see what results I get. Arduino should be capable of 20mA sustained on a GPIO, so I am not bothered about a 5-10mA current to drive the transistor into saturation.
The PNP+NPN solution you suggest is also a good option. I've seen similar designs for MOSFET driving circuits for non logic level MOSFETS in other projects I've tinkered with
Stop reading dangerous nonsense. This is rubbish and one of the best ways to kill an Arduino. If you are lucky you will only destroy that pin.
That's why I didn't implement that method to begin with.
It is painfully easy to correct the inverted PWM value.
Thanks, yes I'm aware of that.
I think I'm back to @EmilyJane 's original suggestion of high-side switching for the 12V power, as no matter what I do I can't get the fan to stop rotating, even by completely disconnecting the GND pin. It must be using the Tacho and PWM pins as a path to ground for a small amount of current and so the fan still moves even without a GND connection when these pins are connected in my circuit.