Ellipse with G-code / no CAM

A place to discuss and ask questions about all things Machining for Mills, Lathes, Laser, and Routers

Moderator: cnckeith

Post Reply
suntravel
Posts: 1967
Joined: Thu Sep 23, 2021 3:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 6433DB0446C1-08115074
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Germany

Ellipse with G-code / no CAM

Post by suntravel »

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)

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
Uwe
Attachments
ellipse.jpg
suntravel
Posts: 1967
Joined: Thu Sep 23, 2021 3:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 6433DB0446C1-08115074
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Germany

Re: Ellipse with G-code / no CAM

Post by suntravel »

Added function to rotate the ellipse and to set start and end angle, define center in X and Y

Now it is possible to integrate the function in other tool paths...

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 = 45 ; Start Angle
#134 = 180 ; End Angle
#122 = 15 ; Y Axis Radius
#123 = 30 ; X Axis Radius
#130 = #4122 ; Current Diameter from tool offset
#131 = 20 ; X position of center
#132 = 10 ; y position of center
#133 = 45 ; R45otation Angle

G68 R[#133] X[#131] Y[#132] ; Rotation

#124 = SIN[#121] ; Incremental Y axis calculation
#125 = COS[#121] ; Incremental X axis calculation
#124 = [[#124*#122]+#132] ; Absolute Y calculation
#125 = [[#125*#123]+#131] ; Absolute X calculation
X[#125] Y[#124] ; Rapid to Start point
G42 X[#125] Y[#124] D8 ; Compensation motion to ellipse
G1 Z-4 F300 ; Dive to depth
N10 #121 = [#121 + #120] ; Angular Count
#124 = SIN[#121] ; Incremental Y axis calculation
#125 = COS[#121] ; Incremental X axis calculation
#124 = [[#124*#122]+#132] ; Absolute Y calculation
#125 = [[#125*#123]+#131] ; Absolute X calculation
X#125 Y#124 ; Movement in X & Y axis
IF [#121 < #134] GOTO 10 ; Restart if less than 360 degree motion
IF [#121 > #134] GOTO 20 ; If final angle becomes greater than 360 degrees recalculate
IF [#121 == #134] GOTO 30 ; Finish if total angle is equal to 360 degree
N20 #121 = #134
GOTO 10
N30 
Z2
G40
G50 ; Scaling OFF
G69 ; Rotation OFF
G0 G90 Z5 M30
S0
M5
M30


Uwe
Attachments
Ellipse.jpg
Post Reply