Menu

Cool stepper drivers

After seeing quite a few stepper drivers die, I decided to put some cooling on mine, but instead of having the fan running all the time, I made an extra function for it.

This new function will turn the fan on when any stepper driver is enabled, and turn the fan back off after a defined amount of seconds, after the last driver have been disabled again.

First we need a function inside the .pde file that can actually do the calculating of time, and set the pin HIGH or LOW

#ifdef CONTROLLERFAN_PIN
unsigned long lastMotor = 0; //Save the time for when a motor was turned on last
unsigned long lastMotorCheck = 0;
void controllerFan()
{
if ((millis() - lastMotorCheck) >= 2500) //Not a time critical function, so we only check every 2500ms
{
lastMotorCheck = millis();
if(!digitalRead(X_ENABLE_PIN) || !digitalRead(Y_ENABLE_PIN) || !digitalRead(Z_ENABLE_PIN) || !digitalRead(E_ENABLE_PIN)) //If any of the drivers are enabled...
{
lastMotor = millis(); //... set time to NOW so the fan will turn on
}
if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
{
digitalWrite(CONTROLLERFAN_PIN, LOW); //... turn the fan off
}
else
{
digitalWrite(CONTROLLERFAN_PIN, HIGH); //... turn the fan on
}
}
}
#endif

After that, we also need to call the function, and the easiest way to do this (in my opinion) is to call it inside manage_heater(), after it have checked the temperatures and so.

#ifdef CONTROLLERFAN_PIN
controllerFan(); //Check if fan should be turned on to cool stepper drivers down
#endif

But before the pin can turn anything on and off, we need to set it to OUTPUT, we can do that by adding this to setup()

To make life a bit easier for everyone, we add two more options to configuration.h

The first one is the pin we decide to use for the fan, and the second is how long the fan should run after the last stepper driver have been disabled.

#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function
#define CONTROLLERFAN_SEC 60 //How many seconds, after all motors were disabled, the fan should run

Thats it! 🙂 All you need to do now is to connect a fan to your controller, and make a nice case for it. But remember! You can NOT drive a fan directly from any of the pins on the controller, not even 5V ones.

To drive a fan, you need a transistor or a mosfet. On the following image I am using a TIP102 to do the heavy lifting the pin can’t do.

If we look at the pins from the left. The first pin is the one connected to the pin on the controller, where you put a 10k resistor on to limit the current. The middle pin goes down to minus/gnd on the fan, and the right pin goes to the minus/gnd on your power supply.

Warning the “flap” on the TIP102 is connected to the middle pin, so never connect it to anything that can conduct electricity, or you might get a short or other unexpected things happening.