diff --git a/README.md b/README.md index c21b9ab..6e534ad 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ fn main() -> Result<()> { 20.0, // Cutter length 10.0, // Cutter diameter Direction::Clockwise, // Spindle rotation direction - 20000.0, // Spindle speed (rpm) - 5000.0, // Max feed rate/speed that the cutter will travel with (mm/min) + 10000.0, // Spindle speed (rpm) + 3000.0, // Max feed rate/speed that the cutter will travel with (mm/min) ); // Get the tool context to extend the program diff --git a/examples/planing.rs b/examples/planing.rs index e432fe7..b6756d3 100644 --- a/examples/planing.rs +++ b/examples/planing.rs @@ -14,7 +14,7 @@ fn main() -> Result<()> { 20.0, // Cutter length 10.0, // Cutter diameter Direction::Clockwise, // Spindle rotation direction - 20000.0, // Spindle speed (rpm) + 5000.0, // Spindle speed (rpm) 500.0, // Max feed rate/speed that the cutter will travel with (mm/min) ); diff --git a/src/program.rs b/src/program.rs index 1739425..fa5232f 100644 --- a/src/program.rs +++ b/src/program.rs @@ -49,6 +49,7 @@ use std::cell::RefCell; use std::collections::hash_map::Entry::Vacant; use std::collections::HashMap; use std::rc::Rc; +use std::time::Duration; use anyhow::{anyhow, Result}; use time::OffsetDateTime; @@ -57,6 +58,7 @@ use crate::cuts::*; use crate::instructions::*; use crate::tools::*; use crate::types::*; +use crate::utils::scale; /// A high level respresentation of a CNC program operation, Cut, Comment, Message, or Empty. #[derive(Debug, Clone)] @@ -726,6 +728,11 @@ impl Program { } else { Instruction::M4(M4 {}) }, + Instruction::G4(G4 { + p: Duration::from_secs( + scale(tool.spindle_speed(), 0.0, 50_000.0, 3.0, 20.0) as u64, + ), + }), ]); // Add tool instructions