Results 1 to 8 of 8
Thread: Sample G Code
04-10-2010, 08:27 PM #1
Sample G Code
Does anyone have any sources for some free sample G Code? We are getting our first CNC Lathe in a few weeks and could use some samples to just help us to learn some G Code. It seems like it would be easier if we had something look at and do some trial runs on the machine.
04-11-2010, 05:38 AM #2
What control will your lathe have?
04-11-2010, 09:47 AM #3
It has a Fanuc OT control. I know that is pretty common control so that should help out I would think.
Just out of curiosity, what is different in the G Code between different controllers? For instance I noticed that the Fanuc OT control will use a command like G00 G28 U0, which Mach3 for instance doe not like.
Any sample code would be appreciated.
04-11-2010, 12:35 PM #4
I've run 0T machines for few years now. I wrote a small program for you:
G99 M42 (feed per rev, high gear if there is a gearbox on the machine)
T101 (tool #1, tool offset #1)
G50 S1500 (spindle speed limiting, this is very important for your safety!)
G96 S180 M3 (constant surface speed, 180m/min, or 180ft/min if you run your machine in imperial units, Spindle start CW)
G0 X105. Z0 M8 (rapid movement to position tool for facing, coolant on)
G1 X-1.6 F0.2 (facing the workpiece, X-1.6 instead of X0 to remove small nub which would be otherwise left on the center, F0.2 is feed 0.2mm/rev, or in/rev)
G0 X102. Z2. (rapid movement to position tool for roughing operation)
G71 U2. R0.2 (roughing cycle, U2 is radial depth of cut, R0.2 retraction amount)
G71 P1 Q2 U1. W0.1 F0.35 (roughing cycle, P1 and Q2 are start and end of desired shape, meaning it begins from N1 and ends to N2. U1. is amount of material left for G70 finishing cycle, this is a diametrical dimension. W0.1 is same for Z-axis. )
N1 G0 X19. (Start of the desired shape)
G1 G42 Z0.5 F0.18 (Cutter compensation on, approaching the face of workpiece)
G3 X50. Z-15. R15. (Cutting an arc, these coordinates are the endpoint for arc. R15. means radius of the arc.)
N2 G40 X102. (End of the desired shape)
G70 P1 Q2 (Finishing cycle, P1 and Q2 mean the same as in roughing cycle)
G0 X200. Z200. M9 (Rapiding the tool away from workpiece, coolant off)
M30 (End of program)
04-11-2010, 04:38 PM #5
Very well explained.
04-11-2010, 08:42 PM #6
A few more tips!
Here are a few more basics. I am a Mazak, Haas and okuma guy, but this is some universal stuff!
Get to know cutter comp, G41, I.D., G42, O.D., engage it with a small perpendicular move in G1 and it will call up your tool nose radius from your offset page, usually the second "01" in T0101, it is the only way to get burr free parts unless you want to program in a pile of radius callups. Turn it off with a G41, again with a small perpendicular move in feed mode.
This is a description of a tool change and a finish pass, this is "NOT" a program! A proper program start will come from the next guy that wants to "school" you, watch these guys even shred this stuff!
G28X0Z0 (HOME FOR TOOL CHANGE OR YOU MIGHT PICK YOUR OWN LOCATION, on my Mazaks we use G28U0W0)
M01 (op stop for first run)
(.016 RAD FINISH, O.D.)
T0101G96S900M3M8 (T1, constant feed, spindle clockwise, coolant on)
X1.3G40F.02M9 (G1 is still engaged, "modal" but I turned up the feed cutting air, coolant off)
G0G28X0Z0 (RETURN TO MACHINE HOME)
Most of your feed and canned cycles are "modal" and in most cases cancled by the next command. If you peck drill a hole, G83, and your line is a different Z or X cord. it will drill again there, G02 and G03, same deal.
Rules, no excetions!
1. Run program or program edits in graphics before you even think about making the machine move, paticular attention to rapids to tool change position. If it looks funky, you can run the part to prove how stupid you really are, been there, done that!
2. First run, put in "single block", rapids at 10%. Turn on op stop and make sure you have programed in M01 after G28 or your home position.
3. As tool approaches part, feed hold machine, check position, X and Z, make sure it looks right.
4. Look at "diatance to go", you might have this you might not.
5. Turn off "single block", stopping tools in the cut is a really bad idea!
Failure to follow these procedures will could lead to your termanition on the first occurance!
But being the shop owner we can be much more lenient, your machine may be "tacoed" on the first occurance!
04-11-2010, 08:47 PM #7
04-11-2010, 09:34 PM #8
Awesome. Thank you guys for to the sample codes and for putting the time into doing that for me. It is much appreciated.