Results 1 to 8 of 8

Thread: Sample G Code

  1. #1
    Greebe is offline Aluminum
    Join Date
    Oct 2009
    Location
    WV, USA
    Posts
    68

    Default 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.

    Thanks
    Greebe

  2. #2
    ARB's Avatar
    ARB
    ARB is offline Titanium
    Join Date
    Dec 2002
    Location
    Granville,NY,USA
    Posts
    3,657

    Default

    What control will your lathe have?

  3. #3
    Greebe is offline Aluminum
    Join Date
    Oct 2009
    Location
    WV, USA
    Posts
    68

    Default

    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.

    Thanks
    Greebe

  4. #4
    JH-Q is offline Aluminum
    Join Date
    Mar 2008
    Location
    Vantaa, Finland, Europe
    Posts
    118

    Default

    I've run 0T machines for few years now. I wrote a small program for you:

    O0001
    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)
    X20. Z0
    G3 X50. Z-15. R15. (Cutting an arc, these coordinates are the endpoint for arc. R15. means radius of the arc.)
    G1 Z-25.
    X99.
    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)

  5. #5
    706jim is offline Stainless
    Join Date
    Jun 2006
    Location
    Thunder Bay Canada
    Posts
    1,257

    Default

    Very well explained.

  6. #6
    landm1's Avatar
    landm1 is offline Aluminum
    Join Date
    Mar 2008
    Location
    Paso Robles, CA
    Posts
    241

    Default A few more tips!

    Hello,

    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)
    G0X.5Z.1
    G1G42Z0F.005
    X1.R.015
    Z-.5R.06
    X1.2R.015
    Z-.8
    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!

    Good luck!

    LandM-1

  7. #7
    CalG is offline Titanium
    Join Date
    Dec 2008
    Location
    Vt USA
    Posts
    3,720

    Default

    The EMC2 pages has several G-code examples, but you will need to look.
    EMC Documentation Wiki: Example G-Code Programs

    Have FUN!

  8. #8
    Greebe is offline Aluminum
    Join Date
    Oct 2009
    Location
    WV, USA
    Posts
    68

    Default

    Awesome. Thank you guys for to the sample codes and for putting the time into doing that for me. It is much appreciated.

    Greebe

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •