Skip to content

Commit

Permalink
releaseなら10kHz自体はいけそう
Browse files Browse the repository at this point in the history
  • Loading branch information
chama1176 committed Sep 9, 2024
1 parent 87661b2 commit 8450284
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ where
self.control_err_integral.i_d += err_current.i_d;
self.control_err_integral.i_q += err_current.i_q;

self.control_err_integral.i_d = self.control_err_integral.i_d.clamp(-1.0, 1.0);
self.control_err_integral.i_q = self.control_err_integral.i_q.clamp(-1.0, 1.0);
// self.control_err_integral.i_d = self.control_err_integral.i_d.clamp(-1.0, 1.0);
// self.control_err_integral.i_q = self.control_err_integral.i_q.clamp(-1.0, 1.0);

tpe = ThreePhaseValue { u: OutputStatus::Enable, v: OutputStatus::Enable, w: OutputStatus::Enable };
let tpv = DQVoltage{
Expand Down
2 changes: 1 addition & 1 deletion src/bldc_motor_driver_stm32g4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn clock_init(perip: &Peripherals, core_perip: &mut CorePeripherals) {
// For ADC
let tim6 = &perip.TIM6;
tim6.psc.modify(|_, w| unsafe { w.bits(1400 - 1) });
tim6.arr.modify(|_, w| unsafe { w.bits(20 - 1) }); // 5kHz
tim6.arr.modify(|_, w| unsafe { w.bits(10 - 1) }); // 10kHz
tim6.dier.modify(|_, w| w.uie().set_bit());
tim6.cr2.modify(|_, w| unsafe { w.mms().bits(0b010) });
}
Expand Down
6 changes: 2 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fn main() -> ! {
free(|cs| match G_APP.borrow(cs).borrow_mut().deref_mut() {
None => (),
Some(app) => {
rad = app.read_encoder_data();
// rad = app.read_encoder_data();
calib_count = app.calib_count();
adcd = free(|cs| bldc_motor_driver_stm32g4::G_ADC_DATA.borrow(cs).borrow().clone());
electrical_angle = app.last_electrical_angle;
Expand All @@ -256,8 +256,6 @@ fn main() -> ! {

}
});
let deg = rad.rad2deg();
defmt::info!("deg: {}, rad: {}", deg, rad);
// write!(uart, "{}, {:4}, {:4}", calib_count, deg, rad).unwrap();
// write!(uart, "\"tv\": {:4}\r\n", tv,).unwrap();

Expand All @@ -274,7 +272,7 @@ fn main() -> ! {
// )
// .unwrap();

// defmt::info!("diff: {}", diff_count);
defmt::info!("diff: {}", diff_count);

// // floatのまま送るとFLASHをバカほど食うのでcastする
// write!(
Expand Down

0 comments on commit 8450284

Please sign in to comment.