Está en la página 1de 17

6.1.

G códigos
Estos son los códigos estándar predeterminados que se utilizan en nuestras máquinas virtuales
normales. Tenga en cuenta que las máquinas personalizadas pueden tener otros códigos y
formatos.

Las siguientes tablas darán una breve explicación de los diversos códigos G, M y otros
reconocidos por el intérprete de CNCSimulator. En la columna Formato, verá el formato esperado
por el programa. Si un código se escribe entre corchetes como este [X #], significa que el código
no es obligatorio y se puede omitir si no es necesario. El signo # significa que el CNCSimulator
espera un número y el signo $ significa que está esperando una cadena de texto entre comillas.

Ejemplo:
G12[X#][Y#]Z#R#Q#S#SA#AS#RA#H#

Esto significa que el código G12 acepta las coordenadas X e Y, pero no son obligatorias y se
pueden omitir. Por otro lado, debe especificar los códigos Z, R, Q, S, SA, AS, RA y H para evitar
una alarma en el tiempo de ejecución.

G-code Ejmeplo Tipo de


Explicación Formato
maquina

G00 Vaya rápidamente (con la velocidad


de desplazamiento máxima) a la G00 [X#] Todas las
posición X / Y / Z. Este código se [Y#][Z#] G00 Z100 maquinas
utiliza para la posición y no para el
mecanizado real.

G01 Viaje en línea recta utilizando la G01 [X#]


velocidad de avance programada (F). [Y#][Z#] G01 X2.5 Todas las
[F#] Y4.1 F200 maquinas
Este código se utiliza para el
mecanizado.
G02
XY-machines Interpolación circular / helicoidal en
sentido horario. Provoca un
movimiento circular en el sentido de
las agujas del reloj a la velocidad de
avance programada (F). El G02[X#]
movimiento puede ser bidimensional [Y#][Z#] G02 X10
(plano) o tridimensional (helicoidal). El [I#][J#] Y10 I10 J0 Todas las
[K#][R#] F200 maquinas
plano predeterminado del movimiento
Lathe circular es el plano XY (G17), pero [F#]
también se pueden usar otros planos
(ver G17-G19). El centro del arco o
círculo se programa usando las letras
I, J y K (R también se puede usar).

G03 Exactamente como G02, pero el G03[X#] G03 X10 Todas las
XY-machines movimiento circular va en sentido [Y#][Z#] Y10 I10 J0 maquinas
contrario a las agujas del reloj. [I#][J#] F200
[K#][R#]
Lathe [F#]

G04 P2000
G04 Morar en milisegundos. Esto
(Two Todas las
mantendrá los ejes inmóviles durante G04 P# seconds maquinas
el período de tiempo especificado por delay)
el número P.
Forzará a la máquina a hacer una
parada completa antes de continuar
G09 Todas las
G09 con el siguiente movimiento. Esta es
maquinas
una variante no modal de G61 y, por
lo tanto, no tiene que ser cancelada.

Ciclo fijo de taladrado circular. Úselo


para taladrar agujeros alrededor del
contorno de un círculo. R es el plano
G12
de inicio y Z es la profundidad total de G12[X#] G12 X0 Y0
perforación para cada orificio. Q es la [Y#]Z# Z-20 R2
profundidad incremental (peck). SA es R#Q#S#SA Q5 SA0 Solo
el ángulo de inicio del círculo (también # AS36 Fresadoras
el ángulo del primer orificio) y AS es el AS#RA#H# RA30 H10
ángulo entre los orificios. RA es el
radio del círculo y H especifica el
número de orificios a perforar.

G17
Selecciona el plano XY para
G17 Solo
movimientos circulares (ver G02 y G17
Fresadoras
G03).

Solo
Selecciona el plano XZ para Fresadoras
movimientos circulares (ver G02 y G18 G18
G03)

Selecciona el plano YZ para G19 G19 Solo


movimientos circulares (ver G02 y Fresadoras
G03)
G20 Todas las
G20 G20
Exigir el uso de unidades de pulgadas. maquinas

Exigir el uso de unidades de G21 Todas las


G21 G21
milimetros. maquinas

Regreso a casa del comando. Este


comando primero irá a la posición
programada X / Y / Z y luego a Xmin
Milling and
Ymax Zmax de los ejes de la G28[X#] turning
G28 máquina. Puede ser una forma [Y#][Z#] G28 Z10 machines
conveniente de finalizar un programa
only
que coloca la mesa de la máquina en
una posición para cambiar la pieza de
trabajo.

G40 Todas las


maquinas
G40
Cancelar la compensación del cortador G40 More info
excepto
previamente activada por G41 o G42. impresora
3D

Todas las
G41
Activa la compensación del cortador G41[D#] maquinas
G41
del lado izquierdo (o la compensación [P#] excepto
More info
del radio de la punta en un torno). impresora
3D

G42
Todas las
Activates right side cutter G42[D#] G42 maquinas
compensation (or nose radius [P#] More info except the
compensation in a lathe).
3D Printer

Activates tool length compensation. G43[H#] G43 H2 Z2 Solo


G43 (Optional, if not used, automatic tool [P#][Z#] More info Fresadoras
length compensation will be used).

Cancel tool length compensation G49 Solo


G49 G49
(activated by G43). Fresadoras

Move in absolute non-compensated G53 [X#] G53 X0 Y0 Todas las


G53 [Y#][Z#] Z100
coordinates. maquinas

G54-G59 Fixture (work) offsets. A typical use of G54 G00 G54 Todas las
these G-codes is to establish a local X0 Y0 Z3 maquinas
coordinate system for each workpiece
when using multiple ones. You need to
setup the offsets in the Zero Points
Data table in the Inventory Browser
(F2).
G54 corresponds to offset registry
index 0, G55 to index number 1 etc…

Fixture (work) offsets. A typical use of


these G-codes is to establish a local
coordinate system for each workpiece
when using multiple ones. You need to G54.1 P# G54.1 P10
Todas las
G54.1 setup the offsets in the Zero Points (0-99) (Use work
maquinas
Data table in the Inventory Browser offset 10)
(F2).
G54.1 uses letter P to specify the
offset registry index.

G61 Todas las


G61 Exact stop mode. G61
maquinas

G64 Todas las


G64 Normal stop mode (cancels G61) G64
maquinas

G65 P#
Direct call of a macro. P is the macro A...
G65 P1005 Todas las
G65 number to be called. For more B...
A180 maquinas
information, see Macro programming. C...
etc.

Initiates modal calling of macro


G66 P#
defined by P. The macro will not be
A...
called in the G66 block but rather after Todas las
G66 B... G66 P7000
each tool move following the block. maquinas
C...
Cancel with G67. For more
etc.
information, see Macro programming.

Cancels any model macro call initiated


Todas las
G67 by G66. For more information, G67
maquinas
see Macro programming.

G68 Activates rotation of the coordinate G68 Milling


system. X(center machines
in X)
Two syntax are allowed. Y(center
in Y)
Use G69 to cancel the rotation. R(angle)

or

G68
A(center
in X)
B(center
in Y)
R(angle)

Cancel the rotation of the coordinate G69 Milling


G69
system. machines

Finishing Cycle.

After roughing, finishing can be


performed with this cycle. P is first
block of finishing contour and Q is the G70 [P#] G70 P100 Turning
G70 last block. [Q#] machines
Q250
only
For more information see: G71 Rough
Turning Cycle and G70 Finishing
Cycle.

Rough Turning Cycle

Two block format Roughing cycle. Turning


G71
G71 G71 machines
For more information see: G71 Rough only
Turning Cycle and G70 Finishing
Cycle.

G73
Peck drilling canned cycle. The cycle
is intended for deep drilling or chip
breaking milling operations. The cycle
retracts the tool to break chips. Code G73 [X#]
letter Q is used for peck size. R is [Y#][Z#] G73 Z-20 Milling
starting plane and Z is total depth. [R#][Q#] R1 Q1 machines
[P#] P100 only
Parameter P is used for dwell at each
peck. Please note that at the end of
the cycle, the return position in Z is
controlled by G98 and G99.

Generic drilling/boring/tapping canned


cycle. These are used in a generic
way to create compatibility with many
common CNC controllers on the G74 [X#] Milling and
market. They will bring the tool to the [Y#][Z#] G74 Z-20 turning
G74-G75
programmed Z depth. If R is [R#] R1 machines
programmed it will be used as the start only
plane, if not the current Z position will
be used as the start plane. All other
parameters will be ignored.

G76 [X#]
Generic drilling/boring/tapping canned [Y#][Z#] Solo
G76
cycle. See G74-G75 above. [R#] Fresadoras

G76 Threading Cycle G76 G76 Turning


machines
For more information see: G76 Lathe
only
Threading Cycle

Milling and
Cancels any canned cycle. Please
G80 turning
G80 note that G00 – G03 also cancels G80
machines
canned cycles.
only

G81

Basic drilling canned cycle. R is


Milling and
starting plane and Z is total depth. G81 [X#]
Please note that at the end of the [Y#][Z#] G81 Z-6 turning
[R#] R2 machines
cycle, the return position in Z is
only
controlled by G98 and G99.

G82 [X#] Milling and


Generic drilling/boring/tapping canned [Y#][Z#] G82 Z-20 turning
G82-G89
cycle. Same as G74-G76 above. [R#] R1 machines
only

Absolute programming mode.


G90 G90 G00 Todas las
G90 Distances given will move the tool
X10 Y10 maquinas
relative to an absolute zero.

Incremental programming mode.


Distances given will move the tool G91 G91 G00 Todas las
G91
relative to the current position of the Z5 maquinas
tool.

Use to reposition the origin point (zero G92[X#] G92 X20 Todas las
G92 [Y#][Z#] Y20 Z10
point). maquinas

Milling and
G94 Set feed in millimeter or inch per G94 turning
G94
minute. machines
only

Milling and
G95 turning
G95 Set feed per revolution mode. G95
machines
only

G96[S#] Turning
G96 Constant surface speed control. G96 S300
machines
Cancel constant surface speed G97 Turning
G97 G97
control. machines

G98
Milling and
G98 G81 G98 turning
Initial level return at the end of a
Z-7 R2 machines
canned cycle.
only

G99
Milling and
R level return at the end of a canned G99 G81 G99 turning
cycle. Z-7 R2 machines
only
6.2. M codes
These are the default standard codes that are used in our normal virtual machines. Please note
that customized machines may have other codes and formats.

M-code
(codes valid from Explanation Format Example Machine type
V1.0.6.5)
Optional stop (pause). Will pause the
M00 execution of the CNC program if the
“Op.Stop” switch on the virtual CNC Todas las
Controller is activated. Click start or play to M00 M00
maquinas
continue.

M01 Unconditional stop (pause). The execution


of the CNC program will pause. Click start Todas las
or play to continue. M01 M01
maquinas

M02
M02 Todas las
Program end. Simulation will stop. M02
maquinas

M03
Milling and
Start of spindle clockwise. The rotation M03 M03
turning
speed is controlled by the S code letter. S2500
machines only

M04
Start of spindle counterclockwise. The Milling and
M04 M04
rotation speed is controlled by the S code turning
S2500
letter. machines only

M05
Milling and
Spindle stop. M05 M05 turning
machines only

M06
Execute a tool change. The number of the Milling and
tool has to be preselected with the T code M06 T17 M06 turning
letter. machines only

M08
Milling and
Turn on coolant. M08 M08 turning
machines only

M09
Milling and
Turn off coolant. M09 M09 turning
machines only

M17 Return from subroutine or subprogram. M17 M17 Todas las


More info maquinas

M20
Todas las
Open machine doors. M20 M20 maquinas with
doors

M21
Todas las
Close machine doors. M21 M21 maquinas with
doors

M30
M30 Todas las
Program end. Simulation will stop. M30
maquinas

M97 and M98


M98
Call sub program. Use P for sub program M98 P# Todas las
P1000 L1
number and L for the number of repetitions. L# maquinas
More info

M99
Return from a macro, subroutine or M99 Todas las
M99
subprogram. More info maquinas
6.3. $-commands and regions
These are the default standard codes that are used in our normal virtual machines. Please note
that customized machines may have other codes and formats.

The $-commands are special simulation commands for controlling the various aspects of the
simulation. They have nothing to do with CNC codes and should not be transferred to a real CNC
controller. $-commands can be put within parenthesis and will still be read by the simulator. Blocks
of $-commands can be hidden from the CNC code by encapsulating them in a region making the
block collapsible.

Do you notice the little - (minus) sign before the region command at the first line? If you click it, the
region will be collapsed hiding the block of $-commands.

A collapsed region will show three dots and a + (plus) sign. If you click the plus sign, the region will
expand.

You can see what a collapsed region hides without expanding it by hover the mouse pointer over it.

When you open a CNC program from the disk, it always loads with its regions collapsed.

In the following table we list and give a brief explanation of all built in $-commands. Please not that
many of them are not for common use but rather made for special use in examples or when
creating portable programs. We have colored the commands you will likely use in red. If you are
not an advanced user that wants to learn all aspect of the CNCSimulator, you can skip over the
commands colored in black. Not even all red command is a must to know. As a minimum, you have
to know the $AddRegPart command as you will need it to place workpieces on the table (or in the
chuck). If you are a 3D Printer only user, you can ignore the $-commands.

$-command Explanation Format


(codes valid from V1.0.6.5)

Puts a workpiece from the user


defined workpiece registry in the
Inventory Browser (F2) on the
machine table (or in the chuck).
The first number is the registry
$AddRegPart index for the workpiece you $AddRegPart # [#][#][#]
want to place. The three
following numbers are the X,Y
and Z coordinate for where you
want to place the workpiece. If
omitted, it will be placed at the
machine zero.
Puts a workpiece from the fixed
$AddEmbeddedRegPart embedded workpiece registry on $AddEmbeddedRegPart # [#][#][#]
the table. See $AddRegPart
above for further explanation.
Put a predefined workpiece on
$AddDefinedPart the table. Use $AddDefinedPart $AddDefinedPart # [#][#][#]
to define workpieces in the
program.
Will block on-screen spindle
rotation. This can be useful in
$BlockSpindleRot the unlimited lathe if visual
rotation of the workpiece is not
desired.
$Inches Enforce the use of Inch units.
(To set millimeters or inches $Inches
units, open the program settings
dialog).
$Millimeters Enforce the use of Millimeter
units. (To set millimeters or $Millimeters
inches units, open the program
settings dialog).
SetView is a special command
to set the 3D-view during
simulation. It should not be
programmed manually as it
contains too many parameters
but rather be created using the $SetView
$SetView
menu action Tools – Insert ################
Command - $SetView.

$Message Displays a message on the 3D $Message $#


view during simulation. First
parameter is a text string of the
message to display. Next
parameter is the number of
seconds to show the message.

Set the solid workpiece cutting


values at run-time in percent.
$Cutting Parameters are FromLeft, $Cutting #####
FromRight, FromFront,
FromBack and FromTop.
Set workpiece cutting.
To show the whole part, left
should be 0 and Right should be
$Cutting 100.<BR />
The last parameter is 0 to show
the workpiece closed and 1 to
show the inside.<BR />
$Pause Will pause the simulation for a $Pause #
given number of milliseconds.
Starts the internal stop watch to
measure the time for an
$StartStopWatch operation. Please note that the $StartStopWatch
time measured is simulation
time and not machining time.
$ShowStopWatch
Stops the internal stop watch
and shows the time that has
elapsed since the $ShowStopWatch
$StartStopWatch command was
executed.

Enforces the use of a lathe


machine. You will see an alarm
$Lathe if you run a program with this $Lathe
command on a non-lathe
machine.
Enforces the use of a milling
machine. You will see an alarm
$Mill if you run a program with this $Mill
command on a non-milling
machine.
This command is used to
directly setup and use a milling
tool without using the user or
embedded registries.
$SetupTool Parameters are: TipAngle, $SetupTool ######
ShaftDiameter, ShaftLength,
ToolDiameter, ToolLength and
ToolTipType (0=Flat, 1=Ball,
2=Pointed)
$OverrideBufferQualitySe This special command is used $OverrideBufferQualitySetting
tting to override the resolution setting #
for the solid buffer. The value
given is the number of 3D pixels
(voxels) per millimeter. A value
of 1 will make each 3D pixel 1
cubic millimeter big. A value of
10 will make each 3D pixel 0.1
mm3 big. A value of 1 will create
ugly results but will run fast. On
the other hand, a value of 10 will
create high resolution
workpieces but will run slow. We
do not recommend using values
higher than 10 as you could
easily run out of memory due to
huge material buffer allocation.
Important: this command must
come before the $AddRegPart
command.
This command is used to
directly setup and use a milling
workpiece without using the
user or embedded registries.
$AddMillPart Parameters are: SizeX, SizeY, $AddMillPart #############
SizeZ, Xpos, Ypos, Zpos,
PartColR, PartColG, PartColB,
TopColR, TopColG, TopColB,
MaterialStyle
Define a lathe workpiece that
can be fetched by using the
command $AddDefinedPart.
$DefineLatheWorkpiece Parameters are $DefineLatheWorkpiece [$]####
NameAndMaterial, Index,
Length, Diameter, Inner
diameter.
Define a mill workpiece that can
be fetched by using the
$DefineMillWorkpiece command $AddDefinedPart. $DefineMillWorkpiece [$]####
Parameters are:
NameAndMaterial, Index, SizeX,
SizeY, SizeZ
Defines a material to be used by
defined workpieces. Parameters
$DefineMaterial are MatrlName, Index, $DefineMaterial [$]########
PartColR, PartColG, PartColG,
TopColR, TopColG, TopColB,
MaterialStype
Defines a milling tool that can be
fetched by the DT code letters.
Parameters are: ToolName,
$DefineMillTool Index, TipAngle, ShaftDiam, $DefineMillTool [$]#######
ShaftLength, ToolDiam,
ToolLength, ToolTipType
(0=Flat, 1=Ball, 2=Pointed)

Turn on or off the display of the


$Toolpaths tool paths during simulation. $Toolpaths #
(1=on, 0=off).
$SetCuttingWidth Used in cutting machines to $SetCuttingWidth
define the cutting width.
Tells the simulator to override
the material for the workpiece
and use the specified one
$UseMaterial instead. The material must exist $UseMaterial
in the materials registry in the
Inventory Browser (F2) to avoid
an alarm.
Tells the simulator to override
the material for the workpiece
$UseEmbeddedMaterial and use the specified embedded $UseEmbeddedMaterial
one instead. The material must
exist in the embedded materials
registry to avoid an alarm.
$InvertLathePart

Flips the lathe workpiece in the


chuck to continue machining the $InvertLathePart
other side of it.

Circle and arc centers are


normally entered as incremental
$AbsoluteCenters values. This command tells the $AbsoluteCenters
simulator to expect absolute
circle and arc center values.

$SetG28pos Set custom position for G28. $SetG28pos{#}{#}{#}

$SetToolChangePos Set custom tool change position. $SetToolChangePos{#}{#}{#}

$DefineDoffsetDiameter Define a D offset in-program. $DefineDoffsetDiameter{#}{#}

When your program has defined


tools (for example in programs
created by SimCam), you call
these tools with "DT". Using this
$ReadTasDefinedTool command you can skip the D $ReadTasDefinedTool
and only use T followed by the
tool index number. For example
"T25". The simulator will treat all
T values as defined tools.
This command rotates the
$RotateWorkpiece workpiece around its Z axis. $RotateWorkpiece

$Color This command sets the surface $Color R G B


color. Any new surface that gets
exposed by a milling operation
will have this color. The
command expects three
parameters: Amount of Red,
amount of Green and amount of
Blue. Values are giving in the
range 0 to 255 where 255 is the
brightest. $Color 0 0 0 will make
the surface black and $Color
255 255 255 will make it white.
For mixing of other colors,
Google "RGB Color Picker".
Is used to define temporary zero
points.
Example: $DefineZeropoint
"N:Name" 0 100 100 20
This will define zero point index
0 to X100 Y100 and Z20. Index
$DefineZeropoint 0 = G54, 1 = G55 etc. $DefineZeropoint[$][#][#][#] [#]
Index 0 can also be called with
G54.1 P0. After this command
has been used,
all G54-G59 and G54.1 calls will
refer to the defined zero point
and not to the
ones in the zero point registry.
Special command to set titles of
tutorials. You can read more
$TutorialLine about these here Creating $TutorialLine[$]
customized tutorials in
CNCSimulator Pro.
Special command to set titles of
tutorials. You can read more
about these here Creating
$Title $Title
customized tutorials in
CNCSimulator Pro.

By default, the simulator will


erase everything to the right
$PreventEraseOnCutOff when the material has been cut $PreventEraseOnCutOff
through to simulate the part
falling down. This command
prevents that from happening.
When your program wants to
use the simulator embedded
tools, you call these tools with
"ET". Using this command you
$ReadTasEmbeddedTool can skip the E and only use T $ReadTasEmbeddedTool
followed by the tool index
number. For example "T25". The
simulator will treat all T values
as embedded tools.
This activates an alternative
$UseAltG92method G92 mode so that it makes the $UseAltG92method
current tool position have the
coordinates you specify.
Used by SimCam and by "Make
$DefineLatheTool program portable" to create in-
program lathe tools.

Note that these commands works even when they are inside parentheses. It is normally good to
keep them in parentheses to avoid confusion with other software or CNC controllers.

6.4. Other codes


Code Explanation Format Example
Absolute or incremental X axis value used in canned X#
X X2.43
cycles and codes like G00-G03.
Absolute or incremental Y axis value used in canned Y#
Y Y1.16
cycles and codes like G00-G03.
Absolute or incremental Z axis value used in canned Z#
Z Z-3.2
cycles and codes like G00-G03.
Represents the center in X in G02 and G03 circle/ arc I# G02 X34 Z106.867
I
commands. I4.8 K0
Represents the center in Y in G02 and G03 circle/ arc J#
J G02 Y0 J-20
commands.
Represents the center in Z in G02 and G03 circle/ arc K# G02 X34 Z106.867
K
commands. I4.8 K0
Selects a tool from the user defined tool registry in the
T Inventory Browser (F2). M06 is used to execute the actual T# T1 M06
tool change.
Selects a tool from the fixed embedded tool registry. M06 ET#
ET ET9 M06
is used to execute the actual tool change.
Selects a predefined milling tool. The tool must first have
DT been defined using the $DefineMillTool command. M06 is DT# DT3 M06
used to execute the actual tool change.
S Defines spindle rotation in revolutions per minute (RPM). S# S2000
F Defines feed rate in millimeter or inches per minute. F# F240
M98 P1001 L1
Used in M98 to define a sub program number. Also used P#
P G73 Z-20 R2 Q5
as dwell time in canned cycles.
P100 F350
L Used in M98 to define the number of repetitions. L# M98 P1001 L1
(Drilling sub
Sub program number. Should be the first line of every sub O#
O program 1)
program.
O1000
Reference or starting plane in canned cycles. R is also
R used in G02/G03 to give the radius when I/J/K are not R# G81 Z-20 R2
used.
Q#G73 Z-20 R2 Q5 P0
Q Peck size in canned cycles.
F350
G12 X0 Y0 Z-20 R2
SA,AS, Start Angle, Angle Step and Radius used in G12 Circular SA# AS#
RA# Q5 SA0 AS36 RA30
RA drilling cycle.
H10
G12 X0 Y0 Z-20 R2
Used for number of holes in the G12 Circular drilling
H Q5 SA0 AS36 RA30
cycle.
H10
Used for comments. G and M codes inside parenthesis
(Drilling sub
( and ) will not be executed. $-commands will be executed even (text)
program 1)
when inside the parenthesis.
G01 Z-20 F440
Used for comment out one or several lines. G, M and $- /G03 I23.2 J0
/
commands will not be executed. /G03 X15 I19
G00 Z7
N Block number. N# N500

También podría gustarte