Welcome! Log In Create A New Profile

Advanced

Enable cooling fan when starting to heat extruder.

Posted by zelogik 
Enable cooling fan when starting to heat extruder.
June 12, 2012 09:03AM
Hello,

I don't know if it's the right topic ... and I use Marlin.

For the moment I use M42 for enabling a fan when I start to heat my extruder. But there is a special line for enable a pin (digital or analog) for starting a fan for cooling the barrel only when I start heating the extruder?

- Put a fan in parallel of the heating circuit is not really good when you use PID.
- I often forget to enable M42 and heat too much the barrel ...
- There is a line for enable a pin when one motor move .... but not when the extruder heat :-(

Thanks you.

Edited 1 time(s). Last edit at 06/12/2012 09:05AM by zelogik.
Re: Enable cooling fan when starting to heat extruder.
June 14, 2012 04:02AM
#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function
#define CONTROLLERFAN_SEC 60

seems to be your best bet unless you are willing to dig into the code.
replace this code in temperature.cpp starting line 313

// Check if temperature is within the correct range
if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e]))
{
soft_pwm[e] = (int)pid_output >> 1;
}
else {
soft_pwm[e] = 0;
}
} // End extruder for loop


with this
//----------------------------------------------cut--------------------------------------------------------------
// Check if temperature is within the correct range
if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e]))
{
soft_pwm[e] = (int)pid_output >> 1;
#ifdef CONTROLLERFAN_PIN
if(current_raw[e] < target_raw[e]) { WRITE (CONTROLLERFAN_PIN,HIGH);// if current temp is less than

//programed turn fan on if it exists, otherwise ignore it.
}
#endif
}
else {
soft_pwm[e] = 0;
}
} // End extruder for loop
//----------------------------------------cut------------------------------------------

either method you will want to set pin for CONTROLLERFAN_PIN, it will still disable if time has past and motors are disabled.

it compiles the code in arduino 1.01, so it programs in, but as with any untested code, verify before placing it in practice.

the intent with this code is if you use CONTROLLERFAN_PIN, then when extruder starts heating, The pin goes high. powering whatever you are going to use before outputting to the fan. be aware of power requirements of fan, and of back emf. for example. use a power transistor and a fly back diode.

Edited 1 time(s). Last edit at 06/14/2012 04:05AM by jamesdanielv.
Re: Enable cooling fan when starting to heat extruder.
June 14, 2012 07:18AM
Hello,

Thanks for your reply,

Yersterday, I have added the Spinter code in marlin for add this functionnality instead of remove controllerFan option. (thanks brddl )
And the fan pin goes on only when the temperature of the extruder is above a configured temperature.

My only problem is that the new gcc-avr/libc-avr package in debian don't compile the code with arduino 1.0.1 !!!

Need to check how to make a proposition in git for being integrated in marlin directly.
For the power transistor of course (12V instead 5V/40mA arduino), but I have forgot the flyback diode winking smiley

@+
ie: I will post the code when I return to Home winking smiley

Edited 1 time(s). Last edit at 06/14/2012 07:20AM by zelogik.
Re: Enable cooling fan when starting to heat extruder.
June 16, 2012 03:02AM
FInally I have take your code with minor add.


in temperature.cpp line 314 change with:

if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e]))
{
soft_pwm[e] = (int)pid_output >> 1;
#ifdef EXTRUDERFAN_PIN
int current_temper = analog2temp(current_raw[e], e);
if(current_temper > EXTRUDERFAN_DEC) {
pinMode(EXTRUDERFAN_PIN, OUTPUT);
WRITE(EXTRUDERFAN_PIN,EXTRUDERFAN_POW);// if current temp is less than
}else{ //programed turn fan on if it exists, otherwise ignore it.
pinMode(EXTRUDERFAN_PIN, OUTPUT);
WRITE(EXTRUDERFAN_PIN, LOW);
}
#endif
}
else {
soft_pwm[e] = 0;
}
} // End extruder for loop


yes I know the pinMode each time is not very good but I don't know where to add this elsewhere.
and in configuration_adv.h add:

#define EXTRUDERFAN_PIN 4 // pin used for the fan to cool the barrel, comment for disable functionnality
#define EXTRUDERFAN_DEC 60 // min temperature before start
#define EXTRUDERFAN_POW 255 // power of fan between 0-255
Sorry, only registered users may post in this forum.

Click here to login