forked from M-Labs/kirdy
pd_mon: Separate ld_power calculation to a file
This commit is contained in:
parent
3cfdee917a
commit
0d12c902fc
@ -89,10 +89,6 @@ impl LdDrive{
|
|||||||
self.settings.ld_drive_current_limit = i_limit;
|
self.settings.ld_drive_current_limit = i_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_pd_i_to_out_pwr(&mut self, val: IToPowerUnit){
|
|
||||||
self.settings.pd_i_to_out_pwr = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn ld_short(&mut self) {
|
pub fn ld_short(&mut self) {
|
||||||
self.ctrl.ld_short_enable();
|
self.ctrl.ld_short_enable();
|
||||||
}
|
}
|
||||||
@ -101,11 +97,6 @@ impl LdDrive{
|
|||||||
self.ctrl.ld_short_disable();
|
self.ctrl.ld_short_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_ld_power_output(&mut self) -> Power {
|
|
||||||
let pd_i = self.get_pd_i();
|
|
||||||
pd_i * self.settings.pd_i_to_out_pwr
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_pd_i(&mut self) -> ElectricCurrent {
|
pub fn get_pd_i(&mut self) -> ElectricCurrent {
|
||||||
self.ctrl.get_pd_mon_v() * Settings::PD_MON_TRANSCONDUCTANCE
|
self.ctrl.get_pd_mon_v() * Settings::PD_MON_TRANSCONDUCTANCE
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
pub mod ld_ctrl;
|
pub mod ld_ctrl;
|
||||||
pub mod max5719;
|
pub mod max5719;
|
||||||
pub mod laser_diode;
|
pub mod laser_diode;
|
||||||
|
pub mod pid_state;
|
||||||
|
pub mod pd_mon;
|
37
src/laser_diode/pd_mon.rs
Normal file
37
src/laser_diode/pd_mon.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use core::{f64::NAN, marker::PhantomData};
|
||||||
|
use uom::si::{
|
||||||
|
f64::{
|
||||||
|
ElectricCurrent,
|
||||||
|
Power
|
||||||
|
},
|
||||||
|
electric_current::microampere,
|
||||||
|
};
|
||||||
|
use uom::{si::{ISQ, SI, Quantity}, typenum::*};
|
||||||
|
use miniconf::Miniconf;
|
||||||
|
|
||||||
|
// Ampere / Watt
|
||||||
|
pub type ResponsitivityUnit = Quantity<ISQ<N2, N1, P3, P1, Z0, Z0, Z0>, SI<f64>, f64>;
|
||||||
|
|
||||||
|
/// Steinhart-Hart equation Photodiode
|
||||||
|
#[derive(Clone, Debug, PartialEq, Miniconf)]
|
||||||
|
pub struct Parameters {
|
||||||
|
/// Responsitivity
|
||||||
|
pub responsitivity: ResponsitivityUnit,
|
||||||
|
pub i_dark: ElectricCurrent,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parameters {
|
||||||
|
pub fn get_ld_output_power(&self, i: ElectricCurrent) -> Power {
|
||||||
|
let ld_power = (i - self.i_dark) / self.responsitivity;
|
||||||
|
ld_power
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Parameters {
|
||||||
|
fn default() -> Self {
|
||||||
|
Parameters {
|
||||||
|
responsitivity: ResponsitivityUnit {dimension: PhantomData, units: PhantomData, value: NAN},
|
||||||
|
i_dark: ElectricCurrent::new::<microampere>(0.0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user