Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Marlin-compatible script for use with a Zero Cube #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added Marlin-compatible zero cube script
Domush committed Oct 24, 2021
commit df5eb56486dfc41116b60e324343e3ca510a7ab3
99 changes: 99 additions & 0 deletions Marlin_Work_Zero_Using_Cube
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
; This script enables the automation of zeroing out new bits to a workpiece using a conductive Zeroing Cube,
; while also automatically measuring and accounting for bit radius.
;
; !! Intended for Marlin 2.xx users, but may work for other firmware with slight adjustments
;
; Link to (3D printable) Zeroing Cube used in this script: https://www.thingiverse.com/thing:4809964

; Start with end mill roughly in center of cube, with bit slightly (~3mm-10mm) above cube surface.
; Bit must extend BELOW the top of the zero cube walls (so it touches them on a lateral move)

; Wait until the planner queue is empty
%wait

; Set user-defined variables
; !! All measurements are in mm (not in Luddite units, you savages)
%WIDEST_BIT_YOU_OWN = 20 ; Diameter of the widest bit you'll ever use with this script
%ZERO_CUBE_HEIGHT = 8 ; Height of main section of Zero Cube
%ZERO_CUBE_WALL_HEIGHT = 12 ; How high the XY wall section extends above %ZERO_CUBE_HEIGHT (ie: NOT the total height)
%ZERO_CUBE_WALL_THICKNESS = 5 ; How wide (laterally thick) are the XY wall sections which extend above %ZERO_CUBE_HEIGHT
%PROBE_XY_DISTANCE = 40 ; Max distance for a probe motion (script will fail if bit further from wall than this)
%PROBE_FEEDRATE_FAST = 200 ; mm/min
%PROBE_FEEDRATE_SLOW = 100 ; mm/min
%PROBE_RETRACT = 20 ; Distance of retract before probing next axis
%Z_FINAL = 10 ; Desired height of bit above ZERO_CUBE_WALL_HEIGHT after probing is finished


%UNITS=modal.units
%DISTANCE=modal.distance


G91 ; Relative positioning
G21 ; Use millimeters
G54 ; Switch to Work Coordinate Set 1 (as opposed to Machine Coords, which should not be altered after homing)

; Make sure initial coordinates remain positive for easier math
G92 X[PROBE_XY_DISTANCE * 2 + ZERO_CUBE_WALL_THICKNESS] Y[PROBE_XY_DISTANCE * 2 + ZERO_CUBE_WALL_THICKNESS] Z[ZERO_CUBE_WALL_HEIGHT]

; Probe Z
G38.2 Z-[ZERO_CUBE_WALL_HEIGHT] F[PROBE_FEEDRATE_FAST]
G0 Z2 ; Retract 2mm
G38.2 Z-4 F[PROBE_FEEDRATE_SLOW] ; Slow Probe
G92 Z[ZERO_CUBE_HEIGHT]
G0 Z3 ; Raise Z
; A dwell time of one second to make sure the planner queue is empty
G4 P1

; Probe X to find side of bit
G38.2 X-[PROBE_XY_DISTANCE] F[PROBE_FEEDRATE_FAST]
G0 X2 ; Retract 2mm
G38.2 X-4 F[PROBE_FEEDRATE_SLOW] ; Slow Probe
%X_LEFT = posx
G0 Z[ZERO_CUBE_WALL_HEIGHT] ; Retract Z above wall
G0 X-[WIDEST_BIT_YOU_OWN + ZERO_CUBE_WALL_THICKNESS + 10] ; Move to other side of wall
G0 -Z[ZERO_CUBE_WALL_HEIGHT] ; Drop Z below wall

; Probe X to find other side of bit
G38.2 X[PROBE_XY_DISTANCE] F[PROBE_FEEDRATE_FAST]
G0 X-2 ; Retract 2mm
G38.2 X4 F[PROBE_FEEDRATE_SLOW] ; Slow Probe
%X_RIGHT = posx
%X_DIFFERENCE = X_LEFT - X_RIGHT + ZERO_CUBE_WALL_THICKNESS
G0 Z[ZERO_CUBE_WALL_HEIGHT] ; Retract Z above wall
G0 X[X_DIFFERENCE / 2] ; Move to where the center of the bit is at zero (the right edge of the left wall)
G92 X0
G0 X[WIDEST_BIT_YOU_OWN] ; Position X for Y probing
G0 -Z[ZERO_CUBE_WALL_HEIGHT] ; Drop Z below wall

; A dwell time of one second to make sure the planner queue is empty
G4 P1

; Probe Y to find side of bit
G38.2 Y-[PROBE_XY_DISTANCE] F[PROBE_FEEDRATE_FAST]
G0 Y2 ; Retract 2mm
G38.2 Y-4 F[PROBE_FEEDRATE_SLOW] ; Slow Probe
%Y_TOP = posy
G0 Z[ZERO_CUBE_WALL_HEIGHT] ; Retract Z above wall
G0 Y-[WIDEST_BIT_YOU_OWN + ZERO_CUBE_WALL_THICKNESS + 10] ; Move to other side of wall
G0 -Z[ZERO_CUBE_WALL_HEIGHT] ; Drop Z below wall

; Probe Y to find other side of bit
G38.2 Y[PROBE_XY_DISTANCE] F[PROBE_FEEDRATE_FAST]
G0 Y-2 ; Retract 2mm
G38.2 Y4 F[PROBE_FEEDRATE_SLOW] ; Slow Probe
%Y_BOTTOM = posy
%Y_DIFFERENCE = Y_TOP - Y_BOTTOM + ZERO_CUBE_WALL_THICKNESS
G0 Z[ZERO_CUBE_WALL_HEIGHT] ; Retract Z above wall
G0 Y[Y_DIFFERENCE / 2] ; Move to where the center of the bit is at zero (the top edge of the lower wall)
G92 Y0

; Place bit center at final X0 Y0
G90 ; Absolute positioning
G0 X0 Y0 Z[ZERO_CUBE_HEIGHT + ZERO_CUBE_WALL_HEIGHT + Z_FINAL]

; A dwell time of one second to make sure the planner queue is empty
G4 P1

[UNITS] [DISTANCE] ; Restore unit and distance modal state

; All finished and ready to carve!