Mill GCode Programming - Rev1h.pdf

(1416 KB) Pobierz
Mach4 CNC Controller
Programming Guide
Version 1.0
1
Copyright © 2014 Newfangled Solutions, Artsoft USA, All Rights Reserved
The following are registered trademarks of Microsoft Corporation: Microsoft, Windows. Any other
trademarks used in this manual are the property of the respective trademark holder.
Table of Contents
Chapter 1: Introduction ................................................................................................................................ 2
Glossary ..................................................................................................................................................... 3
Format ....................................................................................................................................................... 4
Chapter 2: G Code List................................................................................................................................... 5
G Code Descriptions and Examples........................................................................................................... 7
Chapter 3: Canned Cycles ........................................................................................................................... 31
Drilling ..................................................................................................................................................... 33
Tapping.................................................................................................................................................... 38
Boring ...................................................................................................................................................... 41
Chapter 4: Cutter Compensation ................................................................................................................ 48
Chapter 5: M Code List................................................................................................................................ 54
M Code Descriptions ............................................................................................................................... 54
Chapter 1: Introduction
G Code is a special programming language that is interpreted by Computer Numerical Control (CNC)
machines to create motion and other tasks. It is a language that can be quite complex at times and can
vary from machine to machine. The basics, however, are much simpler than it first appears and for the
most part follows an industry adopted standard. Mach4 has made a large leap closer to this standard.
An important point to remember when reading this manual: In describing motion of a machine it will
always be described as tool movement relative to the work piece. In many machines the work piece will
move in more axes than the tool; however the program will always define tool movement around the
work piece. Axes directions follow the right hand rule, see figure A.
2
Figure A: Right hand rule
Glossary
Block
Canned Cycle
Dwell
EOB
Feedrate
Group
Modal
Normal
Origin
RPM
UPM
Word
A single line of G Code
Complex cycle defined by a single block of code
Program pause with a duration defined by “P” in seconds
End of block. Required at the end of every block of G Code. In Mach4 this is a
carriage return
Velocity, set by F, at which an axis will move
Collection of G codes that control the same function or mode, i.e. G90 and G91
positioning modes
Active until a code from the same group is called
A line perpendicular to a plane, pointing in the positive direction.
Point in a coordinate system where X, Y and Z are zero
Revolutions per minute
Units per minute (inches, millimeters, degrees, etc)
A single word of G Code is a letter followed by a number. G01, X1.0, etc. are words
G
M
X, Y, Z, A, B, C
S
T
H
D
F
P
Preparatory function, G followed by a numerical code, specifies machining modes
and functions
Miscellaneous function, M followed by a numerical code, defines program flow and
can control auxiliary functions such as coolant. Can also perform machine specific
functions and macros user or builder.
Movement commands followed by a numerical value, define the end point of a
motion command
Spindle speed, followed by numerical value of desired rpm or surface speed
Tool call, followed by next tool number to be used
Tool height offset to be used, generally matches the tool number
Tool diameter offset to be used, generally matches the tool number
Followed by a numerical value to define the feedrate. The magnitude and value of
which will be determined by the feed mode setting
Followed by a numerical value, specifies dwell time in seconds. (also used in other
functions)
3
N
Sequence numbers. Used for program organization and go to commands
Format
In writing G Code programs there are some rules to be aware of as well as some general formatting
guidelines that should be followed or at least considered.
The first part of any program should be a safe start up block. This line of code is used to make sure that
some modes are disabled and others are set to their most common setting. An example safe start block
would look like this:
G00 G90 G17 G54 G40 G49 G80
This block of code tells the machine that we want to be in rapid mode and using absolute position in the
XY plane of fixture offset 1. At the same time we want to cancel any tool diameter and length offsets
and make sure any active canned cycles are cancelled.
G00 – Rapid mode
G90 – Absolute position mode
G17 – XY plane select
G54 – Fixture offset 1
G40 – Cutter compensation (tool diameter) cancel
G49 – Length offset cancel
G80 – Canned cycle cancel
It is recommended that this safe start block be used at the start of the program and also before or
immediately following every tool change. It is common to restart a program from a tool change, having
the safe start line there can greatly reduce the chance of a machine not acting as expected, the results
of which can be aggravating at best and a crash at worst. The safe start block shown here is just an
example. Every machine and every programmer are a little different and each will have their own start
up block.
Jumping to the end of the program there is not a lot required. Typically there will be a couple blocks of
code to return the Z axis to the home position and maybe move the work piece closer to the operator
for easier loading and unloading of parts. Shutting off the spindle and coolant or any other accessories
is also a good idea here. The final block in a program is a program end code, most commonly M30 but
there are other options. Make sure this final block is followed by an end of block. It is easy to forget this
last EOB in a program for Mach because it is just a carriage return and not always readily apparent. One
way to make sure that there is always an EOB on your program end block is to follow it with %. Like this:
.
.
.
M30
4
%
This percent sign is a familiar symbol to CNC programmers in industry; however any symbol or character
can be used as it will not be read by the control because of the program end before it. If there is no EOB
following the percent sign it will not show up in the program when loaded into Mach.
In between the start and end is the body of the program. There are a few rules here. Each block of code
will contain a combination of words. Multiple G codes can be specified in a single block, however if
more than one from the same modal group is specified the last one in the block will be valid, with the
exception of group 00. Modal G codes stay active until another from the same group is called. For
example; G01 is modal so it is not necessary to put it in consecutive blocks. Once active every successive
positioning block will be in the G1 mode unless another code from group one is called (G00, G02, G03,
etc.). All G codes not in group 0 behave this way.
Only one M code can be specified in a single block. Same holds true for all other words.
Generally leading zeroes are not required in G Code. For example G01 and G1 are the same. The same
holds true for M codes, position commands, feedrates, etc. When specifying values for position,
feedrate, variables, etc., it is good practice to always use a decimal point and trailing zero, instead of X1
use X1.0. Although the decimal point is not required (in Mach X1 = X1.0) it is HIGHLY recommended.
Chapter 2: G Code List
Code
G00
G01
G02
G03
G04
G09
G10
G12
G13
G15
G16
G17
G18
G19
G20
G21
G28
G30
Group
1
1
1
1
0
0
0
1
1
11
11
2
2
2
6
6
0
0
Description
Rapid Move
Linear Feed Move
Clockwise Arc Feed Move
Counter Clockwise Arc Feed Move
Dwell
Exact stop
Fixture and Tool Offset Setting
Clockwise Circle
Counter Clockwise Circle
Polar Coordinate Cancel
Polar Coordinate
XY Plane Select
ZX Plane Select
YZ Plane Select
Inch
Millimeter
Zero Return
2
nd
, 3
rd
, 4
th
Zero Return
5
Modal
Y
Y
Y
Y
N
N
N
Y
Y
Y
Y
Y
Y
Y
Y
Y
N
N
Page
7
7
8
8
11
11
11
14
14
15
15
16
16
16
18
18
18
19
Zgłoś jeśli naruszono regulamin