31
General Mach Discussion / Gcode to zero Z axis during run
« on: April 13, 2014, 02:11:26 PM »
I may be over complicating this; I think what I want to do is to zero my Z axis in code...
I have code that moves my Z axis until a moveable limit switch is tripped (G00 Z40000; ie a figure so large that it ensures the switch will always be tripped at some point.) When this happens, I want the machine to treat this position as Z0, until the end of the file. All other axes will remain as they are. At the end of the file, the next file will be called and run automatically from within the current file, and so a new Z0 position will need to be found... (at least that's what I intend.)
I looked through a post from 2007 entitled 'Gcode to re-zero Z axis', which appears to be about the same kind of thing.
Poppabear suggested a user defined DRO, which passes a value to a macro:-
'G90 G17
G28.1
M700
(the rest of code here)
Here is the Macro:
'M700.m1s 'metal thickness offset macro
z=GetUserDro(1100) 'get the value of your metal thickness from the dro.
Code "G0 Z" & z 'This moves to the new Z position that you put in the dro.
While IsMoving
WEnd'
I may be misunderstanding what the OP wanted; but I think in order to do what I want, I would need to rewrite as:-
G90 G17
G28.1 'only Z would be enabled for this in my soft limits config?
M700
(the rest of code here)
'M700.m1s
z = GetUserDro(1100) 'get value from my DRO
Code "G52 Z" & z
WhileIsMoving
WEnd
Am I right in thinking that this would move my Z axis until the switch trips, then Z stops moving, and mach sets the current Z position as Z0?
Or is there a function in mach that does that anyway? Can't test this for a few days now, which bugs me.
I have code that moves my Z axis until a moveable limit switch is tripped (G00 Z40000; ie a figure so large that it ensures the switch will always be tripped at some point.) When this happens, I want the machine to treat this position as Z0, until the end of the file. All other axes will remain as they are. At the end of the file, the next file will be called and run automatically from within the current file, and so a new Z0 position will need to be found... (at least that's what I intend.)
I looked through a post from 2007 entitled 'Gcode to re-zero Z axis', which appears to be about the same kind of thing.
Poppabear suggested a user defined DRO, which passes a value to a macro:-
'G90 G17
G28.1
M700
(the rest of code here)
Here is the Macro:
'M700.m1s 'metal thickness offset macro
z=GetUserDro(1100) 'get the value of your metal thickness from the dro.
Code "G0 Z" & z 'This moves to the new Z position that you put in the dro.
While IsMoving
WEnd'
I may be misunderstanding what the OP wanted; but I think in order to do what I want, I would need to rewrite as:-
G90 G17
G28.1 'only Z would be enabled for this in my soft limits config?
M700
(the rest of code here)
'M700.m1s
z = GetUserDro(1100) 'get value from my DRO
Code "G52 Z" & z
WhileIsMoving
WEnd
Am I right in thinking that this would move my Z axis until the switch trips, then Z stops moving, and mach sets the current Z position as Z0?
Or is there a function in mach that does that anyway? Can't test this for a few days now, which bugs me.