summaryrefslogtreecommitdiff
path: root/Tonokip_Firmware
diff options
context:
space:
mode:
Diffstat (limited to 'Tonokip_Firmware')
-rw-r--r--Tonokip_Firmware/Tonokip_Firmware.pde19
-rw-r--r--Tonokip_Firmware/configuration.h4
2 files changed, 21 insertions, 2 deletions
diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Tonokip_Firmware/Tonokip_Firmware.pde
index 0be8d40..9615320 100644
--- a/Tonokip_Firmware/Tonokip_Firmware.pde
+++ b/Tonokip_Firmware/Tonokip_Firmware.pde
@@ -104,6 +104,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
@@ -654,9 +658,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
@@ -1052,6 +1062,8 @@ inline int read_max6675()
return max6675_temp;
}
#endif
+
+
inline void manage_heater()
{
#ifdef HEATER_USES_THERMISTOR
@@ -1064,7 +1076,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;
diff --git a/Tonokip_Firmware/configuration.h b/Tonokip_Firmware/configuration.h
index e5e0e5f..aba5176 100644
--- a/Tonokip_Firmware/configuration.h
+++ b/Tonokip_Firmware/configuration.h
@@ -29,6 +29,10 @@ float min_constant_speed_units = 2; // the minimum units of an accelerated move
#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