From b1123047c7571bbaeb7a853fc8fd2af7a7b671bf Mon Sep 17 00:00:00 2001 From: linuswck Date: Tue, 9 Jan 2024 16:11:50 +0800 Subject: [PATCH] ld_drive: Add fns to get pd current & cal ld pwr --- src/laser_diode/ld_drive.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/laser_diode/ld_drive.rs b/src/laser_diode/ld_drive.rs index 36cb074..9ba532b 100644 --- a/src/laser_diode/ld_drive.rs +++ b/src/laser_diode/ld_drive.rs @@ -4,7 +4,7 @@ use core::{marker::PhantomData, f64::NAN}; use uom::si::{ electric_current::{milliampere}, - f64::{ElectricPotential, ElectricCurrent, ElectricalResistance}, + f64::{ElectricPotential, ElectricCurrent, ElectricalResistance, Power}, }; use uom::{si::{ISQ, SI, Quantity}, typenum::*}; @@ -87,6 +87,15 @@ impl LD_Drive{ 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 { + self.ctrl.get_pd_mon_v() * Settings::PD_MON_TRANSCONDUCTANCE + } + pub fn ld_set_i(&mut self, i: ElectricCurrent) -> ElectricCurrent { let ld_i_set = self.ctrl.set_i(i, Settings::LD_DRIVE_TRANSIMPEDANCE, Settings::DAC_OUT_V_MAX); self.settings.ld_drive_current = ld_i_set;