Quantcast
Channel: Practical Machinist - Largest Manufacturing Technology Forum on the Web - CNC Machining
Viewing all articles
Browse latest Browse all 20168

Macro for milling a hex on a lathe

$
0
0
I'm pretty new to macro programming. I've been wanting to do one for milling a hex in a lathe, it comes up fairly regularly. Of course it's not difficult to figure out the points, but I wanted make it quicker and save a lot of typing, since we do all of our programming with Finger Mark 1. Did some searching to see if there was something like what I wanted out there and came up with nothing. So I took a crack at it and came up with the below. Works fine on the first job (1.417 hex).

I'm looking for any suggestions to make it better, and to put it out there if someone else would find it useful. I know there could be more error checking, and I'm thinking of adding another couple arguments for different speed/feed on the finish pass, but that's not a big deal. I know some of the brackets around variables aren't needed, at the time I wasn't sure, so played it safe. Lots of comments because I want to help the other programmer learn how to do macros, too.

This is from a Hyundai-Kia SKT21LMS with a FANUC Oi-TB control. Set up in the parameters as G6. It rapids to a clearance position based on the provided W, if none then .1, and the radius of the tool pulled from the current tool's offset, and size of the hex. Then turns on the tool at S RPM, feeds in to depth Z, mills the hex to size H + finishing allowance of U per side at F feed. If U was specified, then it runs the mill again at the finish size. If U is 0, then it runs again at the same size. No specified U is one pass around. Then it shuts everything off and rapids the turret back to the position it started at.

O9012(G6, MILL HEX)
(H #11 DIST ACROSS HEX)
(S #19 TOOL RPM)
(F #9 FEED IN IPM)
(Z #26 DEPTH OF HEX)
(W #23 Z CLEARANCE POSITION)(DEFAULT .1)
(U #21 FIN ALLOWANCE PER SIDE)

IF[#11EQ#0]GOTO500
IF[#19EQ#0]GOTO500
IF[#9EQ#0]GOTO500
IF[#26EQ#0]GOTO500
IF[#23EQ#0]THEN#23=.1(W .1)

#30=#5041(SAVE X POSITION)
#31=#5042(Z)
#100=#4120(LAST T CALLED)

(FIND LAST 2 DIGITS OF T)
WHILE[#100GT100]DO1
#100=[#100]-100
END1

#101=#[2200+[#100]]+#[2900+[#100]](CURRENT OFST RAD GEOMTRY+WEAR)
#29=[#11+[2*[#21]]](HEX SIZE PLUS FIN PER SIDE)
M5
M43
M111
M13S#19
N100(FOR GOTO FOR 2ND PASS)
#27=[TAN[30]*[#29]/2](CALC FOR HEX)
#28=[#29+4*[#101]](CLEARANCE CALC)
G0G40Z#23C0(Z CLEARANCE)
N101X#28M8(X CLEARANCE)
G98G1Z#26F50.
G112
C[[#29]/2+#101]
G41X#29
C-[#27]F#9
X0C-[2*[#27]]
X-[#29]C-[#27]
C#27
X0C[2*[#27]]
X#28C[2*[#27]-TAN[30]*[#28]/2](CLEARANCE POS)
G40U[2*[#101]]F50.
G113
G0Z#23

(CHECK IF FINISH PASS NEEDED)
IF[#21EQ#0]GOTO200(U0 WILL RERUN)
#21=#0(SET U TO NULL)
#29=#11(SET SIZE TO FINISH)
GOTO100(RERUN)

N200M9(DONE MILLING)
M15
M40
G0X#30(RETURN TO INITIAL X)
Z#31(Z)
GOTO3000

N500#3000=1(NEED H,S,F,Z)
N3000M99

Viewing all articles
Browse latest Browse all 20168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>