Skip to content

Commit

Permalink
Allow tools to persist
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Agricola <[email protected]>
  • Loading branch information
benagricola committed Oct 30, 2024
1 parent 85c7912 commit b15f84e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
16 changes: 16 additions & 0 deletions macro/machine/M4000.g
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ if { !exists(param.P) || !exists(param.R) || !exists(param.S) }
if { param.P >= limits.tools || param.P < 0 }
abort { "Tool index must be between 0 and " ^ limits.tools-1 ^ "!" }

; Check if tool is already defined and matches. If so, skip adding it.
; This allows us to re-run a file that defines the tool that is currently
; loaded, without unloading the tool.
; This has to be split over multiple lines due to length of the condition.
var toolSame = { global.mosTT[param.P][0] == param.R && tools[param.P].spindle == ((exists(param.I)) ? param.I : global.mosSID) }

set var.toolSame = { var.toolSame && tools[param.P].name == param.S }

if { exists(param.X) }
set var.toolSame = { var.toolSame && global.mosTT[param.P][1][0] == param.X }
if { exists(param.Y) }
set var.toolSame = { var.toolSame && global.mosTT[param.P][1][1] == param.Y }

if { var.toolSame }
M99

; Define RRF tool against spindle.
; Allow spindle ID to be overridden where necessary using I parameter.
; This is mainly used during the configuration wizard.
Expand Down
3 changes: 1 addition & 2 deletions post-processors/freecad/millennium_os_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,7 @@ def output(self):
self.comment("Pass tool details to firmware")
# Output tool info
for index, tool in tools.items():
tool_desc = ' '.join([tool['name'], "F={flutes} L={flute_length} CR={corner_radius}".format(**tool['params'])])
self.M(MCODES.ADD_TOOL, P=index, R=tool['params']['radius'], S=rrf_safe_string(tool_desc), ctrl=Control.FORCE)
self.M(MCODES.ADD_TOOL, P=index, R=tool['params']['radius'], S=rrf_safe_string(tool['name'][:32]), ctrl=Control.FORCE)
self.brk()

# Output job setup commands if necessary
Expand Down
7 changes: 2 additions & 5 deletions post-processors/fusion-360/millennium-os.cps
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,11 @@ function onOpen() {
writeComment("Pass tool details to firmware");
for(var i = 0; i < nTools; i++) {
var tool = tools.getTool(i);
writeBlock('{cmd} P{index} R{radius} S"{desc} F={f} L={l} CR={cr}"'.supplant({
writeBlock('{cmd} P{index} R{radius} S"{desc}"'.supplant({
cmd: mCodes.format(M.ADD_TOOL),
index: intFmt.format(tool.number),
radius: axesFmt.format(tool.diameter/2),
desc: tool.description,
l: axesFmt.format(tool.fluteLength),
cr: axesFmt.format(tool.cornerRadius),
f: intFmt.format(tool.numberOfFlutes)
desc: tool.description.substring(0, 32),
}));
}
writeln("");
Expand Down
5 changes: 1 addition & 4 deletions sys/stop.g
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
; Called on cancelling or finishing a job.
; Apparently also triggered when pausing.
; Park the spindle.
G27

; Deselect the current tool.
T-1
G27

0 comments on commit b15f84e

Please sign in to comment.