; This code assumes the units are mm, may work with inches but not checked.
; It is essential that the cutter is long enough to pass between the webs when the pin is at its lowest point.
; y zero and z zero (bottom of cutter) should be on the a axis centre line.
; Set x axis to suit your requirements for each pin.
M0 ; set a axis to zero if required to avoid long wait.
; The following parameters should be set by the user to suit the part being made.
#1=[10] ; Bar diameter
#2=[6] ; PCD of the crank pin
#3=[3] ; Crank pin diameter
#4=[6] ; Cutter diameter
#8=[0] ; Pin offset from TDC.
#9=[1] ; a axis rotation. Set this to -1/+1 if the a axis rotation is wrong direction. Check before cutting any material.
#12=[250] ; Set the speed to suit your cutter and material.
; The following are calculated parameters.
#6=[[#1 /2] + #2] ; Calculated z start height for first pass.
#7=[[#2 /2] + [#3 /2]] ; Calculated z finish height for final pass.
#5=[[#6 – #7] / #2] ; Calculated step size.
; The number of passes is taken as the pin pcd #2.
; This gives a step size close to 1mm but increases if the bar diameter is much larger than the pcd.
f[#1]
#10=[#2] ; Step counter for looping the sub-routine.
; Used as a multiplier to set the z axis before each rotation.
#11=[1] ; Adds 360 degrees to the angle each rev to save rotating backwards each pass.
; Initialisation
G0 G49 G40.1 G64 G17 G80 G50 G90 G98
M6 T1
M03 S4000
G43
G19 ; Set circular motion to the yz plane.
; Start motion
G0 z[#6 + 2] ; Go to initial start height.
G0 a[#9*#8] ; Move a axis to TDC plus offset.
M98 P003 Q#2 ; Loop subroutine #2 times
; Polish passes.
G1 z[#7 + #5*#10] y[#4 /-4] F[#12] ; Reposition cutter to clean up more of the pin.
G03 a[[#9 *#11 *360] + [#9 *#8]] y[#4 /-4] k[#2 /-2] ; Circular motion 360 degrees.
#11=[#11 +1] ; Increase degrees multiplier for final rotation.
G1 z[#7 + #5*#10] y[#4 /-2] ; Reposition cutter to clean up the centre of the pin.
G03 a[[#9 *#11 * 360] + [#9 *#8]] y[#4 /-2] k[#2 /-2] ; Circular motion 360 degrees.
G0 z[#6 + 2] ; Go to initial start height.
G17 ; Set circular motion back to the xy plane.
M5 M9 ; Turn off spindle, coolant etc as required.
M30 ; End program
O003 ; Circular motion subroutine.
G1 y[#4 *-1.5 *#9] F[#12] ; Move slightly to one side.
#10=[#10 – 1] ; Multiplier for z height.
G1 z[#7 + #5*#10] y0 f[#12 /4] ; Ramp down to inital cutting position for circular motion.
G03 a[[#9 *#11 *360] + [#9 *#8]] y0 k[#2 /-2] F[#12] ; Circular motion in yz plane 360 degrees.
#11=[#11 +1] ; Increase degrees multiplier for next rotation.
M99 ; End subroutine.
Had to delete spaces to post it.
Martin C