#adc #interpolation #embedded-hal

adc-interpolator

模拟数字转换器插值器

2个不稳定版本

0.2.0 2021年11月18日
0.1.0 2021年11月14日

#960 in 嵌入式开发


gp2d12中使用

MIT许可证

14KB
206

adc-interpolator

模拟数字转换器插值器。

使用线性插值将ADC的电压读数转换为有意义的数据。

示例

use adc_interpolator::{AdcInterpolator, Config};

let config = Config {
    max_voltage: 1000, // 1000 mV maximum voltage
    precision: 12,     // 12-bit precision
    voltage_to_values: [
        (100, 40), // 100 mV -> 40
        (200, 30), // 200 mV -> 30
        (300, 10), // 300 mV -> 10
    ],
};

let mut interpolator = AdcInterpolator::new(pin, config);

// With voltage at 150 mV, the value is 35
assert_eq!(interpolator.read(&mut adc), Ok(Some(35)));

许可证:MIT


lib.rs:

模拟数字转换器插值器。

使用线性插值将ADC的电压读数转换为有意义的数据。

示例

use adc_interpolator::{AdcInterpolator, Config};

let config = Config {
    max_voltage: 1000, // 1000 mV maximum voltage
    precision: 12,     // 12-bit precision
    voltage_to_values: [
        (100, 40), // 100 mV -> 40
        (200, 30), // 200 mV -> 30
        (300, 10), // 300 mV -> 10
    ],
};

let mut interpolator = AdcInterpolator::new(pin, config);

// With voltage at 150 mV, the value is 35
assert_eq!(interpolator.read(&mut adc), Ok(Some(35)));

依赖项

~71KB