PINDA v2 temperature sensor / compensation (#16293)

This commit is contained in:
tompe-proj
2020-01-18 00:16:45 +01:00
committed by Scott Lahteine
parent 4108c5d01f
commit a338dce83f
16 changed files with 1016 additions and 41 deletions

View File

@ -262,6 +262,10 @@ Temperature thermalManager;
#endif // HAS_HEATED_CHAMBER
#endif // HAS_TEMP_CHAMBER
#if HAS_TEMP_PROBE
probe_info_t Temperature::temp_probe; // = { 0 }
#endif
// Initialized by settings.load()
#if ENABLED(PIDTEMP)
//hotend_pid_t Temperature::pid[HOTENDS];
@ -654,11 +658,11 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
case H_CHAMBER: return temp_chamber.soft_pwm_amount;
#endif
default:
#if HOTENDS
return temp_hotend[heater_id].soft_pwm_amount;
#else
return 0;
#endif
return (0
#if HOTENDS
+ temp_hotend[heater_id].soft_pwm_amount
#endif
);
}
}
@ -1398,7 +1402,7 @@ void Temperature::manage_heater() {
SERIAL_ECHO((int)e);
SERIAL_ECHOLNPGM(MSG_INVALID_EXTRUDER_NUM);
kill();
return 0.0;
return 0;
}
switch (e) {
@ -1498,6 +1502,7 @@ void Temperature::manage_heater() {
#elif ENABLED(HEATER_BED_USES_AD8495)
return TEMP_AD8495(raw);
#else
UNUSED(raw);
return 0;
#endif
}
@ -1516,11 +1521,31 @@ void Temperature::manage_heater() {
#elif ENABLED(HEATER_CHAMBER_USES_AD8495)
return TEMP_AD8495(raw);
#else
UNUSED(raw);
return 0;
#endif
}
#endif // HAS_TEMP_CHAMBER
#if HAS_TEMP_PROBE
// Derived from RepRap FiveD extruder::getTemperature()
// For probe temperature measurement.
float Temperature::analog_to_celsius_probe(const int raw) {
#if ENABLED(PROBE_USER_THERMISTOR)
return user_thermistor_to_deg_c(CTI_PROBE, raw);
#elif ENABLED(PROBE_USES_THERMISTOR)
SCAN_THERMISTOR_TABLE(PROBE_TEMPTABLE, PROBE_TEMPTABLE_LEN);
#elif ENABLED(PROBE_USES_AD595)
return TEMP_AD595(raw);
#elif ENABLED(PROBE_USES_AD8495)
return TEMP_AD8495(raw);
#else
UNUSED(raw);
return 0;
#endif
}
#endif // HAS_TEMP_PROBE
/**
* Get the raw values into the actual temperatures.
* The raw values are created in interrupt context,
@ -1543,6 +1568,9 @@ void Temperature::updateTemperaturesFromRawValues() {
#if HAS_TEMP_CHAMBER
temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw);
#endif
#if HAS_TEMP_PROBE
temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw);
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1);
#endif
@ -1721,6 +1749,9 @@ void Temperature::init() {
#if HAS_TEMP_CHAMBER
HAL_ANALOG_SELECT(TEMP_CHAMBER_PIN);
#endif
#if HAS_TEMP_PROBE
HAL_ANALOG_SELECT(TEMP_PROBE_PIN);
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
HAL_ANALOG_SELECT(FILWIDTH_PIN);
#endif
@ -2215,6 +2246,10 @@ void Temperature::set_current_temp_raw() {
temp_chamber.update();
#endif
#if HAS_TEMP_PROBE
temp_probe.update();
#endif
#if HAS_JOY_ADC_X
joystick.x.update();
#endif
@ -2253,6 +2288,10 @@ void Temperature::readings_ready() {
temp_chamber.reset();
#endif
#if HAS_TEMP_PROBE
temp_probe.reset();
#endif
#if HAS_JOY_ADC_X
joystick.x.reset();
#endif
@ -2661,6 +2700,11 @@ void Temperature::tick() {
case MeasureTemp_CHAMBER: ACCUMULATE_ADC(temp_chamber); break;
#endif
#if HAS_TEMP_PROBE
case PrepareTemp_PROBE: HAL_START_ADC(TEMP_PROBE_PIN); break;
case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break;
#endif
#if HAS_TEMP_ADC_1
case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break;
case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break;
@ -2774,6 +2818,9 @@ void Temperature::tick() {
#if HAS_TEMP_CHAMBER
case H_CHAMBER: k = 'C'; break;
#endif
#if HAS_TEMP_PROBE
case H_PROBE: k = 'P'; break;
#endif
#if HAS_TEMP_HOTEND
default: k = 'T'; break;
#if HAS_HEATED_BED
@ -2842,6 +2889,14 @@ void Temperature::tick() {
, H_CHAMBER
);
#endif // HAS_TEMP_CHAMBER
#if HAS_TEMP_PROBE
print_heater_state(degProbe(), 0
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, rawProbeTemp()
#endif
, H_PROBE
);
#endif // HAS_TEMP_PROBE
#if HOTENDS > 1
HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e)
#if ENABLED(SHOW_TEMP_ADC_VALUES)