G-Code Examples


Results 1 to 10 of 10

Thread: G-Code Examples

  1. #1
    Registered
    Join Date
    Sep 2005
    Location
    USA
    Posts
    91
    Downloads
    0
    Uploads
    0

    Default G-Code Examples

    Could some body post a few example G-Code programs for simple operations such as peck dril, circle mill, pocket mill, linear mill x directions, linear mill x then y direction, and anything else somebody can think of. If I had few simple examples I could just copy and paste it would help me get started.

    Similar Threads:


  2. #2
    Member
    Join Date
    Apr 2005
    Location
    US
    Posts
    460
    Downloads
    0
    Uploads
    0

    Default

    I asume your milling the machinest handbook has most of the standard Gcodes listed with a bref explanation of there actions pocket's and drill cycles are comenly called caned cycles that are machine spefic in some cases Look through the Gcode forum there is a post with a compleat list of G codes with explantion's Good luck Kevin



  3. #3
    Member
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    12177
    Downloads
    0
    Uploads
    0

    Default

    The two programs I have attached make the part in the picture starting from a piece of bar stock 2-1/4" x 4-1/4" x 5/8" held in a vise for the first program and bolted to a fixture held in the vise for the second program. They use spot drill and peck drill canned cycles, circular interpolation, tool compensation, repeat rigid tapping. Tool diameters for tool compensation are entered on lines N4 and N5. In both programs the work origin is placed at the center of the part; this is just for simplicity, these are hand coded and this way the toolpaths are symmetric.

    FIRST PROGRAM:
    Tool 1 spot drills for the holes; the canned cycle is initiated before calling the subroutine N1000 which has coordinates for the holes that will be counterbored. Then subroutine N1100 is used for the holes that will be tapped and the first line in this case has a Z value to reduce the spot drill depth. Finally subroutine N1200 is used to cut a groove around the perimeter so that when the profile is machined a chamfer will remain. This operation uses tool compensation with a tool diameter of 0.2 even though the spot drill is 1/2". This is so the cut line is part way down the cutting edge and the tool overlaps the perimeter to leave the chamfer.

    Tool 2 peck drills the holes that will be counterbored using subroutine N2000.

    Tool 3 interpolates the counterbore using subroutine N3000 for the hole coordinates and N3100 for the helical interpolation. Notice because the Y work zero is on the centerline of the part the tool compensation can be applied in an absolute move. The helical interpolation uses incremental moves for two circuits in a counterclockwise direction then goes back to absolute to clean up the bottom of the counterbore.

    Tool 4 peck drills the holes that will be tapped using subroutine N4000.

    Tool 5 Taps the holes using subroutine N5000 for the hole coordinates and N5100 for the repeat rigid tapping.

    SECOND PROGRAM:
    Tool 1 spot drills all the holes using subroutine N1000 and then cuts the chamfer groove around the perimeter using N1100.

    Tool 2 machines around the perimeter.

    In these programs there is some redundancy in the subroutines because the same coordinates are repeated in different subroutines.

    The entire program could also be written without subroutines. The reason for subroutines is that less editing is needed to change the program to use four or eight work zeroes for production work.

    Attached Thumbnails Attached Thumbnails G-Code Examples-adapt-001-jpg  
    Attached Files Attached Files


  4. #4
    Registered
    Join Date
    Sep 2007
    Location
    United States
    Posts
    7
    Downloads
    0
    Uploads
    0

    Default

    Anybody got a Gcode sample for circle milling a 3" dia hole on a cincinnati milacron. We just bought a used one and need some help.
    Thanks,
    dg



  5. #5
    Member
    Join Date
    May 2007
    Location
    USA
    Posts
    1003
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by HTMDGEARY View Post
    Anybody got a Gcode sample for circle milling a 3" dia hole on a cincinnati milacron. We just bought a used one and need some help.
    Thanks,
    dg
    Not trying to be a smart a$$, but I think you would have gotten a quick answer if you had asked this question in a separate thread. Plenty of people on here that have the knowledge and willingness to answer it.

    I'm sure it is simple, but I don't do mills, so I can't help you. Would if I could. All I know is that some machines require the arc to be broken into at least two parts, and that even on machines that can do a 360 degree arc with a single block call, it usually requires it be done using a specific address (R- instead of R?), but like I said "I don't do mills."



  6. #6
    Registered
    Join Date
    Jan 2008
    Location
    USA
    Posts
    85
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by jhwatts View Post
    Could some body post a few example G-Code programs for simple operations such as peck dril, circle mill, pocket mill, linear mill x directions, linear mill x then y direction, and anything else somebody can think of. If I had few simple examples I could just copy and paste it would help me get started.
    Does your company want you to program center of cutter path or part edge?

    This is programmed in long hand sort of speak with out using subroutines M97 or a M98 as demonstrated by Geof post which will stop allot of repetition and in most cases more versatile.
    I showed this for those that do not have a grasp on G and M Code Programming as of yet.

    %
    O1000 (Example: Part edge 3" bore full depth)
    M6T1
    G0G90G54X5.Y0S3000M3
    G43H1Z2./M8
    Z.1
    G1Z0F50.
    G91G41D1X1.5F18. (Having G91 started here will allow you to start at any location in X and Y)
    G3I-1.5Z-.104L5
    I-1.5
    G1G40X-1.5
    G0G90Z2.
    X-5.Y0.(ADDITIONAL LOCATIONS)
    Z.1
    G1Z0F50.
    G91G41D1X1.5F18.
    G3I-1.5Z-.104L5
    I-1.5
    G1G40X-1.5
    G0G90Z2.
    G91G28Y0Z0
    G90
    M30
    %

    %
    O2000 (Example: Center of .500 Tool Path 3" bore full depth)
    M6T1
    G0G90G54X5.Y0S3000M3
    G43H1Z2./M8
    Z.1
    G1Z0F50.
    G91G41D1X1.25F18.
    G3I-1.25Z-.104L5
    I-1.25
    G1G40X-1.25
    G0G90Z2.
    X-5.Y0(ADDITIONAL LOCATIONS)
    Z.1
    G1Z0F50.
    G91G41D1X1.25F18.
    G3I-1.25Z-.104L5
    I-1.25
    G1G40X-1.25
    G0G90Z2.
    G91G28Y0Z0
    G90
    M30
    %

    Last edited by dapoling; 02-01-2008 at 12:22 AM.
    My Response to "It's Close Enough", "Is Your Tool Box and The Door Close Enough?"


  7. #7
    Registered
    Join Date
    Feb 2008
    Location
    England
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by g-codeguy View Post
    I'm sure it is simple, but I don't do mills, so I can't help you. Would if I could. All I know is that some machines require the arc to be broken into at least two parts, and that even on machines that can do a 360 degree arc with a single block call, it usually requires it be done using a specific address (R- instead of R?), but like I said "I don't do mills."
    Hi, Just thought I would clear this up otherwise anyone starting out with Gcode could end up with alarms all over the place and not a clue why.

    Basically when using circular interpolation (G02/G03) you cannot create a full 360o using only “R” for the radius. Using “R” on its own will allow you to do anything up to 180o, some if not most machines also allow you to use “R-“ with which you can do from 180.001o all the way up to 359.999o, but never a full circle, you may think oh well what difference is 0.001o going to make but trust me, it will leave a mark, and you will have to work out where the end point is.

    Also note that G02 is clockwise and G03 is anti clockwise, when working out which way is clockwise or anti clockwise always take it from the direction of looking towards negative, this may SEEM obvious but you wait until your doing 3D milling, then things get a little interesting!

    So an example of circular interpolation using “R”:

    G00 X10 Y0 Z1.5 (making a few assumptions this will Rapid you to 1.5mm above the start point of your arc/circle)

    G01 Z-1 (again assuming depth of cut is 1mm)

    G02 X-10 R10 (this will do an arc of 180o with a radius of 10mm in clockwise direction)

    That is (I think) about as basic as circular interpolation gets.

    Now say you want to do a FULL 360o, things get a little more interesting here as “R” cannot be used, in stead we must use “I, J and K” these are incremental values for the X, Y and Z planes,
    I = X
    J = Y
    K = Z

    I, J and K are used to input the INCREMENTAL distance from the centre point of the arc to the start point of the arc, REMEMBER that is incrementally from the centre point to the start point, you would be amazed how many people cant get that bit right. This is completely irrelevant whether you are in G90 or G91.

    Here is an example of the same 180o arc but with I J and K:

    G00 X10 Y0 Z1.5
    G01 Z-1
    G02 X-10 I10 (you do not need to enter J and K as the value of these is zero)

    Now for 270o

    G00 X10 Y0 Z1.5
    G01 Z-1
    G02 Y-10 I10

    I think you get the idea.

    So just to sum things up, if using R, then on the line with the G02/G03 X, Y and Z specify the end point of the arc and R the radius

    If using I, J and K then X, Y and Z again specify the end point of the arc and I, J and K specify the distance from the centre of the arc to the start point of the arc.

    And thus concludes lesion one on circular interpolation.

    I have tried to make things as simple as they get here, I’m really sorry if it was a little to simple but I don’t know how much you know already.

    I could have just put an example on here and let you copy and paste it all you like but then I thought your not really going to learn anything from that are you, you would be much better off if I tell you how to work it out for yourself.

    Hay why aren’t there some tutorials for things like this on the site any ware.

    If you want any more help with Gcode then let me know.




  8. #8
    Registered
    Join Date
    Feb 2008
    Location
    Scotland
    Posts
    41
    Downloads
    0
    Uploads
    0

    Default

    Yes, it's all well and good copying and pasting, but as fastnovacrash said, it's better to learn why your doing something.


    G43 Z50.0 H1 M08
    Z2.0
    G81 G98/G99 Z-10.0 R2.0 F20.0
    G82 G98/G99 Z-10.0 R2.0 P1000 F20.0
    G83 G98/G99 Z-10.0 R2.0 Q2.0 F20.0
    G73 G98/G99 Z-10.0 R2.0 Q2.0 F20.0
    G80

    The above are examples of drilling canned cycles.

    G81 feeds to the Z position from the R position (which is where the Z axis returns to using G98 command. It returns to the previous Z position if you use G99) at the specified feed.

    G82 is the same but the P value is a dwell in seconds when it reaches the Z position.

    G83 has a Q value which is the depth of peck in mm. The machine then pulls back to the R point after each peck then returns to where it last cut minus a standoff distance set by parameters.

    G73 is the same as G83 but does not pull back to the R point after each peck. It only standsoff by distance set in the parameters.

    G80 cancels the canned cycles.



  9. #9
    Registered
    Join Date
    Mar 2005
    Location
    usa
    Posts
    21
    Downloads
    0
    Uploads
    0

    Default

    Could someone post me a circle of a 1.5" circle to go with the above 3" So I can learn it my (odd) way?.... (I need a 2" and with the 3" and the 1.5" I will learn faster how to make what I need instead of asking all the time)
    Thanks
    J
    My tool is 1/8 (.125) dia.



  10. #10
    Registered tauntdesigns's Avatar
    Join Date
    Nov 2005
    Location
    USA
    Posts
    655
    Downloads
    0
    Uploads
    0

    Default

    the finish pass for 1.5 dia. using .125 dia. cutter. The center of the hole is x0,y0.

    First I take the hole dia. and subtract tool dia. 1.5 - .125 = 1.475 divide that by 2
    1.475 / 2 = .7375 If I want to ramp onto the finish pass I would also need to know the distance to the center of the ramp on arc. .7375 / 2 = .3687

    (climb cut)
    G0x0y0 (start point)
    z1.
    g1z.05f20.
    g3x-.7375y0i-.3687j0f5. (ramp on)
    g3x-.7375y0i.7375j0 ( full 360 deg cut)
    g3x0y0i.3687j0 (ramp off)
    g1z1.f20.

    g2/g3 line: x and y are finish points, i and j are the incremental distance from the start point to the center of the arc.

    To do a round boss/island 1.5 dia with .125 cutter. center of boss is x0,y0
    divide 1.5 by 2 and devide .125 by 2 and add those together .750 + .0625 = .8125

    Ramp on and ramp off with a start position .5 away from the outside of boss .8125 + .5 = 1.3125

    G0x1.325y0
    z1.
    g1z.2f20
    z-.05f10.
    g3x.8125y0i-.25jof5.
    g2x.8125y0i-.8125j0
    g3x1.3125y0i.25j0
    g1z1.f20.

    later, jack

    Walking is highly over-rated


Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

G-Code Examples

G-Code Examples