OpenPicoRTOS icon indicating copy to clipboard operation
OpenPicoRTOS copied to clipboard

ADC: improve calibration by using a polynomial

Open jnaulet opened this issue 1 year ago • 1 comments

Calibration can be improved by using some kind of polynomial.
As not all architectures support floating point, it might take the form of a series of fractions, like:

struct adc_polynomial {
    unsigned long numerator;
    unsigned long denominator;
};

While calibrating the ADC, it might look like:

    static struct adc_polynomial poly[3] = {
        { 64, 73 }, { 2442, 10000 }, { 32, 37 }
    };

    (void)adc_set_polynomial(&ADCx, poly, (size_t)3);

jnaulet avatar Dec 02 '23 13:12 jnaulet

This might be a upper layer, and make adc_read return uint16_t, for example

jnaulet avatar Jul 03 '24 13:07 jnaulet