Skip to content

Commit

Permalink
Fix unconfigured spindles causing park failure
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Agricola <[email protected]>
  • Loading branch information
benagricola committed Dec 3, 2024
1 parent dac4071 commit 9799e7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion macro/machine/M3.9.g
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if { exists(param.P) && param.P < 0 }
var sID = { (exists(param.P) ? param.P : global.mosSID) }
; Validate Spindle ID
if { var.sID < 0 || var.sID > #spindles-1 || spindles[var.sID] == null }
if { var.sID < 0 || var.sID > #spindles-1 || spindles[var.sID] == null || spindles[var.sID].state == "unconfigured" }
abort { "Spindle ID " ^ var.sID ^ " is not valid!" }

; Validate Spindle Speed parameter
Expand Down
2 changes: 1 addition & 1 deletion macro/machine/M4.9.g
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if { exists(param.P) && param.P < 0 }
var sID = { (exists(param.P) ? param.P : global.mosSID) }
; Validate Spindle ID
if { var.sID < 0 || var.sID > #spindles-1 || spindles[var.sID] == null }
if { var.sID < 0 || var.sID > #spindles-1 || spindles[var.sID] == null || spindles[var.sID].state == "unconfigured" }
abort { "Spindle ID " ^ var.sID ^ " is not valid!" }

; Validate Spindle direction
Expand Down
16 changes: 11 additions & 5 deletions macro/machine/M5.9.g
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ M400
; activated.
var sID = { global.mosSID }
; Validate Spindle ID
if { var.sID < 0 || var.sID > #spindles-1 || spindles[var.sID] == null }
abort { "Spindle ID " ^ var.sID ^ " is not valid!" }

var doWait = false
while { (iterations < #spindles) && !var.doWait }
; Ignore unconfigured spindles
if { spindles[iterations].state == "unconfigured" }
continue
set var.doWait = { spindles[iterations].current != 0 }
; In case M5.9 should stop a spindle that _isnt_ the one
; configured in MOS. We'll calculate the delay time based
Expand All @@ -58,7 +58,13 @@ elif { var.doWait }
; by that percentage with 5% extra leeway.
; Ceil this so we always wait a round second, no point waiting
; less than 1 anyway.
set var.dwellTime = { ceil(var.dwellTime * (abs(spindles[var.sID].current) / spindles[var.sID].max) * 1.05) }
; We want to run M5 regardless of if var.sID is valid or not, so we check
; for nulls on the individual values before doing the dwellTime calculation.
; If the current spindle is not valid then M5 will be called but we wont
; wait for it to stop.
if { spindles[var.sID].current != null && spindles[var.sID].max != null }
set var.dwellTime = { ceil(var.dwellTime * (abs(spindles[var.sID].current) / spindles[var.sID].max) * 1.05) }
; We run M5 unconditionally for safety purposes. If
; the object model is not up to date for whatever
Expand Down

0 comments on commit 9799e7a

Please sign in to comment.