Hello Guest it is December 15, 2019, 01:05:02 AM

Author Topic: M6: how to add manual spindle RPM with tool change?  (Read 1383 times)

0 Members and 1 Guest are viewing this topic.

Re: M6: how to add manual spindle RPM with tool change?
« Reply #10 on: October 04, 2018, 01:03:14 AM »
Thanks for that reference.  I'm not trying to pass a parameter, just get normal M3 functionality with the addition of a popup window telling me what RPM to set.

After a couple hours of messing with this, I finally got it.  Here's my M3 script.  This seems so obvious now...  learning a new programming language just takes a little patience I suppose.

Code: [Select]
function m3()
inst = mc.mcGetInstance()
commandrpm = mc.mcSpindleGetCommandRPM(inst)

mc.mcCntlSetLastError(inst, 'SpindleClockwise')
mc.mcSpindleSetDirection(inst, 1)

wx.wxMessageBox("Set spindle RPM to " .. tostring(commandrpm) .. "\nThen press Cycle Start to continue")
mc.mcCntlToolChangeManual(inst, true)

end

if (mc.mcInEditor() == 1) then
    m3()
end
Re: M6: how to add manual spindle RPM with tool change?
« Reply #11 on: October 04, 2018, 01:41:19 AM »
here's a better one that also tells me what dial setting on my Makita

Code: [Select]
function m3()
inst = mc.mcGetInstance()
commandrpm = mc.mcSpindleGetCommandRPM(inst)

function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end

makitasetting = round((((5/20010)*commandrpm)-1.396),2)
mc.mcCntlSetLastError(inst, 'SpindleClockwise')
mc.mcSpindleSetDirection(inst, 1)

wx.wxMessageBox("Set spindle to " .. tostring(commandrpm) .. " RPM (dial #" .. makitasetting ..")\nThen press Cycle Start to continue" )
mc.mcCntlToolChangeManual(inst, true)

end

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