From ab680d6947c889d0a2e4fedda697c7bc6a5eb28a Mon Sep 17 00:00:00 2001 From: Manianac <2092573+manianac@users.noreply.github.com> Date: Thu, 31 Mar 2022 19:06:57 -0400 Subject: [PATCH 1/2] Use HAL_ADC_VREF instead of 5.0v for filament width ADC --- Marlin/src/feature/filwidth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/filwidth.h b/Marlin/src/feature/filwidth.h index e234380e981a..5051866df030 100644 --- a/Marlin/src/feature/filwidth.h +++ b/Marlin/src/feature/filwidth.h @@ -67,7 +67,7 @@ class FilamentWidthSensor { } // Convert raw measurement to mm - static float raw_to_mm(const uint16_t v) { return v * 5.0f * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } + static float raw_to_mm(const uint16_t v) { return v * HAL_ADC_VREF * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } static float raw_to_mm() { return raw_to_mm(raw); } // A scaled reading is ready From d38036e1c42e5e2c3c704f451f3a54ee92c10092 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 31 Mar 2022 19:18:54 -0500 Subject: [PATCH 2/2] Use ADC_VREF --- Marlin/src/feature/filwidth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/filwidth.h b/Marlin/src/feature/filwidth.h index 5051866df030..9eb1e77762ff 100644 --- a/Marlin/src/feature/filwidth.h +++ b/Marlin/src/feature/filwidth.h @@ -67,7 +67,7 @@ class FilamentWidthSensor { } // Convert raw measurement to mm - static float raw_to_mm(const uint16_t v) { return v * HAL_ADC_VREF * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } + static float raw_to_mm(const uint16_t v) { return v * float(ADC_VREF) * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } static float raw_to_mm() { return raw_to_mm(raw); } // A scaled reading is ready