From 0e97a15fab532d22a2f53e1e5aa071475ca309d0 Mon Sep 17 00:00:00 2001 From: Robert Schauklies Date: Sat, 14 Mar 2026 18:07:23 +0100 Subject: [PATCH 1/2] just testing with the magic value --- spinnyboy_rust/src/bin/dc_driver/dshot.rs | 2 +- spinnyboy_rust/src/bin/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spinnyboy_rust/src/bin/dc_driver/dshot.rs b/spinnyboy_rust/src/bin/dc_driver/dshot.rs index 7249a05..c5e4a97 100644 --- a/spinnyboy_rust/src/bin/dc_driver/dshot.rs +++ b/spinnyboy_rust/src/bin/dc_driver/dshot.rs @@ -323,7 +323,7 @@ impl<'a> DShot<'a> { let erpm = (60 * 1_000_000) / period_ms; let rpm = erpm/XING_EPRO_22_POLES; - self.rpm.set(Some(rpm)) + self.rpm.set(Some((rpm as f32 / 1.7) as _)) } } } diff --git a/spinnyboy_rust/src/bin/main.rs b/spinnyboy_rust/src/bin/main.rs index 834c2da..8905581 100644 --- a/spinnyboy_rust/src/bin/main.rs +++ b/spinnyboy_rust/src/bin/main.rs @@ -126,8 +126,8 @@ fn main() -> ! { //PID-Controller let loop_time = Duration::from_micros(10); let cfg = pid::PidConfigBuilder::default() - .kp(3.0) - .ki(1.0).output_limits(100.00, 2040.00) + .kp(2.0) + .ki(0.1).output_limits(100.00, 2040.00) .sample_time(loop_time) .filter_tc(0.1) .build() @@ -137,7 +137,7 @@ fn main() -> ! { let set_point = DEFAULT_TARGET_RPM; dshot_esc.arm(); let mut rpm = 0; - let mut control: f32 = 200.0; + let mut control: f32 = 600.0; // let timestamp = Instant::now(); loop { dshot_esc.process(); From 14a61d2f84d95d49b6f5517068415a8206581427 Mon Sep 17 00:00:00 2001 From: Robert Schauklies Date: Sat, 14 Mar 2026 18:23:11 +0100 Subject: [PATCH 2/2] magic fafo constant found --- spinnyboy_rust/src/bin/dc_driver/dshot.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spinnyboy_rust/src/bin/dc_driver/dshot.rs b/spinnyboy_rust/src/bin/dc_driver/dshot.rs index c5e4a97..a5dbe53 100644 --- a/spinnyboy_rust/src/bin/dc_driver/dshot.rs +++ b/spinnyboy_rust/src/bin/dc_driver/dshot.rs @@ -16,6 +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)] @@ -322,8 +323,9 @@ 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; - self.rpm.set(Some((rpm as f32 / 1.7) as _)) + let rpm = erpm/(XING_EPRO_22_MAGNETS/2); + // let rpm = erpm/7; + self.rpm.set(Some((rpm as f32) as _)) } } }