357
« on: January 15, 2018, 02:07:00 PM »
Had to go blow some snow for the last hour, going to get to below 0 f here later.
Here now is the sum total of the m6691.mcs. Deleted all bak and mcc in the macro folder and then started m4.
function m6691(hVars)
wx.wxMessageBox('hello')
--[[
local rt = require 'rtMyModule'
if rt== nil then
wx.wxMessageBox('rt==nil')
return
end
local xNow,zNow,maxVal,rc
local ts,tr,te,sCode
local currPos
local plungeFeed=1
local roughDOC=0.018
local roughFeed=18
local roughSpeed=800
local finishDOC=0.018
local finishFeed=18
local finishSpeed=800
local endX=.850 --param1()
local inst=mc.mcGetInstance()
if mc.mcSpindleGetCurrentRange(inst)~=1 then
--rt.rtAudio("notify")
--wx.wxSound('C:\\mach4Hobby\\Sounds\\Notify.wav',0):Play()
wx.wxMessageBox('Set Spindle Gearing to High Speed')
mc.mcSpindleSetRange(inst,1)
end
if (hVars ~= nil) then
local DFlag = mc.mcCntlGetLocalVarFlag(inst, hVars, mc.SV_D)
if(DFlag == 1) then
endX = mc.mcCntlGetLocalVar(inst, hVars, mc.SV_D)
mc.mcCntlSetLastError(inst,"Turning Diameter to "..endX)
end
end
xNow,rc = mc.mcAxisGetPos(inst,0)
zNow,rc = mc.mcAxisGetPos(inst,2)
if xNow<=endX then
rt.rtAudio("chord")
wx.wxMessageBox("start X diameter "..xNow.." is <= to end diameter of "..tostring(endX))
return
end
if zNow<=0 then
rt.rtAudio("chord")
wx.wxMessageBox("start Z is less than or = to 0")
return
end
ts=os.time()
--rough cuts
mc.mcCntlGcodeExecuteWait(inst,"M3 S"..tostring(roughSpeed).."\ng04 p3.0")
currPos,rc=mc.mcAxisGetPos(inst,0)
while ((currPos-2*roughDOC)>(endX+finishDOC*2)) do
maxVal=math.max(endX+2*finishDOC,currPos-roughDOC)
sCode="G01 F"..tostring(plungeFeed).." X"..tostring(maxVal-roughDOC)
mc.mcCntlGcodeExecuteWait(inst,sCode)
currPos,rc=mc.mcAxisGetPos(inst,0)
mc.mcCntlGcodeExecuteWait(inst,"G01 F"..tostring(roughFeed).." Z0")
if mc.mcSpindleGetSensorRPM(inst)==0 then
rt.rtAudio("chord")
wx.wxMessageBox("Spindle Stopped")
return
end
currPos,rc=mc.mcAxisGetPos(inst,0)
maxVal=math.max(endX+2*finishDOC,currPos-roughDOC)
if currPos==endX+2*finishDOC then
break
end
mc.mcCntlGcodeExecuteWait(inst,"G01 F"..tostring(plungeFeed).." X"..tostring(math.max(endX+2*finishDOC,currPos-roughDOC)))
if mc.mcSpindleGetSensorRPM(inst)==0 then
rt.rtAudio("chord")
wx.wxMessageBox("Spindle Stopped")
return
end
mc.mcCntlGcodeExecuteWait(inst,"G01 F"..tostring(roughFeed).." Z"..tostring(zNow))
if (currPos)==endX+2*finishDOC then
break
end
end
tr=os.difftime(os.time(),ts)/60
mc.mcCntlSetLastError(inst,"Roughing Time: "..string.format("%.1f min",tr))
--finish cuts
mc.mcCntlGcodeExecuteWait(inst,"M3 S"..tostring(finishSpeed))
while (mc.mcAxisGetPos(inst,0)>=(endX+finishDOC)) do
currPos,rc=mc.mcAxisGetPos(inst,0)
maxVal=math.max(endX,currPos-finishDOC)
mc.mcCntlGcodeExecuteWait(inst,"G01 F"..tostring(plungeFeed).." X"..tostring(maxVal))
if mc.mcSpindleGetSensorRPM(inst)==0 then
rt.rtAudio("chord")
wx.wxMessageBox("Spindle Stopped")
return
end
mc.mcCntlGcodeExecuteWait(inst,"G01 F"..tostring(finishFeed).." Z0")
currPos,rc=mc.mcAxisGetPos(inst,0)
if currPos==endX then
break
end
mc.mcCntlGcodeExecuteWait(inst,"G01 F"..tostring(plungeFeed).." X"..tostring(endX))
if mc.mcSpindleGetSensorRPM(inst)==0 then
rt.rtAudio("chord")
wx.wxMessageBox("Spindle Stopped")
return
end
mc.mcCntlGcodeExecuteWait(inst,"G01 F"..tostring(finishFeed).." Z"..tostring(zNow))
currPos,rc=mc.mcAxisGetPos(inst,0)
if currPos==endX then
break
end
end
mc.mcCntlGcodeExecuteWait(inst,"M5\nM9")
te=(os.time()-ts)/60
mc.mcCntlSetLastError(inst,"Roughing Time: "..string.format("%.1f min",tr).." - Total Time: "..string.format("%.1f min",te))
local subj='Lathe'
local msg='Roughing Complete'
rt.sendSMS(subj,msg)
--]]
end
if mc.mcInEditor()==1 then
m6691()
end
Guess what, it still ran the old macro code that doesn't exist!!!