Search

Showing posts with label CNC programming. Show all posts
Showing posts with label CNC programming. Show all posts

CNC Programming Examples - Step Turning CNC Lathe

CNC Mill Subprogram Example Joining Multiple Arcs G02 G03 G41


CNC milling program to describe how two or more radii can be joint together in a cnc mill program.

CNC Mill Subprogram Example


CNC Part Program

N10 T1 H1 M6 G43 M3
        N20 F150 S250
        N30 G0 X-21 Y50 Z0.5
        N40 G0 Z0
        N50 M98 P040050
        N60 G49
        N70 G0 Z50
        N80 M30

Subprogram

O0050
        N10 F160 S400
        N20 G0 Z-2.5 G91
        N30 G1 G90 X5 Y50 G41      (P1)
        N40 G2 X22 Y85.23 I45 J0   (P2)
        N50 G3 X78 Y85.23 R45      (P3)
        N60 G2 X78 Y14.77 R45      (P4) 
        N70 G3 X22 Y14.77 R45      (P5)
        N80 G2 X5 Y50 R45          (P1)
        N90 G0 G40 X-21
        N100 M99

G M S T Codes Explanation

Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed

-------------

CNC Pocket Milling Program Example – Peck Milling

CNC milling program example which shows how a cnc program can be made to machine Pockets on a cnc mill.
This program example uses Peck milling to cut material to machine a rectangular and one round pocket.
Contents

CNC Pocket Milling Program Example


Main Program

Milling cutter diameter: 10mm
N05 G55
            N10 M6 T2 H3 G43 M3
            N15 S1000 F60
            N20 G0 X9 Y9 Z1
            N25 G1 Z0
            N30 M98 P030035
            N35 G0 Z1 G90
            N40 X42 Y38
            N45 G1 Z-2 F30
            N50 X47 F300
            N55 G3 X47 Y38 I-5 J0
            N60 G0 Z100
            N65 G49
            N70 M30

Subprogram

O0035
            N05 G1 Z-2 G91 F30
            N10 X10 F100
            N15 Y36
            N20 X-10
            N25 Y-36
            N30 M99

Explanation

Although this cnc mill program is self explanatory
M98 P030035
this code mean call Subprogram No. 0035 three times.

------------

Multi Start Threads with Fanuc G76 Threading Cycle

Fanuc cnc controls has no direct threading cycle for cutting multi start threads on cnc. But you can cut multi start threads on a cnc with fanuc control by using Fanuc G76 Threading Cycle.
Related: Fanuc G76 Thread Cycle for Dummies

Multi Start Threads with Fanuc G76 Threading Cycle
There are multiple techniques for cutting multi-start threads on cnc with Fanuc G76 threading cycle. Here is one of them.
This cnc programming example uses cnc subprogram call to cut multi-start threads on Fanuc cnc.

CNC Main program
N50 G00 X48 Z5
                N60 M98 P0034713

CNC Sub Program

N10 G76 P020000 Q100 R0.05
                N20 G76 X42 Z-15 P974 Q200 F4.5
                N30 G00 W1.5
                N40 M99
The above cnc main program calls the 4713 sub-program three times.

CNC Programming Examples - Peck Milling

CNC Milling Machine Programming Example for Beginners

* Best ebooks for CNC programming: 
CNC Programming Basics 
G-Code and M-Code 
CNC programming 
G-Code Reference 
CNC Machine Tutorial 
CNC M-Code Tutorial




CNC Mill Program Example

A very simple cnc milling machine programming tutorial for beginner level cnc machinists.

An easy to understand cnc mill programming code. This is a cnc g code example without the use of any cnc canned cycle.
Related cnc mill program examples
  • CNC G02 Circular Interpolation Clockwise CNC Milling Sample Program
  • CNC Milling Circular Interpolation G02 G03 G-Code Program Example


Beginner level cnc program examples for CNC Lathe
  • Fanuc CNC Program Example
  • CNC Programming for Beginners a Simple CNC Programming Example
  • CNC Programming for Beginners a CNC Programming Example

CNC Milling Machine Programming Example for Beginners
N05 G0 G90 X40 Y48 Z2 S500 M3
        N10 G1 Z-12 F100
        N15 X20 Y18 Z-10
        N20 G0 Z100
        N25 X-20 Y80
        N30 M2
N05 The tool traverses in rapid traverse on P1, three axes concurrently, spindle speed = 500 rpm, clockwise
N10 Infeed on Z-12, feed 100 mm/min
N15 Tool travels on a straight line in space on P2
N20 Retraction in rapid traverse
N30 End of program

CNC Programming Examples - Bolt Hole Circle

Fanuc G72.1 G72.2 Figure Copy Program Example (Bolt Hole Circle)





This CNC program example shows how both G72.1 and G72.2 figure copy functions can call one-another in one part program, read Programming Notes below carefully.
Contents

* Best ebooks for CNC programming: 
CNC Programming Basics 
G-Code and M-Code 
CNC programming 
G-Code Reference 
CNC Machine Tutorial 

Programming

Fanuc G72.1 Rotational Copy

Using G72.1 Rotational Copy G-code a figure specified by a subprogram can be repeatedly produced with Rotational movement.
Read G72.1 definition with program example Fanuc G72.1 Rotational Copy (Figure Copy Function CNC Mill)

Fanuc G72.2 Linear Copy

Using G72.2 Linear Copy G-code a figure specified by a subprogram can be repeatedly produced with Linear movement.
Read G72.2 definition with program example Fanuc G72.2 Linear Copy (Figure Copy Function CNC Mill)

Fanuc G81 Drilling Cycle

G81 drilling cycle is used for simple drilling/spot drilling operations.
Read G81 drilling cycle definition with program examples Fanuc G81 Drilling Cycle

Programming Notes

Specifying two or more commands to copy a figure
  1. G72.1 cannot be specified more than once in a subprogram for making a rotational copy (If this is attempted, alarm PS0900 will occur).
  2. G72.2 cannot be specified more than once in a subprogram for making a linear copy (If this is attempted, alarm PS0901 will occur).
  3. In a subprogram that specifies rotational copy, however, linear copy can be specified. Similarly, in a subprogram that specifies linear copy, rotational copy can be specified.

Fanuc G71.2 G72.2 Program Example


Main program
        O4000 ;
        N10 G90 G00 G17 X240. Y230. Z100. ; (P0)
        N20 G72.1 P4100 X120. Y120. L8 R45. ;
        N30 G80 G00 X240. Y230. ; (P0)
        N40 M30 ;
Sub program Rotation copy (G72.1)
        O4100 N100 G72.2 P4200 I0 J20. L3 ;
        N200 M99 ;
Sub program Linear copy (G72.2 )
        O4200 N110 G90 G81 X120. Y180. R60. Z10. F200. ; (P1)
        N210 M99 ;

CNC Programming Examples - Drilling

Fanuc G72.1 G72.2 Figure Copy Program Example (Bolt Hole Circle)

* Best ebooks for CNC programming: 
CNC Programming Basics 
G-Code and M-Code 
CNC programming 
G-Code Reference 
CNC Machine Tutorial 

This CNC program example shows how both G72.1 and G72.2 figure copy functions can call one-another in one part program, read Programming Notes below carefully.

Programming

Fanuc G72.1 Rotational Copy

Using G72.1 Rotational Copy G-code a figure specified by a subprogram can be repeatedly produced with Rotational movement.
Read G72.1 definition with program example Fanuc G72.1 Rotational Copy (Figure Copy Function CNC Mill)

Fanuc G72.2 Linear Copy

Using G72.2 Linear Copy G-code a figure specified by a subprogram can be repeatedly produced with Linear movement.
Read G72.2 definition with program example Fanuc G72.2 Linear Copy (Figure Copy Function CNC Mill)

Fanuc G81 Drilling Cycle

G81 drilling cycle is used for simple drilling/spot drilling operations.
Read G81 drilling cycle definition with program examples Fanuc G81 Drilling Cycle

Programming Notes

Specifying two or more commands to copy a figure
  1. G72.1 cannot be specified more than once in a subprogram for making a rotational copy (If this is attempted, alarm PS0900 will occur).
  2. G72.2 cannot be specified more than once in a subprogram for making a linear copy (If this is attempted, alarm PS0901 will occur).
  3. In a subprogram that specifies rotational copy, however, linear copy can be specified. Similarly, in a subprogram that specifies linear copy, rotational copy can be specified.

Fanuc G71.2 G72.2 Program Example


Main program
O4000 ;
        N10 G90 G00 G17 X240. Y230. Z100. ; (P0)
        N20 G72.1 P4100 X120. Y120. L8 R45. ;
        N30 G80 G00 X240. Y230. ; (P0)
        N40 M30 ;
Sub program Rotation copy (G72.1)
O4100 N100 G72.2 P4200 I0 J20. L3 ;
        N200 M99 ;
Sub program Linear copy (G72.2 )
O4200 N110 G90 G81 X120. Y180. R60. Z10. F200. ; (P1)
        N210 M99 ;

------------------

Fanuc G81 Drilling Cycle

G81 drilling cycle is used for simple drilling/spot drilling operations.

Syntax

G81 X... Y... Z... R... K... F...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tool will travel with feed to Z-depth starting from R plane.
R Position of the R plane.
K Number of cycle repetitions (if required) .
F Feedrate.
Once G81 drilling cycle is defined, the canned cycle is repeated at every X-Y position in sequential blocks. So G81 drilling cycle must be cancelled with G80.

Usage

            N30 G81 X10 Y30 Z-17 R2 F75
            N40 Y10
            N50 X30
            N60 Y30
            N70 X90
            N80 Y10
            N90 G80


In the above example drilling will start with G81 drilling cycle at X10 Y30, so first drill will be at X10 Y30, then second at Y10, third at X30, fourth at Y30, fifth at X90 and the last one at Y10, because next block have G80 code, so drilling cycle will no more be repeated.

Working

Here is briefly described how G81 drilling cycle operates,
1- Rapid traverse to the specified x,y axis position (drilling position).
2- Rapid traverse to the R plane position.
3- Drilling with specified Feed from R-plane position to Z-depth position.
4- Rapid traverse to Initial level or R-plane depends on G98, G99 modes.

G81 drilling cycle working

G98 G99 Modes

After completing drilling depth the return is made with Rapid feed, the return height can be controlled through using G98 or G99.
G98 Drill will return to the Initial level
G99 Drill will return to R-plane.
G98, G99 can be used multiple times during G81 drilling cycle.

Example

            N30 G81 X10 Y30 Z-17 R2 F75
            N40 Y10
            N50 G98 X30
            N60 G99 Y30
            N70 X90
            N80 Y10
            N90 G80

Repeat Drilling

With G81 drilling cycle drilling operation can be repeated multiple times. The drilling is repeated K times when that parameter is given with G81 drilling cycle.
Repeat drilling is normally used with G91 Incremental mode, and a good example of repeated drilling is Grid-plate drilling. the example for repeat drilling  is given below.

Working Examples


G81 Drilling Cycle Example
            N10 T1 M06
            N20 G90 G54 G00 X30 Y25
            N30 S1200 M03
            N40 G43 H01 Z5 M08
            N50 G81 Z-10 R2 F75
            N60 X80 Y50
            N70 G80 G00 Z100 M09
            N80 M30

G98 G99 Example


G81 drilling cycle usage with G98 G99
            N10 M06 T1
            N20 G90 G00 X12.5 Y10 Z12 S1000 M03
            N30 G99 G81 X12.5 Y10 Z-17 R2 F75
            N40 Y30
            N50 G98 X57.5
            N60 G99 Y10
            N70 G91 G80 G28 X0 Y0 Z0 M05
            N80 M30

Repeat Drilling Example


Repeat drilling with G81 Drilling Cycle
            T1 M6
            G00 G90 G40 G21 G17 G94
            G54 X0 Y0 S1000 M03
            G43 H1 Z100
            Z3
            G81 G99 G91 X20 Y20 R3 Z-20 K3 F100 M08
            G80
            G00 G90 Z100
            M30
OR
            T1 M6
            G00 G90 G40 G21 G17 G94
            G54 X20 Y20 S1000 M03
            G43 H1 Z100
            Z3
            G81 G99 R3 Z-20 F100 M08
            G91 X20 Y20 K2
            G80
            G00 G90 Z100
            M30
-------------------------------------------------

Fanuc G82 Drilling Cycle

G82 drilling cycle is also called G82 counter boring cycle.
G82 is a normal drilling cycle the only difference is that it dwell for specified time at the bottom of the hole, normally used for accurate depth drilling.

Syntax

G82 X... Y... Z... R... P... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tool will travel with feed to Z-depth starting from R plane.
R Position of the R plane.
P Dwell at the bottom of hole.
K Number of cycle repetitions (if required) .
F Feedrate.

Usage

                N30 G82 X10 Y30 Z-17 R2 P1000 F75
                N40 Y10
                N50 X30
                N60 Y30
                N70 G80


Once G82 drilling cycle is specified with it’s parameters in a program block, this will keep drilling at every axis movement, until cycle is ended with G80

Working

How G82 drilling cycle works
1- Rapid traverse to x, y position
2- Rapid traverse to R-plane position
3- Drilling with feed from R-plane to Z-depth position.
4- Dwell for specified time at hole bottom.
5- Rapid traverse to R-plane or Initial-level depends on G99, G98 mode.

G82 drilling cycle working

G98 G99 Modes

How G82 drilling cycle behaves upon G98 or G99 mode,
G98 Drill will return to the Initial level
G99 Drill will return to R-plane.
For a working example see G81 drilling cycle.

Example

                N30 G82 X10 Y30 Z-17 R2 P2000 F75
                N40 Y10
                N50 G98 X30
                N60 G99 Y30
                N70 X90
                N80 Y10
                N90 G80

Repeat Drilling

If K parameter value is given with G82 drilling cycle, then drilling will repeat the number of times given with K. An effective use of repeat drilling is while drilling multiple same distance holes, this way G82 cycle is used in G91 incremental mode. See G81 drilling cycle for repeat drilling example.

Working Example


G82 drilling cycle example
                N10 T1 M06
                N20 G90 G54 G00 X30 Y25
                N30 S1200 M03
                N40 G43 H01 Z5 M08
                N50 G82 Z-10 R2 P1000 F75
                N60 X80 Y50
                N70 G80 G00 Z100 M09
                N80 M30

------------------------------------------------------

[CNC Programming Examples] U W CNC Lathe CNC Program Examples

U W CNC Lathe CNC Program Examples

Fanuc G71 Turning Cycle

G71 turning cycle is used for rough-material removal from a cnc lathe component. G71 turning cycle makes large diameter cutting easy. Cutting can be done in simple straight line or a complex contour can also be machined very easily.
Through G71 turning cycle parameters cnc machinists can control
  • Depth of cut.
  • Retract height.
  • Finishing allowance in x-axis and z-axis.
  • Cycle cutting-feed, spindle speed.

Programming

G71 U... R...
G71 P... Q... U... W... F... S...

Parameters

First block
Parameter Description
U Depth of cut.
R Retract height.
Second block
Parameter Description
P Contour start block number.
Q Contour end block number.
U Finishing allowance in x-axis.
W Finishing allowance in z-axis.
F Feedrate during G71 cycle.
S Spindle speed during G71 cycle.

G71 Turning Cycle Overview

  • G71 turning cycle cuts the whole contour repeatedly which is given in P Q blocks.
  • Depth of every cut can be controlled by first-block U value.
  • Second-block U W are the finishing allowances which can be given if you want to make a finish cut with G70 finishing cycle.
  • F is cutting feed and S is spindle speed (given in second-block) which are used during G71 turning cycle.
Note – The F and S given inside P Q block will not be used during G71 turning cycle, they are used with G70 finishing cycle if later called.

G71 Turning Cycle Working

N60 G71 U10 R10 
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
When G71 turning cycle is run the whole operation will be done in following sequence,
First-cut
1 – Tool will move in x-axis U (depth of cut) deep with programmed feed from starting-point.
2 – Tool will travel with feed in z-axis (destination point in z-axis is given in P Q blocks )
3 – Tool rapidly retracts R amount in both x-axis and z-axis (at 45 degrees).
4 – Tool rapidly travel in z-axis to start-point
Later-cuts
5 – Tool rapidly moves to last cut depth.
6 – Tool moves with feed in x-axis U deep (first-block U depth of cut).
7 – Tool with feed moves in z-axis (destination point given in P Q blocks).
8 – Tool rapidly retracts in x-axis and z-axis R amount (45 degrees).
9 – Tool rapidly moves to start-point only in z-axis.
This whole sequence of operation keep on going, until the destination point in x-axis is met.
If finishing allowance is given tool will not make the exact diameter and length given in P Q blocks but will leave that much allowance, This finishing allowance can be later machined by calling G70 finishing cycle.


Fanuc G71 Turning Cycle

Fanuc G71 Example

Here is a cnc part-program which shows how G71 turning cycle can be used, this is the program for the drawing given above
N50 G00 X106 Z5 M3 S800
N60 G71 U10 R10 
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
In this program G71 turning cycle will keep repeating the contour given inside P Q blocks shown below
N80 G00 X60
N90 G01 Z-75
These two cnc program blocks tell us that we want to remove material till X60 deep and in Z-75 in length.
The depth of cut is given in first-block U10 retract amount is also given R10.
Finishing allowance in x-axis is U3 but there is no finishing allowance given in z-axis W0.

G70 Finishing Cycle

If you programmed G71 turning cycle with finishing allowances then that finish allowances can be removed with G70 finishing cycle.
G70 finishing cycle repeats the whole contour the G71 way, but in just one-cut removing the finishing allowances.

Why Use G70 Finishing Cycle

As material can be removed with G71 turning cycle, but if you want a different cutting-feed and spindle speed for the last cut, then it is recommended that you use G70 finishing cycle.
G70 finishing cycle use F and S values which are given inside P Q programmed blocks. (G71 use F S values which are given inside G71 second block.)

Fanuc G70 Example

N50 G00 X106 Z5 M3 S800
N60 G71 U10 R10 
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75 F0.15
N100 G00 X200 Z100
N110 G92 S1200
N120 T3 G96 S150 M03
N130 G00 X106 Z5
N140 G70 P80 Q90
N150 G00 X200 Z100
N160 M30

G70 G71 Example


G71 Rough Turning Cycle Example

O0004
G00 X200 Z10 M3 S800
G71 U2 R1 F200
G71 P80 Q120 U0.5 W0.2
N80 G00 X40 S1200
G01 Z-30 F100
X60 W-30
W-20
N120 X100 W-10
G70 P80 Q120
M30


***********************************