371
General Mach Discussion / Re: Edit X Position (newb, be gentle)
« on: January 13, 2018, 05:05:23 PM »
BTW, you will have much better luck getting answer of you post in the Mach4 general discussion portion of the forum.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
function m6691(hVars)
local xNow,zNow,maxVal,rc
local ts,tr,te,sCode
local currPos
local plungeFeed=1
local roughDOC=0.018
local roughFeed=18
local roughSpeed=1200
local finishDOC=0.004
local finishFeed=8
local finishSpeed=1800
local endX=.850 --param1()
local inst=mc.mcGetInstance()
wx.wxMessageBox('nil') --HOW IS THIS SKIPPED?
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') --THIS ONE DOES GET EXECUTED!!!
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))
end
if mc.mcInEditor()==1 then
m6691()
end