temp.c: allow smoothing temperature readings.
This is done by an Exponentially Weighted Moving Average (EWMA) formula. Contribution by DaveX, see http://forums.reprap.org/read.php?147,33082,157978#msg-157978 Thanks a lot, Dave.
This commit is contained in:
parent
8b05e77d49
commit
8e27595a5f
|
|
@ -251,6 +251,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 1.0
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -256,6 +256,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 0.1
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
// #define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -251,6 +251,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 0.1
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -259,6 +259,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 1.0
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -259,6 +259,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 1.0
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -254,6 +254,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 0.1
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -258,6 +258,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 0.1
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -255,6 +255,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 0.1
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -255,6 +255,19 @@
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 0.1
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
|
|
@ -339,6 +339,19 @@ New plan:
|
|||
*/
|
||||
#define TEMP_RESIDENCY_TIME 60
|
||||
|
||||
/**
|
||||
TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be
|
||||
noisy. Set to 1.0 for unfiltered data (and a 140 bytes smaller binary).
|
||||
|
||||
Instrument Engineer's Handbook, 4th ed, Vol 2 p126 says values of
|
||||
0.05 to 0.1 are typical. Smaller is smoother but slower adjusting, larger is
|
||||
quicker but rougher. If you need to use this, set the PID parameter to zero
|
||||
(M132 S0) to make the PID loop insensitive to noise.
|
||||
|
||||
Valid range: 0.001 to 1.0
|
||||
*/
|
||||
#define TEMP_EWMA 0.1
|
||||
|
||||
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
|
||||
// #define TEMP_MAX6675
|
||||
#define TEMP_THERMISTOR
|
||||
|
|
|
|||
12
temp.c
12
temp.c
|
|
@ -289,7 +289,17 @@ void temp_sensor_tick() {
|
|||
default: /* prevent compiler warning */
|
||||
break;
|
||||
}
|
||||
temp_sensors_runtime[i].last_read_temp = temp;
|
||||
/* Exponentially Weighted Moving Average alpha constant for smoothing
|
||||
noisy sensors. Instrument Engineer's Handbook, 4th ed, Vol 2 p126
|
||||
says values of 0.05 to 0.1 for TEMP_EWMA are typical. */
|
||||
#ifndef TEMP_EWMA
|
||||
#define TEMP_EWMA 1.0
|
||||
#endif
|
||||
#define EWMA_SCALE 1024L
|
||||
#define EWMA_ALPHA ((long) (TEMP_EWMA * EWMA_SCALE))
|
||||
temp_sensors_runtime[i].last_read_temp = (EWMA_ALPHA * temp +
|
||||
(EWMA_SCALE-EWMA_ALPHA) * temp_sensors_runtime[i].last_read_temp
|
||||
) / EWMA_SCALE;
|
||||
}
|
||||
if (labs((int16_t)(temp_sensors_runtime[i].last_read_temp - temp_sensors_runtime[i].target_temp)) < (TEMP_HYSTERESIS*4)) {
|
||||
if (temp_sensors_runtime[i].temp_residency < (TEMP_RESIDENCY_TIME*120))
|
||||
|
|
|
|||
Loading…
Reference in New Issue