I used LUA to write some peck drilling code for a deep hole how would you do it?

Smertrios

Registered
Registered
Joined
Dec 19, 2012
Messages
4
I have a TAIG micromill and will be drilling about 200 (.201 diameter) holes 2.5" deep in 6061-T6 aluminum. I'm using a spindle speed of about 1800 rpm and a black oxide HSS drill bit. I do not have flood coolant and the way I have my machine wired right now would cause problems if I did =). I tried using a G83 canned cycle and then adding oil while it was running but there is not much time to put oil in the hole and it ends up spinning off the drill bit. I wrote a lua program that writes GCode for peck drilling but with a programed stop every 5 pecks so I can add a drop of oil to the hole. Do you know of another way to do this?

In anycase this is the lua program and the code that was generated. If your interested in LUA goto www.lua.org and download the lua for windows installation. It gives you the basic lua interpreter *and* a ton of useful libraries. Its a fairly powerful and easy to learn programming language.

Code:
local RetractHeight = 0.1
local HoleTop = 0.0
local HoleBottom = -2.65
local PeckAmount = 0.1
local FeedRate = 3.6
local StopPecks = 5


print("(PAUSABLE_PECKDRILL - R"..RetractHeight.." HoleTop"..HoleTop.." Z"..HoleBottom.." Q"..PeckAmount.." F"..FeedRate.." StopPecks"..StopPecks..")")


local PeckCount = 0
local Z = HoleTop
repeat
-- rapid to current Z
    print("G00 Z"..Z)
-- feed drill into material
    Z = Z - PeckAmount
    if Z < HoleBottom then
        Z = HoleBottom
    end
    Z = tonumber(tostring(Z)) -- necessary to avoid errors
    print("G01 Z"..Z.." F"..FeedRate)
    PeckCount = PeckCount + 1
-- exit loop if at hole depth
    if Z == HoleBottom then
        break
    end
-- stop program after StopPecks pecks
    if Z ~= HoleBottom and PeckCount == StopPecks then
        print("G00 Z"..RetractHeight)
        print("M0")
        PeckCount = 0
-- otherwise just rapid to top of part to clear chips
    else
        print("G00 Z"..HoleTop)
    end


until false


print("G00 Z"..RetractHeight)
os.exit()

Code:
(PAUSABLE_PECKDRILL - R0.1 HoleTop0 Z-2.65 Q0.1 F3.6 StopPecks5)
G00 Z0
G01 Z-0.1 F3.6
G00 Z0
G00 Z-0.1
G01 Z-0.2 F3.6
G00 Z0
G00 Z-0.2
G01 Z-0.3 F3.6
G00 Z0
G00 Z-0.3
G01 Z-0.4 F3.6
G00 Z0
G00 Z-0.4
G01 Z-0.5 F3.6
G00 Z0.1
M0
G00 Z-0.5
G01 Z-0.6 F3.6
G00 Z0
G00 Z-0.6
G01 Z-0.7 F3.6
G00 Z0
G00 Z-0.7
G01 Z-0.8 F3.6
G00 Z0
G00 Z-0.8
G01 Z-0.9 F3.6
G00 Z0
G00 Z-0.9
G01 Z-1 F3.6
G00 Z0.1
M0
G00 Z-1
G01 Z-1.1 F3.6
G00 Z0
G00 Z-1.1
G01 Z-1.2 F3.6
G00 Z0
G00 Z-1.2
G01 Z-1.3 F3.6
G00 Z0
G00 Z-1.3
G01 Z-1.4 F3.6
G00 Z0
G00 Z-1.4
G01 Z-1.5 F3.6
G00 Z0.1
M0
G00 Z-1.5
G01 Z-1.6 F3.6
G00 Z0
G00 Z-1.6
G01 Z-1.7 F3.6
G00 Z0
G00 Z-1.7
G01 Z-1.8 F3.6
G00 Z0
G00 Z-1.8
G01 Z-1.9 F3.6
G00 Z0
G00 Z-1.9
G01 Z-2 F3.6
G00 Z0.1
M0
G00 Z-2
G01 Z-2.1 F3.6
G00 Z0
G00 Z-2.1
G01 Z-2.2 F3.6
G00 Z0
G00 Z-2.2
G01 Z-2.3 F3.6
G00 Z0
G00 Z-2.3
G01 Z-2.4 F3.6
G00 Z0
G00 Z-2.4
G01 Z-2.5 F3.6
G00 Z0.1
M0
G00 Z-2.5
G01 Z-2.6 F3.6
G00 Z0
G00 Z-2.6
G01 Z-2.65 F3.6
G00 Z0.1
 
Last edited:
You could try G4 (dwell) to add a pause, instead of a stop (M0), that requires you to hit a button to continue. You could also probably write this in GCode, depending on your machine controller. I have done some pretty intricate stuff in using LinuxCNC/EMC2.

I would also suggest maybe trying a greater return height on the canned cycle, this will give you a bit more time to get some fluid in the hole, maybe also try lowering your rapids, that will give you more time to act as well.

(edit)

To clarify, I mean, you could probably write the program logic in GCode. Most controllers implement some form of control logic. Linux CNC has subroutines, while loops, and if statements. If you are using Mach3, I believe it uses visual basic as an extension language. May be more convenient than writing an external script, generating code, and then importing it. Course, you may be using different machine controller that doesn't have this feature.
 
Last edited:
I agree with DMS, using M0 is a bit harder on the machine, but then again you are moving your hands into the area of that spinning bit.
Pierre
 
Back
Top