Skip to content

Instantly share code, notes, and snippets.

@reox
Last active Aug 29, 2015
Embed
What would you like to do?
Mill a spiral for a hole
G21 ;mm
G90 ; absolute coordinates
G64 ; continuous mode for corners
G0 Z40.000000
F1800
M3 S6000
G54
G17
(create a hole with size r=10 at X10, Y20)
(THIS CODE IS FOR DEMONSTRATION OF POLAR COORDINATES ONLY!!!)
(DO NOT ACTUALLY MILL IT!)
(goto the center point of the hole)
G0 X10 Y20 Z10
(go to the offset point)
G91 G1 X2.5
(set the offset point)
G92 X2.5 Y0
(The offset is the start of the spiral, in a real case scenario it would be the point where the millhead enters)
(Beware that the offset must be non zero for at least one coordinate! G92 X0 Y0 would not work!)
(2000 = 10 turns * 1.8 degree)
o100 repeat [2000]
(the increment value is size of hole - offset / repeats)
(in this example 10 - 2.5 / 2000 = 0.00375)
(every 1,8 degree turn 0.00375mm is added to the offset coordinate in X and Y direction)
(for better understanding: the @ parameter is the radius.)
(we set it to the offset in the beginning, so polar coodinates asume that 0,0 is the center and the current point you are at)
(is the radius (= r = sqrt(x^2 + y^2)). If we set the Offset with the G92 command to X2.5 and Y0, the radius is of course 2.5)
(in every step you do with an incremental move of polar coordinates, the radius and angle is incremented.)
(that means that the radius is now a function of angle (archimedean spiral))
(Because we add n times a number to the radius, the resulting size of the spiral is n * increment + starting radius.)
g91 g1 @0.00375 ^1.8
(you can also use G91 G1 @0.00375 ^-1.8 to run the spiral the other way around)
o100 endrepeat
G92.1
G90
(do a real circle at the end)
G2 X20 Y20 I-10
M30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment