Make ADC sensor reading frequency adjustable
This commit is contained in:
@ -50,6 +50,49 @@
|
||||
#define EXTRUDER_IDX active_extruder
|
||||
#endif
|
||||
|
||||
/**
|
||||
* States for ADC reading in the ISR
|
||||
*/
|
||||
enum ADCSensorState {
|
||||
#if HAS_TEMP_0
|
||||
PrepareTemp_0,
|
||||
MeasureTemp_0,
|
||||
#endif
|
||||
#if HAS_TEMP_1
|
||||
PrepareTemp_1,
|
||||
MeasureTemp_1,
|
||||
#endif
|
||||
#if HAS_TEMP_2
|
||||
PrepareTemp_2,
|
||||
MeasureTemp_2,
|
||||
#endif
|
||||
#if HAS_TEMP_3
|
||||
PrepareTemp_3,
|
||||
MeasureTemp_3,
|
||||
#endif
|
||||
#if HAS_TEMP_4
|
||||
PrepareTemp_4,
|
||||
MeasureTemp_4,
|
||||
#endif
|
||||
#if HAS_TEMP_BED
|
||||
PrepareTemp_BED,
|
||||
MeasureTemp_BED,
|
||||
#endif
|
||||
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
||||
Prepare_FILWIDTH,
|
||||
Measure_FILWIDTH,
|
||||
#endif
|
||||
SensorsReady, // Temperatures ready. Delay the next round of readings to let ADC pins settle.
|
||||
StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
|
||||
};
|
||||
|
||||
// Minimum number of Temperature::ISR loops between sensor readings.
|
||||
// Multiplied by 16 (OVERSAMPLENR) to obtain the total time to
|
||||
// get all oversampled sensor readings
|
||||
#define MIN_ADC_ISR_LOOPS 10
|
||||
|
||||
#define ACTUAL_ADC_SAMPLES max(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
|
||||
|
||||
class Temperature {
|
||||
|
||||
public:
|
||||
@ -74,7 +117,7 @@ class Temperature {
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
|
||||
#define PID_dT ((OVERSAMPLENR * 12.0)/(F_CPU / 64.0 / 256.0))
|
||||
#define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (F_CPU / 64.0 / 256.0))
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
|
Reference in New Issue
Block a user