23
Introduction To CNC-Programming

Basics Types Structure of a program Common G and M Codes Analyzing a Code

Embed Size (px)

Citation preview

Page 1: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Introduction To CNC-Programming

Page 2: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Topics• Basics• Types• Structure of a program• Common G and M Codes• Analyzing a Code

Page 3: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Basics

• Geometric code• G-code is a language used to communicate to a CNC

machine. It tells the machine how to move and what commands to execute.

• It is a way for a machinist to tell a CNC machine what to do.

What is G-Code?

What is M-Code?• Miscellaneous code• Examples: coolant, spindle speed, clockwise,

counterclockwise and changing to a specific tool number, etc.

Page 4: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Significance• Supreme accuracy and precession• Automation to reduce the need of manual labor and skill• Reduces manufacturing cycle time• Complex and sophisticated manufacturing• Mistake proofing and continuous flow

Basics

Page 5: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Types of program

Basic G-coding can be categorized into two types:• Turn (Lathe machine)

Does operations such as turning, parting, facing, contouring, drilling etc.

• Mill (Vertical milling machine)

Does operations such as slot cutting, drilling, design on plate, a lot of other applications.

Don’t get anxious if you are lost. It will be clear as we take some examples

Page 6: Basics Types Structure of a program Common G and M Codes Analyzing a Code

ExamplesC

utt

ing

vie

wA

fter

each

cu

t

FINAL OBJECT

Turn

Page 7: Basics Types Structure of a program Common G and M Codes Analyzing a Code

ExamplesMill

FINAL OBJECT

Page 8: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Types of program (contd..)

According to axis it can be: 2 axis (Turn ---X, Y) 3 axis (Mill ---X, Y, Z) 4 axis (Combined) 5 axis (Combined)

Let’s take examples !

Page 9: Basics Types Structure of a program Common G and M Codes Analyzing a Code

2 Axis 3 Axis

4th (A) & 5th (B) Axis

Page 10: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Tips• X= Horizontal• Y= Vertical• Z= Up and down or depth• A= Rotation about X• B= Rotation about Y• The number beside either x, y or z in the G-Code language

is the distance it travels in that general axis.

Page 11: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Layout of a program• % (it means the start of program)• Program number (reference)• Safety codes (safety codes to cancel presets)• Stock definition• Tool change• Move to position• Spindle turns on• Coolant turns on• Cutting begins• End of program• Reset

Page 12: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Frequently used G Codes and their useG00 --Rapid move to position---Quickly travels to the position specified by X, Y, Z G01– Move to position while cutting– Reaches position specified by X, Y, Z while making cutG02– Making clockwise cut– Makes arc/round cutG03– Making anticlockwise cut--Makes arc/round cutG17– XY plane– If the plane is changed due to previous program it will again return to XYG90– Absolute distance– Always considers from 0,0,0G54– Cancel offset– Previous offset of 0,0,0 will be cancelledG40– Cancel tool radius offsetG49– Cancel tool length offsetG94– Feed per minuteG41– tool compensation left of cut (looking from behind)– Considers the tool radiusG42-- tool compensation right of cut (looking from behind)G43– tool length compensation – Considers the tool lengthG80-- Cancel all canned cycle– Canned cycle is used to do multiple similar works like drilling in different positions with same parametersG83– Pecking canned cycle– Used for peck drillingG91– Incremental movement– Adds the given value with previous positionG04– Dwell– Stays in the specified position for given time. Its calculated as 1000th of a second. So 4000 will mean 4 second.G20– Unit in inchG21– Unit in mm

Page 13: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Frequently used M Codes and their use

M03– Spindle start clockwiseM05– Spindle stopM06– Tool changeM08– Coolant startM04-- Spindle start anticlockwiseM00– Program stopM09– Coolant stop

Page 14: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Tips

• The codes sometime differ for different controls/machines

• The best way to deal with it is to know the machine

• We can know our machine by running trials with standard codes.

• Practicing makes it easy to remember the G and M codes.

Page 15: Basics Types Structure of a program Common G and M Codes Analyzing a Code

We will do coding for this object !

Page 16: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Lets analyze the program

The pictures above shows the process in brief

1 2 3

4 5 6

Page 17: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Code%(STOCK/BLOCK,3.5,2,.51,0,0,1)O1000 (Program Number)(Start of safety code)G20 G17 G40 (G20 inch/G21 Metric, XY plane, cancel cutter compensation)G49 G64 G80 (Cancel tool length compensation, normal cutting mode, cancel canned cycles)G90 G94 G98 (absolute mode, feed per minute, initial plane for canned cycles)(end of safety code)

(TOOL/MILL,2,0,5,0)(COLOR,128,255,255)M6 T20 G00 X0 Y0 Z0 T20 S2250 M03 M08G01 Z-.51 F25X3.5 Y.5X0Y1X3.5Y1.5X0Z1M05 M09(TOOL/MILL,0.5,0,5,0)(COLOR,0,128,128)M6 T1G00 X-.25 Y1.06 S7500 M03 M08G01 Z-1.1 F75

Y.38G03 R.625 X.38 Y-.25G01 X3.13G03 R.625 X3.75 Y.38G01 Y1.4 Z1G00 X3.42 Y1.28G01 Z-1.1 G02 X2.78 Y1.92 I-.17 J.47G01 Z1G00 X3.46 Y2.25G01 Z-1.1X.38G03 R.625 X-.25 Y1.63G01 Y.5Z1M05 M09

(TOOL/DRILL,0.375,120,5)(COLOR,0,0,0) M06 T2 G00 X.75 Y.5 Z-.25 S2200 M03 M08G83 X.75 Y.5 Z-1.3 R-.475 Q.125 P4000 F12X1.48X2.25X.75 Y1.25X1.48X2.25G01 Z1M05 M09M00

Page 18: Basics Types Structure of a program Common G and M Codes Analyzing a Code

Lets breakdown the program to discuss

%(STOCK/BLOCK,3.5,2,.51,0,0,1)

O1000 (Program Number) 1(Start of safety code)G20 G17 G40 (G20 inch/G21 Metric, XY plane, cancel cutter compensation)G49 G64 G80 (Cancel tool length compensation, normal cutting mode, cancel canned cycles)G90 G94 G98 (absolute mode, feed per minute, initial plane for canned cycles)(end of safety code)

(TOOL/MILL,2,0,5,0)(COLOR,128,255,255)M6 T20

G00 X0 Y0 Z0 T20 S2250 M03 M08 2G01 Z-.51 F25X3.5 Y.5X0Y1X3.5Y1.5X0Z1M05 M09(TOOL/MILL,0.5,0,5,0)(COLOR,0,128,128)M6 T1G00 X-.25 Y1.06 S7500 M03 M08G01 Z-1.1 F75 Y.38

G03 R.625 X.38 Y-.25G01 X3.13G03 R.625 X3.75 Y.38G01 Y1.4 Z1G00 X3.42 Y1.28G01 Z-1.1 G02 X2.78 Y1.92 I-.17 J.47

3G01 Z1G00 X3.46 Y2.25G01 Z-1.1X.38G03 R.625 X-.25 Y1.63G01 Y.5Z1M05 M09

(TOOL/DRILL,0.375,120,5)(COLOR,0,0,0) M06 T2 G00 X.75 Y.5 Z-.25 S2200 M03 M08G83 X.75 Y.5 Z-1.3 R-.475 Q.125 P4000 F12

4X1.48X2.25X.75 Y1.25X1.48X2.25G01 Z1M05 M09M00

Page 19: Basics Types Structure of a program Common G and M Codes Analyzing a Code

1% indicates the start of the

program. In some controls it is ignored.

Then there is the definition of stock. The initial object for machining. 3.5X2X.51

Machine initial position is 0,0,1

Now it’s the program number which will help us recognize the program in the machine

Now the safety codesThese will cancel memory

from previous operation and set the parameters for this program such as unit (G20), Plane (G17), feed (G94), travel mode (G90).

%(STOCK/BLOCK,3.5,2,.51,0,0,1)

O1000 (Program Number)

(Start of safety code)G20 G17 G40 (G20 inch/G21 Metric, XY plane, cancel cutter compensation)G49 G64 G80 (Cancel tool length compensation, normal cutting mode, cancel canned cycles)G90 G94 G98 (absolute mode, feed per minute, initial plane for canned cycles)(end of safety code)

Page 20: Basics Types Structure of a program Common G and M Codes Analyzing a Code

2 Defines the tool geometry. In the bracket the yellow

number 2 means diameter and then there is height 5 Color code for the tool These are for visualization in simulation. These will

not go in to the machines Then there is the command for tool change to ‘Tool

20’. M6 stands for tool change. Then G00 is asking the tool 20 to rapidly go to 0,0,0

and then the spindle starts. M03 means clockwise rotation of spindle and ‘S’ specifies the speed

M08 means coolant start G01 is asking the tool to go to the specified position

while cutting. ‘F’ indicates the feed rate. G01 continues and no need to write again and again.

The tool travels to the specified positions in X, Y and Z while cutting. Facing of the top part is being done.

Now the machine needs to stop for tool change. M05 stops the machine and M09 stops the coolant.

M6 changes the tool to tool 1 G01 is asking rapid positioning to the specified

location. Spindle starts with speed 7500 and rotating in clockwise direction. Coolant starts as well.

G01 indicated moving to the location while cutting as the tool and speed has changes we have a different requirement for feed.

Cutting continues on y axis. A straight travel has been completed and now it will

turn the corner with a radius.

(top part facing)(TOOL/MILL,2,0,5,0)(COLOR,128,255,255)T20 M6 G00 X0 Y0 Z0 T20 S2250 M03 M08G01 Z-.51 F25X3.5 Y.5X0Y1X3.5Y1.5X0Z1M05 M09(Profiling)(TOOL/MILL,0.5,0,5,0)(COLOR,0,128,128)M6 T1G00 X-.25 Y1.06 S7500 M03 M08G01 Z-1.1 F75 Y.38

Page 21: Basics Types Structure of a program Common G and M Codes Analyzing a Code

3 A straight travel has been completed and now it

will turn the corner with a radius G03 means turning corner counter clockwise. R is

the radius of travel. And specified X,Y is the end point

First positioning the tool then direction, radius and end position. This is the sequence.

Then again a straight cut and round corner and again a straight cut (G01 Y1.4). After that the tool moves up (use G01 to avoid collition) to take position for the cutting with ‘I’ and ‘J’.

Rapid positioning and then tool climbs down cutting. Tool is in start position for the round cut.

G02 for clockwise cut. X,Y denotes the end position and then I indicated the start position from center of arc along X axis. And J indicated the Y value. These are not co-ordinates these are lengths.

After that the tool moves up, takes another position for profiling a straight cut and then makes another counter clockwise round cut. Radius coordination system has been used for this one.

After this tool makes another straight cut and climbs up and stops for tool change.

Coolant is also stopped.

G03 R.625 X.38 Y-.25G01 X3.13G03 R.625 X3.75 Y.38G01 Y1.4 Z1G00 X3.42 Y1.28G01 Z-1.1 G02 X2.78 Y1.92 I-.17 J.47

G01 Z1G00 X3.46 Y2.25G01 Z-1.1X.38G03 R.625 X-.25 Y1.63G01 Y.5Z1M05 M09

Page 22: Basics Types Structure of a program Common G and M Codes Analyzing a Code

4 Tool is changed to a drill. G00 performed rapid positioning for

drilling Canned cycle has been used to avoid

coding for repeating task G83 has been used as the

requirement is peck drilling. X,Y gives the drill position, Z gives

the final depth, R gives the retract height in drilling, Q gives the pecking depth, P gives he dwell time in final depth for smoothing the hole and F gives the feed rate.

As we used the canned cycle we do not need to write the specifications again. Just providing the next drill location does the job

After the drilling the tool climbs up and spindle is stopped as well as the coolant supply.

M00 indicates the end of the program.

(TOOL/DRILL,0.375,120,5)(COLOR,0,0,0) M06 T2 G00 X.75 Y.5 Z-.25 S2200 M03 M08G83 X.75 Y.5 Z-1.3 R-.475 Q.125 P4000 F12

X1.48X2.25X.75 Y1.25X1.48X2.25G01 Z1M05 M09M00

Page 23: Basics Types Structure of a program Common G and M Codes Analyzing a Code

THANK YOU