Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: mcardoso on April 30, 2019, 10:31:22 AM

Title: Mach 4 Mill CSS
Post by: mcardoso on April 30, 2019, 10:31:22 AM
Does Mach 4 Mill support constant surface speed? If so how do you set it up?

I am running my mill as a lathe for small diameter work using work offsets for tool positions. This works great but it would be nice if I could use CSS and feed per rev like a normal lathe.
Title: Re: Mach 4 Mill CSS
Post by: Chaoticone on April 30, 2019, 10:55:19 AM
In lathe it is handled in the default screens PLC script. I'm not sure but you may be able to adapt it to work for your purpose in doing some mill turning. The API says its for lathe but it may well work for mill too. Take note that it uses the X axis current position to determine diameter. Depending on how your doing things that may not work for you. But you could adapt it. Just pointing it out. It uses some screen elements so you would need to....

1) Save your screen as something new and unique.
2) Modify the new screen making sure it has all the elements needed (and named correctly).
3) Test

Here is the code that does the magic in lathe............

Code: [Select]
-------------------------------------------------------
--  Calculate CSS
-------------------------------------------------------
local NativeUnits, rc = mc.mcCntlGetUnitsDefault(inst)
local units, rc = mc.mcCntlGetUnitsCurrent(inst)
local xDia = mc.mcAxisGetPos(inst, 0)
local dia, rc = mc.mcCntlGetDiaMode(inst)

if (dia == 0) then
 xDia = (xDia * 2)
end

if (NativeUnits == 200) and (units == 210) then
 xDia = (xDia * 25.4)
elseif (NativeUnits == 210) and (units == 200) then
 xDia = (xDia / 25.4)
end

if (units == 200) then --Gcode is in inch mode (G20)
    mc.mcSpindleCalcCSSToRPM(inst, xDia, true)
elseif (units == 210) then --Gcode is in mm mode (G21)
    mc.mcSpindleCalcCSSToRPM(inst, xDia, false)
end

-------------------------------------------------------
--  CSS DRO
-------------------------------------------------------
local FeedRate, SpinRPM, CurrentCSS
FeedRate = scr.GetProperty ("droFeedRate", "Value")
FeedRate = tonumber(FeedRate)
SpinRPM = scr.GetProperty("droSpinRPM", "Value")
SpinRPM = tonumber(SpinRPM)
CurrentCSS = (FeedRate / SpinRPM)
if CurrentCSS ~= LastCSS then --We need to update our user DRO
    LastCSS = CurrentCSS --So we only update DRO when needed. Stops blinking DRO
    if (FeedRate > 0) and (SpinRPM > 0) then
        scr.SetProperty("droConstantSurfaceSpeed", "Value", tostring(CurrentCSS))
    else
        scr.SetProperty("droConstantSurfaceSpeed", "Value", "0.0000")
    end
end
Title: Re: Mach 4 Mill CSS
Post by: mcardoso on April 30, 2019, 11:21:28 AM
Awesome! Thank you. I am using the X axis same as the lathe (just in radius mode). I will play around with this.
Title: Re: Mach 4 Mill CSS
Post by: Graham Waterworth on May 01, 2019, 06:03:00 AM
It sure can be done, here is a video :- https://www.youtube.com/watch?v=i02DmXtH3XM (https://www.youtube.com/watch?v=i02DmXtH3XM)