Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: antonyakhno on October 11, 2016, 02:31:54 PM

Title: Mach 4 Macro with Lua script
Post by: antonyakhno on October 11, 2016, 02:31:54 PM
Hi!
I have a trouble with my Lua script for plasma CNC machine.
Help me please with code.
 
Code: [Select]
function M3()
local inst = mc.mcGetInstance()
mc.mcCntlGcodeExecute(inst, "G00 X73")
mc.mcCntlGcodeExecute(inst, "G04 P0.2")

hsig,rc=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT0)
mc.mcSignalSetState(hsig, 1);

mc.mcCntlGcodeExecute(inst, "G04 P0.2")

mc.mcCntlGcodeExecute(inst, "G31 Z-100 F300")
mc.mcCntlGcodeExecute(inst, "G04 P0.2")

mc.mcCntlGcodeExecute(inst, "G92 Z0")
mc.mcCntlGcodeExecute(inst, "G04 P0.1")

hsig,rc=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT0)
mc.mcSignalSetState(hsig, 0);

mc.mcCntlGcodeExecute(inst, "G00 X-73")
mc.mcCntlGcodeExecute(inst, "G04 P0.2")

mc.mcCntlGcodeExecute(inst, "G00 Z-10,0")
mc.mcCntlGcodeExecute(inst, "G04 P0.1")

mc.mcCntlGcodeExecute(inst, "G92 Z0")
mc.mcCntlGcodeExecute(inst, "G04 P0.2")

mc.mcCntlGcodeExecute(inst, "G00 Z3.8 ")
mc.mcCntlGcodeExecute(inst, "G04 P0.5")

local hsig = mc.mcSignalGetHandle(inst,mc.OSIG_SPINDLEON)
mc.mcCntlGcodeExecute(inst, "G04 P0.3")

mc.mcCntlGcodeExecute(inst, "G00 Z1.5 ")
mc.mcCntlGcodeExecute(inst, "G04 P0.2")
end
Title: Re: Mach 4 Macro with Lua script
Post by: DazTheGas on October 11, 2016, 04:19:39 PM
A brief outline on what you are trying to do will help

DazTheGas
Title: Re: Mach 4 Macro with Lua script
Post by: robertspark on October 11, 2016, 04:32:32 PM
Its a touch off routine for the plasma start cycle

(not sure why the G00 X73 or G00 X-73 comes into it)

presume its for an ohmic probe ..... not sure if mach4 needs while {IsMoving} statements (or whatever they are in lua + mach4) to give the machine a chance to complete the last motion move before trying to execute the next.

....ohmic probe because it turns on and off an output that probably provides the isolation of the ohmic probe input ....  (I use something similar but with a floating head too.... allows me to check which input was triggered and offset for either the floating heat (1.4mm ) or the ohmic probe (0.4mm)....  all into the same probe input

... isolation as in stops false triggering not isolation of plasma tip voltages as the ohmic touch off sensor circuity will do that ....