Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: FocusPaul on November 10, 2017, 04:20:45 AM
-
Hello!
Is there a way to zero specific axis (G54) in G code?
I currently use the following piece of code, but I guess there's a better way to do it, because without the appended wait, it sometimes does not work.
G10 L2 P1 X[#5001] Y[#5002] (#5001 and #5002 are machine coordinates for X/Y; make a local coordinate system shift)
G4 P0.3 (wait for variable to become set)
Best regards,
Paule
-
Hi,
Machs API provides:
LUA Syntax:
rc = mc.mcAxisSetPos(
number mInst,
number axisId,
number val);
Description:
Set the Position of an axis by changing the fixture offset.
Which could be used:
function m105();
local inst=mc.mcGetInstance();
mc.mcAxisSetPos(inst,mc.X_AXIS,0.0);
mc.mcAxisSetPos(inst,mc.Y_AXIS,0.0);
mc.mcAxisSetPos(inst,mc.Z_AXIS,0.0);
end
if mc.mcInEditor()==1 then
m105()
end
Thus whenever you want to zero the axes you can code m105.
Craig
-
Hello Craig,
thank you for the Lua script!
Is there a G code only way to do it, which is easier than the G code mentioned in my 1st post? (M code breaks the CV chain, that's why I ask.)
Paule
-
Hi,
not to my knowledge. The Gcode that you posted is simple and effective but doesn't it occasion a pause as well?
Craig
-
Correctly, there's a 0.3 seconds pause. Without it, the new axis position is sometimes not recognized. That's why I'm looking for smth better.
Your Lua script is probably faster than my one, but maybe there's a version without any delay. *cough-cough-Steve-cough*