forked from M-Labs/kirdy
ld_drive: Add soft current limit
This commit is contained in:
parent
8ae27725c6
commit
33d9cb45c4
|
@ -63,7 +63,7 @@ pub fn bootup(
|
||||||
laser.setup();
|
laser.setup();
|
||||||
laser.ld_open();
|
laser.ld_open();
|
||||||
laser.power_up();
|
laser.power_up();
|
||||||
|
laser.set_ld_drive_current_limit(ElectricCurrent::new::<ampere>(0.2));
|
||||||
laser.ld_set_i(ElectricCurrent::new::<ampere>(0.15));
|
laser.ld_set_i(ElectricCurrent::new::<ampere>(0.15));
|
||||||
|
|
||||||
// Set a non-zero value so that there is a non NAN power reading
|
// Set a non-zero value so that there is a non NAN power reading
|
||||||
|
|
|
@ -40,6 +40,7 @@ impl Settings{
|
||||||
#[derive(Clone, Debug, Miniconf)]
|
#[derive(Clone, Debug, Miniconf)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
ld_drive_current: ElectricCurrent,
|
ld_drive_current: ElectricCurrent,
|
||||||
|
ld_drive_current_limit: ElectricCurrent,
|
||||||
pd_i_to_out_pwr: IToPowerUnit,
|
pd_i_to_out_pwr: IToPowerUnit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ impl Default for Settings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
ld_drive_current: ElectricCurrent::new::<milliampere>(0.0),
|
ld_drive_current: ElectricCurrent::new::<milliampere>(0.0),
|
||||||
|
ld_drive_current_limit: ElectricCurrent::new::<milliampere>(0.0),
|
||||||
pd_i_to_out_pwr: IToPowerUnit {dimension: PhantomData, units: PhantomData, value: NAN}
|
pd_i_to_out_pwr: IToPowerUnit {dimension: PhantomData, units: PhantomData, value: NAN}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +85,10 @@ impl LdDrive{
|
||||||
self.settings.ld_drive_current
|
self.settings.ld_drive_current
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_ld_drive_current_limit(&mut self, i_limit: ElectricCurrent){
|
||||||
|
self.settings.ld_drive_current_limit = i_limit;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_pd_i_to_out_pwr(&mut self, val: IToPowerUnit){
|
pub fn set_pd_i_to_out_pwr(&mut self, val: IToPowerUnit){
|
||||||
self.settings.pd_i_to_out_pwr = val;
|
self.settings.pd_i_to_out_pwr = val;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +111,8 @@ impl LdDrive{
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ld_set_i(&mut self, i: ElectricCurrent) -> ElectricCurrent {
|
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);
|
let ld_i_set = i.min(self.settings.ld_drive_current_limit);
|
||||||
|
let ld_i_set = self.ctrl.set_i(ld_i_set, Settings::LD_DRIVE_TRANSIMPEDANCE, Settings::DAC_OUT_V_MAX);
|
||||||
self.settings.ld_drive_current = ld_i_set;
|
self.settings.ld_drive_current = ld_i_set;
|
||||||
ld_i_set
|
ld_i_set
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue