PINDA v2 temperature sensor / compensation (#16293)
This commit is contained in:
committed by
Scott Lahteine
parent
4108c5d01f
commit
a338dce83f
@ -114,6 +114,10 @@
|
||||
#include "../feature/tmc_util.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBE_TEMP_COMPENSATION)
|
||||
#include "../feature/probe_temp_compensation.h"
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 1) // No padding between variables
|
||||
|
||||
typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_stepper_current_t;
|
||||
@ -212,6 +216,18 @@ typedef struct SettingsDataStruct {
|
||||
//
|
||||
uint16_t servo_angles[EEPROM_NUM_SERVOS][2]; // M281 P L U
|
||||
|
||||
//
|
||||
// Temperature first layer compensation values
|
||||
//
|
||||
#if ENABLED(PROBE_TEMP_COMPENSATION)
|
||||
int16_t z_offsets_probe[COUNT(temp_comp.z_offsets_probe)], // M871 P I V
|
||||
z_offsets_bed[COUNT(temp_comp.z_offsets_bed)] // M871 B I V
|
||||
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
|
||||
, z_offsets_ext[COUNT(temp_comp.z_offsets_ext)] // M871 E I V
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
//
|
||||
// BLTOUCH
|
||||
//
|
||||
@ -699,6 +715,19 @@ void MarlinSettings::postprocess() {
|
||||
EEPROM_WRITE(servo_angles);
|
||||
}
|
||||
|
||||
//
|
||||
// Thermal first layer compensation values
|
||||
//
|
||||
#if ENABLED(PROBE_TEMP_COMPENSATION)
|
||||
EEPROM_WRITE(temp_comp.z_offsets_probe);
|
||||
EEPROM_WRITE(temp_comp.z_offsets_bed);
|
||||
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
|
||||
EEPROM_WRITE(temp_comp.z_offsets_ext);
|
||||
#endif
|
||||
#else
|
||||
// No placeholder data for this feature
|
||||
#endif
|
||||
|
||||
//
|
||||
// BLTOUCH
|
||||
//
|
||||
@ -1514,6 +1543,20 @@ void MarlinSettings::postprocess() {
|
||||
EEPROM_READ(servo_angles_arr);
|
||||
}
|
||||
|
||||
//
|
||||
// Thermal first layer compensation values
|
||||
//
|
||||
#if ENABLED(PROBE_TEMP_COMPENSATION)
|
||||
EEPROM_READ(temp_comp.z_offsets_probe);
|
||||
EEPROM_READ(temp_comp.z_offsets_bed);
|
||||
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
|
||||
EEPROM_READ(temp_comp.z_offsets_ext);
|
||||
#endif
|
||||
temp_comp.reset_index();
|
||||
#else
|
||||
// No placeholder data for this feature
|
||||
#endif
|
||||
|
||||
//
|
||||
// BLTOUCH
|
||||
//
|
||||
|
@ -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)
|
||||
|
@ -47,8 +47,8 @@
|
||||
|
||||
// Identifiers for other heaters
|
||||
typedef enum : int8_t {
|
||||
INDEX_NONE = -4,
|
||||
H_REDUNDANT, H_CHAMBER, H_BED,
|
||||
INDEX_NONE = -5,
|
||||
H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
|
||||
H_E0, H_E1, H_E2, H_E3, H_E4, H_E5
|
||||
} heater_ind_t;
|
||||
|
||||
@ -114,6 +114,9 @@ enum ADCSensorState : char {
|
||||
#if HAS_TEMP_CHAMBER
|
||||
PrepareTemp_CHAMBER, MeasureTemp_CHAMBER,
|
||||
#endif
|
||||
#if HAS_TEMP_PROBE
|
||||
PrepareTemp_PROBE, MeasureTemp_PROBE,
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_1
|
||||
PrepareTemp_1, MeasureTemp_1,
|
||||
#endif
|
||||
@ -202,6 +205,9 @@ struct PIDHeaterInfo : public HeaterInfo {
|
||||
typedef heater_info_t bed_info_t;
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_TEMP_PROBE
|
||||
typedef temp_info_t probe_info_t;
|
||||
#endif
|
||||
#if HAS_HEATED_CHAMBER
|
||||
typedef heater_info_t chamber_info_t;
|
||||
#elif HAS_TEMP_CHAMBER
|
||||
@ -258,6 +264,9 @@ typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t;
|
||||
#if ENABLED(HEATER_BED_USER_THERMISTOR)
|
||||
CTI_BED,
|
||||
#endif
|
||||
#if ENABLED(HEATER_PROBE_USER_THERMISTOR)
|
||||
CTI_PROBE,
|
||||
#endif
|
||||
#if ENABLED(HEATER_CHAMBER_USER_THERMISTOR)
|
||||
CTI_CHAMBER,
|
||||
#endif
|
||||
@ -289,11 +298,12 @@ class Temperature {
|
||||
#endif
|
||||
static hotend_info_t temp_hotend[HOTEND_TEMPS];
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
static bed_info_t temp_bed;
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_PROBE
|
||||
static probe_info_t temp_probe;
|
||||
#endif
|
||||
#if HAS_TEMP_CHAMBER
|
||||
static chamber_info_t temp_chamber;
|
||||
#endif
|
||||
@ -301,7 +311,6 @@ class Temperature {
|
||||
#if ENABLED(AUTO_POWER_E_FANS)
|
||||
static uint8_t autofan_speed[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_POWER_CHAMBER_FAN)
|
||||
static uint8_t chamberfan_speed;
|
||||
#endif
|
||||
@ -467,6 +476,9 @@ class Temperature {
|
||||
#if HAS_HEATED_BED
|
||||
static float analog_to_celsius_bed(const int raw);
|
||||
#endif
|
||||
#if HAS_TEMP_PROBE
|
||||
static float analog_to_celsius_probe(const int raw);
|
||||
#endif
|
||||
#if HAS_TEMP_CHAMBER
|
||||
static float analog_to_celsius_chamber(const int raw);
|
||||
#endif
|
||||
@ -662,6 +674,19 @@ class Temperature {
|
||||
|
||||
#endif // HAS_HEATED_BED
|
||||
|
||||
#if HAS_TEMP_PROBE
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
FORCE_INLINE static int16_t rawProbeTemp() { return temp_probe.raw; }
|
||||
#endif
|
||||
FORCE_INLINE static float degProbe() { return temp_probe.celsius; }
|
||||
#endif
|
||||
|
||||
#if WATCH_PROBE
|
||||
static void start_watching_probe();
|
||||
#else
|
||||
static inline void start_watching_probe() {}
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_CHAMBER
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; }
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
#define OV(N) int16_t((N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE))
|
||||
|
||||
#define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTORBED == n || THERMISTORCHAMBER == n)
|
||||
#define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n)
|
||||
|
||||
// Pt1000 and Pt100 handling
|
||||
//
|
||||
@ -249,13 +249,20 @@
|
||||
#else
|
||||
#define CHAMBER_TEMPTABLE_LEN 0
|
||||
#endif
|
||||
#ifdef THERMISTORPROBE
|
||||
#define PROBE_TEMPTABLE TT_NAME(THERMISTORPROBE)
|
||||
#define PROBE_TEMPTABLE_LEN COUNT(PROBE_TEMPTABLE)
|
||||
#else
|
||||
#define PROBE_TEMPTABLE_LEN 0
|
||||
#endif
|
||||
|
||||
// The SCAN_THERMISTOR_TABLE macro needs alteration?
|
||||
static_assert(
|
||||
HEATER_0_TEMPTABLE_LEN < 256 && HEATER_1_TEMPTABLE_LEN < 256
|
||||
&& HEATER_2_TEMPTABLE_LEN < 256 && HEATER_3_TEMPTABLE_LEN < 256
|
||||
&& HEATER_4_TEMPTABLE_LEN < 256 && HEATER_5_TEMPTABLE_LEN < 256
|
||||
&& BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256,
|
||||
&& BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256
|
||||
&& PROBE_TEMPTABLE_LEN < 256,
|
||||
"Temperature conversion tables over 255 entries need special consideration."
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user