Implement automatic extruder/cold-end fan control based on temperature

This change allows fan outputs to automatically turn on/off when the
associated nozzle temperature of an extruder is above/below a threshold
temperature.
Multiple extruders can be assigned to the same pin in which case the fan
will turn on when any selected extruder is above the threshold.
It also makes the M42 command compatible with the M106/M107 command.
The majority of the logic in this change will be evaluated by the
compiler at build time (i.e, low code space requirements).
This commit is contained in:
Robert F-C
2013-03-01 21:57:23 +11:00
parent 4eb81a69e6
commit 372e12f83f
4 changed files with 302 additions and 234 deletions

View File

@@ -157,12 +157,12 @@ float add_homeing[3]={0,0,0};
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
// Extruder offset, only in XY plane
#if EXTRUDERS > 1
#if EXTRUDERS > 1
float extruder_offset[2][EXTRUDERS] = {
#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y
#endif
};
};
#endif
uint8_t active_extruder = 0;
int fanSpeed=0;
@@ -982,6 +982,10 @@ void process_commands()
break;
}
}
#if FAN_PIN > -1
if (pin_number == FAN_PIN)
fanSpeed = pin_status;
#endif
if (pin_number > -1)
{
pinMode(pin_number, OUTPUT);
@@ -1380,7 +1384,7 @@ void process_commands()
}
}break;
#endif // FWRETRACT
#endif // FWRETRACT
#if EXTRUDERS > 1
case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
{
@@ -1405,7 +1409,7 @@ void process_commands()
SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
}
SERIAL_ECHOLN("");
}break;
}break;
#endif
case 220: // M220 S<factor in percent>- set speed factor override percentage
{
@@ -1756,7 +1760,7 @@ void process_commands()
if(make_move && Stopped == false) {
prepare_move();
}
}
}
#endif
SERIAL_ECHO_START;
SERIAL_ECHO(MSG_ACTIVE_EXTRUDER);