From d418da5b12ab0d3e44ab3d537999812ae766147a Mon Sep 17 00:00:00 2001 From: Robert Schauklies Date: Sat, 14 Mar 2026 18:40:32 +0100 Subject: [PATCH] this should work, we added the magic constant, the pid looks fine is not flaky anymore --- spinnyboy_rust/src/bin/dc_driver/dshot.rs | 4 ++-- spinnyboy_rust/src/bin/main.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spinnyboy_rust/src/bin/dc_driver/dshot.rs b/spinnyboy_rust/src/bin/dc_driver/dshot.rs index 7249a05..d2b65b7 100644 --- a/spinnyboy_rust/src/bin/dc_driver/dshot.rs +++ b/spinnyboy_rust/src/bin/dc_driver/dshot.rs @@ -16,7 +16,7 @@ fn calculate_crc(frame: u16) -> u16 { IFlight XING-E Pro 2207 2750KV */ const XING_EPRO_22_POLES: u32 = 4; - +const XING_EPRO_22_MAGNETS: u32 = 14; #[allow(dead_code)] #[allow(non_camel_case_types)] #[derive(Debug)] @@ -322,7 +322,7 @@ impl<'a> DShot<'a> { let period_ms: u32 = (mantissa << exp).into(); let erpm = (60 * 1_000_000) / period_ms; - let rpm = erpm/XING_EPRO_22_POLES; + let rpm = erpm/(XING_EPRO_22_MAGNETS/2); self.rpm.set(Some(rpm)) } } diff --git a/spinnyboy_rust/src/bin/main.rs b/spinnyboy_rust/src/bin/main.rs index e6e8bac..b2501a2 100644 --- a/spinnyboy_rust/src/bin/main.rs +++ b/spinnyboy_rust/src/bin/main.rs @@ -128,7 +128,7 @@ fn main() -> ! { //PID-Controller let loop_time = Duration::from_micros(10); let cfg = pid::PidConfigBuilder::default() - .kp(0.4) + .kp(2.0) .ki(0.0) .output_limits(100.00, 2040.00) .sample_time(loop_time)