Hello Guest it is April 28, 2024, 02:47:13 AM

Author Topic: Mach 4 Macro with Lua script  (Read 2317 times)

0 Members and 1 Guest are viewing this topic.

Mach 4 Macro with Lua script
« 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

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach 4 Macro with Lua script
« Reply #1 on: October 11, 2016, 04:19:39 PM »
A brief outline on what you are trying to do will help

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach 4 Macro with Lua script
« Reply #2 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 ....
« Last Edit: October 11, 2016, 04:38:15 PM by robertspark »
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”