Added PWM control to fan pin, added smoothing code for erratic gen6 temp readings
This commit is contained in:
parent
6becb19dc5
commit
ef8099b6dd
2 changed files with 21 additions and 2 deletions
|
|
@ -103,6 +103,10 @@ int error;
|
|||
int temp_iState_min = 100*-PID_INTEGRAL_DRIVE_MAX/PID_IGAIN;
|
||||
int temp_iState_max = 100*PID_INTEGRAL_DRIVE_MAX/PID_IGAIN;
|
||||
#endif
|
||||
#ifdef SMOOTHING
|
||||
uint32_t nma=SMOOTHFACTOR*analogRead(TEMP_0_PIN);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//Inactivity shutdown variables
|
||||
|
|
@ -653,9 +657,15 @@ inline void process_commands()
|
|||
}
|
||||
break;
|
||||
case 106: //M106 Fan On
|
||||
digitalWrite(FAN_PIN, HIGH);
|
||||
if (code_seen('S'))
|
||||
digitalWrite(FAN_PIN, HIGH);
|
||||
analogWrite(FAN_PIN,constrain(code_value(),0,255));
|
||||
else
|
||||
digitalWrite(FAN_PIN, HIGH);
|
||||
break;
|
||||
case 107: //M107 Fan Off
|
||||
analogWrite(FAN_PIN, 0);
|
||||
|
||||
digitalWrite(FAN_PIN, LOW);
|
||||
break;
|
||||
case 80: // M81 - ATX Power On
|
||||
|
|
@ -1049,6 +1059,8 @@ inline int read_max6675()
|
|||
return max6675_temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
inline void manage_heater()
|
||||
{
|
||||
#ifdef HEATER_USES_THERMISTOR
|
||||
|
|
@ -1061,7 +1073,10 @@ inline void manage_heater()
|
|||
#elif defined HEATER_USES_MAX6675
|
||||
current_raw = read_max6675();
|
||||
#endif
|
||||
|
||||
#ifdef SMOOTHING
|
||||
nma=(nma+current_raw)-(nma/SMOOTHFACTOR);
|
||||
current_raw=nma/SMOOTHFACTOR;
|
||||
#endif
|
||||
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_MAX66675)
|
||||
#ifdef PIDTEMP
|
||||
error = target_raw - current_raw;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ float min_constant_speed_units = 0.6; // the minimum units of an accelerated mov
|
|||
#define PID_DGAIN 100 //100 is 1.0
|
||||
#endif
|
||||
|
||||
//Experimental temperature smoothing - only uncomment this if your temp readings are noisy
|
||||
//#define SMOOTHING 1
|
||||
//#define SMOOTHFACTOR 16 //best to use a power of two here - determines how many values are averaged together by the smoothing algorithm
|
||||
|
||||
// Select one of these only to define how the nozzle temp is read.
|
||||
#define HEATER_USES_THERMISTOR
|
||||
//#define HEATER_USES_AD595
|
||||
|
|
|
|||
Loading…
Reference in a new issue