updated pwm code to account for pico 2 clock speed
150Mhz is a much better number to work with
This commit is contained in:
parent
1a0301ddd9
commit
60aa584f43
1 changed files with 6 additions and 5 deletions
|
@ -52,10 +52,10 @@ async fn main(spawner: Spawner) {
|
|||
spawner.spawn(logger_task(driver)).unwrap();
|
||||
|
||||
let mut drive_conf: pwm::Config = Default::default();
|
||||
drive_conf.divider = 40.into();
|
||||
drive_conf.top = 62500; // 20ms
|
||||
drive_conf.compare_b = 4687; // 1.5ms
|
||||
drive_conf.compare_a = 4687; // 1.5ms
|
||||
drive_conf.divider = 15.into();
|
||||
drive_conf.top = 50000; // 5ms
|
||||
drive_conf.compare_b = 15000; // 1.5ms
|
||||
drive_conf.compare_a = 15000; // 1.5ms
|
||||
let stopped = drive_conf.clone();
|
||||
let mut drive_pwm = Pwm::new_output_ab(p.PWM_SLICE0, p.PIN_16, p.PIN_17, drive_conf.clone());
|
||||
|
||||
|
@ -101,6 +101,7 @@ async fn main(spawner: Spawner) {
|
|||
};
|
||||
command
|
||||
} else {
|
||||
info!("waiting for command");
|
||||
COMMANDS.receive().await
|
||||
};
|
||||
|
||||
|
@ -196,7 +197,7 @@ async fn telemetry(mut tx: BufferedUartTx<'static, UART1>, enabled: &'static Ato
|
|||
|
||||
/// -1 to 1
|
||||
fn calc_speed(speed: f32) -> u16 {
|
||||
const COUNTS_PER_MS: f32 = 3125.;
|
||||
const COUNTS_PER_MS: f32 = 10000.;
|
||||
let speed = speed.clamp(-1., 1.);
|
||||
|
||||
let ms = (speed/2.0)+1.5;
|
||||
|
|
Loading…
Reference in a new issue