Hello Guest it is April 26, 2024, 06:10:05 PM

Author Topic: mach4 m6 macros  (Read 896 times)

0 Members and 1 Guest are viewing this topic.

mach4 m6 macros
« on: October 07, 2021, 03:24:13 PM »
I have been forced to switch to mach4 because Mach 3 doesn't hold enough code for me anymore. the problem I'm having is with the m6 macros, I have tried the mach4 supplied script/Lua from the video and I have tried a few others. and they seem to do the same thing. roughing tool change goes fine but when it comes too the second tool change the tool change goes fine but then it goes back to the beginning of the roughing code instead of continuing with the gcode for the finishing path. otherwise it works flawlessly.

any help is greatly appreciated
Jamie Doeren
Renegade carving Co LLC
Re: mach4 m6 macros
« Reply #1 on: October 11, 2021, 10:16:51 PM »
maybe I asked this question wrong or something as I got no response so let me try it a different way.
I'm running Mach4 version: 4.2.0.4612 build: 4612 , for the tool change m6 I am using this code:

  function m6()
   
local inst = mc.mcGetInstance()

----------------------------------------------------------------------------------
--change lines here to either auto rapid, or manually jog to a tool change position
----------------------------------------------------------------------------------
--Manual Lines. Uncomment line below to allow you to manually jog to a tool change position.
--local MyChoice = wx.wxMessageBox("Click OK, \nThen Jog to A Safe Tool Change Position,\nInsert New tool,\nThen Click Cycle Start.","Click OK to continue" , 16)
---------------------------------------------------------------------------------
--Auto Lines.  Uncomment both lines below (and comment out local MyChoice line above) to automatically move to tool change position.
--Edit to include the machine coordinate values of that tool change position.

--AUTO LINES
--mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z0\nG53 G0 X14.7148 Y-22.713")--Move the Z to Home.Then to the X, Y Coords for our touch pad.
--mc.mcCntlSetLastError(inst, 'Now in Tool Change Position. Hit Cycle Start!')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --get the current mode so we can return to it when macro ends
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
   
 if selectedtool == currenttool then
        mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
 else
        mc.mcCntlToolChangeManual(inst, true);
  mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. "   Previous Tool == " .. tostring(currenttool))
  mc.mcToolSetCurrent(inst, selectedtool)

local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)
        mc.mcCntlSetLastError(inst, "Probing in Progress!")
        mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-5. F5.")--probe the new tool
local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
        mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91
  mc.mcCntlGcodeExecuteWait(inst, "G00 G53 Z0 ")--Retract
 
local NewOffset = probedz
  mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool, NewOffset)
  mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
        end

end

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






I'm using sprutcam 14
this is the first part of the code and the first tool change and it works correctly:
(Tool) (1) (Diametr)(0.875) (.875) (Operation) (Rotary Roughing 875)
(Tool) (2) (Diametr)(0.5) (0.5) (Operation) (Rotary finishing)

N10 G90 G64 G50 G54 G80 G17 G40 G49
N20 G20 (Inch)
(Rotary Roughing 875)
N30 M998
N40 T1 G43 H1 M6
(.875)
N50 S18000 M3 M8
N60 G0 G94 X-47.4688 Z5.761 A-124.965
N70 G1 Z4.011 F300
N80 Z4.0122 A-129.811 F884.18
N90 Z4.0082 A-132.406 F1651.35


this runs fine untill it gets to the finishing bit this is the code, after the tool change it goes back to the beginning 
of the roughout code. to be clear it asks for you to hit ok , then the spindle starts and the code rewinds all the way back to the begining of the roughout code after the roughout tool change. any help would be greatly appreciated, I'm sure its right in front of me but I'm new to Mach 4

N341070 Z5.092 A162.095 F171.43
N341080 M5 M9

(Rotary finishing)
N341090 M998
N341100 T2 G43 H2 M6
(0.5)
N341110 S18000 M3
N341120 G0 X-47.2 Z4.3506 A0.
N341130 Z2.0054
N341140 G1 Z1.0054 F300
N341150 X-47.0802 Z0.8602 F300
N341160 X-47.0602 Z0.8291 F300




Jamie Doeren
Renegade carving Co LLC
Re: mach4 m6 macros
« Reply #2 on: October 13, 2021, 01:31:26 AM »
what is M998 mean?

Offline Bill_O

*
  •  563 563
    • View Profile
Re: mach4 m6 macros
« Reply #3 on: October 13, 2021, 10:32:49 AM »
What is M998?

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: mach4 m6 macros
« Reply #4 on: October 13, 2021, 08:07:58 PM »
I would try the T2 M6 on its own line before the original line.

I would also put the G43 H2 on the first Z rapid line (G00), G43 can make the Z axis move if there is an offset set.

What is in your M998 macro?
Without engineers the world stops
Re: mach4 m6 macros
« Reply #5 on: October 14, 2021, 02:44:32 AM »
M998 is a mcode for tormach machines, not sure why its in there? I didnt write the post processor , I think it was taken from a mach postprocessor that had originally been written for a tormach machine as they sell sprutcam with those machines I guess? Ill remove it and try it and Ill also try the other suggestions and share the results.

thanks 
Jamie Doeren
Renegade carving Co LLC