Hello Guest it is April 20, 2024, 01:35:12 AM

Author Topic: Creating an M6 Toolchange in Mach4 (Part 1)  (Read 4522 times)

0 Members and 1 Guest are viewing this topic.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Creating an M6 Toolchange in Mach4 (Part 1)
« on: October 06, 2015, 06:09:49 PM »
This is part 1 of creating my own M6 Toolchange in mach4

https://youtu.be/m1eMEec0N-E

The Code so far in this part

Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)

    if selectedtool == currenttool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated but Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X260 Y50")
    local changetoo = mc.mcToolGetDesc(inst,selectedtool)
    wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press ok to continue")

    wx.wxMessageBox('Toolchange finished')
    end

end

if (mc.mcInEditor() == 1) then
    M6()
end


DazTheGas
New For 2022 - Instagram: dazthegas

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Creating an M6 Toolchange in Mach4 (Part 1)
« Reply #1 on: October 07, 2015, 03:24:49 AM »
 mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n X260 \n Y50 ") can work the same as both Gcode lines, \n = wait to finished probably know that already

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Creating an M6 Toolchange in Mach4 (Part 1)
« Reply #2 on: October 07, 2015, 03:37:37 AM »
Yes that is correct and such lines can be joined after function is finished, but during a tutorial it makes sense to show in separate steps so others can follow easier what the function is doing.

BTW \n = newline

DazTheGas
« Last Edit: October 07, 2015, 03:42:25 AM by DazTheGas »
New For 2022 - Instagram: dazthegas

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Creating an M6 Toolchange in Mach4 (Part 1)
« Reply #3 on: October 07, 2015, 03:42:29 AM »
cool more info on \n for other`s
http://www.lua.org/pil/2.4.html
« Last Edit: October 07, 2015, 03:49:11 AM by blockhead »