Hi,
Mach4 uses Lua which is a very small (compact code base) and very fast yet remarkably powerful scripting language. This allows you to automate processes.
This is a simple example. I use a program called EAGLE for making PCB's. Certain parts of EAGLE's output, for drilling the holes in particular is not and exact match for Mach4.
This piece of code converts the EAGLE output to that suitable for my machine, you might like to call it a post processor.
Code:
local file = wx.wxFileDialog(panel, "Select Drill File", "", "", "Tap files (*.tap)|*.tap|Text files (*.txt)|*.txt",
wx.wxFD_OPEN,wx.wxDefaultPosition,wx.wxDefaultSize, "File Dialog" );
if(file:ShowModal() == wx.wxID_OK)then
path=file:GetPath()
end
inputpath=path
inputfile=io.input(inputpath)
index=0
repeat
previndex=index
index=string.find(path,"\\",(index+1))
until(index==nil)
name=string.sub(path,(previndex+1))
name="MODDED"..name
path=string.sub(path,1,previndex)
outputpath=path..name
outputfile=io.output(outputpath)
io.write("G0 Z2","\n","M3 S24000 \n","G4 P6.00 \n")
inputline=io.read()
while(inputline~=nil)do
G82presi,G82presj=string.find(inputline,"G82")
Rpres=string.find(inputline,"R")
if(G82presi~=nil and Rpres~=nil)then
io.write(inputline,"\n")
end
if(G82presi~=nil and Rpres==nil)then
inputline=string.sub(inputline,G82presj+1)
io.write(inputline,"\n")
end
inputline=io.read()
end
io.write("G0 Z50","\n","X0 Y0","\n","M30","\n")
io.flush()
io.close(outputfile)
io.close(inputfile)
end
if (mc.mcInEditor() == 1) then
m200()
end
This is a simple example. Note that it uses wxWidgets, that in this case has been used to generate a Windows file dialogue to navigate to the file you want to process.
Mach4 has a quite extensive and mostly well documented API, which allows you to write scripts that can effect certain behaviours within Mach's core without having to write C++ code to run in the core.
Mach4 has a pretty complete screen editing suite. This allows you to rapidly and easily compose your own screen sets, adding buttons, LEDs, code windows, toolpath windows etc at will.
Mach4 is modular, so various modules can be used or dismissed as required to achieve certain behaviours. For example there is a good MODBUS module that allows you to communicate
with a MODBUS device through a single consistent data interface. The PLC module and the Ladder Logic module are other notable examples.
One of the design priorities, as described by the lead developer of Mach4, was that it should be readily customisable. This would make it attractive and amenable for OEMs to craft a solution and look
specific to their machine for market differentiation.
Having said that for mills, lathes, plasmas and routers no extra code need be written, all the required operational functionality is already there. Its only if you want something specific that you need to write
some code. I have myself only about three or four chunks of code like the example I posted, all to automate certain processes that I use for making PCBs. There are a considerable number
of one line, two line and three line code fragments that I have added to the basic Mach installation that add behaviours like 'what does the machine do when it encounters a servo 'following error' fault?'
I also have a few bits of code to reflect my desired machine behaviour with regards to my home brew wire pendant.
Mach4 is flexible....if you need it, but is mostly complete as is. LinuxCNC is even better with regards to programmable flexibility....but it requires coding in C, which is not every ones forte.
Craig