1
Mach4 General Discussion / Macro will not jog mill
« on: November 20, 2023, 02:09:46 PM »
It's my first Lua attempt, and a macro looked less challenging than a Lua panel. I to code this -
After homing, I use the bit like an edge finder (turning it manually as I jog) and set the X and Y zero. I then jog X and Y by 1/2 the bit diameter using the MDI (hopefully after raising the Z) and zero Z and Y again. I verify that the cutter is centered over the corner of the workpiece.
When I step through this code in the debugger, it works. The axes jog and the work coordinates are zeroed.
function m1250()
local inst = mc.mcGetInstance()
local AxisJog = .125
-- Jog controller 0 in the X and Y axes.
mc.mcJogIncStart(0, 0, AxisJog)
mc.mcJogIncStart(0, 1, AxisJog)
-- Set the position of the X axis by changing the fixture offset.
mc.mcAxisSetPos(0, 0, 0)
mc.mcAxisSetPos(0, 1, 0)
end
if (mc.mcInEditor() == 1) then
m1250()
end
When I run this from the MDI (m1250) on the CNC (or the Mach4-Demo), the coordinates zero, but the machine does not jog.
I think this tells me the macro is being compiled. It is enabled.
I have deleted the mcLua.mcc file and restarted Mach4.
I suspect this has something to do with the Mach4 core versus the GUI, but I'm at a loss.
Can anyone suggest how to make the jog command work?
Thank you in advance for suggestions.
(I would guess the work coordinates could be changed without jogging, but I would like to move the machine to the new (0,0) to get visual confirmation.)
After homing, I use the bit like an edge finder (turning it manually as I jog) and set the X and Y zero. I then jog X and Y by 1/2 the bit diameter using the MDI (hopefully after raising the Z) and zero Z and Y again. I verify that the cutter is centered over the corner of the workpiece.
When I step through this code in the debugger, it works. The axes jog and the work coordinates are zeroed.
function m1250()
local inst = mc.mcGetInstance()
local AxisJog = .125
-- Jog controller 0 in the X and Y axes.
mc.mcJogIncStart(0, 0, AxisJog)
mc.mcJogIncStart(0, 1, AxisJog)
-- Set the position of the X axis by changing the fixture offset.
mc.mcAxisSetPos(0, 0, 0)
mc.mcAxisSetPos(0, 1, 0)
end
if (mc.mcInEditor() == 1) then
m1250()
end
When I run this from the MDI (m1250) on the CNC (or the Mach4-Demo), the coordinates zero, but the machine does not jog.
I think this tells me the macro is being compiled. It is enabled.
I have deleted the mcLua.mcc file and restarted Mach4.
I suspect this has something to do with the Mach4 core versus the GUI, but I'm at a loss.
Can anyone suggest how to make the jog command work?
Thank you in advance for suggestions.
(I would guess the work coordinates could be changed without jogging, but I would like to move the machine to the new (0,0) to get visual confirmation.)