pt-rtd

Crates.iopt-rtd
lib.rspt-rtd
version0.1.1
sourcesrc
created_at2023-02-19 19:50:04.93885
updated_at2023-02-19 20:18:32.070129
descriptionCalculation of resistance and temperature for platinum type RTDs, e.g. PT100.
homepage
repositoryhttps://github.com/thecodechemist99/pt-rtd
max_upload_size
id789243
size20,155
(thecodechemist99)

documentation

README

pt-rtd

Latest Version Documentation License Dependency Status

Usage

Add this to your Cargo.toml:

[dependencies]
pt-rtd = "0.1"

Examples

Conversion of temperature and resistance values:

use pt_rtd::{
    self as rtd,
    RTDType,
};

fn main() -> ! {
    let resistance: f32 = 100.0;
    let temperature: f32 = 0.0;

    // Convert resistance to temperature
    let result = rtd::calc_t(resistance, RTDType::PT100);
    let t = match result {
        Ok(temp) => temp,
        Err(e) => // handle error
    }

    // Convert temperature to resistance
    let result = rtd::calc_r(temperature, RTDType::PT100);
    let r = match result {
        Ok(res) => res,
        Err(e) => // handle error
    }
}

For relative mesurements, the library can also convert the ADC reading to a resistance value:

use pt_rtd::{
    self as rtd,
    ADCRes,
};

fn main() -> ! {
    let adc_value: u32 = 1000;
    let adc_resolution = ADCRes::B24;
    let ref_resistance = 5600;
    let pga_gain = 16;

    let result = rtd::conv_d_val_to_r(adc_value, ref_resistance, adc_resolution, pga_gain);
    let r = match result {
        Ok(res) => res,
        Err(e) => // handle error
    }
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 11

cargo fmt