Hi,
Mach4 IS NOT Mach3 and never will be. Mach3 had hundreds of little cheats and work-arounds that it became a nightmare to maintain or develop.
The 'Offline' button is an example. I know you have become used to it in Mach3 and believe it is therefore universal in the world of CNC....its not.
Every controller manufacturer has their own interpretation of it, all claim that theirs is the 'only correct way' to do it. There is no such thing as the
'only correct way'.
Mach4s strength is that it is very flexible, you can program it to behave much like Mach3 or maybe even identically, or any other way that seems right to you.
The real market for Mach4 is OEM manufacturers, they have a piece of software that they can adapt to their machine, it might be simple like a lathe
but it might also be a multiaxis grinder or 5 axis wire EDM or a 12 axis Swiss lathe or....the list goes on.
The challenge for you is to learn how to program Mach4 to behave the way you want. You can whinge and moan that it should all be done for you but its not
and NFS has no interest in doing it for you, if you can't be bothered to learn why should they be bothered to help?
This is a preliminary sketch of the code. Note that I have written it as a function so that I can use the debugger. When in service this code will
be in the screenload script and attached as an event script for your button.
function OfflineButton()
local inst=mc.mcGetInstance()
local hsigenable=mc.mcSignalGetHandle(inst,mc.OSIG_ENABLE0)
local hsigbuttonstate=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT2)
if (mc.mcSignalGetState(hsigenable)==1) then
if (mc.mcSignalGetState(hsigbuttonstate)==1) then
-- Mach is enabled and the servos are 'online'
-- Need to save current position and set servos 'offline'
local Xpos=mc.mcAxisGetMachinePos(inst,mc.X_AXIS)
local Zpos=mc.mcAxisGetMachinePos(inst,mc.Z_AXIS)
mc.mcCntlSetPoundVar(inst,500,Xpos)
mc.mcCntlSetPoundVar(inst,501,Zpos)
mc.mcSignalSetState(hsigbuttonstate,0)
else
--Mach enabled but servos 'offline'
--Need to restore current position and reset servos 'online'
local Xpos=mc.mcCntlGetPoundVar(inst,500)
local Zpos=mc.mcCntlGetPoundVar(inst,501)
mc.mcCntlGcodeExecuteWait(inst,'g53 g0 x'..Xpos..' z'..Zpos)
mc.mcSignalSetState(hsigbuttonstate,1)
end
else
--Mach disabled....do nothing
end
end
if ( mc.mcInEditor()==1) then
OfflineButton()
end
You may recall right at the beginning of this thread I said this would be easy. If you have a look at the code it is. Twenty lines of code.
The only real difficulty we've encountered is that the CSMIO device has a quirk I don't understand. Without that quirk it would be simpler still.
Craig