This manual is a work in progress.If you are able to help with writing, editing, or graphic
preparation please contact any member of the writing team or join and send an email to emcusers@lists.sourceforge.net.
Copyright (c) 2000-9 LinuxCNC.org
Permission is granted to copy, distribute and/or modify this document under the terms of the
GNU Free Documentation License, Version 1.1 or any later version published by the Free Software
Foundation; with no Invariant Sections, no Front-Cover Texts, and one Back-Cover Text: "This EMC
Handbook is the product of several authors writing for linuxCNC.org. As you find it to be of value in
your work, we invite you to contribute to its revision and growth." A copy of the license is included in
the section entitled "GNU Free Documentation License". If you do not find the license you may order
a copy from Free Software Foundation, Inc. 59 Temple Place, Suite 330 Boston, MA 02111-1307
EMC2 is modular and flexible. These attributes lead many to see it as a confusing jumble of little
things and wonder why it is the way it is. This page attempts to answer that question before you
get into the thick of things.
EMC started at the National Institute of Standards and Technology in the USA. It grew up using
Unix as it’s operating system. Unix made it different. Among early Unix developers there grew a set
of code writing ideas that some call the Unix way. These early EMC authors followed those ways.
Eric S. Raymond, in his book The Art of Unix Programming, summarizes the Unix philosophy as the widely-used engineering philosophy, "Keep it Simple, Stupid" (KISS Principle).
He then describes how he believes this overall philosophy is applied as a cultural Unix
norm, although unsurprisingly it is not difficult to find severe violations of most of the
following in actual Unix practice:
* Rule of Modularity: Write simple parts connected by clean interfaces.
* Rule of Clarity: Clarity is better than cleverness.
* Rule of Composition: Design programs to be connected to other programs.
* Rule of Separation: Separate policy from mechanism; separate interfaces from engines.
1
Mr Raymond offered several more rules but these four describe essential characteristics of the EMC2
motion control system.
The Modularity rule is critical. Throughout these handbooks you will find talk of the interpreter or
task planner or motion or HAL. Each of these is a module or collection of modules. It’s modularity
that allows you to connect together just the parts you need to run your machine.
The Clarity rule is essential. EMC2 is a work in progress – it is not finished nor will it ever be. It is
complete enough to run most of the machines we want it to run. Much of that progress is achieved
because many users and code developers are able to look at the work of others and build on what
they have done.
The Composition rule allows us to build a predictable control system from the many modules
available by making them connectable. We achieve connectability by setting up standard interfaces
to sets of modules and following those standards.
The Separation rule requires that we make distinct parts that do little things. By separating functions debugging is much easier and replacement modules can be dropped into the system and
comparisons easily made.
What does the Unix way mean for you as a user of EMC2. It means that you are able to make choices
about how you will use the system. Many of these choices are a part of machine integration, but
1
Found at http://en.wikipedia.org/wiki/Unix_philosophy, 07/06/2008
1
Page 15
EMC V2.4 User ManualChapter 1. Foreword
many also affect the way you will use your machine. As you read you will find many places where
you will need to make comparisons. Eventually you will make choices, "I’ll use this interface rather
than that” or, “I’ll write part offsets this way rather than that way." Throughout these handbooks
we describe the range of abilities currently available.
As you begin your journey into using EMC2 we offer two cautionary notes:
2
• Praphrasing the words of Doug Gwyn on UNIX: "emc2 was not designed to stop its users from
doing stupid things, as that would also stop them from doing clever things."
• Likewise the words of Steven King: "emc2 is user-friendly. It just isn’t promiscuous about
which users it’s friendly with."
2
Found at http://en.wikipedia.org/wiki/Unix_philosophy, 07/06/2008
2
Page 16
Chapter 2
EMC2
The Enhanced Machine Control
2.1This Manual
The focus of this manual is on using EMC. It is intended to be used once EMC is installed and
configured. For standard installations see the Getting Started Guide for step by step instructions
to get you up and going. For detailed information on installation and configuration of EMC see the
Integrator Manual.
2.2How EMC2 Works
The Enhanced Machine Controller (EMC2) is a lot more than just another CNC mill program. It
can control machine tools, robots, or other automated devices. It can control servo motors, stepper
motors, relays, and other devices related to machine tools.
There are four main components to the EMC2 software: a motion controller, a discrete I/O controller, a task executor which coordinates them, and graphical user interfaces. In addition there is
a layer called HAL (Hardware Abstraction Layer) which allows configuration of EMC2 without the
need of recompiling.
3
Page 17
EMC V2.4 User ManualChapter 2. EMC2
Figure 2.1: Simple EMC2 Controlled Machine
Figure 2.1 shows a simple block diagram showing what a typical 3-axis EMC2 system might look
like. This diagram shows a stepper motor system. The PC, running Linux as its operating system,
is actually controlling the stepper motor drives by sending signals through the printer port. These
signals (pulses) make the stepper drives move the stepper motors. The EMC2 can also run servo
motors via servo interface cards or by using an extended parallel port to connect with external
control boards. As we examine each of the components that make up an EMC2 system we will
remind the reader of this typical machine.
2.3User Interfaces
A user interface is the part of the EMC2 that the machine tool operator interacts with. The EMC2
comes with several types of user interfaces:
• AXIS an OpenGL-based GUI (Graphical User Interface), with an interactive G-Code previewer.
This interface is one of the few that are still under active development and improvement.
4
Page 18
EMC V2.4 User ManualChapter 2. EMC2
• Keystick a character-based screen graphics program suitable for minimal installations (without the X server running).
• Xemc an X Windows program
• two Tcl/Tk-based GUIs named TkEMC and Mini
• a HAL based user interface called halui, which allows to control emc2 using knobs and
switches
• a telnet based user interface called emcrsh, which allows commands to be sent to emc2 from
remote computers
2.4Languages
EMC2 uses translation files to translate EMC User Interfaces into many languages. You just need to
log in with the language you intend to use and when you start up EMC it comes up in that language.
If your language has not been translated contact a developer on the IRC or the mailing list if you
can assist in the translation.
5
Page 19
EMC V2.4 User ManualChapter 2. EMC2
2.5Thinking Like a Machine Operator
This book will not even pretend that it can teach you to run a mill or a lathe. Becoming a machinist
takes time and hard work. An author once said, "We learn from experience, if at all." Broken tools,
gouged vices, and scars are the evidence of lessons taught. Good part finish, close tolerances, and
careful work are the evidence of lessons learned. No machine, no computer program, can take the
place of human experience.
As you begin to work with the EMC2 program, you will need to place yourself in the position of
operator. You need to think of yourself in the role of the one in charge of a machine. It is a machine
that is either waiting for your command or executing the command that you have just given it.
Throughout these pages we will give information that will help you become a good operator of the
EMC2 mill. You will need some information right up front here so that the following pages will make
sense to you.
2.6Modes of Operation
When an EMC2 is running, there are three different major modes used for inputting commands.
These are Manual, Auto, and MDI. Changing from one mode to another makes a big difference in
the way that the EMC2 behaves. There are specific things that can be done in one mode that can
not be done in another. An operator can home an axis in manual mode but not in auto or MDI
modes. An operator can cause the machine to execute a whole file full of G-codes in the auto mode
but not in manual or MDI.
In manual mode, each command is entered separately. In human terms a manual command might
be "turn on coolant" or "jog X at 25 inches per minute". These are roughly equivalent to flipping a
switch or turning the hand wheel for an axis. These commands are normally handled on one of the
graphical interfaces by pressing a button with the mouse or holding down a key on the keyboard.
In auto mode, a similar button or key press might be used to load or start the running of a whole
program of G-code that is stored in a file. In the MDI mode the operator might type in a block of
code and tell the machine to execute it by pressing the <return> or <enter> key on the keyboard.
Some motion control commands are available and will cause the same changes in motion in all
modes. These include A BORT, ESTOP, and F EED R ATE OV ERR IDE. Commands like these should be
self explanatory.
The AXIS user interface hides some of the distinctions between Auto and the other modes by making Auto-commands available at most times. It also blurs the distinction between Manual and MDI
because some Manual commands like Touch Off are actually implemented by sending MDI commands. It does this by automatically changing to the mode that is needed for the action the user
has requested.
6
Page 20
Chapter 3
User Concepts
This chapter covers important user concepts that should be understood before attempting to run a
CNC machine with g code.
3.1Trajectory Control
3.1.1Trajectory Planning
Trajectory planning, in general, is the means by which EMC follows the path specified by your G
Code program, while still operating within the limits of your machinery.
A G Code program can never be fully obeyed. For example imagine you specify as a single-line
program the following move:
G1 X1 F10 (G1 is linear move, X1 is the destination, F10 is the speed)
In reality, the whole move can’t be made at F10, since the machine must accelerate from a stop,
move toward X=1, and then decelerate to stop again. Sometimes part of the move is done at F10,
but for many moves, especially short ones, the specified feed rate is never reached at all. Having
short moves in your G Code can cause your machine to slow down and speed up for the longer
moves if the "naive cam detector" is not employed with G64 Pn.
The basic acceleration and deceleration described above is not complex and there is no compromise
to be made. In the INI file the specified machine constraints such as maximum axis velocity and
axis acceleration must be obeyed by the trajectory planner.
3.1.2Path Following
A less straightforward problem is that of path following. When you program a corner in G Code, the
trajectory planner can do several things, all of which are right in some cases: it can decelerate to a
stop exactly at the coordinates of the corner, and then accelerate in the new direction. It can also do
what is called blending, which is to keep the feed rate up while going through the corner, making it
necessary to round the corner off in order to obey machine constraints. You can see that there is a
trade off here: you can slow down to get better path following, or keep the speed up and have worse
path following. Depending on the particular cut, the material, the tooling, etc., the programmer
may want to compromise differently.
Rapid moves also obey the current trajectory control. With moves long enough to reach maximum
velocity on a machine with low acceleration and no path tolerance specified, you can get a fairly
round corner.
7
Page 21
EMC V2.4 User ManualChapter 3. User Concepts
3.1.3Programming the Planner
The trajectory control commands are as follows:
G61 (Exact Path Mode) visits the programmed point exactly, even though that means it might
temporarily come to a complete stop in order to change direction to the next programmed
point.
G61.1 (Exact Stop Mode) tells the planner to come to an exact stop at every segment’s end.
G64 (Blend Without Tolerance Mode) G64 is the default setting when you start EMC. G64 is just
blending and the naive cam detector is not enabled. G64 and G64P0 tell the planner to sacrifice path following accuracy in order to keep the feed rate up. This is necessary for some
types of material or tooling where exact stops are harmful, and can work great as long as the
programmer is careful to keep in mind that the tool’s path will be somewhat more curvy than
the program specifies. When using G0 (rapid) moves with G64 use caution on clearance moves
and allow enough distance to clear obstacles based on the acceleration capabilities of your
machine.
G64 P- Q- (Blend With Tolerance Mode) This enables the "naive cam detector" and enables blending
with a tolerance. If you program G64 P0.05, you tell the planner that you want continuous
feed, but at programmed corners you want it to slow down enough so that the tool path can
stay within 0.05 user units of the programmed path. The exact amount of slowdown depends
on the geometry of the programmed corner and the machine constraints, but the only thing
the programmer needs to worry about is the tolerance. This gives the programmer complete
control over the path following compromise. The blend tolerance can be changed throughout
the program as necessary. Beware that a specification of G64 P0 has the same effect as G64
alone (above), which is necessary for backward compatibility for old G Code programs. See the
G Code Chapter for more information on G64 P- Q-.
Blending without tolerance The controlled point will touch each specified movement at at least
one point. The machine will never move at such a speed that it cannot come to an exact stop
at the end of the current movement (or next movement, if you pause when blending has already
started). The distance from the end point of the move is as large as it needs to be to keep up
the best contouring feed.
Naive Cam Detector Successive G1 moves that involve only the XYZ axes that deviate less than
Q- from a straight line are merged into a single straight line. This merged movement replaces
the individual G1 movements for the purposes of blending with tolerance. Between successive
movements, the controlled point will pass no more than P- from the actual endpoints of the
movements. The controlled point will touch at least one point on each movement. The machine
will never move at such a speed that it cannot come to an exact stop at the end of the current
movement (or next movement, if you pause when blending has already started) On G2/3 moves
in the G17 (XY) plane when the maximum deviation of an arc from a straight line is less than
the G64 Q- tolerance the arc is broken into two lines (from start of arc to midpoint, and from
midpoint to end). those lines are then subject to the naive cam algorithm for lines. Thus,
line-arc, arc-arc, and arc-line cases as well as line-line benefit from the "naive cam detector".
This improves contouring performance by simplifying the path.
In the following figure the blue line represents the actual machine velocity. The red lines are the
acceleration capability of the machine. The horizontal lines below each plot is the planned move.
The upper plot shows how the trajectory planner will slow the machine down when short moves are
encountered to stay within the limits of the machines acceleration setting to be able to come to an
exact stop at the end of the next move. The bottom plot shows the effect of the Naive Cam Detector
to combine the moves and do a better job of keeping the velocity as planned.
8
Page 22
EMC V2.4 User ManualChapter 3. User Concepts
Figure 3.1: Naive Cam Detector
3.1.4Planning Moves
Make sure moves are "long enough" to suit your machine/material. Principally because of the rule
that "the machine will never move at such a speed that it cannot come to a complete stop at the
end of the current movement", there is a minimum movement length that will allow the machine to
keep up a requested feed rate with a given acceleration setting.
The acceleration and deceleration phase each use half the ini file MAX_ACCELERATION. In a blend
that is an exact reversal, this causes the total axis acceleration to equal the ini file MAX_ACCELERATION.
In other cases, the actual machine acceleration is somewhat less than the ini file acceleration
To keep up feed rate, the move must be longer than the distance it takes to accelerate from 0 to the
desired feed rate and then stop again. Using A as 1/2 the ini file MAX_ACCELERATION and F as
the feed rate *in units per second*, the acceleration time is ta = F/A and the acceleration distance
is da = (1/2) ∗ F ∗ ta the deceleration time and distance are the same, making the critical distance d
= da + dd = 2*da = F^2 / A.
For example, for a feed rate of 1 inch per second and an acceleration of 10 inch/sec^2, the critical
distance is 1^2 / 10 = .1 inch. For a feed rate of .5 inch per second, the critical distance is .5^2 /
10 = .025 inch.
3.2G Code
3.2.1Defaults
When EMC first starts up many G and M codes are loaded by default. The current active G and M
codes can be viewed on the MDI tab in the "Active G-Codes:" window in the AXIS interface. These
G and M codes define the behavior of EMC and it is important that you understand what each one
does before running EMC. The defaults can be changed when running a G-Code file and left in a
different state than when you started your EMC session. The best practice is to set the defaults
needed for the job in the preamble of your G-Code file and not assume that the defaults have not
changed. Printing out the G-Code Quick Reference (15.2) page can help you remember what each
one is.
3.2.2Feed Rate
How the feed rate is applied depends on if an axis involved with the move is a rotary axis. Read and
understand the Feed Rate section (9.2.5) if you have a rotary axis or a lathe.
9
Page 23
EMC V2.4 User ManualChapter 3. User Concepts
3.2.3Tool Radius Offset
Tool Radius Offset (G41/42) requires that the tool be able to touch somewhere along each programmed move without gouging the two adjacent moves. If that is not possible with the current tool
diameter you will get an error. A smaller diameter tool may run without an error on the same path.
This means you can program a cutter to pass down a path that is narrower than the cutter without
any errors. See the Tool Compensation Section (11.3) for more information.
3.3Homing
After starting EMC2 each axis must be homed prior to running a program or running a MDI command.
If you want to deviate from the default behavior, or want to use the Mini interface you will need to
set the option NO_FORCE_HOMING = 1 in the [TRAJ] section of your ini file. More information on
homing can be found in the Integrators Manual.
3.4Tool Changes
There are several options when doing manual tool changes. See the [EMCIO] section of the Integrators Manual for information on configuration of these options. Also see the G28 and G30 section of
the User Manual.
3.5Coordinate Systems
The Coordinate Systems can be confusing at first. Before running a CNC machine you must understand the basics of the coordinate systems used by EMC. In depth information on the EMC
Coordinate Systems is in the coordinate section 10 of this manual.
3.5.1G53 Machine Coordinate
When you home EMC you set the G53 Machine Coordinate System to 0 for each axis homed.
• No other coordinate systems or tool offsets are changed by homing.
The only time you move in the G53 machine coordinate system is when you program a G53 on the
same line as a move. Normally you are in the G54 coordinate system.
3.5.2G54-59.3 User Coordinates
Normally you use the G54 Coordinate System. When an offset is applied to a current user coordinate
system a small blue ball with lines will be at the machine origin when your DRO is displaying
"Position: Relative Actual" in Axis. If your offsets are temporary use the Zero Coordinate System
from the Machine menu or program G10 L2 P1 X0 Y0 Z0 at the end of your G Code file. Change the
"P" number to suit the coordinate system you wish to clear the offset in.
• Offsets stored in a user coordinate system are retained when EMC is shut down.
• Using the "Touch Off" button in Axis sets an offset for the chosen User Coordinate System.
10
Page 24
EMC V2.4 User ManualChapter 3. User Concepts
3.5.3When You’re Lost
If you’re having trouble getting 0,0,0 on the DRO when you think you should, you may have some
offsets programmed in and need to remove them.
• Move to the Machine origin with
G53 G0 X0 Y0 Z0
• Clear any G92 offset with
G92.1
• Use the G54 coordinate system with
G54
• Set the G54 coordinate system to be the same as the machine coordinate system with
G10 L2 P1 X0 Y0 Z0
• Turn off tool offsets with
G49
• Turn on the Relative Coordinate Display from the menu
Now you should be at the machine origin X0 Y0 Z0 and the relative coordinate system should be
the same as the machine coordinate system.
11
Page 25
Part I
Interfaces
12
Page 26
Chapter 4
AXIS
4.1Introduction
AXIS is a graphical front-end for EMC2 which features a live preview and backplot. It is written in
Python and uses Tk and OpenGL to display its user interface.
Figure 4.1: AXIS Window
13
Page 27
EMC V2.4 User ManualChapter 4. AXIS
4.2Getting Started
To select AXIS as the front-end for EMC2, edit the .ini file. In the section [DISPLAY] change the
DISPLAY line to read
DISPLAY = axis
Then, start EMC2 and select that ini file. The sample configuration sim/axis.ini is already configured to use AXIS as its front-end.
When you start AXIS, a window like the one in Figure 4.1 is shown.
4.2.1A Typical Session
1. Start EMC.
2. Clear the E-STOP (F1) and turn the Machine Power (F2) on.
3. Home all axes.
4. Load the g-code file.
5. Use the preview plot to verify that the program is correct.
6. Set the proper offsets for each axis by jogging and using the Touch Off button.
7. Run the program.
8. To run the same file again, return to step 6. To run a different file, return to step 4. When
you’re done, exit AXIS.
4.3AXIS Display
The AXIS window contains the following elements:
• A display area that shows a preview of the loaded file (in this case, "axis.ngc"), as well as the
current location of the CNC machine’s "controlled point". Later, this area will display the path
the CNC machine has moved through, called the "backplot"
• A menu bar and toolbar that allow you to perform various actions
• "Manual Control Tab" , which allows you to make the machine move, turn the spindle on or
off, and turn the coolant on or off if included in the ini file.
• "MDI Tab” , where G-code programs can be entered manually, one line at a time. This also
shows the "Active G Codes" which shows which modal G Codes are in effect.
• "Feed Override" , which allows you to increase or decrease the speed at which EMC executes
Feed Moves the selected program. The default maximum is 120% and can be set to a different
value in the ini file. See the Integrators Manual for more information on this setting.
• "Spindle Override" , which allows you to increase or decrease the speed at which EMC commands the spindle to run if spindle control is configured.
• "Jog Speed" , which allows you to set the jog speed within the limits set in the ini file. See the
Integrators Manual for more information on the ini file.
14
Page 28
EMC V2.4 User ManualChapter 4. AXIS
• "Max Velocity", which allows you to set the maximum velocity for rapids and cap feed rates
(except spindle synchronized motion) for dry runs. Currently only AXIS and Halui allow you to
set it.
• A text display area that shows the G-code source of the loaded file.
• A status bar which shows the state of the machine. In this screen shot, the machine is turned
on, does not have a tool inserted, and the displayed position is "Relative” to the machine offset
(as opposed to “Absolute”), and the “Actual” (as opposed to “Commanded” position)
4.3.1Menu Items
Some menu items might be grayed out depending on how you have your .ini file configured. For
more information on configuration see the Integrators Manual.
4.3.1.1 File Menu
Open... Opens a standard dialog box to open a g code file to load in AXIS. If you have configured
EMC to use a filter program you can also open it up. See the Integrators manual for more
information on filter programs.
Recent Files Displays a list of recently opened files.
Edit... Open the current g code file for editing if you have an editor configured in your ini file. See
the Integrators Manual for more information on specifying an editor to use.
Reload reload the current g code file. If you edited it you must reload it for the changes to take
affect. If you stop a file and want to start from the beginning then reload the file. The toolbar
reload is the same as the menu.
Save gcode as... Save the current file with a new name.
Properties The sum of the rapid and feed moves. Does not factor in acceleration, blending or path
mode so time reported will never be less than the actual run time.
Edit tool table... Same as Edit if you have defined an editor you can open the tool table and edit it.
Reload tool table After editing the tool table you must reload it.
Ladder editor If you have loaded Classic Ladder you can edit it from here. See the Integrators
Manual on setting up Classic Ladder
Quit Terminates the current EMC session.
4.3.1.2 Machine
Toggle Emergency Stop F1
Toggle Machine Power F2
Run Program
Run From Selected Line Select the line you want to start from first. Use with caution as this will
move the tool to the expected position before the line first then it will execute the rest of the
code.
Step Single step through a program.
Pause Pause a program.
15
Page 29
EMC V2.4 User ManualChapter 4. AXIS
Resume Resume running from a pause.
Stop Stop a running program.
Stop at M1 If you have a M1 in your g code and this is checked program execution will stop on the
M1 line. Press Resume to continue.
Skip lines with "/" If a line begins with / and this is checked it will skip that line.
Clear MDI history Clears the MDI history window.
Copy from MDI history Copies the MDI history to the clipboard
Paste to MDI history Paste from the clipboard to the MDI history window
Calibration This is a servo testing pop up widow for each axis. After making changes and testing
them it can save them to your .ini file.
Show HAL Configuration Opens up the HAL Configuration widow where you can monitor HAL
Components, Pins, Parameters, Signals, Functions, and Threads.
HAL Meter Opens up a window where you can monitor a single HAL Pin, Signal, or Parameter.
HAL Scope Opens up a Scope window where you can set up and monitor Pins and Signals.
Show EMC Status Opens up a window showing EMC’s status.
Set Debug Level Opens a window where debug levels can be viewed and some can be set.
Homing Home any or all axis.
Unhoming Unhome any or all axis.
Zero Coordinate System Zero work offsets.
4.3.1.3 View
Top View
Rotated Top View
Side View
Front View
Perspective View
Display Inches
Display MM
Show Program
Show Live Plot
Show Tool
Show Extents
Show Machine Limits
Show Velocity
Show Distance to Go
Clear Live Plot
16
Page 30
EMC V2.4 User ManualChapter 4. AXIS
Show Commanded Position
Show Actual Position
Show Machine Position
Show Relative Position
4.3.1.4 Help
About Axis
Quick Reference Shows the keyboard shortcut keys.
4.3.2Toolbar buttons
From left to right, the toolbar buttons (keyboard shortcuts in []).
1.Toggle Emergency Stop [F1] (also called E-Stop)
2.Toggle Machine Power [F2]
3.Open G Code file [O]
4.Reload current file [Ctrl-R]
5.Begin executing the current file [R]
6.Execute next line [T]
7.Pause Execution [P] Resume Execution[S]
8.Stop Program Execution [ESC]
9.Toggle Skip lines with "/" [Alt-M-/]
10.Toggle Optional Pause [Alt-M-1]
11.Zoom In
12.Zoom Out
13.Top view
14.Rotated Top view
17
Page 31
EMC V2.4 User ManualChapter 4. AXIS
15.Front view
16.Side view
17.Perspective view
18.Toggle between Drag and Rotate Mode [D]
19.Clear live backplot [Ctrl-K]
4.3.3Graphical Display Area
4.3.3.1 Coordinate Display
In the upper-left corner of the program display is the coordinate display. It shows the position of the
machine. To the left of the axis name, an origin symbol ( ) is shown if the axis has been properly
homed. To the right of the axis name, a limit symbol ( ) is shown if the axis is on one of its limit
switches.
To properly interpret these numbers, refer to the "Position:" indicator in the status bar. If the
position is "Absolute", then the displayed number is in the machine coordinate system. If it is
"Relative", then the displayed number is in the offset coordinate system. When the coordinates
displayed are relative and an offset has been set, the display will include a cyan "machine origin"
marker ( ). If the position is "Commanded", then it is the ideal position–for instance, the exact
coordinate given in a G0 command. If it is "Actual", then it is the position the machine has actually
been moved to. These values can differ for several reasons: Following error, dead band, encoder
resolution, or step size. For instance, if you command a movement to X 0.0033 on your mill, but
one step of your stepper motor is 0.00125, then the "Commanded" position will be 0.0033 but the
"Actual" position will be 0.0025 (2 steps) or 0.00375 (3 steps).
4.3.3.2 Preview Plot
When a file is loaded, a preview of it is shown in the display area. Fast moves (such as those
produced by the G0 command) are shown as green lines. Moves at a feed rate (such as those
produced by the G1 command) are shown as solid white lines. Dwells (such as those produced by
the G4 command) are shown as small "X" marks.
G0 (Rapid) moves prior to a feed move will not show up on the preview plot. Rapid moves after a
T<n> (Tool Change) will not show on the AXIS preview until after a feed move. To turn either of
these features off program a G1 without any moves prior to the G0 moves.
4.3.3.3 Program Extents
The "extents" of the program in each axis are shown. At each end, the least or greatest coordinate
value is indicated. In the middle, the difference between the coordinates is shown. In Figure (4.1),
the X extent of the file is from 0.00 to 6.92 inches, a total of 6.92 inches.
When some coordinates exceed the "soft limits" in the .ini file, the relevant dimension is shown in a
different color and enclosed by a box. In Figure (4.2) the maximum soft limit is exceeded on the X
axis as indicated by the box surrounding the coordinate value.
18
Page 32
EMC V2.4 User ManualChapter 4. AXIS
Figure 4.2: Soft Limit
4.3.3.4 Tool Cone
The location of the tip of the tool is indicated by the "tool cone". The cone does not indicate anything
about the shape, length, or radius of the tool.
When a tool is loaded (for instance, with the MDI command T1M6), the cone changes to a cylinder
which shows the diameter of the tool given in the tool table file.
4.3.3.5 Backplot
When the machine moves, it leaves a trail called the backplot. The color of the line indicates the
type of motion: Yellow for jogs, faint green for rapid movements, red for straight moves at a feed
rate, and magenta for circular moves at a feed rate.
4.3.3.6 Interacting
By left-clicking on a portion of the preview plot, the line will be highlighted in both the graphical
and text displays. By left-clicking on an empty area, the highlighting will be removed.
By dragging with the left mouse button pressed, the preview plot will be shifted (panned).
By dragging with shift and the left mouse button pressed, or by dragging with the mouse wheel
pressed, the preview plot will be rotated. When a line is highlighted, the center of rotation is the
center of the line. Otherwise, the center of rotation is the center of the file as a whole.
By rotating the mouse wheel, or by dragging with the right mouse button pressed, or by dragging
with control and the left mouse button pressed, the preview plot will be zoomed in or out.
By clicking one of the "Preset View" icons, or by pressing "V", several preset views may be selected.
4.3.4Text Display Area
By left-clicking a line of the program, the line will be highlighted in both the graphical and text
displays in blue.
When the program is running, the line currently being executed is highlighted in red. If no line has
been selected by the user, the text display will automatically scroll to show the current line.
19
Page 33
EMC V2.4 User ManualChapter 4. AXIS
Figure 4.3: Current and Selected Lines
4.3.5Manual Control
While the machine is turned on but not running a program, the items in the "Manual Control" tab
can be used to move the machining center or turn different parts of it on and off.
When the machine is not turned on, or when a program is running, the manual controls are unavailable.
Many of the items described below are not useful on all machines. When AXIS detects that a particular pin is not connected in HAL, the corresponding item in the Manual Control tab is removed. For
instance, if the HAL pin motion.spindle-brake is not connected, then the "Brake" button will not
appear on the screen. If the environment variable AXIS_NO_AUTOCONFIGURE is set, this behavior is
disabled and all the items will appear.
4.3.5.1 The "Axis" group
"Axis" allows you to manually move the machine. This action is known as "jogging". First, select the
axis to be moved by clicking it. Then, click and hold the "+" or "-" button depending on the desired
direction of motion. The first four axes can also be moved by the arrow keys (X and Y), PAGE UP
and PAGE DOWN keys (Z) and the [ and ] keys (A).
20
Page 34
EMC V2.4 User ManualChapter 4. AXIS
If "Continuous" is selected, the motion will continue as long as the button or key is pressed. If
another value is selected, the machine will move exactly the displayed distance each time the button
is clicked or the key is pressed. By default, the available values are:
0.1000, 0.0100, 0.0010, 0.0001
See the Configure section of the Integrators Manual for more information on setting the increments.
4.3.5.2 Homing
If your machine has home switches and a homing sequence defined for all axes the button will
read "Home All". The "Home All" button or the Ctrl-HOME key will home all axes using the homing
sequence. Pressing the HOME key will home the current axis, even if a homing sequence is defined.
If your machine has home switches and no homing sequence is defined or not all axes have a
homing sequence the button will read "Home" and will home the selected axis only. Each axis must
be selected and homed separately.
If your machine does not have home switches defined in the configuration the "Home" button will
set the current selected axis current position to be the absolute position 0 for that axis and will set
the "is-homed" bit for that axis.
See the Integrators Manual for more information on homing.
4.3.5.3 Touch Off
By pressing "Touch Off" or the END key, the "G54 offset" for the current axis is changed so that
the current axis value will be the specified value. Expressions may be entered using the rules for
rs274ngc programs, except that variables may not be referred to. The resulting value is shown as a
number.
Figure 4.4: Touch Off
4.3.5.4 Override Limits
By pressing "Override Limits", the machine will temporarily be allowed to jog off of a physical limit
switch. This check box is only available if a limit switch is tripped.
21
Page 35
EMC V2.4 User ManualChapter 4. AXIS
4.3.5.5 The "Spindle" group
The buttons on the first row select the direction for the spindle to rotate: Counterclockwise, Stopped,
Clockwise. Counterclockwise will only show up if the pin motion.spindle-reverse is in the hal file
(it can be net trick-axis motion.spindle-reverse). The buttons on the next row increase or
decrease the rotation speed. The checkbox on the third row allows the spindle brake to be engaged
or released. Depending on your machine configuration, not all the items in this group may appear.
Pressing the spindle start button sets the "S" speed to 1.
4.3.5.6 The "Coolant" group
The two buttons allow the "Mist" and "Flood" coolants to be turned on and off. Depending on your
machine configuration, not all the items in this group may appear.
4.3.6MDI
MDI, allows G-code programs can be entered manually, one line at a time. When the machine is
not turned on, or when a program is running, the MDI controls are unavailable.
Figure 4.5: The MDI tab
History: This shows MDI commands that have been typed earlier in this session.
MDI Command: This allows you to enter a g-code command to be executed. Execute the command
by pressing Enter or by clicking "Go".
Active G-Codes: This shows the "modal codes" that are active in the interpreter. For instance,
"G54" indicates that the "G54 offset" is applied to all coordinates that are entered. When in
Auto the Active G-Codes represent the codes after any read ahead by the interpreter.
4.3.7Feed Override
By moving this slider, the programmed feed rate can be modified. For instance, if a program requests
F60 and the slider is set to 120%, then the resulting feed rate will be 72.
22
Page 36
EMC V2.4 User ManualChapter 4. AXIS
4.3.8Spindle Speed Override
By moving this slider, the programmed spindle feed rate can be modified. For instance, if a program
requests F8000 and the slider is set to 80%, then the resulting spindle speed will be 6400. This
item only appears when the HAL pin motion.spindle-speed-out is connected.
4.3.9Jog Speed
By moving this slider, the speed of jogs can be modified. For instance, if the slider is set to 1 in/min,
then a .01 inch jog will complete in about .6 seconds, or 1/100 of a minute. Near the left side (slow
jogs) the values are spaced closely together, while near the right side (fast jogs) they are spaced
much further apart, allowing a wide range of jog speeds with fine control when it is most important.
On machines with a rotary axis, a second jog speed slider is shown. This slider sets the jog rate for
the rotary axes (A, B and C).
4.3.10Max Velocity
By moving this slider, the maximum velocity can be set. This caps the maximum velocity of axis no
matter what is programed in the g code file.
4.4Keyboard Controls
Almost all actions in AXIS can be accomplished with the keyboard. A full list of keyboard shortcuts
can be found in the AXIS Quick Reference, which can be displayed by choosing HELP > QUICK
REFEREN CE. Many of the shortcuts are unavailable when in MDI mode.
Feed Override Keys
The Feed Override keys behave differently when in Manual Mode. The keys ‘12345678 will select
an axis if it is programed. If you have 3 axis then ‘ will select axis 0, 1 will select axis 1 and 2 will
select axis 2. The remainder of the number keys will still set the Feed Override. When running a
program ‘1234567890 will set the Feed Override to 0% - 100%.
The most frequently used keyboard shortcuts are shown in Table 6.1.
AXIS includes a program called "emctop" which shows some of the details of EMC’s state. You can
run this program by invoking MACHINE > SHOW EMC STATUS
24
Page 38
EMC V2.4 User ManualChapter 4. AXIS
Figure 4.6: EMC Status Window
The name of each item is shown in the left column. The current value is shown in the right column.
If the value has recently changed, it is shown on a red background.
4.6MDI interface
AXIS includes a program called "MDI" which allows text-mode entry of MDI commands to a running
EMC session. You can run this program by opening a terminal and typing
mdi /path/to/emc.nml
Once it is running, it displays the prompt MDI>. When a blank line is entered, the machine’s current
position is shown. When a command is entered, it is sent to EMC to be executed.
AXIS includes a program called "axis-remote" which can send certain commands to a running
AXIS. The available commands are shown by running axis-remote --help and include checking whether AXIS is running (--ping), loading a file by name, reloading the currently loaded file
(--reload), and making AXIS exit (--quit).
4.8Manual Tool Change
EMC2 includes a userspace hal component called "hal_manualtoolchange", which shows a window
(Figure 4.7) when a M6 command is issued. After the OK button is pressed, execution of the program
will continue.
The HAL configuration file configs/sim/axis_manualtoolchange.hal shows the HAL commands
necessary to use this component.
hal_manualtoolchange can be used even when AXIS is not used as the GUI. This component is most
useful if you have presettable tools and you use the tool table.
Important Note: Rapids will not show on the preview after a T<n> is issued until the next feed move
after the M6. This can be very confusing to most users. To turn this feature off for the current tool
change program a G1 with no move after the T<n>.
Figure 4.7: The Manual Toolchange Window
4.9Python modules
AXIS includes several Python modules which may be useful to others. For more information on one
of these modules, use "pydoc <module name>" or read the source code. These modules include:
• emc provides access to the emc command, status, and error channels
• gcode provides access to the rs274ngc interpreter
• rs274 provides additional tools for working with rs274ngc files
• hal allows the creation of userspace HAL components written in Python
• _togl provides an OpenGL widget that can be used in Tkinter applications
• minigl provides access to the subset of OpenGL used by AXIS
To use these modules in your own scripts, you must ensure that the directory where they reside
is on Python’s module path. When running an installed version of EMC2, this should happen
automatically. When running "in-place", this can be done by using scripts/emc-environment.
26
Page 40
EMC V2.4 User ManualChapter 4. AXIS
4.10Lathe Mode
By including the line
LATHE=1
in the [DISPLAY] section of the ini file, AXIS selects lathe mode. The "Y" axis is not shown in
coordinate readouts, the view is changed to show the Z axis extending to the right and the X axis
extending towards the bottom of the screen, and several controls (such as those for preset views)
are removed.
Pressing "V" zooms out to show the entire file, if one is loaded.
When in lathe mode, the shape of the loaded tool (if any) is shown.
Figure 4.8: Lathe Tool Shape
4.11Advanced Configuration
For more information on ini file settings that can change how AXIS works see the INI File/Sections/[DISPLAY]
Section of Configuration chapter in the Integrators manual.
4.11.1Program Filters
AXIS has the ability to send loaded files through a "filter program". This filter can do any desired
task: Something as simple as making sure the file ends with ’M2’, or something as complicated as
detecting whether the input is a depth image, and generating g-code to mill the shape it defines.
The [FILTER] section of the ini file controls how filters work. First, for each type of file, write a
PROGRAM_EXTENSION line. Then, specify the program to execute for each type of file. This program
is given the name of the input file as its first argument, and must write rs274ngc code to standard
output. This output is what will be displayed in the text area, previewed in the display area, and
executed by EMC when "Run". The following lines add support for the "image-to-gcode" converter
included with EMC2:
In this way, any Python script can be opened, and its output is treated as g-code. One such example
script is available at nc_files/holecircle.py. This script creates g-code for drilling a series of
holes along the circumference of a circle.
Figure 4.9: Circular Holes
If the environment variable AXIS_PROGRESS_BAR is set, then lines written to stderr of the form
FILTER_PROGRESS=%d
will set the AXIS progress bar to the given percentage. This feature should be used by any filter that
runs for a long time.
4.11.2The X Resource Database
The colors of most elements of the AXIS user interface can be customized through the X Resource
Database. The sample file axis_light_background changes the colors of the backplot window to a
"dark lines on white background" scheme, and also serves as a reference for the configurable items
in the display area. The sample file axis_big_dro changes the position readout to a larger size
font. To use these files:
For information about the other items which can be configured in Tk applications, see the Tk man
pages.
Because modern desktop environments automatically make some settings in the X Resource Database
that adversely affect AXIS, by default these settings are ignored. To make the X Resource Database
items override AXIS defaults, include the following line in your X Resources:
*Axis*optionLevel: widgetDefault
this causes the built-in options to be created at the option level "widgetDefault", so that X Resources
(which are level "userDefault") can override them.
4.11.3Physical jog wheels
To improve the interaction of AXIS with physical jog wheels, the axis currently selected in the GUI
is also reported on a pin with a name like axisui.jog.x. Except for a short time when the active
axis has just been changed, exactly one of these pins is TRUE at one time, and the rest are FALSE.
After AXIS has created these HAL pins, it executes the halfile named in [HAL]POSTGUI_HALFILE.
Unlike [HAL]HALFILE, only one such file may be used.
4.11.4axisrc
If it exists, the contents of ~/.axisrc are executed as Python source code just before the AXIS gui
is displayed. The details of what may be written in the axisrc are subject to change during the
development cycle.
The following adds Control-Q as a keyboard shortcut for Quit and turns on "Distance to go" by
default.
The menu options File > Edit... and File > Edit Tool Table... become available after defining the editor
in the ini section [DISPLAY]. Useful values include EDITOR=gedit and EDITOR=gnome-terminal e vim. For more information, see the DISPLAY section of the INI Configuration Chapter in the
Integrators Manual.
4.11.6Virtual Control Panel
AXIS can display a custom virtual control panel in the right-hand pane. You can program buttons,
indicators, data displays and more. For more information, see the Integrators Manual.
4.11.7Special Comments
Special comments can be inserted into the G Code file to control how the preview of AXIS behaves. In
the case where you want to limit the drawing of the preview use these special comments. Anything
between the (AXIS,hide) and (AXIS,show) will not be drawn during the preview. The (AXIS,hide) and
(AXIS,show) must be used in pairs with the (AXIS,hide) being first. Anything after a (AXIS,stop) will
not be drawn during the preview.
These comments are useful to unclutter the preview display (for instance while debugging a larger
g-code file, one can disable the preview on certain parts that are already working OK).
29
Page 43
EMC V2.4 User ManualChapter 4. AXIS
• (AXIS,hide) Stops the preview (must be first)
• (AXIS,show) Resumes the preview (must follow a hide)
• (AXIS, stop) Stops the preview from here to the end of the file.
30
Page 44
Chapter 5
Touchy
Touchy is a GUI for touch screens. It needs no mouse or keyboard.
Figure 5.1: Touchy
31
Page 45
EMC V2.4 User ManualChapter 5. Touchy
5.1Hard Controls
Required Controls
• Abort button (momentary contact) connected to the hal pin touchy.abort
• Cycle start button (momentary contact) connected to touchy.cycle-start
• Wheel/mpg, connected to touchy.wheel-counts
• Single block (toggle switch) connected to touchy.single-block
Recommended for any setup
• Estop button hardwired in the estop chain
Optional Controls
• Continuous Jog needs three center-off bidirectional momentary toggles (or worse, six buttons),
hooked to touchy.jog.continuous.x.negative, ....x.positive, ... y ..., ... z ...
• If a quill up button is wanted (to jog Z to the top of travel at top speed), a momentary button
connected to touchy.quill-up
• Optional indicator output: touchy.jog.active can be connected to a panel lamp to show when
the panel jogging controls are live
• Touchy has several output pins that are meant to be connected to the motion controller to
control wheel jogging. They are:
• touchy.jog.wheel.increment => axis.N.jog-scale (for all relevant N) touchy.jog.wheel.x => axis.0.jogenable ... y ... => ... 1 ..., ... z ...
• Also be sure to connect the wheel/mpg to axis.N.jog-counts as well as to touchy.wheel-counts.
If you use ilowpass to smooth wheel jogging, be sure to smooth only axis.N.jog-counts and not
touchy.wheel-counts.
5.2Configuration
Touchy requires you to create a file named "touchy.hal" in the same folder as your ini file to make
these connections. Touchy executes the hal commands in this file after it has made its pins available
for connection.
To use Touchy in the [DISPLAY] section of your ini file change the DISPLAY = touchy
Font Configuration is done on the Preferences Tab. Changes will be saved to the current computer
in a hidden file.
32
Page 46
Chapter 6
TkEMC
6.1Introduction
TkEMC is one of the most traditional graphical front-ends for EMC. It is written in Tcl and uses
the Tk toolkit for the display. Being written in TCL makes it very portable (runs on a multitude of
platforms). A separate backplot window can be displayed as shown in Figure(6.1).
Figure 6.1: TkEMC Window
6.2Getting Started
To select TkEMC as the front-end for EMC2, edit the .ini file. In the section [DISPLAY] change the
DISPLAY line to read
33
Page 47
EMC V2.4 User ManualChapter 6. TkEMC
DISPLAY = tkemc
Then, start EMC2 and select that ini file. The sample configuration sim/tkemc.ini is already
configured to use TkEMC as its front-end.
When you start EMC2 with TkEMC, a window like the one in Figure 6.1 is shown.
6.2.1A typical session with TkEMC
1. Start EMC2 and select a configuration file.
2. Clear the “E-STOP” condition and turn the machine on (by pressing F1 then F2).
3. “Home” each axis.
4. Load the file to be milled.
5. Put the stock to be milled on the table.
6. Set the proper offsets for each axis by jogging and either homing again or right-clicking an axis
name and entering an offset value.
1
7. Run the program.
8. To mill the same file again, return to step 6. To mill a different file, return to step 4. When
you’re done, exit EMC2.
6.3Elements of the TkEMC window
The TkEMC window contains the following elements:
• A menubar that allows you to perform various actions ;
• A set of buttons that allow you to change the current working mode, start/stop spindle and
other relevant I/O ;
• Status bar for various offset related displays ;
• Coordinate display area ;
• A set of sliders which control “Jogging speed”, “Feed Override”, and “Spindle speed Override”
which allow you to increase or decrease those settings ;
• Manual data input text box ;
• Status bar display with active G-codes, M-codes, F- and S-words ;
• Interpreter related buttons ;
• A text display area that shows the G-code source of the loaded file.
1
for some of these actions it might be needed to change the mode emc2 currently is in.
34
Page 48
EMC V2.4 User ManualChapter 6. TkEMC
6.3.1Main buttons
From left to right, the buttons are:
1. Machine enable: “ESTOP” / “ESTOP RESET” / “ON”
2. Toggle mist
3. Decrease spindle speed
4. Set spindle direction “SPINDLE OFF” / “SPINDLE FORWARD” / “SPINDLE REVERSE”
5. Increase spindle speed
6. Abort
then on the second line:
1. Operation mode: “MANUAL” / “MDI” / “AUTO”
2. Toggle flood
3. Toggle spindle brake control
6.3.2Offset display status bar
The Offset display status bar displays the currently selected tool (selected with Txx M6), the tool
length offset (if active), and the work offsets (set by right clicking the coordinates).
6.3.3Coordinate Display Area
The main part of the display shows the current position of the tool. The colour of the position
readout depends on the state of the axis. If the axis is unhomed the axis will be displayed in yellow
letters. Once homed it will be displayed in green letters. If there is an error with the current axis
TkEMC will use red letter to show that. (for example if an hardware limit switch is tripped).
To properly interpret these numbers, refer to the radio boxes on the right. If the position is “Machine”, then the displayed number is in the machine coordinate system. If it is “Relative”, then the
displayed number is in the offset coordinate system. Further down the choices can be “actual” or
“commanded”. Actual refers to the feedback coming from encoders (if you have a servo machine),
and the “commanded” refers to the position command send out to the motors. These values can differ for several reasons: Following error, deadband, encoder resolution, or step size. For instance, if
you command a movement to X 0.0033 on your mill, but one step of your stepper motor is 0.00125,
then the “Commanded” position will be 0.0033 but the “Actual” position will be 0.0025 (2 steps) or
0.00375 (3 steps).
Another set of radio buttons allows you to choose between “joint” and “world” view. These make little
sense on a normal type of machine (e.g. trivial kinematics), but helps on machines with non-trivial
kinematics like robots or stewart platforms. (you can read more about kinematics in the Integrators
Handbook).
6.3.3.1 Backplot
When the machine moves, it leaves a trail called the backplot. You can start the backplot window
by selecting View->Backplot.
35
Page 49
EMC V2.4 User ManualChapter 6. TkEMC
Figure 6.2: TkEMC Interpreter / program control
6.3.4Automatic control
6.3.4.1 Buttons for control
The buttons in the lower part of TkEMC (seen in Figure 6.2) are used to control the execution of a
program: “Open” to load a program, “Verify” to check it for errors, “Run” to start the actual cutting,
“Pause” to stop it while running, “Resume” to resume an already paused program, “Step” to advance
one line in the program and “Optional Stop” to toggle the optional stop switch (if the button is green
the program execution will be stopped on any M1 encountered).
6.3.4.2 Text Program Display Area
When the program is running, the line currently being executed is highlighted in white. The text
display will automatically scroll to show the current line.
6.3.5Manual Control
6.3.5.1 Implicit keys
TkEMC allows you to manually move the machine. This action is known as “jogging”. First, select
the axis to be moved by clicking it. Then, click and hold the “+” or “-” button depending on the
desired direction of motion. The first four axes can also be moved by the arrow keys (X and Y),
PAGE UP and PAGE DOWN keys (Z) and the [ and ] keys (A).
If “Continuous” is selected, the motion will continue as long as the button or key is pressed. If
another value is selected, the machine will move exactly the displayed distance each time the button
is clicked or the key is pressed. The available values are:
1.0000 0.1000 0.0100 0.0010 0.0001
By pressing “Home” or the HOME key, the selected axis will be homed. Depending on your configuration, this may just set the axis value to be the absolute position 0.0, or it may make the machine
move to a specific home location through use of “home switches”. See the Integrators Manual for
more information on homing.
By pressing “Override Limits”, the machine will temporarily be permitted to jog outside the limits
defined in the .ini file. (Note: if “Override Limits” is active the button will be displayed using a red
colour).
36
Page 50
EMC V2.4 User ManualChapter 6. TkEMC
Figure 6.3: TkEMC Override Limits & Jogging increments example
6.3.5.2 The “Spindle” group
The button on the first row select the direction for the spindle to rotate: Counterclockwise, Stopped,
Clockwise. The buttons next to it allow the user to increase or decrease the rotation speed. The
button on the second row allows the spindle brake to be engaged or released. Depending on your
machine configuration, not all the items in this group may have an effect.
6.3.5.3 The “Coolant” group
The two buttons allow the “Mist” and “Flood” coolants to be turned on and off. Depending on your
machine configuration, not all the items in this group may appear.
6.3.6Code Entry
Manual Data Input (also called MDI), allows G-code programs to be entered manually, one line at
a time. When the machine is not turned on, and not set to MDI mode, the code entry controls are
unavailable.
Figure 6.4: The Code Entry tab
6.3.6.1 MDI:
This allows you to enter a g-code command to be executed. Execute the command by pressing
Enter.
6.3.6.2 Active G-Codes
This shows the “modal codes” that are active in the interpreter. For instance, “G54” indicates that
the “G54 offset” is applied to all coordinates that are entered.
37
Page 51
EMC V2.4 User ManualChapter 6. TkEMC
6.3.7Jog Speed
By moving this slider, the speed of jogs can be modified. The numbers above refer to axis units
/ second. The text box with the number is clickable. Once clicked a popup window will appear,
allowing for a number to be entered.
6.3.8Feed Override
By moving this slider, the programmed feed rate can be modified. For instance, if a program requests
F60 and the slider is set to 120%, then the resulting feed rate will be 72. The text box with the
number is clickable. Once clicked a popup window will appear, allowing for a number to be entered.
6.3.9Spindle speed Override
The spindle speed override slider works exactly like the feed override slider, but it controls to the
spindle speed. If a program requested S500 (spindle speed 500 RPM), and the slider is set to 80%,
then the resulting spindle speed will be 400 RPM. This slider has a minimum and maximum value
defined in the ini file. If those are missing the slider is stuck at 100%. The text box with the number
is clickable. Once clicked a popup window will appear, allowing for a number to be entered.
6.4Keyboard Controls
Almost all actions in TkEMC can be accomplished with the keyboard. Many of the shortcuts are
unavailable when in MDI mode.
The most frequently used keyboard shortcuts are shown in Table 6.1.
Table 6.1: Most Common Keyboard Shortcuts
KeystrokeAction Taken
F1Toggle Emergency Stop
F2Turn machine on/off
‘, 1 .. 9, 0Set feed override from 0% to 100%
X, ‘Activate first axis
Y, 1Activate second axis
Z, 2Activate third axis
A, 3Activate fourth axis
HomeSend active axis Home
Left, RightJog first axis
Up, DownJog second axis
Pg Up, Pg DnJog third axis
[, ]Jog fourth axis
ESCStop execution
38
Page 52
Chapter 7
MINI
7.1Introduction
1
Figure 7.1: The Mini Graphical Interface
1
Much of this chapter quotes from a chapater of the Sherline CNC operators manual.
39
Page 53
EMC V2.4 User ManualChapter 7. MINI
Mini was designed to be a full screen graphical interface. It was first written for the Sherline CNC
but is available for anyone to use, copy, and distribute under the terms of the GPL copyright.
Rather than popup new windows for each thing that an operator might want to do, Mini allows you
to display these within the regular screen. Parts of this chapter are copied from the instructions
that were written for that mill by Joe Martin and Ray Henry.
7.2Screen layout
Figure 7.2: Mini Display for a Running EMC
The Mini screen is laid out in several sections. (See Figure8.1 ) These include a menu across the
top, a set of main control buttons just below the menu and two rather large columns of information
that show the state of your machine and allow you to enter commands or programs.
When you compare figure8.1 with figure 7.2 you will see many differences. In the second figure
• each axis has been homed – the display numbers are dark green
• the EMC mode is auto – the auto button has a light green background
• the backplotter has been turned on – backplot is visible in the pop-in window
40
Page 54
EMC V2.4 User ManualChapter 7. MINI
• the tool path from the program is showing in the display.
Once you start working with Mini you will quickly discover how easily it shows the conditions of the
EMC and allows you to make changes to it.
7.3Menu Bar
The first row is the menu bar across the top. Here you can configure the screen to display additional
information. Some of the items in this menu are very different from what you may be acustomed
to with other programs. You should take a few minutes and look under each menu item in order to
familiarize yourself with the features that are there.
The menu includes each of the following sections and subsections.
Program This menu includes both reset and exit functions. Reset will return the EMC to the
condition that it was in when it started. Some startup configuration items like the normal
program units can be specified in the ini file.
View This menu includes several screen elements that can be added so that you can see additional
information during a run. These include
Position_Type This menu item adds a line above the main position displays that shows
whether the displays are in inches or metric and whether they are Machine or Relative
location and if they are Actual positions or Commanded positions. These can be changed
using the Settings menu described below.
Tool_Info This adds a line immediately below the main position displays that shows which
tool has been selected and the length of offset applied.
Offset_Info adds a line immediately below the tool info that shows what offsets have been
applied. This is a total distance for each axis from machine zero.
Show_Restart adds a block of buttons to the right of the program display in auto mode. These
allow the operator to restart a program after an abort or estop. These will pop in whenever
estop or abort is pressed but can be shows by the operator anytime auto mode is active
by selecting this menu item.
Hide_Restart removes the block of buttons that control the restart of a program that has been
aborted or estopped.
Show_Split_Right changes the nature of the right hand column so that it shows both mode
and pop-in information.
Show_Mode_Full changes the right hand column so that the mode buttons or displays fill
the entire right side of the screen. In manual mode, running with mode full you will see
spindle and lube control buttons as well as the motion buttons.
Show_Popin_Full changes the right hand column so that the popin fills the entire right side
of the screen.
Settings These menu items allow the operator to control certain parameters during a run.
Actual_Position sets the main position displays to actual(machine based) values.
Commanded_Position sets the main position displays to the values that they were com-
manded to.
Machine_Position sets the main position displays to the absolute distance from where the
machine was homed.
Relative_Position sets the main position displays to show the current position including any
offsets like part zeros that are active. For more information on offsets see the chapter on
coordinate systems.
41
Page 55
EMC V2.4 User ManualChapter 7. MINI
Info lets you see a number of active things by writing their values into the MESSAGE pad.
Program_File will write the currently active program file name.
Editor_File will write the currently active file if the editor pop in is active and a file has been
selected for editing.
Parameter_File will write the name of the file being used for program parameters. You can
find more on this in the chapters on offsets and using variables for programming.
Tool_File will write the name of the tool file that is being used during this run.
Active_G-Codes will write a list of all of the modal program codes that are active whenever
this item is selected. For more information about modal codes see the introductory part
programming chapter.
Help opens a text window pop in that displays the contents of the help file.
You will notice between the info menu and the help menu there are a set of four buttons. These
are called check buttons because they have a small box that shows red if they have been selected.
These four buttons, Editor, Backplot, Tools, and Offsets pop in each of these screens. If more than
one pop-in is active (button shown as red) you can toggle between these pop-ins by right clicking
your mouse.
7.4Control Button Bar
Below the menu line is a horizontal line of control buttons. These are the primary control buttons
for the interface. Using these buttons you can change mode from [MANUAL] to [AUTO] to [MDI]
(Manual Data Input). These buttons show a light green background whenever that mode is active.
You can also use the [FEEDHOLD], [ABORT], and [ESTOP] buttons to control a programmed move.
7.4.1MANUAL
This button or pressing <F3> sets the EMC to Manual mode and displays an abreviated set of
buttons the operator can use to issue manual motion commands. The labels of the jog buttons
change to match the active axis. Whenever Show_Mode_Full is active in in manual mode, you will
see spindle and lube control buttons as well as the motion buttons. A keyboard <i> or <I> will
switch from continuous jog to incremental jog. Pressing that key again will toggle the increment
size through the available sizes.
Figure 7.3: Manual Mode Buttons
A button has been added to designate the present position as the home position. We
felt that a machine of this type (Sherline 5400) would be simpler to operate if it didn’t use
a machine home position. This button will zero out any offsets and will home all axes
right where they are.
42
Page 56
EMC V2.4 User ManualChapter 7. MINI
Axis focus is important here. Notice (in figure 8.1) that in manual mode you see a line
or groove around the X axis to highlight its position display. This groove says that X is the
active axis. It will be the target for jog moves made with the plus and minus jog buttons.
You can change axis focus by clicking on any other axis display. You can also change axis
focus in manual mode if you press its name key on your keyboard. Case is not important
here. [Y] or [y] will shift the focus to the Y axis. [A] or [a] will shift the focus to the A axis.
To help you remember which axis will jog when you press the jog buttons, the active axis
name is displayed on them.
The EMC can jog (move a particular axis) as long as you hold the button down when it
is set for continuous, or it can jog for a preset distance when it is set for incremental. You
can also jog the active axis by pressing the plus [+] or minus [-] keys on the keyboard.
Again, case is not important for keyboard jogs. The two small buttons between the large
jog buttons let you set which kind of jog you want. When you are in incremental mode,
the distance buttons come alive. You can set a distance by pressing it with the mouse.
You can toggle between distances by pressing [i] or [I] on the keyboard. Incremental jog
has an interesting and often unexpected effect. If you press the jog button while a jog is in
progress, it will add the distance to the position it was at when the second jog command
was issued. Two one-inch jog presses in close succession will not get you two inches of
movement. You have to wait until the first one is complete before jogging again.
Jog speed is displayed above the slider. It can be set using the slider by clicking in the
slider’s open slot on the side you want it to move toward, or by clicking on the [Default]
or [Rapid] buttons. This setting only affects the jog move while in manual mode. Once a
jog move is initiated, jog speed has no effect on the jog. As an example of this, say you
set jog mode to incremental and the increment to 1 inch. Once you press the [Jog] button
it will travel that inch at the rate at which it started.
7.4.2AUTO
When the Auto button is pressed, or <F4> on the keyboard, the EMC is changed into that mode, a
set of the traditional auto operation buttons is displayed, and a small text window opens to show a
part program. During run the active line will be displayed as white lettering on a red background.
In the auto mode, many of the keyboard keys are bound to controls. For example the numbers
above the querty keys are bound to feed rate override. The 0 sets 100%, 9 sets 90% and such.
Other keys work much the same as they do with the tkemc graphical interface.
Figure 7.4: Auto Mode
Auto mode does not normally display the active or modal codes. If the operator wishes to check
these, use menu Info -> Active_G-Codes. This will write all modal codes onto the message scratch
pad.
If abort or estop is pressed during a run a set of buttons displays to the right of the text that allows
the operator to shift the restart line forward or backwards. If the restart line is not the last active
line, it will be highlighted as white letters on a blue background. Caution, a very slow feed rate, and
a finger poised over the pause button is advised during any program restart.
43
Page 57
EMC V2.4 User ManualChapter 7. MINI
The real heart of CNC machine tool work is the auto mode. Sherline’s auto mode
displays the typical functions that people have come to expect from the EMC. Along the
top are a set of buttons which control what is happening in auto mode. Below them is
the window that shows the part of the program currently being executed. As the program
runs, the active line shows in white letters on a red background. The first three buttons,
[Open], [Run], and [Pause] do about what you’d expect. [Pause] will stop the run right
where it is. The next button, [Resume], will restart motion. They are like feedhold if used
this way. Once [Pause] is pressed and motion has stopped, [Step] will resume motion and
continue it to the end of the current block. Press [Step] again to get the motion of the
next block. Press [Resume] and the interpreter goes back to reading ahead and running
the program. The combination of [Pause] and [Step] work a lot like single block mode on
many controllers. The difference is that [Pause] does not let motion continue to the end
of the current block. Feed rate Override ... can be very handy as you approach a first cut.
Move in quickly at 100 percent, throttle back to 10% and toggle between [Feedhold] and
10% using the pause button. When you are satisfied that you’ve got it right, hit the zero
to the right of nine and go.
The [Verify] button runs the interpreter through the code without initiating any motion.
If Verify finds a problem it will stop the read near the problem block and put up some sort
of message. Most of the time you will be able to figure out the problem with your program
by reading the message and looking in the program window at the highlighted line. Some
of the messages are not very helpful. Sometimes you will need to read a line or two ahead
of the highlight to see the problem. Occasionally the message will refer to something well
ahead of the highlight line. This often happens if you forget to end your program with an
acceptable code like %, m2, m30, or m60.
7.4.3MDI
The MDI button or <F5> sets the Manual Data Input mode. This mode displays a single line of text
for block entry and shows the currently active modal codes for the interpreter.
MDI mode allows you to enter single blocks and have the interpreter execute them as
if they were part of a program (kind of like a one-line program). You can execute circles,
arcs, lines and such. You can even test sets of program lines by entering one block,
waiting for that motion to end, and then enter the next block. Below the entry window,
there is a listing of all of the current modal codes. This listing can be very handy. I often
forget to enter a g00 before I command a motion. If nothing happens I look down there to
see if g80 is in effect. G80 stops any motion. If it’s there I remember to issue a block like
g00 x0 y0 z0. In MDI you are entering text from the keyboard so none of the main keys
work for commands to the running machine. [F1] will Estop the control.
Since many of the keyboard keys are needed for entry, most of the bindings that were available in
auto mode are not available here.
7.4.4[FEEDHOLD] – [CONTINUE]
Feedhold is a toggle. When the EMC is ready to handle or is handling a motion command this
button shows the feedhold label on a red backgrouund. If feedhold has been pressed then it will
show the continue label. Using it to pause motion has the advantage of being able to restart the
program from where you stopped it. Feedhold will toggle between zero speed and whatever feed
rate override was active before it was pressed. This button and the function that it activates is also
bound to the pause button on most keyboards.
44
Page 58
EMC V2.4 User ManualChapter 7. MINI
7.4.5[ABORT]
The abort button stops any motion when it is pressed. It also removes the motion command from
the EMC. No further motions are cued up after this button is pressed. If you are in auto mode, this
button removes the rest of the program from the motion cue. It also records the number of the line
that was executing when it was pressed. You can use this line number to restart the program after
you have cleared up the reasons for pressing it.
7.4.6[ESTOP]
The estop button is also a toggle but it works in three possible settings.
• When Mini starts up it will show a raised button with red background with black letters that
say “ESTOP PUSH.” This is the correct state of the machine when you want to run a program
or jog an axis. Estop is ready to work for you when it looks like this.
• If you push the estop button while a motion is being executed, you will see a recessed gray
button that says “ESTOPPED.” You will not be able to move an axis or do any work from the
Mini gui when the estop button displays this way. Pressing it with your mouse will return Mini
to normal ready condition.
• A third view is possible here. A recessed green button means that estop has been take off but
the machine has not been turned on. Normally this only happens when <F1> estop has been
pressed but <F2> has not been pressed.
Joe Martin says, “When all else fails press a software [ESTOP].” This does everything that abort does
but adds in a reset so that the EMC returns to the standard settings that it wakes up on. If you
have an external estop circuit that watches the relevant parallel port or DIO pin, a software estop
can turn off power to the motors.
Most of the time, when we abort or E-Stop it’s because something went wrong. Perhaps
we broke a tool and want to change it. We switch to manual mode and raise the spindle,
change tools, and assuming that we got the length the same, get ready to go on. If we
return the tool to the same place where the abort was issued, the EMC will work perfectly.
It is possible to move the restart line back or ahead of where the abort happened. If
you press the [Back] or [Ahead] buttons you will see a blue highlight that shows the
relationship between the abort line and the one on which the EMC will start up again.
By thinking through what is happening at the time of the restart you can place the tool
tip where it will resume work in an acceptable manner. You will need to think through
things like tool offsets barriers to motion along a diagonal line and such before you press
the [Restart] button.
7.5Left Column
There are two columns below the control line. The left side of the screen displays information of
interest to the operator. There are very few buttons to press here.
7.5.1Axis Position Displays
The axis position displays work exactly like they do with tkemc. The color of the letters is important.
• Red indicates that the machine is sitting on a limit switch or the polarity of a min or max limit
is set wrong in the ini file.
45
Page 59
EMC V2.4 User ManualChapter 7. MINI
• Yellow indicates that the machine is ready to be homed.
• Green indicates that the machine has been homed.
The position can be changed to display any one of several values by using the menu settings. The
startup or default settings can be changed in the ini file so these displays wake up just the way that
you want them.
7.5.2Feed rate Override
Immediately below the axis position displays is the feed rate override slider. You can operate feed
rate override and feedhold in any mode of operation. Override will change the speed of jogs or feed
rate in manual or MDI modes. You can adjust feed rate override by grabbing the slider with your
mouse and dragging it along the groove. You can also change feed rate a percent at a time by
clicking in the slider’s groove. In auto mode you can also set feed override in 10% increments by
pressing the top row of numbers. This slider is a handy visual reference to how much override is
being applied to programmed feed rate.
7.5.3Messages
The message display located under the axis positions is a sort of scratch pad for the EMC. If there
are problems it will report them there. If you try to home or move an axis when the [ESTOP] button
is pressed, you’ll get a message that says something about commanding motion when the EMC is
not ready. If an axis faults out for something like falling behind, the message pad will show what
happened. If you want to remind an operator to change a tool, for example, you can add a line of
code to your program that will display in the message box. An example might be (msg, change to
tool #3 and press resume). This line of code, included in a program, will display “change to tool #3
and press resume” in the message box. The word msg, (with comma included) is the command to
make this happen; without msg, the message wouldn’t be displayed. It will still show in the auto
modes’ display of the program file.
To erase messages simply click the message button at the top of the pad or on the keyboard hold
down the [Alt] key and press the [m] key.
7.6Right Column
The right column is a general purpose place to display and work. Here you can see the modal
buttons and text entry or displays. Here you can view a plot of the tool path that will be commanded
by your program. You can also write programs and control tools and offsets here. The modal screens
have been described above. Each of the popin displays are described in detail below.
46
Page 60
EMC V2.4 User ManualChapter 7. MINI
7.6.1Program Editor
Figure 7.5: Mini Text Editor
The editor is rather limited compared to many modern text editors. It does not have undo nor paste
between windows with the clipboard.These were eliminated because of interaction with a running
program. Future releases will replace these functions so that it will work the way you’ve come
to expect from a text editor. It is included because it has the rather nice feature of being able to
number and renumber lines in the way that the interpreter expects of a file. It will also allow you to
cut and paste from one part of a file to another. In addition, it will allow you to save your changes
and submit them to the EMC interpreter with the same menu click. You can work on a file in here
for a while and then save and load if the EMC is in Auto mode. If you have been running a file and
find that you need to edit it, that file will be placed in the editor when you click on the editor button
on the top menu.
47
Page 61
EMC V2.4 User ManualChapter 7. MINI
7.6.2Backplot Display
Figure 7.6: Mini’s Backplotter
Backplot [Backplot] will show the tool path that can be viewed from a chosen direction. ’3-D’ is the
default. Other choices and controls are displayed along the top and right side of the pop-in. If you
are in the middle of a cut when you press one of these control buttons the machine will pause long
enough to re-compute the view.
Along the right side of the pop-in there is a small pyramid shaped graphic that tries to show the
angle you are viewing the tool path from. Below it are a series of sliders that allow you to change the
angle of view and the size of the plot. You can rotate the little position angle display with these. They
take effect when you press the [Refresh] button. The [Reset] button removes all of the paths from
the display and readies it for a new run of the program but retains your settings for that session.
If backplot is started before a program is started, it will try to use some color lines to indicate the
kind of motion that was used to make it. A green line is a rapid move. A black line is a feed rate
move. Blue and red indicate arcs in counterclockwise and clockwise directions.
The backplotter with Mini allows you to zoom and rotate views after you have run your program but
it is not intended to store a tool path for a long period of time.
7.6.3Tool Page
The tool page is pretty much like the others. You can set length and diameter values here and
they become effective when you press the [Enter] key. You will need to set up your tool information
before you begin to run a program. You can’t change tool offsets while the program is running or
when the program is paused.
48
Page 62
EMC V2.4 User ManualChapter 7. MINI
Figure 7.7: Mini Tool Display
The [Add Tools] and [Remove Tools] buttons work on the bottom of the tool list so you will want to fill
in tool information in decending order. Once a new tool has been added, you can use it in a program
with the usual G-code commands. There is a 32 tool limit in the current EMC configuration files
but you will run out of display space in Mini long before you get there. (Hint You can use menu ->
view -> show popin full to see more tools if you need.)
7.6.4Offset Page
The offset page can be used to display and setup work offsets. The coordinate system is selected
along the left hand side of the window. Once you have selected a coordinate system you can enter
values or move an axis to a teach position.
Figure 7.8: Mini Offset Display
You can also teach using an edgefinder by adding the radius and length to the offset_by widgets.
When you do this you may need to add or subtract the radius depending upon which surface
49
Page 63
EMC V2.4 User ManualChapter 7. MINI
you choose to touch from. This is selected with the add or subtract radiobuttons below the offset
windows.
The zero all for the active coordinate system button will remove any offsets that you have showing
but they are not set to zero in the variable file until you press the write and load file button as well.
This write and load file button is the one to use when you have set all of the axis values that you
want for a coordinate system.
7.7Keyboard Bindings
A number of the bindings used with tkemc have been preserved with mini. A few of the bindings
have been changed to extend that set or to ease the operation of a machine using this interface.
Some keys operate the same regradless of the mode. Others change with the mode that EMC is
operating in.
7.7.1Common Keys
Pause Toggle feedhold
Escape abort motion
F1 toggle estop/estop reset state
F2 toggle machine off/machine on state
F3 manual mode
F4 auto mode
F5 MDI mode
F6 reset interpreter
The following only work for machines using auxiliary I/O
F7 toggle mist on/mist off
F8 toggle flood on/flood off
F9 toggle spindle forward/off
F10 toggle spindle reverse/off
F11 decrease spindle speed
F12 increase spindle speed
7.7.2Manual Mode
1-9 0 set feed override to 10%-90%, 0 is 100%
~ set feed override to 0 or feedhold
x select X axis
y select Y axis
z select Z axis
50
Page 64
EMC V2.4 User ManualChapter 7. MINI
a select A axis
b select B axis
c select C axis
Left Right Arrow jog X axis
Up Down Arrow jog Y axis
Page Up Down jog Z axis
- _ jog the active axis in the minus direction
+ = jog the active axis in the plus direction.
Home home selected axis
i I toggle through jog increments
The following only work with a machine using auxiliary I/O
b take spindle brake off
Alt-b put spindle brake on
7.7.3Auto Mode
1-9,0 set feed override to 10%-90%, 0 is 100%
~ set feed override to 0 or feedhold
o/O open a program
r/R run an opened program
p/P pause an executing program
s/S resume a paused program
a/A step one line in a paused program
7.8Misc
One of the features of Mini is that it displays any axis above number 2 as a rotary and will display
degree units for it. It also converts to degree units for incremental jogs when a rotary axis has the
focus.
51
Page 65
Chapter 8
KEYSTICK
8.1Introduction
Figure 8.1: The Mini Graphical Interface
Keystick is a minimal text based interface.
8.2Installing
To use keystick change the DISPLAY ini file setting to:
[DISPLAY]
DISPLAY = keystick
52
Page 66
EMC V2.4 User ManualChapter 8. KEYSTICK
8.3Using
Keystick is very simple to use. In the MDI Mode you simply start typing the g code and it shows up
in the bottom text area. The “?” key toggles help.
53
Page 67
Part II
Using EMC
54
Page 68
Chapter 9
CNC Machine Overview
This section gives a brief description of how a CNC machine is viewed from the input and output
ends of the Interpreter.
9.1Mechanical Components
A CNC machine has many mechanical components that may be controlled or may affect the way in
which control is exercised. This section describes the subset of those components that interact with
the Interpreter. Mechanical components that do not interact directly with the Interpreter, such as
the jog buttons, are not described here, even if they affect control.
9.1.1Axes
Any CNC machine has one or more Axes. Different types of CNC machines have different combinations. For instance, a "4-axis milling machine" may have XYZA or XYZB axes. A lathe typically
has XZ axes. A foam-cutting machine may have XYUZ axes. In EMC, the case of a XYYZ "gantry"
machine with two motors for one axis is better handled by kinematics rather than by a second linear
axis.
1
9.1.1.1 Primary Linear Axes
The X, Y, and Z axes produce linear motion in three mutually orthogonal directions.
9.1.1.2 Secondary Linear Axes
The U, V, and W axes produce linear motion in three mutually orthogonal directions. Typically, X
and U are parallel, Y and V are parallel, and Z and W are parallel.
9.1.1.3 Rotational Axes
The A, B and C axes produce angular motion (rotation). Typically, A rotates around a line parallel
to X, B rotates around a line parallel to Y, and C rotates around a line parallel to Z.
1
If the motion of mechanical components is not independent, as with hexapod machines, the RS274/NGC language and
the canonical machining functions will still be usable, as long as the lower levels of control know how to control the actual
mechanisms to produce the same relative motion of tool and workpiece as would be produced by independent axes. This is
called kinematics.
55
Page 69
EMC V2.4 User ManualChapter 9. CNC Machine Overview
9.1.2Spindle
A CNC machine typically has a spindle which holds one cutting tool, probe, or the material in the
case of a lathe. The spindle may or may not be controlled by the CNC software.
9.1.3Coolant
If a CNC machine has components to provide mist coolant and/or flood coolant they can be controlled by G-Codes.
9.1.4Feed and Speed Override
A CNC machine can have separate feed and speed override controls, which let the operator specify
that the actual feed rate or spindle speed used in machining at some percentage of the programmed
rate. See Section 9.3.1.
9.1.5Block Delete Switch
A CNC machine can have a block delete switch. See Section 9.3.2.
9.1.6Optional Program Stop Switch
A CNC machine can have an optional program stop switch. See Section 9.3.3.
9.2Control and Data Components
9.2.1Linear Axes
The X, Y, and Z axes form a standard right-handed coordinate system of orthogonal linear axes.
Positions of the three linear motion mechanisms are expressed using coordinates on these axes.
The U, V and W axes also form a standard right-handed coordinate system. X and U are parallel, Y
and V are parallel, and Z and W are parallel.
9.2.2Rotational Axes
The rotational axes are measured in degrees as wrapped linear axes in which the direction of positive
rotation is counterclockwise when viewed from the positive end of the corresponding X, Y, or Z-axis.
By “wrapped linear axis,” we mean one on which the angular position increases without limit (goes
towards plus infinity) as the axis turns counterclockwise and deceases without limit (goes towards
minus infinity) as the axis turns clockwise. Wrapped linear axes are used regardless of whether or
not there is a mechanical limit on rotation.
Clockwise or counterclockwise is from the point of view of the workpiece. If the workpiece is fastened
to a turntable which turns on a rotational axis, a counterclockwise turn from the point of view of the
workpiece is accomplished by turning the turntable in a direction that (for most common machine
configurations) looks clockwise from the point of view of someone standing next to the machine.
2
If the parallelism requirement is violated, the system builder will have to say how to distinguish clockwise from counterclockwise.
56
2
Page 70
EMC V2.4 User ManualChapter 9. CNC Machine Overview
9.2.3Controlled Point
The controlled point is the point whose position and rate of motion are controlled. When the tool
length offset is zero (the default value), this is a point on the spindle axis (often called the gauge
point) that is some fixed distance beyond the end of the spindle, usually near the end of a tool
holder that fits into the spindle. The location of the controlled point can be moved out along the
spindle axis by specifying some positive amount for the tool length offset. This amount is normally
the length of the cutting tool in use, so that the controlled point is at the end of the cutting tool. On
a lathe, tool length offsets can be specified for X and Z axes, and the controlled point is either at the
tool tip or slightly outside it (where the perpendicular, axis-aligned lines touched by the “front” and
“side” of the tool intersect).
9.2.4Coordinated Linear Motion
To drive a tool along a specified path, a machining center must often coordinate the motion of several
axes. We use the term “coordinated linear motion” to describe the situation in which, nominally,
each axis moves at constant speed and all axes move from their starting positions to their end
positions at the same time. If only the X, Y, and Z axes (or any one or two of them) move, this
produces motion in a straight line, hence the word “linear” in the term. In actual motions, it is
often not possible to maintain constant speed because acceleration or deceleration is required at
the beginning and/or end of the motion. It is feasible, however, to control the axes so that, at all
times, each axis has completed the same fraction of its required motion as the other axes. This
moves the tool along same path, and we also call this kind of motion coordinated linear motion.
Coordinated linear motion can be performed either at the prevailing feed rate, or at traverse rate,
or it may be synchronized to the spindle rotation. If physical limits on axis speed make the desired
rate unobtainable, all axes are slowed to maintain the desired path.
9.2.5Feed Rate
The rate at which the controlled point or the axes move is nominally a steady rate which may be set
by the user. In the Interpreter, the interpretation of the feed rate is as follows unless “inverse time
feed” or “feed per revolution” modes are being used (see Section 15.45).
1. If any of XYZ are moving, F is in units per minute in the XYZ cartesian system, and all other
axes (UVWABC) move so as to start and stop in coordinated fashion
2. Otherwise, if any of UVW are moving, F is in units per minute in the UVW cartesian system,
and all other axes (ABC) move so as to start and stop in coordinated fashion
3. Otherwise, the move is pure rotary motion and the F word is in rotary units in the ABC
“pseudo-cartesian” system.
9.2.6Coolant
Flood coolant and mist coolant may each be turned on independently. The RS274/NGC language
turns them off together (see Section 16.4).
9.2.7Dwell
A machining center may be commanded to dwell (i.e., keep all axes unmoving) for a specific amount
of time. The most common use of dwell is to break and clear chips, so the spindle is usually turning
during a dwell. Regardless of the Path Control Mode (see Section 9.2.15) the machine will stop
exactly at the end of the previous programmed move, as though it was in exact path mode.
57
Page 71
EMC V2.4 User ManualChapter 9. CNC Machine Overview
9.2.8Units
Units used for distances along the X, Y, and Z axes may be measured in millimeters or inches.
Units for all other quantities involved in machine control cannot be changed. Different quantities
use different specific units. Spindle speed is measured in revolutions per minute. The positions
of rotational axes are measured in degrees. Feed rates are expressed in current length units per
minute, or degrees per minute, or length units per spindle revolution, as described in Section 9.2.5.
9.2.9Current Position
The controlled point is always at some location called the “current position,” and the controller
always knows where that is. The numbers representing the current position must be adjusted in
the absence of any axis motion if any of several events take place:
1. Length units are changed.
2. Tool length offset is changed.
3. Coordinate system offsets are changed.
9.2.10Selected Plane
There is always a “selected plane”, which must be the XY-plane, the YZ-plane, or the XZ-plane of
the machining center. The Z-axis is, of course, perpendicular to the XY-plane, the X-axis to the
YZ-plane, and the Y-axis to the XZ-plane.
9.2.11Tool Carousel
Zero or one tool is assigned to each slot in the tool carousel.
9.2.12Tool Change
A machining center may be commanded to change tools.
9.2.13Pallet Shuttle
The two pallets may be exchanged by command.
9.2.14Feed and Speed Override Switches
The feed and speed override switches may be enabled (so they work as expected) or disabled (so they
have no effect on the feed rate or spindle speed). The RS274/NGC language has one command that
enables both switches and one command that disables both (see Section 16.5.1). See Section 9.3.1
for further details.
9.2.15Path Control Mode
The machining center may be put into any one of three path control modes: (1) exact stop mode, (2)
exact path mode, or (3) continuous mode with optional tolerance. In exact stop mode, the machine
stops briefly at the end of each programmed move. In exact path mode, the machine follows the
programmed path as exactly as possible, slowing or stopping if necessary at sharp corners of the
path. In continuous mode, sharp corners of the path may be rounded slightly so that the feed rate
may be kept up (but by no more than the tolerance, if specified). See Section 15.28.
58
Page 72
EMC V2.4 User ManualChapter 9. CNC Machine Overview
9.3Interpreter Interaction with Switches
The Interpreter interacts with several switches. This section describes the interactions in more
detail. In no case does the Interpreter know what the setting of any of these switches is.
9.3.1Feed and Speed Override Switches
The Interpreter will interpret RS274/NGC commands which enable (M48) or disable (M49) the feed
and speed override switches. For certain moves, such as the traverse out of the end of a thread
during a threading cycle, the switches are disabled automatically.
EMC2 reacts to the speed and feed override settings when these switches are enabled.
9.3.2Block Delete Switch
If the block delete switch is on, lines of RS274/NGC code which start with a slash (the block delete
character) are not interpreted. If the switch is off, such lines are interpreted. Normally the block
delete switch should be set before starting the NGC program.
9.3.3Optional Program Stop Switch
If this switch is on and an M1 code is encountered, program execution is paused.
9.4Tool File
A tool file is required to use the Interpreter. The file tells which tools are in which carousel slots and
what the length and diameter of each tool are.
The file consists of any number of header lines, followed by one blank line, followed by any number
of lines of data. The header lines are ignored by the interpreter. It is important that there be exactly
one blank line (with no spaces or tabs, even) before the data. The header line shown in Table 9.1
describes the data columns, so it is suggested (but not required) that such a line always be included
in the header.
Each data line of the file contains the data for one tool. The line may contain 4 or 5 elements (“mill
format”) or 8 or 9 elements (“lathe format”).
The units used for the length and diameter are in machine units.
The lines do not have to be in any particular order. Switching the order of lines has no effect unless
the same slot number is used on two or more lines, which should not normally be done, in which
case the data for only the last such line will be used.
In emc, the location of the tool file is specified in the ini file. See the Integrator Manual for more
details.
A tool file may have a mixture of “mill format” and “lathe format” lines, though usually the “lathe
format” lines are only required for lathe-type tooling.
59
Page 73
EMC V2.4 User ManualChapter 9. CNC Machine Overview
9.4.1Mill Format Tool Files
The “mill format” of a tool file is shown in Table 9.1.
Table 9.1: Sample Tool File (mill format)
PocketFMSTLODiameterComment
112.01.0
221.00.2
551.50.25endmill
10102.4-0.3for testing
Each line has five entries. The first four entries are required. The last entry (a comment) is optional.
It makes reading easier if the entries are arranged in columns, as shown in the table, but the only
format requirement is that there be at least one space or tab after each of the first three entries on
a line and a space, tab, or newline at the end of the fourth entry. The meanings of the columns and
the type of data to be put in each are as follows.
The “Pocket” column contains the number (unsigned integer) which represents the pocket number
(slot number) of the tool carousel slot in which the tool is placed. The entries in this column must
all be different.
The “FMS” column contains the number (unsigned integer) which represents a code number for the
tool. The user may use any code for any tool, as long as the codes are unsigned integers. This is
typically the same as the pocket number.
The “TLO” column contains a real number which represents the tool length offset. This number will
be used if tool length offsets are being used and this pocket is selected. This is normally a positive
real number, but it may be zero or any other number if it is never to be used.
The “Diameter” column contains a real number. This number is used only if tool radius compensation is turned on using this pocket. If the programmed path during compensation is the edge of the
material being cut, this should be a positive real number representing the measured diameter of the
tool. If the programmed path during compensation is the path of a tool whose diameter is nominal,
this should be a small number (positive, negative, or zero) representing the difference between the
measured diameter of the tool and the nominal diameter. If cutter radius compensation is not used
with a tool, it does not matter what number is in this column.
The “Comment” column may optionally be used to describe the tool. Any type of description is OK.
This column is for the benefit of human readers only.
9.4.2Lathe Format Tool Files
The “lathe format” of a tool file is shown in Table 9.2.
The Pocket, FMS, DIA and Comment fields are as for mill format tool files. The ZOFFSET field is the
same as the TLO field of mill format tool files. The DIA is also used by the AXIS gui display.
The XOFFSET field gives an offset for the X coordinate when tool length offsets are in effect.
60
Page 74
EMC V2.4 User ManualChapter 9. CNC Machine Overview
The ORIENTATION field gives the orientation of the lathe tool, as illustrated in 9.1. The red cross is
the controlled point. See 9.2.3.
The FRONTANGLE and BACKANGLE fields are used by some user interfaces to display a fancy
representation of the lathe tool.
Figure 9.1: Tool Orientations
9.5Parameters
In the RS274/NGC language view, a machining center maintains an array of over 5400 numerical
parameters defined by a system definition (RS274NGC_MAX_PARAMETERS). Many of them have
specific uses especially in defining coordinate systems. The number of numerical parameters can
increase as development adds support for new parameters. The parameter array persists over time,
even if the machining center is powered down. EMC2 uses a parameter file to ensure persistence
and gives the Interpreter the responsibility for maintaining the file. The Interpreter reads the file
when it starts up, and writes the file when it exits.
61
Page 75
EMC V2.4 User ManualChapter 9. CNC Machine Overview
Table 9.3: Parameters Used by the RS274NGC Interpreter
Parameter Number(s)Meaning
1 - 30Subroutine local parameters of call arguments
1 - 5000G-Code user parameters
5061-5070Result of "G38.2" Probe
5161-5169"G28" Home
5181-5189"G30" Home
5211-5219"G92" offset
5220Coordinate System Number
5221-5229Coordinate System 1
5241-5249Coordinate System 2
5261-5269Coordinate System 3
5281-5289Coordinate System 4
5301-5309Coordinate System 5
5321-5329Coordinate System 6
5341-5349Coordinate System 7
5361-5369Coordinate System 8
5381-5389Coordinate System 9
5399Result of M66 - Check or wait for input
5400 - 5413Loaded Tool parameters
The format of a parameter file is shown in Table 9.4. The file consists of any number of header
lines, followed by one blank line, followed by any number of lines of data. The Interpreter skips over
the header lines. It is important that there be exactly one blank line (with no spaces or tabs, even)
before the data. The header line shown in Table 9.4 describes the data columns, so it is suggested
(but not required) that that line always be included in the header.
The Interpreter reads only the first two columns of the table. The third column, “Comment,” is not
read by the Interpreter.
Each line of the file contains the index number of a parameter in the first column and the value to
which that parameter should be set in the second column. The value is represented as a doubleprecision floating point number inside the Interpreter, but a decimal point is not required in the
file. All of the parameters shown in Table 9.4 are required parameters and must be included in any
parameter file, except that any parameter representing a rotational axis value for an unused axis
may be omitted. An error will be signalled if any required parameter is missing. A parameter file
may include any other parameter, as long as its number is in the range 1 to 5400. The parameter
numbers must be arranged in ascending order. An error will be signalled if not. Any parameter
included in the file read by the Interpreter will be included in the file it writes as it exits. The
original file is saved as a backup file when the new file is written. Comments are not preserved
when the file is written.
Table 9.4: Parameter File Format
Parameter NumberParameter ValueComment
51610.0G28 Home X
51620.0G28 Home Y
62
Page 76
Chapter 10
Coordinate System
10.1Introduction
You have seen how handy a tool length offset can be. Having this allows the programmer to ignore
the actual tool length when writing a part program. In the same way, it is really nice to be able to
find a prominent part of a casting or block of material and work a program from that point rather
than having to take account of the location at which the casting or block will be held during the
machining.
This chapter introduces you to offsets as they are used by the EMC. These include;
• machine coordinates (G53)
• nine fixture offsets (G54-G59.3)
• global offsets (G92)
10.2The Machine Position Command (G53)
Regardless of any offsets that may be in effect, putting a G53 in a block of code tells the interpreter
to go to the real or absolute axis positions commanded in the block. For example
g53 g0 x0 y0 z0
will get you to the actual position where these three axes are zero. You might use a command like
this if you have a favorite position for tool changes or if your machine has an auto tool changer. You
might also use this command to get the tool out of the way so that you can rotate or change a part
in a vice.
G53 is not a modal command. It must be used on each line where motion based upon absolute
machine position is desired.
63
Page 77
EMC V2.4 User ManualChapter 10. Coordinate System
10.3Fixture Offsets (G54-G59.3)
Figure 10.1: Fixture Offsets
Work or fixture offset are used to make a part home that is different from the absolute, machine
coordinate system. This allows the part programmer to set up home positions for multiple parts. A
typical operation that uses fixture offsets would be to mill multiple copies of parts on multiple part
holders or vises.
The values for offsets are stored in the VAR file that is requested by the INI file during the startup
of an EMC. In our example below we’ll use G55. The values for each axis for G55 are stored as
variable numbers.
52410.000000
52420.000000
52430.000000
52440.000000
52450.000000
52460.000000
In the VAR file scheme, the first variable number stores the X offset, the second the Y offset and so
on for all six axes. There are numbered sets like this for each of the fixture offsets.
Each of the graphical interfaces has a way to set values for these offsets. You can also set these
values by editing the VAR file itself and then restarting EMC so that the EMC reads the new values
however this is not the recommended way. G10, G92, G28.1, etc are better ways to affect variables.
For our example let’s directly edit the file so that G55 takes on the following values.
52412.000000
52421.000000
5243 -2.000000
52440.000000
52450.000000
52460.000000
64
Page 78
EMC V2.4 User ManualChapter 10. Coordinate System
You should read this as moving the zero positions of G55 to X = 2 units, Y= 1 unit, and Z = -2 units
away from the absolute zero position.
Once there are values assigned, a call to G55 in a program block would shift the zero reference by
the values stored. The following line would then move each axis to the new zero position. Unlike
G53, G54 through G59.3 are modal commands. They will act on all blocks of code after one of
them has been set. The program that might be run using figure 10.1 would require only a single
coordinate reference for each of the locations and all of the work to be done there. The following
code is offered as an example of making a square using the G55 offsets that we set above.
"But," you say, "why is there a G54 in there near the end." Many programmers leave the G54
coordinate system with all zero values so that there is a modal code for the absolute machine based
axis positions. This program assumes that we have done that and use the ending command as a
command to machine zero. It would have been possible to use g53 and arrive at the same place but
that command would not have been modal and any commands issued after it would have returned
to using the G55 offsets because that coordinate system would still be in effect.
G54use preset work coordinate system 1
G55use preset work coordinate system 2
G56use preset work coordinate system 3
G57use preset work coordinate system 4
G58use preset work coordinate system 5
G59use preset work coordinate system 6
G59.1 use preset work coordinate system 7
G59.2 use preset work coordinate system 8
G59.3 use preset work coordinate system 9
10.3.1Default coordinate system
One other variable in the VAR file becomes important when we think about offset systems. This
variable is named 5220. In the default files its value is set to 1.00000. This means that when the
EMC starts up it should use the first coordinate system as its default. If you set this to 9.00000
it would use the ninth offset system as its default for start up and reset. Any value other than an
integer (decimal really) between 1 and 9, or a missing 5220 variable will cause the EMC to revert to
the default value of 1.00000 on start up.
10.3.2Setting coordinate system values within G-code.
In the general programming chapter we listed a G10 command word. This command can be used
to change the values of the offsets in a coordinate system. (add here)
65
Page 79
EMC V2.4 User ManualChapter 10. Coordinate System
10.4G92 Offsets
The way that it works has changed just a bit from the early days to the current releases. It should
be thought of as a temporary offset that is applied to all other offsets.
10.4.1The G92 commands
This set of commands include;
G92 This command, when used with axis names, sets values to offset variables.
G92.1 This command sets zero values to the g92 variables.
G92.2 This command suspends but does not zero out the g92 variables.
G92.3 This command applies offset values that have been suspended.
When the commands are used as described above, they will work pretty much as you would expect.
A user must understand the correct ways that the g92 values work. They are set based
upon the location of each axis when the g92 command is invoked. The NIST document
is clear that, "To make the current point have the coordinates" x0, y0, and z0 you would
use g92 x0 y0 z0. G92 does not work from absolute machine coordinates. It works from
current location.
G92 also works from current location as modified by any other offsets that are in effect
when the g92 command is invoked. While testing for differences between work offsets
and actual offsets it was found that a g54 offset could cancel out a g92 and thus give
the appearance that no offsets were in effect. However, the g92 was still in effect for all
coordinates and did produce expected work offsets for the other coordinate systems.
It is likely that the absence of home switches and proper home procedures will result in
very large errors in the application of g92 values if they exist in the var file. Many EMC
users do not have home switches in place on their machines. For them home should be
found by moving each axis to a location and issuing the home command. When each
axis is in a known location, the home command will recalculate how the g92 values are
applied and will produce consistent results. Without a home sequence, the values are
applied to the position of the machine when the EMC begins to run.
10.4.2Setting G92 values
There are at least two ways to set G92 values.
• right mouse click on position displays of tkemc will popup a window into which you can type
a value.
• the g92 command
Both of these work from the current location of the axis to which the offset is to be applied.
Issuing g92 x y z a b c does in fact set values to the g92 variables such that each axis
takes on the value associated with its name. These values are assigned to the current
position of the machine axis. These results satisfy paragraphs one and two of the NIST
document.
G92 commands work from current axis location and add and subtract correctly to give
the current axis position the value assigned by the g92 command. The effects work even
though previous offsets are in.
66
Page 80
EMC V2.4 User ManualChapter 10. Coordinate System
So if the X axis is currently showing 2.0000 as its position a G92 x0 will set an offset of -2.0000 so
that the current location of X becomes zero. A G92 X2 will set an offset of 0.0000 and the displayed
position will not change. A G92 X5.0000 will set an offset of 3.0000 so that the current displayed
position becomes 5.0000.
10.4.3G92 Cautions
Sometimes the values of a G92 offset will remain in the VAR file. This can happen when a file is
aborted during processing that has G92 offsets in effect. When this happens reset or a startup will
cause them to become active again. The variables are named
where 5211 is the X axis offset and so on. If you are seeing unexpected positions as the result of
a commanded move, as a result of storing an offset in a previous progam and not clearing them at
the end then issue a G92.1 in the MDI widow to clear the stored offsets.
If G92 values exist in the VAR file when the EMC starts up the g92 values in the var file is that it
will apply the values to current location of each axis. If this is home position and home position is
set as machine zero everything will be correct. Once home has been established using real machine
switches or moving each axis to a known home position and issuing an axis home command any
G92 offsets will be applied. If you have a G92 X1 in effect when you home the X axis the DRO
will read "X: 1.000" instead of the expected "X: 0.000" because the G92 was applied to the machine
origin. If you issue a G92.1 and the DRO now reads all zeros then you had a G92 offset in effect
when you last ran EMC.
Unless your intention is to use the same G92 offsets in the next program best practice is to issue a
G92.1 at the end of any G Code files where you use G92 offsets.
10.5Sample Program Using Offsets
This sample engraving project mills a set of four .1 radius circles in roughly a star shape around a
center circle. We can setup the individual circle pattern like this.
G10 L2 P1 x0 y0 z0 (ensure that g54 is set to machine zero)
g0 x-.1 y0 z0
g1 f1 z-.25
g3 x-.1 y0 i.1 j0
g0 z0
m2
We can issue a set of commands to create offsets for the four other circles like this.
G10 L2 P2 x0.5 (offsets g55 x value by 0.5 inch)
G10 L2 P3 x-0.5 (offsets g56 x value by -0.5 inch)
G10 L2 P4 y0.5 (offsets g57 y value by 0.5 inch)
G10 L2 P5 y-0.5 (offsets g58 y value by -0.5 inch)
67
Page 81
EMC V2.4 User ManualChapter 10. Coordinate System
We put these together in the following program.
(a program for milling five small circles in a diamond shape)
G10 L2 P1 x0 y0 z0 (ensure that g54 is machine zero)
G10 L2 P2 x0.5 (offsets g55 x value by 0.5 inch)
G10 L2 P3 x-0.5 (offsets g56 x value by -0.5 inch)
G10 L2 P4 y0.5 (offsets g57 y value by 0.5 inch)
G10 L2 P5 y-0.5 (offsets g58 y value by -0.5 inch)
g54 g0 x-.1 y0 z0 (center circle)
g1 f1 z-.25
g3 x-.1 y0 i.1 j0
g0 z0
g55 g0 x-.1 y0 z0 (first offset circle)
g1 f1 z-.25
g3 x-.1 y0 i.1 j0
g0 z0
g56 g0 x-.1 y0 z0 (second offset circle)
g1 f1 z-.25
g3 x-.1 y0 i.1 j0
g0 z0
g57 g0 x-.1 y0 z0 (third offset circle)
g1 f1 z-.25
g3 x-.1 y0 i.1 j0
g0 z0
g58 g0 x-.1 y0 z0 (fourth offset circle)
g1 f1 z-.25
g3 x-.1 y0 i.1 j0
g54 g0 x0 y0 z0
m2
Now comes the time when we might apply a set of G92 offsets to this program. You’ll see that it is
running in each case at z0. If the mill were at the zero position, a g92 z1.0000 issued at the head
of the program would shift everything down an inch. You might also shift the whole pattern around
in the XY plane by adding some x and y offsets with g92. If you do this you should add a G92.1
command just before the m2 that ends the program. If you do not, other programs that you might
run after this one will also use that g92 offset. Furthermore it would save the g92 values when you
shut down the EMC and they will be recalled when you start up again.
68
Page 82
Chapter 11
Tool Compensation
11.1Tool Length Offsets
11.1.1Touch Off
Using the Touch Off Screen in the AXIS interface you can update the tool table automatically.
Typical steps for updating the tool table:
1. After homing load a tool with "TnM6" where "n" is the tool number.
2. Move tool to an extablished point using a gauge or take a test cut and measure.
3. Select "Tool Table" in the Coordinate System drop down box.
4. Enter the gauge or measured dimension and select OK.
The Tool Table will be changed with the correct Z length to make the DRO display the correct Z
position and a G43 command will be issued so the new tool Z length will be in effect. Tool table
touch off is only available when a tool is loaded with "TnM6".
Figure 11.1: Touch Off Tool Table
11.1.2Using G10 L1
By using "G10 L1 Pn Zx" where "n" is the tool number and "x" is the offset from the MDI window or
in your program you can also set the tool table.
69
Page 83
EMC V2.4 User ManualChapter 11. Tool Compensation
11.2Tool Table
The "Tool Table" is a text file that contains information about each tool. The file is located in the
same directory as your configuration and is called "tool.tbl". The tools might be in a tool changer or
just changed manually. The file can be edited with a text editor or be updated using G10 L1. See
the Lathe Specifics Section for lathe tool table example. The maximum number of entries in the tool
table is 56. The maximum tool and pocket number is 99999.
T1P1D0.125000Z+0.511000;1/8” End Mill
T2P2D0.062500Z+0.100000;1/16” End Mill
T99999P99999D23.75000Z-0.3000000;You have a lot of tools
In general new tool table line format is:
• T - integer tool number
• P - integer pocket number
• D - float tool diameter
• X..W - float tool length offset on specified axis
• I - float front angle (lathe tools)
• J - float back angle (lathe tools)
• Q - int tool orientation (lathe)
• ; - begin of comment
Table 11.1: Mill Format Tool File
11.2.1Tool Changers
EMC supports three types of tool changers "manual", "random location" and "fixed location". Information about configuring an EMC tool changer is in the Integrators Manual.
Manual Tool Changer
Manual tool changer (you change the tool by hand) is treated like a fixed location tool changer and
the P number is ignored. Using the manual tool changer only makes sense if you have tool holders
that remain with the tool (Cat, NMTB, Kwik Switch etc.) when changed thus preserving the location
of the tool to the spindle. Machines with R-8 or router collet type tool holders do not preserve the
location of the tool and the manual tool changer should not be used.
Fixed Location Tool Changers
Fixed location tool changers like lathe turrets the tools are in a fixed position in the tool changer.
When EMC is configured for a fixed location tool changer the "P" number is ignored (but read,
preserved and rewritten) by EMC, so you can use P for any bookkeeping number you want.
Random Location Tool Changers
Random location tool changers swaps the tool in the spindle with the one in the changer. This type
of tool changer the tool location will always be in a different pocket after a tool change. When a
tool is changed EMC rewrites the pocket number to keep track of where the tool are. T can be any
number but P must be a number that makes sense for the machine.
70
Page 84
EMC V2.4 User ManualChapter 11. Tool Compensation
11.3Cutter Radius Compensation
Cutter Radius Compensation allows the programmer to program the tool path without knowing the
exact tool diameter. The only caveat is the programmer must program the lead in move to be at
least as long as the largest tool radius that might be used.
There are two possible paths the cutter can take while cutter radius compensation is on to the left
or right side of a line when facing the direction of cutter motion from behind the cutter. To visualize
this imagine you were standing on the part walking behind the tool as it progresses across the part.
G41 is your left side of the line and G42 is the right side of the line.
The end point of each move depends on the next move. If the next move creates an outside corner
the move will be to the end point of the compensated cut line. If the next move creates in an
inside corner the move will stop short so to not gouge the part. The following figure shows how the
compensated move will stop at different points depending on the next move.
Figure 11.2: Compensation End Point
11.3.1Overview
Tool Table
Cutter radius compensation uses the data from the tool table to determine the offset needed. The
data can be set at run time with G10 L1.
71
Page 85
EMC V2.4 User ManualChapter 11. Tool Compensation
Programming Entry Moves
Any move that is long enough to perform the compensation will work as the entry move. The
minimum lenght is the cutter radius. This can be a rapid move above the work piece. If several
rapid moves are issued after a G41/42 only the last one will move the tool to the compensated
position.
In the following figure you can see that the entry move is compensated to the right of the line. This
puts the center of the tool to the right of X0 in this case. If you were to program a profile and the
end is at X0 the resulting profile would leave a bump due to the offset of the entry move.
Figure 11.3: Entry Move
Z Motion
Z axis motion may take place while the contour is being followed in the XY plane. Portions of the
contour may be skipped by retracting the Z axis above the part and by extending the Z-axis at the
next start point.
Rapid Moves
Rapid moves may be programed while compensation is turned on.
Good Practices
• Start a program with G40 to make sure compensation is off.
72
Page 86
EMC V2.4 User ManualChapter 11. Tool Compensation
11.3.2Examples
11.3.2.1 Outside Profile
Figure 11.4: Outside Profile
11.3.2.2 Inside Profile
73
Page 87
EMC V2.4 User ManualChapter 11. Tool Compensation
Figure 11.5: Inside Profile
74
Page 88
Chapter 12
G Code Overview
The EMC2 G Code language is based on the RS274/NGC language. The G Code language is based
on lines of code. Each line (also called a "block") may include commands to do several different
things. Lines of code may be collected in a file to make a program.
A typical line of code consists of an optional line number at the beginning followed by one or more
"words". A word consists of a letter followed by a number (or something that evaluates to a number).
A word may either give a command or provide an argument to a command. For example, "G1 X3"
is a valid line of code with two words. "G1" is a command meaning "move in a straight line at the
programmed feed rate to the programmed end point", and "X3" provides an argument value (the
value of X should be 3 at the end of the move). Most EMC2 G Code commands start with either G
or M (for General and Miscellaneous). The words for these commands are called "G codes" and "M
codes."
The EMC2 language has no indicator for the start of a program. The Interpreter, however, deals with
files. A single program may be in a single file, or a program may be spread across several files. A file
may demarcated with percents in the following way. The first non-blank line of a file may contain
nothing but a percent sign, "%", possibly surrounded by white space, and later in the file (normally
at the end of the file) there may be a similar line. Demarcating a file with percents is optional if the
file has an M2 or M30 in it, but is required if not. An error will be signalled if a file has a percent line
at the beginning but not at the end. The useful contents of a file demarcated by percents stop after
the second percent line. Anything after that is ignored.
The EMC2 G Code language has two commands (M2 or M30), either of which ends a program. A
program may end before the end of a file. Lines of a file that occur after the end of a program are
not to be executed. The interpreter does not even read them.
12.1Format of a line
A permissible line of input code consists of the following, in order, with the restriction that there is
a maximum (currently 256) to the number of characters allowed on a line.
1. an optional block delete character, which is a slash "/" .
2. an optional line number.
3. any number of words, parameter settings, and comments.
4. an end of line marker (carriage return or line feed or both).
Any input not explicitly allowed is illegal and will cause the Interpreter to signal an error.
75
Page 89
EMC V2.4 User ManualChapter 12. G Code Overview
Spaces and tabs are allowed anywhere on a line of code and do not change the meaning of the line,
except inside comments. This makes some strange-looking input legal. The line "G0X +0.12 34Y7" is equivalent to "G0 x+0.1234 Y7", for example.
Blank lines are allowed in the input. They are to be ignored.
Input is case insensitive, except in comments, i.e., any letter outside a comment may be in upper
or lower case without changing the meaning of a line.
12.2Line Number
A line number is the letter N followed by an integer (with no sign) between 0 and 99999 written with
no more than five digits (000009 is not OK, for example). Line numbers may be repeated or used
out of order, although normal practice is to avoid such usage. Line numbers may also be skipped,
and that is normal practice. A line number is not required to be used, but must be in the proper
place if used.
12.3Word
A word is a letter other than N followed by a real value.
Words may begin with any of the letters shown in Table 12.1. The table includes N for completeness,
even though, as defined above, line numbers are not words. Several letters (I, J, K, L, P, R) may
have different meanings in different contexts. Letters which refer to axis names are not valid on a
machine which does not have the corresponding axis.
Table 12.1: Words and their meanings
LetterMeaning
AA axis of machine
BB axis of machine
CC axis of machine
DTool radius compensation number
FFeed rate
GGeneral function (See table 12.4)
HTool length offset index
IX offset for arcs and G87 canned cycles
JY offset for arcs and G87 canned cycles
KZ offset for arcs and G87 canned cycles.
Spindle-Motion Ratio for G33 synchronized movements.
MMiscellaneous function (See table 12.4)
NLine number
PDwell time in canned cycles and with G4.
Key used with G10.
QFeed increment in G73, G83 canned cycles
RArc radius or canned cycle plane
SSpindle speed
TTool selection
UU axis of machine
VV axis of machine
WW axis of machine
XX axis of machine
YY axis of machine
ZZ axis of machine
76
Page 90
EMC V2.4 User ManualChapter 12. G Code Overview
12.4Number
The following rules are used for (explicit) numbers. In these rules a digit is a single character
between 0 and 9.
• A number consists of (1) an optional plus or minus sign, followed by (2) zero to many digits,
followed, possibly, by (3) one decimal point, followed by (4) zero to many digits - provided that
there is at least one digit somewhere in the number.
• There are two kinds of numbers: integers and decimals. An integer does not have a decimal
point in it; a decimal does.
• Numbers may have any number of digits, subject to the limitation on line length. Only about
seventeen significant figures will be retained, however (enough for all known applications).
• A non-zero number with no sign as the first character is assumed to be positive.
Notice that initial (before the decimal point and the first non-zero digit) and trailing (after the decimal
point and the last non-zero digit) zeros are allowed but not required. A number written with initial
or trailing zeros will have the same value when it is read as if the extra zeros were not there.
Numbers used for specific purposes in RS274/NGC are often restricted to some finite set of values
or some to some range of values. In many uses, decimal numbers must be close to integers; this
includes the values of indexes (for parameters and carousel slot numbers, for example), M codes,
and G codes multiplied by ten. A decimal number which is supposed be close to an integer is
considered close enough if it is within 0.0001 of an integer.
12.5Numbered Parameters
A numbered parameter is the pound character # followed by an integer between 1 and 5399. The
parameter is referred to by this integer, and its value is whatever number is stored in the parameter.
A value is stored in a parameter with the = operator; for example "#3 = 15" means "set parameter
3 to 15." A parameter setting does not take effect until after all parameter values on the same line
have been found. For example, if parameter 3 has been previously set to 15 and the line "#3=6G1 x#3" is interpreted, a straight move to a point where x equals 15 will occur and the value of
parameter 3 will be 6.
The # character takes precedence over other operations, so that, for example, "#1+2" means the
number found by adding 2 to the value of parameter 1, not the value found in parameter 3. Of
course, #[1+2] does mean the value found in parameter 3. The # character may be repeated; for
example ##2 means the value of the parameter whose index is the (integer) value of parameter 2.
The interpreter maintains a number of readonly parameters for a loaded tool:
• #5400 tool number
• #5401 tool x offset
• #5402 tool y offset
• #5403 tool z offset
• #5404 tool a offset
• #5405 tool b offset
• #5406 tool c offset
• #5407 tool u offset
77
Page 91
EMC V2.4 User ManualChapter 12. G Code Overview
• #5408 tool v offset
• #5409 tool w offset
• #5410 tool diameter
• #5411 tool frontangle
• #5412 tool backangle
• #5413 tool orientation
12.6Named Parameters
Named parameters work like numbered parameters but are easier to read. All parameter names are
converted to lower case and have spaces and tabs removed. Named parameters must be enclosed
with < > marks.
#<named parameter here> is a local named parameter. By default, a named parameter is local
to the scope in which it is assigned. You can’t access a local parameter outside of its subroutine this is so that two subroutines can use the same parameter names without fear of one subroutine
overwriting the values in another.
#<_global named parameter here> is a global named parameter. They are accessible from within
called subroutines and may set values within subroutines that are accessible to the caller. As far
as scope is concerned, they act just like regular numeric parameters. They are not stored in files.
Examples:
• Declaration of named global variable
#<_endmill_dia> = 0.049
• Reference to previously declared global variable
The global parameters _a, _b, _c, ... _z have been reserved for special use. In the future, they may
provide access to the last Aword, Bword, Cword, etc.
12.7Expressions
An expression is a set of characters starting with a left bracket [ and ending with a balancing right
bracket ]. In between the brackets are numbers, parameter values, mathematical operations, and
other expressions. An expression is evaluated to produce a number. The expressions on a line
are evaluated when the line is read, before anything on the line is executed. An example of an
expression is [1 + acos[0] - [#3
[4.0/2]]].
**
78
Page 92
EMC V2.4 User ManualChapter 12. G Code Overview
12.8Binary Operators
Binary operators only appear inside expressions. There are four basic mathematical operations:
addition (+), subtraction (-), multiplication (*), and division (/). There are three logical operations:
non-exclusive or (OR), exclusive or (XOR), and logical and (AND). The eighth operation is the modulus
operation (MOD). The ninth operation is the "power" operation (**) of raising the number on the left
of the operation to the power on the right. The relational operators are equality (EQ), inequality (NE),
strictly greater than (GT), greater than or equal to (GE), strictly less than (LT), and less than or equal
to (LE).
The binary operations are divided into several groups according to their precedence. (see table 12.2)
If operations in different precedence groups are strung together (for example in the expression [2.0/ 3*1.5 - 5.5 / 11.0]), operations in a higher group are to be performed before operations in
a lower group. If an expression contains more than one operation from the same group (such as
the first / and*in the example), the operation on the left is performed first. Thus, the example is
equivalent to: [[[2.0 / 3]*1.5] - [5.5 / 11.0]] , which is equivalent to to [1.0 - 0.5] ,
which is 0.5.
The logical operations and modulus are to be performed on any real numbers, not just on integers.
The number zero is equivalent to logical false, and any non-zero number is equivalent to logical
true.
Table 12.2: Operator Precedence
OperatorsPrecedence
**highest
* / MOD
+ -
EQ NE GT GE LT LE
AND OR XORlowest
12.9Functions
A function is either "ATAN" followed by one expression divided by another expression (for example
"ATAN[2]/[1+3]") or any other function name followed by an expression (for example "SIN[90]").
The available functions are shown in table 12.3. Arguments to unary operations which take angle
measures (COS, SIN, and TAN) are in degrees. Values returned by unary operations which return
angle measures (ACOS, ASIN, and ATAN) are also in degrees.
The FIX operation rounds towards the left (less positive or more negative) on a number line, so that
FIX[2.8] =2 and FIX[-2.8] = -3, for example. The FUP operation rounds towards the right (more
positive or less negative) on a number line; FUP[2.8] = 3 and FUP[-2.8] = -2, for example.
79
Page 93
EMC V2.4 User ManualChapter 12. G Code Overview
Function NameFunction result
ATAN[Y]/[X]Four quadrant inverse tangent
ABS[arg]Absolute value
ACOS[arg]Inverse cosine
ASIN[arg]Inverse sine
COS[arg]Cosine
EXP[arg]e raised to the given power
FIX[arg]Round down to integer
FUP[arg]Round up to integer
ROUND[arg]Round to nearest integer
LN[arg]Base-e logarithm
SIN[arg]Sine
SQRT[arg]Square Root
TAN[arg]Tangent
Table 12.3: Functions
12.10Repeated Items
A line may have any number of G words, but two G words from the same modal group (see Section
12.13) may not appear on the same line.
A line may have zero to four M words. Two M words from the same modal group may not appear on
the same line.
For all other legal letters, a line may have only one word beginning with that letter.
If a parameter setting of the same parameter is repeated on a line, "#3=15 #3=6", for example, only
the last setting will take effect. It is silly, but not illegal, to set the same parameter twice on the
same line.
If more than one comment appears on a line, only the last one will be used; each of the other
comments will be read and its format will be checked, but it will be ignored thereafter. It is expected
that putting more than one comment on a line will be very rare.
12.11Item order
The three types of item whose order may vary on a line (as given at the beginning of this section)
are word, parameter setting, and comment. Imagine that these three types of item are divided into
three groups by type.
The first group (the words) may be reordered in any way without changing the meaning of the line.
If the second group (the parameter settings) is reordered, there will be no change in the meaning of
the line unless the same parameter is set more than once. In this case, only the last setting of the
parameter will take effect. For example, after the line “#3=15 #3=6” has been interpreted, the value
of parameter 3 will be 6. If the order is reversed to “#3=6 #3=15” and the line is interpreted, the
value of parameter 3 will be 15.
If the third group (the comments) contains more than one comment and is reordered, only the last
comment will be used.
If each group is kept in order or reordered without changing the meaning of the line, then the three
groups may be interleaved in any way without changing the meaning of the line. For example, the
line “g40 g1 #3=15 (foo) #4=-7.0” has five items and means exactly the same thing in any of
the 120 possible orders (such as “#4=-7.0 g1 #3=15 g40 (foo)”) for the five items.
80
Page 94
EMC V2.4 User ManualChapter 12. G Code Overview
12.12Commands and Machine Modes
Many commands cause the controller to change from one mode to another, and the mode stays
active until some other command changes it implicitly or explicitly. Such commands are called
"modal". For example, if coolant is turned on, it stays on until it is explicitly turned off. The G codes
for motion are also modal. If a G1 (straight move) command is given on one line, for example, it
will be executed again on the next line if one or more axis words is available on the line, unless an
explicit command is given on that next line using the axis words or cancelling motion.
"Non-modal" codes have effect only on the lines on which they occur. For example, G4 (dwell) is
non-modal.
12.13Modal Groups
Modal commands are arranged in sets called "modal groups", and only one member of a modal
group may be in force at any given time. In general, a modal group contains commands for which
it is logically impossible for two members to be in effect at the same time - like measure in inches
vs. measure in millimeters. A machining center may be in many modes at the same time, with one
mode from each modal group being in effect. The modal groups are shown in Table 12.4.
Table 12.4: Modal Groups
Modal Group MeaningMember Words
Motion ("Group 1")G0 G1 G2 G3 G33 G38.x G73 G76 G80 G81
M7 and M8 may be active at the same time
Override SwitchesM48, M49
Flow ControlONon-modal codes (“Group 0”)G4, G10 G28, G30, G53
G92, G92.1, G92.2, G92.3
M100 to M199
For several modal groups, when a machining center is ready to accept commands, one member of
the group must be in effect. There are default settings for these modal groups. When the machining
center is turned on or otherwise re-initialized, the default values are automatically in effect.
Group 1, the first group on the table, is a group of G codes for motion. One of these is always in
effect. That one is called the current motion mode.
It is an error to put a G-code from group 1 and a G-code from group 0 on the same line if both of
them use axis words. If an axis word-using G-code from group 1 is implicitly in effect on a line (by
81
Page 95
EMC V2.4 User ManualChapter 12. G Code Overview
having been activated on an earlier line), and a group 0 G-code that uses axis words appears on
the line, the activity of the group 1 G-code is suspended for that line. The axis word-using G-codes
from group 0 are G10, G28, G30, and G92.
It is an error to include any unrelated words on a line with O- flow control.
12.14Comments
Comments can be added to lines of G code to help clear up the intention of the programmer. Comments can be embedded in a line using parentheses () or for the remainder of a line using a semicolon. The semi-colon is not treated as the start of a comment when enclosed in parentheses.
G0 (Rapid to start) X1 Y1
G0 X1 Y1 (Rapid to start; but don’t forget the coolant)
M2 ; End of program.
12.15File Size
The interpreter and task are carefully written so that the only limit on part program size is disk
capacity. The TkEMC and Axis interface both load the program text to display it to the user, though,
so RAM becomes a limiting factor. In Axis, because the preview plot is drawn by default, the redraw
time also becomes a practical limit on program size. The preview can be turned off in Axis to speed
up loading large part programs. In Axis sections of the preview can be turned off using special
comments.
82
Page 96
Chapter 13
G Code Order of Execution
The order of execution of items on a line is defined not by the position of each item on the line, but
by the following list:
1. Comment (including message)
2. Set feed rate mode (G93, G94).
3. Set feed rate (F).
4. Set spindle speed (S).
5. Select tool (T).
6. Change tool (M6).
7. Spindle on or off (M3, M4, M5).
8. Coolant on or off (M7, M8, M9).
9. Enable or disable overrides (M48, M49).
10. Dwell (G4).
11. Set active plane (G17, G18, G19).
12. Set length units (G20, G21).
13. Cutter radius compensation on or off (G40, G41, G42)
14. Cutter length compensation on or off (G43, G49)
19. Go to reference location (G28, G30) or change coordinate system data (G10) or set axis offsets
(G92, G92.1, G92.2, G94).
20. Perform motion (G0 to G3, G33, G73, G76, G80 to G89), as modified (possibly) by G53.
21. Stop (M0, M1, M2, M30, M60).
83
Page 97
Chapter 14
G Code Best Practices
Use an appropriate decimal precision
Use at least 3 digits after the decimal when milling in millimeters, and at least 4 digits after the
decimal when milling in inches.
Use consistent white space
G-code is most legible when at least one space appears before words. While it is permitted to insert
white space in the middle of numbers, there is no reason to do so.
Use "Center-format" arcs
Center-format arcs (which use I- J- K- instead of R-) behave more consistently than R-format
arcs, particularly for included angles near 180 or 360 degrees.
Put important modal settings at the top of the file
When correct execution of your program depends on modal settings, be sure to set them at the
beginning of the part program. Modes can carry over from previous programs and from the MDI
commands.
As a good preventative measure, put a line similar to the following at the top of all your programs:
G17 G20 G40 G49 G54 G80 G90 G94
(XY plane, inch mode, cancel diameter compensation, cancel length offset, coordinate system 1,
cancel motion, non-incremental motion, feed/minute mode)
Perhaps the most critical modal setting is the distance units–If you do not include G20 or G21, then
different machines will mill the program at different scales. Other settings, such as the return mode
in canned cycles may also be important.
Don’t put too many things on one line
Ignore everything in Section 13, and instead write no line of code that is the slightest bit ambiguous.
84
Page 98
EMC V2.4 User ManualChapter 14. G Code Best Practices
Don’t set & use a parameter on the same line
Don’t use and set a parameter on the same line, even though the semantics are well defined.
Updating a variable to a new value, such as #1=[#1+#2] is ok.
Don’t use line numbers
Line numbers offer no benefits. When line numbers are reported in error messages, the numbers
refer to the line number in the file, not the N-word value.
When moving more than one coordinate system, consider inverse
time feed mode
Because the meaning of an F-word in feed-per -minute mode varies depending on which axes are
commanded to move, and because the amount of material removed does not depend only on the
feed rate, it may be easier to use G93 inverse time feed mode to achieve the desired material removal
rate.
85
Page 99
Chapter 15
G Code Reference
Conventions used in this section
In the G Code prototypes the hyphen (-) stands for a real value.
A real value may be :
• An explicit number, 4
• An expression, [2+2]
• A parameter value, #88
• A unary function value, acos[0]
In most cases, if axis words (any or all of X-, Y-, Z-, A-, B-, C-, U-, V-, W-) are given, they specify a
destination point.
Axis numbers are in the currently active coordinate system, unless explicitly described as being in
the absolute coordinate system. Where axis words are optional, any omitted axes will have their
current value.
Any items in the G Code prototypes not explicitly described as optional are required.
The values following letters are often given as explicit numbers. Unless stated otherwise, the explicit
numbers can be real values. For example, G10 L2 could equally well be written G[2*5] L[1+1]. If
the value of parameter 100 were 2, G10 L#100 would also mean the same.
If L- is written in a prototype the "-" will often be referred to as the "L number", and so on for any
other letter.
15.1Polar Coordinates
Polar Coordinates can be used to specify the XY coordinate of a move. The @n is the distance and
^n is the angle. The advantage of this is for things like bolt hole circles which can be done very
simply by moving to a point in the center of the circle, setting the offset and then moving out to the
first hole then run the drill cycle. Polar Coordinates always are from the current XY zero position.
To shift the Polar Coordinates from machine zero use an offset or select a coordinate system.
In Absolute Mode the distance and angle is from the XY zero position and the angle starts with 0
on the X Positive axis and rotates in a CCW direction about the Z axis. The code G1 @1^90 is the
same as G1 Y1.
In Relative Mode the distance and angle is also from the XY zero position but it is cumulative. This
can be confusing at first how this works in incremental mode.
For example if you have the following program you might expect it to be a square pattern.
You can see from the following figure that the output is not what you might expect. Because we
added .5 to the distance each time the distance from the XY zero position increased with each line.
Figure 15.1: Polar Spiral
The following code will produce our square pattern.