So so so… Did some study and knocked out new macro with G43.1
Have been testing it now past one week and it works for me nicely. it would make sense if tool reference and change values are done in machine coordinates (G53) but as now i dont know if CNCjs has posz command for G53.
*G43.1 is dynamic tool offset for Z
*When you activate first macro it will record and saves G54 Z value from probe.
*When you run second macro “tool change” then macro compares now G54 Z value with saved reference value, does simple math and difference is set as G43.1 and offsets the tool height in all WCS exept G53
- When needed to deactivate tool offset you need to write in Console a command G49. This deactivates G43.1
- When you plan to set new Z in same day cycle you must run first G49 other wise tool change offset will be wrong
So my workflow is:
I choose one fixed sized tool as “master tool” in my case round 6mm blank precision rod and ill push it max in.
I use one fixed “master tool” so i would have nice reference of what tool i did first Z zero and if needed i can re call and do sanity check.
And i could run relay easily multi day jobs
- Ill Zero all WCS. with “master tool” or first tool
- Ill run in G54 tool referencing macro
a. if using first tool as ref. Then start cutting
- Then ill run Tool change macro with tool what im planing to use.
- When gcode done. Ill do tool change macro… and go cutting…
When New day and im still in same production…
- Ill load “master tool”
- ill run first macro “tool ref”
- change tool and run tool change macro
- some times ill do sanity check.
- Start cutting and changing tools with macro till day is over or something happens
When im planing in same day (i have not shutdown machine or program) to set new Z height
- Ill type in Command G49 so ill deactivate G43.1
- Probe or set new Z with “master tool” or first tool
- Run tool change macro
- Run gcode and make some chips
- Rinse and repeat 3-4 till jobs are done
Soo here comes the codes:
Firs i called Tool Reference
;Define tool first height for all WCS for future references
; Before launch macro, Set Z in G54
; Make sure that you are in G54 WCS
; Need to launch this macro again when machine is switched off, program is closed or when you manually abort g-code
; Wait until the planner queue is empty
%wait
; Set user-defined variables
%global.state.SAFE_HEIGHT = -3 ; clear everything height(negative number, distance below Z limit)
;Following set probe location
%global.state.PROBE_X_LOCATION = -2;machine coordinates
%global.state.PROBE_Y_LOCATION = -795 ;machine coordinates
%global.state.PROBE_Z_LOCATION = -36 ;machine coordinates --> lower this (more negative) to start the probing closer to waste-board
%global.state.TOOLC_X_LOCATION = -422 ; tool change location
%global.state.TOOLC_Y_LOCATION = -833 ; Tool change location
%global.state.TOOLC_Z_LOCATION = -10 ;Tool change location
%global.state.PROBE_DISTANCE = 100 ;Probing distant
%global.state.PROBE_RAPID_FEEDRATE = 350 ;mm/min ; Speed how fast does first probe
%wait
; Keep a backup of current work position
%X0=posx, Y0=posy, Z0=posz
; Save modal state
%WCS = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant
G21 ;metric
M5 ;Stop spindle
G90 ;Absolute positioning
%wait
G53 G0 Z[global.state.SAFE_HEIGHT]
G53 X[global.state.PROBE_X_LOCATION] Y[global.state.PROBE_Y_LOCATION]
%wait
; Set up for probing...pause for attaching wires and stuff
; Here starts G54 define
G49 ; Cancel tool length offset
G53 Z[global.state.PROBE_Z_LOCATION]
G91
G38.2 Z-[global.state.PROBE_DISTANCE] F[global.state.PROBE_RAPID_FEEDRATE];fast probe(so it doesn't take forever)
G0 z2
G38.2 z-5 F40 ;"dial-it-in" probes
G38.4 z10 F20
G4 P0.5
G90
G43.1 Z0
%global.state.TOOL_REFERENCE54 = posz ;establish a global tool reference work offset
%wait
(TOOL_REFERENCE54 = [global.state.TOOL_REFERENCE54])
G90
G53 G0 Z[global.state.SAFE_HEIGHT]
M0
%wait
;Go to work zero at a SAFE_HEIGHT for Z
G54
G0 X0 Y0
; Restore modal state
[WCS] [PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]
And here is second macro what i called “tool change”
;Tool change for all WCS G54-59
;This macro allows you to use a fixed machine location for a tool change/probe. Ideal when you're work-piece surface has been carved away.
; This macro change tool change with G43.1 so differences apply in all WCS
; When you have started this macro for machine apply tool dynamic offset G43.1 (adds or retracts from reference number)
; To disable G43.1 type in command G49, or machine is shut down, program is closed, or when you manually stop g-code
; ideal macro to run tool changes so they work in all WCS
; Make sure you are in G45 WCS before doing tool change
; Wait until the planner queue is empty
%wait
; Set user-defined variables
%SAFE_HEIGHT = -3 ; clear everything height(negative number, distance below Z limit)
%PROBE_DISTANCE = 100
%PROBE_RAPID_FEEDRATE = 450 ;mm/min
%wait
; Keep a backup of current work position
%X0=posx, Y0=posy, Z0=posz
; Save modal state
%WCS = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant
G21 ;metric
M5 ;Stop spindle
G90 ;Absolute positioning
; goes to tool change location
G53 G0 Z[global.state.SAFE_HEIGHT] ; go to tool change location
G53 X[global.state.TOOLC_X_LOCATION] Y[global.state.TOOLC_Y_LOCATION]
%wait
;Pause for manual tool change & probing
M0
;Goes to Probe location
G53 G0 Z[global.state.SAFE_HEIGHT] ;go to probe location
G53 X[global.state.PROBE_X_LOCATION] Y[global.state.PROBE_Y_LOCATION]
%wait
G49 ; Cancel tool length offset
; probe sequence
G53 Z[global.state.PROBE_Z_LOCATION]
; here starts Probe for G54
G54
G91
G38.2 z-[global.state.PROBE_DISTANCE] F[global.state.PROBE_RAPID_FEEDRATE];fast probe (so it doesn't take forever)
G0 z2
G38.2 z-5 F40 ;"dial-it-in" probes
G38.4 z10 F20
G4 P0.5
G90
G43.1 Z[posz-global.state.TOOL_REFERENCE54] ; Makes offset of the tool
G90
G53 G0 Z[global.state.SAFE_HEIGHT]
%wait
;Go to work zero at a SAFE_HEIGHT for Z
G54
G0 X0 Y0
; Restore modal state
[WCS] [PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]
I hope its useful for some one else than me.
If something new happens. ill defiantly post it here
Thank you @neilferreri for first macros and some ideas and seeds for creating these macros
@CrookedWoodTex hope its useful for you.
Best regards
Silver