From 749f19b105a47c1c4b5f8bc22c15d4cf534aac0a Mon Sep 17 00:00:00 2001 From: linuswck Date: Tue, 28 Jan 2025 15:57:10 +0800 Subject: [PATCH] ld_current_out_ctrl_timer: lower current ramp rate - Ld current ramp now updates in 250Hz (< 500Hz IIR filter cutoff frequency) for pwr_exc_protector --- src/laser_diode/ld_current_out_ctrl_timer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/laser_diode/ld_current_out_ctrl_timer.rs b/src/laser_diode/ld_current_out_ctrl_timer.rs index 7986cc2..0c73a0d 100644 --- a/src/laser_diode/ld_current_out_ctrl_timer.rs +++ b/src/laser_diode/ld_current_out_ctrl_timer.rs @@ -1,6 +1,6 @@ use core::marker::PhantomData; -use fugit::{KilohertzU32, TimerDurationU32}; +use fugit::{HertzU32, TimerDurationU32}; use log::debug; use stm32f4xx_hal::{pac::{interrupt, Interrupt, TIM2}, timer::{Counter, Event}, @@ -20,7 +20,7 @@ pub const FREQ: u32 = 1000000; /// This timer notifies the main loop to set the correct output current so that ld output current can ramp up/down slowly. /// The current output slope is guaranteed to be larger but not necessarily equal to than the preset value. impl LdCurrentOutCtrlTimer { - const TIME_STEP_MS: TimerDurationU32 = TimerDurationU32::from_rate(KilohertzU32::from_raw(1)); + const TIME_STEP: TimerDurationU32 = TimerDurationU32::from_rate(HertzU32::from_raw(250)); const STEP_SIZE: ElectricCurrent = ElectricCurrent { dimension: PhantomData, units: PhantomData, @@ -28,7 +28,7 @@ impl LdCurrentOutCtrlTimer { }; pub fn setup(mut tim2: Counter) { - tim2.start(LdCurrentOutCtrlTimer::TIME_STEP_MS).unwrap(); + tim2.start(LdCurrentOutCtrlTimer::TIME_STEP).unwrap(); unsafe { cortex_m::peripheral::NVIC::unmask(Interrupt::TIM2); }