this should work, we added the magic constant, the pid looks fine is not flaky anymore

This commit is contained in:
Robert Schauklies 2026-03-14 18:40:32 +01:00
parent 9e842a2a30
commit d418da5b12
2 changed files with 3 additions and 3 deletions

View file

@ -16,7 +16,7 @@ fn calculate_crc(frame: u16) -> u16 {
IFlight XING-E Pro 2207 2750KV IFlight XING-E Pro 2207 2750KV
*/ */
const XING_EPRO_22_POLES: u32 = 4; const XING_EPRO_22_POLES: u32 = 4;
const XING_EPRO_22_MAGNETS: u32 = 14;
#[allow(dead_code)] #[allow(dead_code)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Debug)] #[derive(Debug)]
@ -322,7 +322,7 @@ impl<'a> DShot<'a> {
let period_ms: u32 = (mantissa << exp).into(); let period_ms: u32 = (mantissa << exp).into();
let erpm = (60 * 1_000_000) / period_ms; 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)) self.rpm.set(Some(rpm))
} }
} }

View file

@ -128,7 +128,7 @@ fn main() -> ! {
//PID-Controller //PID-Controller
let loop_time = Duration::from_micros(10); let loop_time = Duration::from_micros(10);
let cfg = pid::PidConfigBuilder::default() let cfg = pid::PidConfigBuilder::default()
.kp(0.4) .kp(2.0)
.ki(0.0) .ki(0.0)
.output_limits(100.00, 2040.00) .output_limits(100.00, 2040.00)
.sample_time(loop_time) .sample_time(loop_time)