1. ## Spiral Milling

Hello fellow cnc-fans

I've had lots of time for spare at work lately, so i started playing around with macros again.

Now at school, i've been using G12/G13 for spiral milling, but on my fanuc o-m there is no such g-code, so i intented to program it.

But i found it that it aint realy an easy task, and now im afraid i need a bit of assistence.

I've only been working on it today, so its not much, but i think i've got the general understanding of it right.

Code:
```T1 M6
G00 X0. Y0.
#110=0
#112=0
#11=1. (Little C)
#10=[#12/360] (BIG A)

IF[#110EQ0] THEN[#110=ROUND[[#11*COS[#10]]]]
IF[#112EQ0] THEN[#112=ROUND[[#11*SIN[#10]]]]

WHILE[#100LE#12] DO1
#120=#110
#130=#112
#110=[#120-#130]
#112=[#130+#120]
G01 G91 X#110 Y#112
#100=[#100+1]
END1```
To give you the understanding of the program, #100 is just used to make it stop at some point, i havent started working on that yet.

Little C (#11) is taken from the the need of caluclations, as its called in my book , same goes with Big A/ Max Radius.

Anyway, thanks alot for looking by

Best regards
Nick. D. Pedersen.

2. the simpliest way to aproximate a spiral is with a two center construction.Spiral radius is constant for 180 degree but each arc center have an offset from spiral center.Offset=[distance between spire/2].
from this concept i wrote the following macro. Very basic and untested but it could give you a starting point

format is:
G65 P9013 Axx Bxx Dxx Fxx Hxx Rxx

A=STEP OVER
B=TOOL DIAMETER
D=FINAL DIAMETER
F=X-Y FEED
H=Z FEED
R=RETRACT PLANE

O9013(SPIRAL MACRO)
#7=#7-#2 (FINAL DIAMETER-TOOL DIAMETER)
#100=FUP[#7/#1+0.5] (NUMBER OF HALF TURN NEEDED TO REACH FINAL DIAM)
#101=[#7/[0.5*#100-0.25]] (CORRECTED STEP OVER )
#102=1 (HALF TURN COUNTER)
#103=#101*[#102-0.5] (CURRENT DIAMETER)
G0 G90 X#24 Y#25 (RAPID TO CENTER)
Z#18 (RAPID TO RETRACT PLANE)
G91
G03 X#103 I[#103/2] F#9 (CUT THE FIRST ARC)
#102=#102+1 (INCREMENT COUNTER)
WHILE[#102 LE #100] DO1 (IF NEEDED HALF TURN NOT REACHED)
#103=#101*[#102-0.5] (CURRENT DIAMETER)
G03 X-#103 I[-#103/2]
#102=#102+1
IF[#102GT#100] GOTO10
#103=#101*[#102-0.5]
G03 X#103 I[#103/2] F#9
#102=#102+1
END1
G03 I-[#7/2] (ENTIRE CIRCLE AT FINAL DIAMETER)
GOTO20
N10 G03 I[#7/2] (ENTIRE CIRCLE AT FINAL DIAMETER)
N20 G0 G90 Z#18
M99

MY LOGIC TO CALCULATE THE END OF THE SPIRAL IS TO SLIGHTLY CHANGE THE PROGRAMMED STEP OVER TO OBTAIN A SPIRAL TANGEANT TO FINAL DIAMETER AT 0 OR 180 DEGREE

I JOINED A DRAWING OF THE TWO CENTER SPIRAL.
IF YOU HAVE ANY QUESTION OR NEED HELP TO IMPROVE THIS MACRO IT WILL BE A PLEASURE FOR ME TO HELP YOU.

3. Uh, that looks great, i'll try to have a look at it later on today.

Best regards

4. i took a look on the way you plane to program it. On the first look i was sure it dont give a spiral but a put equations on excel sheet and what a surprise, it was a spiral, but not with constant distance between spire, after only 45 moves, the spiral radius is about 3 000 000!!!

For what kind of application you want to use spiral milling?
If it is for circular pocketting, you definately need a constant distance between spire.

If i find some time, maybe in the middle of the week, i could test my previous macro. Let me know if you are interested.

5. Yeah, the plan is to use it for pocketting.

But yes, the place i kinda got kicked down was with the constant distance between the spires :/

6. Here is an updated version of the spiral macro. It fixes several issues.

The D param is the diameter (was the radius).

The B tool diameter is now actually the tool diameter. It was.... uhhh... something else.

The working variables are now local variables. Calling the macro will not affect any global variables.

The final full circle cut has been fixed to cut the full diameter (it was cutting only half the diameter).

Added a Z parameter for specifying the cut depth.

The H plunge feed rate parameter is now used.

Fixed the R retract plane move.

The subroutine exits with the tool at the initial X/Y center coords. Z is at the retract plane.

The code has been modified to offset the cutting start point based upon the number of half turns. Otherwise the circle will not be centered on the input coordinates.

The macro does does not alter the initial G90/G91 state.

G00 X0Y0Z0
G65 P9013 X2. Y3. Z-.25 A.15 B.50 D2.00 H5.0 F10.0 R0.50
M30

O9013 (SPIRAL MACRO)
(A=STEP OVER)
(B=TOOL DIAMETER)
(D=FINAL DIAMETER)
(F=X-Y FEED RATE)
(H=Z FEED RATE)
(R=RETRACT PLANE - ABSOLUTE COORDS)
(X,Y = CIRCLE CENTER - ABSOLUTE COORDS)
(Z=CUTTING PLANE - ABSOLUTE COORDS)
#30=FUP[#7/#1+0.5] (NUMBER OF HALF TURNS NEEDED TO REACH FINAL DIAM)
#28=[1-[[#30AND1]*2]]*[-1] (+1 IF ODD, -1 IF EVEN)
#31=[#7/[0.5*#30-0.25]] (CORRECTED STEP OVER)
#32=1 (HALF TURN COUNTER)
#33=#31*[#32-0.5] (CURRENT DIAMETER)
#29=#4003 (SAVE G90/G91 STATE)
G00 G90 Z#18 (RAPID TO RETRACT PLANE)
X[#24-#33/2.0*#28] Y#25 (RAPID TO CENTER WITH DIAMETER OFFSET IN X)
G01 Z#26 F#11 (FEED TO CUTTING DEPTH)
G91
G03 X#33 I[#33/2.0] F#9 (CUT THE FIRST ARC)
#32=#32+1.0 (INCREMENT COUNTER)
WHILE[#32 LE #30] DO1 (HERE WE GO ROUND AND ROUND...)
#33=#31*[#32-0.5] (CURRENT DIAMETER)
G03 X-#33 I[-#33/2]
#32=#32+1.0
IF[#32GT#30] GOTO10
#33=#31*[#32-0.5]
G03 X#33 I[#33/2.0]
#32=#32+1.0
END1
G03 I-[#7] (CUT ENTIRE CIRCLE AT FINAL DIAMETER)
GOTO20
N10 G03 I[#7] (CUT ENTIRE CIRCLE AT FINAL DIAMETER)
N20 G0 G90 Z#18 (RAPID TO RETRACT PLANE)
G0 X#24Y#25 (RAPID TO CENTER)
IF[#29NE91]GOTO40 (RESTORE G90 STATE)
G91
N40 (WE IS ALL DONE)
M99

Another improvement that could be made would be to modify the cutting of the final full diameter circle to only cut a half circle... the other half of the full circle was already cut. I'll leave this exercise to the reader...

7. Are you sure you don't just want to check in the parameter book and see if your control is set to allow 3 axis simultaneous moves and then try adding a Z coordinate to the G02 move? (See the programming book for the format - it should be under helix)

8. This macro is for a circular pocketing type of operation where you are cleaning out the whole inner diameter of the circle and leaving a flat bottom. Helical G02 moves won't do that (but can be useful for ramping into the operation if you don't have the proper end-cutting bit).