Cooling Fan MOSFET Driver

by Danjhamer, published

Cooling Fan MOSFET Driver by Danjhamer Apr 28, 2012


Use This Project

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

45622Views 1023Downloads Found in Electronics


If you'd like to purchase a kit from me please go to:

This is a MOSFET driver board to enable the control of a cooling fan from a Sanguinololu board using Sprinter firmware. I have included a protection diode and suppressing capacitor which is overkill if you are using a PC/GPU brushless DC motor fan but I wanted to make this drive general purpose for use in other expansion projects and experiments.
I also considered having this made by a PCB maker using SMD's but I would probably need to order a couple of hundred units to make it worth while as its such a small circuit. I think this would be a useful prototyping gadget for Arduino projects as well as 3d printer upgrades as it could be made really small using SMD's, small enough even to tuck inside a cable sleeve. I'd love to have a bunch of these in my tool box as it would save a lot of time faffing with breadboards when you just want to try something quickly. So if anyone else is interested in buying one or two let me know and if enough people show willing I'll advance the project.

I have refined the design of this driver and had some boards made up. It's an SMD design and I've made it as small as possible while still allowing various connector/wiring possibilities. I'm currently making it available as a kit as not everyone has the necessary materials to hand and it can be a pain trying to source one of a particular 0603 resistor.
If you'd like to purchase a kit from me please go to:

If you'd like just a board or a kit with slightly different parts let me know and if enough people ask for a particular packing list I'll make it available. The kit comes with a brief instruction card but I'm compiling more comprehensive instructions. As soon as they are done I'll upload them and some new photos. Meanwhile please check out my listing above.
Buy the way before anyone asks the supplied transistor is an IRLML0030TRPBF.


You will need

1x 1N4001 Diode
1x 1K Ohm Resistor
1x 6.7K Ohm Resistor
1x 0.1uF Capacitor
1x 7 rows x 5 tracks Stripboard
1x 2way header male Connector
1x 3way header male Connector

Solder, Wire, Connectors etc.

Make up the PCB.
Coat circuit board both sides with hot melt but leave the MOSFETs heatsink and the connection pins exposed.
Wire up.
Open up you arduino IDE, go to the pins file and scroll down to the motherboard 62 section.
Locate the FAN_PIN value, it should be -1, change it to 4.
Save, compile and upload the firmware to your Sanguinololu.

You can test your fan by sending the following commands:

M106 This will turn the fan on
M107 This will turn the fan off
M106 S127 This will turn the fan on at half speed.
(You can set any speed from 0 to 255)

There will be a cooling fan option somewhere in your slicing options. Use it and enjoy finer more accurate prints.

More from Electronics

view more

All Apps

Upgrade this Thing with Thingiverse Apps

No results.

hi Dan, could toy tell me on your drawing fig 2 track side, is the top one ( Fan -) or (Sig) ? thanks a bunch .

Does anyone have files for this design or a similar for an etched pcb instead of strip board?

will this circuit work also with an IRFZ44N and HB outlet?
I have some lying around and maybe it would be nice to have the big HB amps not on RAMPS.

I can't seem to get this to work. Connecting up a mosfet ala this guide: https://solidoodletips.wordpress.com/2012/10/26/gcode-controlled-extruder-fan gives me an always-on fan, while using your board gives me an always-off fan. Any idea why?

I am having a requirement in a bulk quantity 50000nos. approx BLDC 12 V ADDA fan regulators input 120v - 220v

Mohammad Dilshad Ansari

This works perfect with Repetier firmware 0.91 build 6+ on the Reprappro Huxley Melzi board.
I use the lower pins for the 5v pwm signal (pin 42 I think) and then configure feature fan for that pin :-)

I just had a need to power my RAMPS heated bed off the board. Thanks for posting this circuit.

  • I have a question if anyone with electronic experienced reads this. I read about a snubber circuit which combines a flyback diode and a capacitor in series. Shouldn't the diode in this circuit be in series with the cap rather than parallel? I am looking at the following wiki description for a RCD snubber circuit: http://en.wikipedia.org/wiki/Snubberhttp://en.wikipedia.org/wiki/S... - This description seems to outline the purpose to use a Cap and Diode for this particular circuit. As the above circuit is built the cap would not charge/discharge. --- Go easy - I am not highly electronics literate.

The exact type of snubber circuit you use
depends on many things. The circuit on the Wikipedia page is a flyback circuit
so the current will reverse and the diode is configured to stop it. In my
circuit I wanted to absorb any back emf if a regular dc motor was used. My
circuit is only intended for current flowing in one direction, so any back emf
is directed back up to the high rail and impeded by the capacitor (reactance).
If a large solenoid was to be used with my circuit then additional emf
protection would be recommended. I hope this clearers things up for you however
this is a fairly big subject and emf protection depends on the situation. My
circuit is intended for connecting small motors etc. to Arduinos and the diode
and capacitor just add a little extra protection.

Which would be the diode for the SMD version?

The diode I used on the SMD version is a S1M, Recovery Rectifier Diode, 1A 1000V SMA


is it possible to feed this driver with 24V? I feed my RAMPS and all components on 24V, which was not good for the RRD Fan extender - it blew up as it's intended for 12V :-( I'd like to use two of these as a replacement.

Yes, this driver will handle up to 30V.

Hi Danjhamer! Could use this driver with ramps 1.4? Thanks in advance.

Hi Patricio, you can defiantly use this driver with any
microcontroller so there should be no problem using it with Ramps. I think
ramps is already set up with fan control on pin 9 which is on Aux 2 ,but don't
quote me as I've never used Ramps. Test it with a meter, just give it a M106 to get a high, or M107 to
get a low. Hope this helps.

Hi Dan! Thanks a lot.

I bought RF540 "without the A" I can still use it ?

Not entirely sure
what that is but if its a RF540 MOSFET it should be fine.

Bought some of your ebay smd 's and must say ok BUT... you have at least 3mm of empty space on the board and the cap is too close to the resistors, seems less than half a mm between pads. If I were a robot it would be fine but I have plates for hands and had many problems stopping surface tension pulling resistor in the capasitor black hole during heating. I bought a few as well so at least 2 in the bin.

I know it can be tricky to place SMD components by hand ( I've done quite a few myself) but with the right tools and the right technique it gets easier. Here's a couple of tips. First ( very important ) with solder paste less is more, providing you have paste touching the pad and pin any more will just cause you problems it always astonishes me just how little you need to make a really reliable joint. Secondly perfect a way of positioning the components. The way I do it is to first put the component in the correct orientation on a blank space on the board near to its location. Then get a sharp pair of tweezers. now rest your hand on the bench holding the tweezers so its comfortable and easy to open and close the tweezers precisely and pivot your hand so the tweezers move up and down ( in Z ). Now with your other hand nudge the board around with your fingers ( in X & Y). The mistake is to try and do all 3 with your tweezering hand. If you do your hand will drag on the bench making precision movements in X & Y very difficulty and you will have trouble controlling the pressure on the tweezers grip. You will also find you can get really good precision placement by nudging and rolling your fingertip against the edges of the board. Hope this helps. In the near future I may do a tutorial on this ( maybe a video) if anyone is interested.

Exactly what i needed. thank you.

Hi, is there a special reason why you put a 6.7k? Any chance a 10k would work as well ?

No particular reason, I just happened to have plenty of 6.7Ks to hand. A 10K would work fine. In fact, my surface mount version will use a 10K as the pull down.

Great work, this is an excellent part for prototyping new features on our printers. Please let us know as soon as you've got them manufactured, I'm excessively interested :-)

Danjhamer - is the connection to the Sanguinololu card which you show in the schematic on on the circuit board picture correct? Given the change which you have described for the firmware, I would have thought that the correct pin for the signal is that marked A4 (immediately below the pin shown). Isn't D12 used to control the MOSFET connected to the heated bed and as such not available for use from the set of pins marked as extension pins on the Sanguinololu? Alan

I am 100% sure that this wiring and the changes in the firmware are correct for the Sanguinololu 1.3a. I knew someone would ask this question. If you look at the second firmware screenshot you'll see a comment with all 5 of the possible labels for the net connected to pin 5 of the micro. But the pin labelled D12 on the expansion header is definitely connected to it.

Ignore this explanation as you might find it confusing.
Pin 5 of the chip is Port B pin4 aka PWM PB4
There seems to be some error here since D12 should according to Sanguino be PWM PD4 but hey that's open source for you ( fix the problem but don't tell anyone about it).
The pin on the expansion
header of the Sanguinololu labelled A4 should be connected to chip pin 36 which is Port A pin 4 or AI PA4. (However I haven't tested this yet). The MOSFET the heated bed is controlled by is chip pin 18 or PWM PD4 ( this is probably where the error occurred).
I hope this helps.

Count me in as interested in buying some. Any good plans for production?

The cost of this circuit is almost nothing. And requires very little soldering experience. You could make one yourself. I have a simple circuit to control the speed of the fan also. Only 5 parts required.

I'm just waiting for some parts for testing. So hopefully I'll have something to report in the next couple of weeks. I'll keep you posted.

This is great. Nicely illustrated and simple for non-electronics guys like me. I've read through the comments and think I understand and the logic and reasoning behind everyone's comments and Dan's responses. The only question which remains outstanding in my mind is...

If I wanted to build this for general purpose use as suggested by Dan, then what cap should be used?

It would be fine to leave it out completely however if you were to use this on a powerful motor or a solenoid then attaching an appropriate capacitor directly to the motors across its terminals is highly recommended. But if you really wanted to keep the capacitor in at this stage I'd say a 100nF ceramic. I'm looking into this carefully for the production version as I've seen some good surface mount cap configurations for this type of thing and I want to make this as general purpose as possible.

A couple notes regarding the components:

a) The resistors are not needed. The 1k is not necessary since the FET's gate is merely a capacitor. You don't need to limit the current flowing "through it". The 6k8 one is not needed since the Atmel's outputs can source and drain current, it can discharge the gate all by itself without a pulldow
n resistor.
b) The IRF540 is way, way overkill. It can handle 28A and depending on where you buy it, it can cost up to 1€. Any n-channel MOSFET (heck, even a 4ct bipolar 547 works) will do the trick for a regular PC fan. But, as a general purpose driver, the 540 should be ok.
c) Don't use an elect
rolytic cap. Even though you included the diode, when the fan generates a reverse voltage (it really shouldn't) the diode still has a forward voltage of ~0.6V, which is enough to kill the cap. Leave the cap out altogether, PC fans don't care much about the quality of their power supply.

Sorry for s
o much criticism. :'(

Thanks for your comments, I admit this is not the perfect driver I would like or would have made at a PCB makers, but I threw this together with components I had laying around on my bench (it took me longer to write it up). However I would always use resistors in this configuration as the more you limit current being draw through the micro the better. I
’m new to the Atmel chips (I’m a PIC man) and have yet to find my way around their data sheets, but I usually find that although you can draw up to 40mA through an I/O pin there is a lower total load you can put on all the pins. Also I always use a pull down as on similar circuits I’ve experie
nced MOSFET’s turning on momentarily as the micro goes through its start up procedures (this class of MOSFET has a habit of turning on at the drop of a hat.) In robotics things just turning on when you don’t intend, can be really bad. There are more elaborate hold off circuits you can use but th
is is a simple but effective way that works well in most cases. The capacitor was a bad choice but I have my eye on some SMD ceramics that are great for suppressing inductive loads, yes, I know that’s not a problem here but I want a general purpose driver that could handle a largish DC motor.

"Also I always use a pull down as on similar circuits I
’ve experienced MOSFET’s turning on momentarily as the micro goes through its start up procedures"
Good point. You might want to consider adjusting the voltage divider that the 1k and 6k8 resistors form, though - in this configuration, only ~4.35V reach the gate (probably a little less), limitin
g the FET's driving capabilities to around 5A. The attached image is taken from ST's irl540 datasheet (two graphs).
A weaker logic-level FET (i have some irliz34n kicking around) allows for larger currents at these low gate voltages (one graph, taken from IR's irliz34n datasheet). At the same voltag
e, the irliz34n will already drive around 20A.

"The main danger with FETs used like this is the gradual erosion of the FET by any excess current, voltage or noise. FETs DO wear out, if they are driven badly."
Yes, they do wear if treated wrong. The 540 has an absolute maximum gate voltage of 20V, w
hich shouldn't be a problem when driving it with 5V, considering that the gate is driven by an Atmel and connected through a thin wire. As the gate resistor is mainly necessary for protecting the driver (the Atmel), the resistance (and inductance) of the wiring and traces should be enough to keep th
e current below the Atmel's 40mA.

SteveMac - in reply to

The 1k resistor is required for driving a FET like like a IRF540, because the gate capacitance will cause excess current when it is turned on without current limitiing, and that will cause noise and flyback problems.

The IRF540 is typically used because it can run reasonable current without proper heatsinking, as in this case. If you want to run a heavy load you can, but you would have to decide on your heatsinking capapability.

The main danger with FETs used like this is the gradual erosion of the FET by any excess current, voltage or noise. FETs DO wear out, if they are driven badly.

so, is the diode needed?

That depends on what kind of load you're running. For a low-current load (PC fan) or one that is mostly resistive (like a PCB heater, hotend etc...), no. For partially- or fully-inductive loads, like larger DC motors (i'd say anything larger than a 380) or anything that involves coils, yes, definitely, or else your transistor might release its magic smoke, depending on what voltage it is rated for.

The diode doesn't hurt in any case, so if you're unsure about whether you need it or not, leave it in.

Btw, 1N4007 diodes are rated for 1000V instead of 50V DC but cost the same (2ct), so buy those instead. They might be useful for other projects where you're dealing with a little more voltage 8-)

You could cut the size of the unit almost in half by bending the FET down on the front or back of the board, you just need to cut the leads longer and (if you put it on the back) make sure that the heatsink tab is insulated from the soldered leads.

’s a great idea that would be good in some situations, however I like to have the heatsinks well exposed for cooling and bolting to some additional heatsinking. I was also going for long and thin rather that overall compactness. If I get something manufactured it’ll be inline so it can go inside
cable sleeving.

Bonjours peut t on maitre un IRF630A ? ou le quel? pouvé vous me donner quelque equivalent svp merci et merci du partage