Author Topic: Gcode and Macro for Cutting a gear Using Horizontal Spindle  (Read 8503 times)

0 Members and 1 Guest are viewing this topic.

Offline ozwes007

  • Active Member
  • Posts: 103
    • View Profile
Gcode and Macro for Cutting a gear Using Horizontal Spindle
« on: April 22, 2015, 01:34:51 AM »
I Posted this in the VB section as well. the actual files are there
Just realised you could use it to cut a spline etc as well on a vertical mill
Just my take on cutting a Gear(I do heaps for gear boxes of different teeth)
Its not finished but its functional and will cut but doesn't allow for lead in or out.
This can be altered in the GCode. Also it only uses Z axis to get depth, but allows feeds from x or y axis.
Feed back would be appreciated and expected. :o

Gcode
%Gear Cutting Program for A Axis
G00 G49 G40  G17 G80 G50 G90
G21
(Program Setup)
#1= 0 (Degrees between Teeth)
#2= 0 (Width of Teeth)
#3= 1234 (X or Y Axis to Cut)
#4= 0 (Total Tooth Depth)
#5= 0 (Cut Loops)
#6= 0 (Number of Teeth)
#7= 0 (Last Cut Depth)
#8= 0 (Cutting Depth)
#9= 0 (X/Y Start Position)
#10= 0 (X/Y End Position)
#11= 3000 (Feed Rate)
#12= 4 (Safe Z Height)

(Bring in the Variables)
M2044
M03 S0
#13= 0 (Container to do A Axis Adding)
#14= 0 (Container to do Z Cut Depth Adding)
M98 P#3
M30

%Start the run for X Cuts
o1234
M6 (Tool Change - All OK)
M98 P1236 L#6 (One Loop per Tooth)
M99

%Start the run for Y Cuts
o1235
M6 (Tool Change - All OK)
M98 P1237 L#6 (One Loop per Tooth)
M99

%X Cut & Z Cut Moves
o1236
M98 P1238 L#5 (cutting down in Z Moves)
G01 Z#4
G01 X[#2+#9+#10] F#11
G00 Z#12
G00 X#9
%G04 P1000
#13= [#13+#1]
G00 A#13
#14= 0 (Reset Cutting Depth)
M99

%Y Cut & Z Cut Moves
o1237
M98 P1239 L#5 (cutting down in Z Moves)
G01 Z#4
G01 Y[#2+#9+#10] F#11
G00 Z#12
G00 Y#9
%G04 P1000
#13= [#13+#1]
G00 A#13
#14= 0 (Reset Cutting Depth)
M99

%X Zmoves
o1238
#14= [#14-#8]
G01 Z#14
G01 X[#2+#9+#10] F#11
G00 Z#12
G00 X#9
%G04 P1000
M99

%Y Zmoves
o1239
#14= [#14-#8]
G01 Z#14
G01 Y[#2+#9+#10] F#11
G00 Z#12
G00 Y#9
%G04 P1000
M99

Macro - M2044.m1s
Sub main
Dim Msg ' Declare variable.
Msg = "This GCode is for making Gears with the A Axis. "
Msg = Msg & "Only use Positive numbers when requested."
MsgBox Msg, 64, "Macro Parameters"
Dim Gear1 As Double
Dim AxisCut As String
Teeth = Question ("How Many Teeth on the Gear?")
Gear1=Val(Teeth)
SetVar(6,Gear1)
Gear1 = 360/Gear1
Print Gear1
SetVar(1, Gear1)
Message "Angle Between Teeth " & Gear1
GearWidth = Question ("How wide is the tooth?")
SetVar(2,Val(GearWidth))
 AxisCut=InputBox ("What Axis are you cutting with - X or Y?","Axis Choice", "X", 200, 200)
If AxisCut = "X" Then
 SetVar(3,1234)
 Else
 SetVar(3,1235)
End If
Print AxisCut
DepthCut= Question ("What is the total tooth Depth?")
SetVar(4,Val(DepthCut-(2*DepthCut)))
CutPass=Question("What is the Maximum Cut Depth per Pass?")
SetVar(8,Val(CutPass))
Loops = Val(DepthCut)/Val(CutPass)
Print Loops
MainLoops= Val(Fix(Loops))
LastCut=(Loops - MainLoops) * Val(CutPass)
Print LastCut
SetVar(7,LastCut)
SetVar(5,MainLoops)
Print MainLoops
Test=Val(DepthCut-(2*DepthCut))
Print Test

End Sub

Offline BR549

  • Mach4 Alpha
  • Posts: 6,855
    • View Profile
Re: Gcode and Macro for Cutting a gear Using Horizontal Spindle
« Reply #1 on: April 23, 2015, 12:43:26 PM »
Looks pretty good to me BUT most people don't have a horizonal (;-)  With a vertical you would need to use different axis.

(;-) TP