Gcode Controlled Extruder Fan

Printing small features can be challenging .  Sometimes a layer is so small and takes so little time to print that it is still melted and soft when the next layer goes on.  The plastic gets pushed around, and quality suffers. Another problem is overhanging perimeters.  Sometimes loops that are only partially supported curl up as they cool.  Later after they have hardened, the nozzle can bump into them with enough force to break fragile pieces, or knock them from the bed.

One solution is slow-down cooling.  You set a minimum time per layer, and the extruder will slow down enough to take that much time to print, giving the plastic more time to cool.  This can dramatically increase print times depending on the model.

The other way to cool the plastic is with a fan blowing into a duct that directs the air out through a ring around the nozzle.  This cools the plastic as it is extruded.  Slow down cooling may still be needed as well for very small featuers, but you can turn the minimum time down to something like 5 seconds when a fan is there to help out.

You can find a fan duct for the Solidoodle at Thingiverse – http://www.thingiverse.com/thing:30828 .


With ABS, keeping a fan on all of the time might not be a good idea.  The layers need to be hot to bond together, and if they are cooled too quickly the print may turn out very weak.  It’s best to save the fan for the very small layers, and also unsupported bridges.  If a thread needs to be pulled over open space, cooling with the fan can prevent it from sagging.  Slic3r and Cura can both turn on fans for layers under a minimum time, and Slic3r can also run a fan during bridges.  To make this happen however, you need to be able to connect the fan in a way that allows it to be controlled by Gcode.  This capability is built into RAMPS and Azteeg controllers, but not the Sanguinololu.  It can be added, however.

I discovered this from Nophead’s blog post – http://hydraraptor.blogspot.com/2012/07/sanguinololu-fan-hack.html

You will need a Logic Level Mosfet such as this one – http://www.amazon.com/POWER-MOSFET-N-CHANNEL-TO-220-SWITCH/dp/B008UTXK78/ref=sr_1_3?ie=UTF8&qid=1351296606&sr=8-3&keywords=nte+2985

You will need to add some headers to the Sanguinololu.  This isn’t too difficult, but if you haven’t soldered anything to a PCB before I recommend these tutorials-

http://www.youtube.com/watch?v=J5Sb21qbpEQ Part 1
http://www.youtube.com/watch?v=fYz5nIHH0iY Part 2

The host is a bit eccentric, but the info is good.  I had a go at it myself with a $6 solder iron and whatever solder and had a hard time of it.  Then I watched the videos and followed his recommendation of a solder station, a chisel tip and the proper solder, and found that it was quite easy.  If you are inclined to modify your printer to do great things, then some equipment and basic soldering skills are a good investment, and nothing to be afraid of.

One more thing you will need is a solder sucker, which is just a bulb with a tip.  The holes for the headers are filled with solder which will need to be removed.  Heat the solder from one side of the board and hold the sucker against the other side.  When the solder melts, suck it up with the bulb.  This would be easiest with a pointed tip that will fit through the hole.  This way you can push the melted solder through and suck it out at the same time.  Do this a couple of times from both directions to really get it cleared out.

You will need some straight headers, like  http://www.amazon.com/30-Pin-Single-Row-Snappable-Header/dp/B0083COCZG/ref=sr_1_22?ie=UTF8&qid=1351297518&sr=8-22&keywords=square+header+.1%22 .  Any self respecting electronics store should have them (which rules out Radio Shack).

At minimum you will need to solder headers into the four pins at the left end of the expansion area.  I recommend you solder all of the pins while you are at it.  At least add headers to the pair at the far right.  This will allow you to plug in an SD card reader, should you choose to buy one.

Note the shaky work here due to diving in without the proper equipment or education.  Still functional, if not a little ugly.  You will need a couple of connectors like these http://www.digikey.com/scripts/DkSearch/dksus.dll?vendor=0&keywords=50-57-9002&WT.term=50-57-9002&WT.mc_id=Connectors,%20Interconnects&WT.medium=cpc&WT.campaign=Connectors,%20Interconnects&WT.content=text&WT.srch=1&type=Phrase&WT.source=google&cshift_ck=452CDBE6-2610-4AC2-BEEE-57A4932EE148csDGEoepNp

This photo from http://www.thingiverse.com/thing:22202 shows where the MOSFET will connect to the board-

Solder some wires onto the legs of the MOSFET, with some shrinkwrap tubing at the ready-

The right leg is Source and it will go to GND on the board.  The middle leg is Drain and will go to the black wire on the fan.  The left leg is the Gate and will go to PWM B12 on the board.  The red wire from the fan goes directly to 12v on the board.

You can switch the fan on and off by manually entering a M106 code in Pronterface, such as M106 S255 where S is the speed, expressed as a number from 0 to 255.  Repetier host has a button and a slider to control the fan.

The fan may not already be activated in firmware, so follow the directions here for how to download and update the firmware.  When you have the firmware open in Arduino, change to the Pins.H tab.  This will probably be too far down to appear at the top of the screen, but on the right side there will be an arrow that pulls down the full list.  Scroll about halfway down, looking for the section for Sangiunololu.  In that section look for

#define FAN_PIN            -1

and change the -1 to 4.

31 thoughts on “Gcode Controlled Extruder Fan

    • It’s one or the other with the LCD mod unfortunately. The Panelolu leaves the 12V and GND pins free, but uses all the signal pins. You can work around it a little by installing a switch as in Lawsey’s tutorial. The best way to get both is to upgrade to a RAMPS controller.

  1. Is there any way you can post a diagram of the overall circuit? I’m a little confused as to what the header with the red and blue wires does/where it goes.

  2. Hey Ian,

    is there anything that has to be changed in the Marlin Firmware (setting the FAN Pin correctly)? If yes, what du i have to set it to?

  3. Hello Ian, I think that in order for this to work reliably, you might need a different MOSFET; the one that you indicated doesn’t seem to be self-protected and might need extra limiting resistors (as also mentioned in the blog post that you link). Or am I wrong?

      • From the comparison table, none of them seems self-protected. Otherwise you should see something like “internally limited” in the “Maximum Continuous Drain Current (Amps)” line. I am planning to use the NCV8405ADTRKG, but I found that farnell/newark/element14 has quite a range of these components. Do a search for “Protected MOSFET” – then click on the MOSFET category and you can pick more or less any component from there. (this link might work: http://goo.gl/sbWk8)

        I want to stress that the risk of frying the Arduino is theoretical and might never happen in practice, but it still might be worth switching for a safer component.

        Hope this helps. Thanks a lot for your wonderful blog (I’m currently struggling with RepetierHost under Linux, but I think I found the problem, the baud rate :), next step: the fan)

      • Just stick a 1K resistor on the PWM line. Pretty standard practice for a setup like this, and I have verified it works with the MOSFET shown in your pictures.

        Also, you will have to assign the fan pin in the firmware as Stefan mentioned in the previous comment

      • I actually ordered the kit for that, but the reflow soldering was beyond my ability. I didn’t get it hot enough the first time around, and then I lost one of the diodes, which is smaller than a grain of rice. I ordered the parts for the board as shown on Thingiverse, but then realized that was all for making a regular MOSFET work, while according to Nophead you didn’t need any of that if you had a self protected logic level MOSFET.

  4. I have another observation worth noting. It seems that after having controlled the fan with Repetier, it changes something that makes it such that the number following the S designator in the command M106 S100 is the PWM value, not percentage. So to run the fan at full speed in Pronterface, I had to enter M106 S255.

  5. Can someone please expound a little more about how to change the firmware to the correct pin?

    I hope up Marlin.pde but can’t seem to see anything. I have a file the same folder called pins.h but I am not sure what to open it in. When I open it in arduino is just opens up marlin.pde…help please

    • There should be a row of tabs across the top which represents the other files in the directory. Pins.h is too far down to appear there, but there is an arrow at the right end of the tabs which will pull down the full list. If your monitor is too small to show the full list, you can cycle through the tabs with CTRL-ALT-ARROW.

      • Yep that was the problem. As always thank you. Would it be possible to wire up two fans (one controlled like above and one always on for the electronics?) Could this be down by just putting the two systems in parallel or is that too much power for the single 12V pin?

      • @Kyle: It is in principle possible, but it depends on the fans. My idea was to use a 8cm case fan (260mA) for the electronics and a 4cm fan for the extruder so I estimated a max consumption of 500mA. I asked Solidoodle some time ago regarding the specs of the power supply, and they would hesitate to draw an extra 500mA from it. So.In the end I decided to “risk” it for the extruder fan (120mA or so), but for the electronics fan I will use external power.

  6. I have a couple of questions. What length should the wires be? How do I make this look nice and tidy? What does the MOSFET mount to, if anything? Also, I have a 40mm fan which was used on a mother board to cool the nothrh-bridge. This fan has 3 wires. Can I wire the fan directly to the board without needing the MOSFET? 3 wires from the fan to the 3 contacts on the board sounds like it should work but I have a feeling it won’t, I’m just not sure why.

    • Hi,

      for the length, just pull the cable through and cut it accordingly. For the most tidy look you should create a PCB. About your three pin fan:

      you will always need the MOSFET, as the PWM pin of the board can not supply enough current to drive the fan. On your 3 pin fan, there should be one pin with the monitor signal (I think the middle one). This one won’t be used so you can just cut it. The other two need to be connected to the 12V and MOSFET according to Ians description.

  7. I have it all hooked up but there is no control. The button and slider in Repetier do nothing. Any advice would be greatly appreciated.

    • @Fatal:
      1. Open Pronterface and send the command M106 S255. It should spin up to full speed. M107 or M106 S0 to shut it off. If it runs, Repetier is not configured correctly. If nothing happens, continue…
      2. Did you update the firmware? If so, check that you modified the correct section of pins.h
      3. Double check the wiring on your mosfet.
      4. Double check that you have the mosfet connected to the right pins on the board.
      5. Try connecting the fan to 12V just to verify that the fan does work.

      • The fan would power on and then stop once I started to heat the extruder so I knew the wiring was good.
        I didn’t realize settings for so many different boards were all wrapped up in there. I did, in fact, change from -1 to 4 for the wrong board. Made the change now all is good. Thank you very much.
        Also, Ian, your’e not kidding about Radio Shack. I suggest they rename it to what it really is: Tax Shelter.

  8. Hi Ian,
    I am planning to install a fan for the extruder (and controller):

    Does this method work for the Sanguinololu controller board that comes with solidoodle 3? It is different from the one in your post and I do not know where the connection will be.

    After making these changes, will the fan be controlled by Repetier host to turn on/off automatically during printing (without manually changing the gcode)?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s