Fix a ld current ramp up bug

- During ld_i ramp up, if pwr up cmd is called, ld_i is set incorrectly
This commit is contained in:
linuswck 2024-03-18 16:39:22 +08:00
parent c06491a8b2
commit 3ad7c417f6
2 changed files with 10 additions and 2 deletions

View File

@ -117,13 +117,14 @@ impl LdDrive{
self.ctrl.ld_short_disable();
}
pub fn power_up(&mut self){
pub fn power_up(&mut self){
let prev_i_set = LdCurrentOutCtrlTimer::get_target_i();
LdCurrentOutCtrlTimer::reset();
let _ = self.ctrl.set_i(ElectricCurrent::new::<milliampere>(0.0), Settings::LD_DRIVE_TRANSIMPEDANCE, Settings::DAC_OUT_V_MAX);
LdPwrExcProtector::pwr_on_and_arm_protection();
// Wait for LD Power Supply to start up before driving current to laser diode
sleep(30);
self.ld_set_i(self.settings.ld_drive_current);
self.ld_set_i(prev_i_set);
self.settings.pwr_on = true;
}

View File

@ -63,6 +63,13 @@ impl LdCurrentOutCtrlTimer {
}
}
pub fn get_target_i() -> ElectricCurrent {
if let Some(ref mut ld_current_out_ctrl_timer ) = LdCurrentOutCtrlTimer::get() {
return ld_current_out_ctrl_timer.target_i
}
ElectricCurrent::new::<ampere>(0.0)
}
pub fn set_alarm() {
if let Some(ref mut ld_current_out_ctrl_timer ) = LdCurrentOutCtrlTimer::get() {
ld_current_out_ctrl_timer.timeout = true;