ADC needs to be tuned with regards to the input voltage
this feature should be implemented on the core of the marlin, regarding the analogue data reads like temperature sensor reads and so on. As you know Arduino boards does not have a reference voltage pin connected and so the controller will use the Vcc as the V_ref for ADC conversions. this will result in imprecise readings of the analogue input.
there is a video on the you-tube channel "Andreas Spiess" with the following link: https://www.youtube.com/watch?v=UAJMLTzrM9Q
in this link it is explained why the ADC is imprecise on many controllers regarding the reference voltage sampling and a code is suggested for somehow correcting the current ADC result for super precise measurements
please consider this for more accurate temperature readings on all hardware.
https://www.youtube.com/watch?v=UAJMLTzrM9Q
https://www.youtube.com/watch?v=xI_qU2auVx8
This mostly does not apply to our 3d printers.
This applies to measuring external voltages. The voltages we measure are derived from the same vcc that is applied to the a_ref
eg thermistors. Basically a voltage divider. 4.7k fixed with a variable resistor that is the thermistor.
Ie this
voltage dividers
let presume that the thermistor is also reading 4.7k to make the math simple
So the math becomes Vout = Vin/2
Vin = 5v => Vout 2.5v so half the a_ref voltage so you get max adc value/2 ie 1024/2 512
now we drop the voltage
Vin = 4v => Vout 2v so half the a_ref voltage so you get max adc value/2 ie still 512
The result in the same temperature reading.
That's right as long we are measuring resistor relations.
But there are a few cases where we are indeed measuring voltages directly. For example when we use tables 20 or 21, -1 or -4. And the we are in trouble. There switching the power supply for the processor from USB to an other voltage regulator usually makes a noticeable difference.
Additionally to the already provided solution for the AVRs i could find a solution for the STM32s using stm32duino.
The best exactness could be achieved by handling the Vref-channel like the other ADC-pins, in every loop over the pins.
A far less performance intensive variation could be to test Vref only one during startup. This would at least be able to handle the big differences when running from different sources for the power.
Most helpful comment
This mostly does not apply to our 3d printers.
This applies to measuring external voltages. The voltages we measure are derived from the same vcc that is applied to the a_ref
eg thermistors. Basically a voltage divider. 4.7k fixed with a variable resistor that is the thermistor.
Ie this
voltage dividers
let presume that the thermistor is also reading 4.7k to make the math simple
So the math becomes Vout = Vin/2
Vin = 5v => Vout 2.5v so half the a_ref voltage so you get max adc value/2 ie 1024/2 512
now we drop the voltage
Vin = 4v => Vout 2v so half the a_ref voltage so you get max adc value/2 ie still 512
The result in the same temperature reading.