steinhart_hart: Beta Parameter uom dimensions
The Beta Parameter is not dimensionless, and has unit Kelvin. Incorporate that into the type system for better checks.
This commit is contained in:
parent
1ae6a6fdd4
commit
c1b183ddd5
|
@ -38,7 +38,7 @@ use uom::{
|
||||||
electric_current::ampere,
|
electric_current::ampere,
|
||||||
electric_potential::volt,
|
electric_potential::volt,
|
||||||
electrical_resistance::ohm,
|
electrical_resistance::ohm,
|
||||||
thermodynamic_temperature::degree_celsius,
|
thermodynamic_temperature::{degree_celsius, kelvin},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ impl Handler {
|
||||||
use super::command_parser::ShParameter::*;
|
use super::command_parser::ShParameter::*;
|
||||||
match parameter {
|
match parameter {
|
||||||
T0 => sh.t0 = ThermodynamicTemperature::new::<degree_celsius>(value),
|
T0 => sh.t0 = ThermodynamicTemperature::new::<degree_celsius>(value),
|
||||||
B => sh.b = value,
|
B => sh.b = ThermodynamicTemperature::new::<kelvin>(value),
|
||||||
R0 => sh.r0 = ElectricalResistance::new::<ohm>(value),
|
R0 => sh.r0 = ElectricalResistance::new::<ohm>(value),
|
||||||
}
|
}
|
||||||
send_line(socket, b"{}");
|
send_line(socket, b"{}");
|
||||||
|
|
|
@ -15,16 +15,16 @@ use serde::{Deserialize, Serialize};
|
||||||
pub struct Parameters {
|
pub struct Parameters {
|
||||||
/// Base temperature
|
/// Base temperature
|
||||||
pub t0: ThermodynamicTemperature,
|
pub t0: ThermodynamicTemperature,
|
||||||
/// Base resistance
|
/// Resistance at base temperature
|
||||||
pub r0: ElectricalResistance,
|
pub r0: ElectricalResistance,
|
||||||
/// Beta
|
/// Beta
|
||||||
pub b: f64,
|
pub b: ThermodynamicTemperature,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parameters {
|
impl Parameters {
|
||||||
/// Perform the voltage to temperature conversion.
|
/// Perform the resistance to temperature conversion.
|
||||||
pub fn get_temperature(&self, r: ElectricalResistance) -> ThermodynamicTemperature {
|
pub fn get_temperature(&self, r: ElectricalResistance) -> ThermodynamicTemperature {
|
||||||
let inv_temp = 1.0 / self.t0.get::<kelvin>() + (r / self.r0).get::<ratio>().ln() / self.b;
|
let inv_temp = 1.0 / self.t0.get::<kelvin>() + (r / self.r0).get::<ratio>().ln() / self.b.get::<kelvin>();
|
||||||
ThermodynamicTemperature::new::<kelvin>(1.0 / inv_temp)
|
ThermodynamicTemperature::new::<kelvin>(1.0 / inv_temp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ impl Default for Parameters {
|
||||||
Parameters {
|
Parameters {
|
||||||
t0: ThermodynamicTemperature::new::<degree_celsius>(25.0),
|
t0: ThermodynamicTemperature::new::<degree_celsius>(25.0),
|
||||||
r0: ElectricalResistance::new::<ohm>(10_000.0),
|
r0: ElectricalResistance::new::<ohm>(10_000.0),
|
||||||
b: 3800.0,
|
b: ThermodynamicTemperature::new::<kelvin>(3800.0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue