Ellipse with G-code / no CAM
Posted: Fri Nov 04, 2022 10:54 am
I needed a function to mill an circle or an ellipse only with a few lines G-code.
So I made an interpolation with a simple GOTO loop
Another cool thing is that it works with G51 scaling (G2/3 can not be scaled to be an ellipse)
Uwe
So I made an interpolation with a simple GOTO loop
Another cool thing is that it works with G51 scaling (G2/3 can not be scaled to be an ellipse)
Code: Select all
G40 G21
G94 G80
G54
M6 T8
G43 D8
M3 S3000
T8 M6
G43 Z2 H8
G51 X0.0 Y0.0 Z0.0 I1 J1 K1 ; Scaling ON
#120 = 1 ; Incremental degree calculation
#121 = 0 ; Start Angle
#122 = 15 ; Y Axis Radius
#123 = 30 ; X Axis Radius
#130 = #4122 ; Current Diameter from tool offset
X[#123+2+#130] Y0 ; Rapid to Start point
G1 Z-4 F300 ; Dive to depth
G42 X#123 D8 ; Compensation motion to ellipse
N10 #121 = [#121 + #120] ; Angular Count
#124 = SIN[#121] ; Incremental Y axis calculation
#125 = COS[#121] ; Incremental X axis calculation
#124 = [#124*#122] ; Absolute Y calculation
#125 = [#125*#123] ; Absolute X calculation
X#125 Y#124 ; Movement in X & Y axis
IF [#121 < 360] GOTO 10 ; Restart if less than 360 degree motion
IF [#121 > 360] GOTO 20 ; If final angle becomes greater than 360 degrees recalculate
IF [#121 == 360] GOTO 30 ; Finish if total angle is equal to 360 degree
N20 #121 = 360
GOTO 10
N30 G40 X[#123+2+#130]
G50 ; Scaling OFF
G0 G90 Z5 M30
S0
M5
M30