Optimize jogging parameters

This commit is contained in:
Frederik Menke 2023-12-09 21:57:54 +01:00
parent edaaafbb15
commit 604a0771f2

View file

@ -11,7 +11,7 @@ use tokio::time::sleep;
/// ///
/// For a given GCode buffer size on the machine, we can assume /// For a given GCode buffer size on the machine, we can assume
/// a maximum delay of `TIME_PER_MOVEMENT * BUFFER_COUNT` /// a maximum delay of `TIME_PER_MOVEMENT * BUFFER_COUNT`
const TIME_PER_MOVEMENT: Duration = Duration::from_millis(50); const TIME_PER_MOVEMENT: Duration = Duration::from_millis(30);
/// Movement speed of gantry when going full throttle in x/y-direction /// Movement speed of gantry when going full throttle in x/y-direction
/// in units/min (mm/min) /// in units/min (mm/min)
const FULL_SCALE_SPEED_XY: f64 = 1000.0; const FULL_SCALE_SPEED_XY: f64 = 1000.0;
@ -23,6 +23,11 @@ const FULL_SCALE_SPEED_Z: f64 = 10.0;
/// for the motion planner on the printer to plan ahead. /// for the motion planner on the printer to plan ahead.
const TARGET_BUFER_FILL_LEVEL: usize = 4; const TARGET_BUFER_FILL_LEVEL: usize = 4;
/// Time to wait before sending new commands if the GCODE buffer is overfull
const LONG_COMMAND_DELAY: Duration = TIME_PER_MOVEMENT;
/// Divider for `LONG_COMMAND_DELAY` for waiting if we've reached `TARGET_BUFER_FILL_LEVEL`
const SHORT_COMMAND_DELAY_DIVIDER: u32 = 2;
/// Should be mm on most machine including the Leapfrog /// Should be mm on most machine including the Leapfrog
pub struct PrinterUnits; pub struct PrinterUnits;
pub type PrinterVec = Vector3D<f64, PrinterUnits>; pub type PrinterVec = Vector3D<f64, PrinterUnits>;
@ -68,9 +73,9 @@ pub async fn jog(gamepad: Arc<Gamepad>, mut printer: Printer) -> Never {
println!("remaining capacity: {}", printer.remaining_capacity()); println!("remaining capacity: {}", printer.remaining_capacity());
println!("fill level: {}", fill_level); println!("fill level: {}", fill_level);
if fill_level > TARGET_BUFER_FILL_LEVEL { if fill_level > TARGET_BUFER_FILL_LEVEL {
sleep(TIME_PER_MOVEMENT * 2).await; sleep(LONG_COMMAND_DELAY).await;
} else if fill_level == TARGET_BUFER_FILL_LEVEL { } else if fill_level == TARGET_BUFER_FILL_LEVEL {
sleep(TIME_PER_MOVEMENT / 2).await; sleep(LONG_COMMAND_DELAY / SHORT_COMMAND_DELAY_DIVIDER).await;
} }
} }
} }