Mach4 CNC Controller Config
Mach4 CNC Controller Config
1 Of 25
Copyright © 2014 Newfangled Solutions, Artsoft USA, All Rights Reserved
The following are registered trademarks of Microsoft Corporation: Microsoft, Windows. Any
other trademarks used in this manual are the property of the respective trademark holder.
Table of Contents
Chapter 1 Introduc on to CNC Systems.......................................................................................................4
Introduc on............................................................................................................................................4
Mach4 Layout.........................................................................................................................................5
Installa on..............................................................................................................................................6
Downloading...........................................................................................................................................6
Installing.................................................................................................................................................7
Se ng up the Profile..............................................................................................................................7
Configuring Plugins..............................................................................................................................11
Select Mo on device............................................................................................................................11
Other Plugins........................................................................................................................................12
2 Of 25
Motor Tuning........................................................................................................................................14
Velocity.................................................................................................................................................16
Accelera on..........................................................................................................................................17
Backlash................................................................................................................................................17
Reverse.................................................................................................................................................17
Enable Delay.........................................................................................................................................17
Axis Mapping........................................................................................................................................18
Home Order..........................................................................................................................................19
Home Offset.........................................................................................................................................19
Home Speed.........................................................................................................................................19
Home In Place.......................................................................................................................................20
So Enable............................................................................................................................................20
So Max / So Min...............................................................................................................................20
Signals in General.................................................................................................................................20
Input Signals.........................................................................................................................................23
Output Signals......................................................................................................................................24
Spindle..................................................................................................................................................26
Machine Limits.....................................................................................................................................27
3 Of 25
Chapter 1 Introduction to CNC Systems
This chapter introduces you to terminology used in the rest of this manual and explains the purpose
of the different components in a computer numerically controlled (CNC) system. CNC machines are in
many industries and becoming more popular in manufacturing lines. The tradi onal machine types are
Mills, Routers, Lathes and Plasma cu ers. The non tradi onal things that can be done with a CNC system
can be but not limited to laser measurement, pick and place, quil ng, assembly, laser cu ng, rapid
prototype, pain ng and so on. Because of the popularity of CNC's in non tradi onal CNC industries
Mach4 has been made to be extremely configurable and expandable. The ability to add and remove
modules will be covered in this manual but the screen and scrip ng customiza on will be covered in
their respec ve manuals.
Introduction
This document tells how to install and setup Mach4 mo on control so ware. The founda on of
Mach4 is the core called Mach4Core. Mach4Core can be setup in many configura ons for the following
machine configura ons general automa on, Mill, Router, Lathe, Plasma, Pick and Place, etc... A separate
document explains how to operate Mach4 with the specific machine types. The user interface has no
rela on to the core or mo on and/or IO devices used.
YOU WILL NEED TO READ THIS DOCUMENTATION! Mach4 is a very complex so ware package that
cannot be simply made "to work" without proper configura on. The install and play with the se ngs
approach may work for other so ware packages but this is not the case with Mach4. The me spent
reading the manual will save many hours of aggrava on and will result in a be er running machine. This
manual will give the steps in a logical order that must be followed.
Mach4 Layout
Mach4 is built on a central core called Mach4Core.dll and is what connects all the parts of Mach4
together. The following diagram (see Drawing 1) shows how all the components are connected:
4 Of 25
Mach4Core.dll
Sim.dll
3rd Party plugin Motion Simulation
plugin
All IO, Mo on and addon devices are plugins allowing them to be setup and configured in Mach4. The
plugins supplied by Newfangled Solu ons in the installer are added as appendixes to the end of this
document. Any plugins that are not being used should be removed from the system to lower the
overhead of Mach4 on the computer. Development partners of Newfangled Solu ons have access to
Mach4's SDK allowing them to manufacture plugins for other devices and/or func ons. The setup,
configura on, and any diagnos cs will not be covered in this manual for their devices.
If the machine is setup by an OEM or manufactured as a complete system, many if not all of the steps
in the following chapter may have already been done for you. The machine se ngs are all saved in the
profile directory with its own named directory. The named directories can be added and removed from
the profiles dialog but it is useful to know where the se ngs are. The named directory for each machine
contains all the machine se ngs in it's machine.ini file. The machine.ini file is backed up every me
mach4 is started so the user can roll back se ngs if there was an error made during so ware
5 Of 25
configura on. The other directories in the named profile directory contain the macros, tool table, fixture
table, ini backups, screw maps and so on. If a new computer is being setup to replace the an exis ng PC
with Mach4 a simple copy of the profile named directory can be done to move over all the machine
se ngs.
Installation
Mach4 is distributed by Newfangled Solu ons over the internet. The so ware is available as a single
installer from the web-page with a download size of about 17MB. A er install Mach4 will be in demo
mode with a limita on of how long Gcode will execute. The me the so ware can be run in demo is
about 20 min and then it will randomly stop in the middle of a run. Newfangled Solu ons recommends
that Mach4 is setup and tested before purchasing a license. Pricing and op ons are available at
www.machsupport.com .
Downloading
Download the installa on package from www.machsupport.com . Click on the download link and
save the self-installing file on the desktop or in a convenient folder. Mach4 needs to be install as
administrator, this can be done by right clicking on the self-installing file and telling it to “Run as
Administrator”. If installing in a remote loca on the installa on file can be saved and moved to a
machine that has no web access. The file will require a CD or USB drive to have adequate storage
volume.
Installing
This sec on will guide the process of installing Mach4 so ware. If Mach4 has been previously
installed on the machine, Mach4 can be installed on top of a previous installa on. There is no need to
uninstall before reinstalling.
If a machine is connected:
The machine that is connected to the computer should be set in a condi on that will not allow
mo on or IO to be triggered. If the machine can be disconnected please disconnect. If the machine
can't be disconnected please press the E-stop bu on to put the machine into an E-stop condi on.
6 Of 25
needs. The basic install will load the appropriate files needed for each machine type (Lathe. Mill and
Plasma).
A "Copy Profile" is very powerful as it will copy all the machine se ngs such as the tool data,
fixture data, ini backups, Macros, and all machine se ngs. This can be used later to make a test profile
to allow changes to be made without harming the running machine profile. The profile can be removed
a er tes ng is finished with the "Delete Profile" bu on. The profile se ngs can also be restored to a
previous session if a bad se ng has been made. The "Restore Backup" bu on (see Figure 1) will launch
the Restore Backup dialog (see Figure 2). The machine.ini can be selected by looking at the Date and
Time if the last known running configura on.
7 Of 25
Create Shortcut to Profile
A shortcut can be created to allow the an immediate launch of the so ware with a selected profile.
By adding the following " /p Mach4Mill" to the end of the target string (see Figure 3) allows
MachGUI.exe to load and immediately load the "Mach4Mill" profile.
Any other profile can be loaded by changing the profile name a er the /p in the target string.
8 Of 25
Chapter 3 Setting up the software
By the end of this chapter a typical machine should be setup and capable of mo on and IO (inputs and
outputs). In order to setup the machine the first step is to install all the plugins that you need for the
machine. Examples of plugins that may be needed could be Parallel Port and Modbus.
Note: If the so ware is locked the configura on se ngs may not be available. If the so ware is locked
non of the configura on dialogs will be available.
A plugin must be enabled to allow the plugin to func on. The so ware must be restarted a er enabling
or disabling to allow the plugin func on to change its state. To remove a plugin highlight the row of the
plugin and press the "Remove" bu on (see Figure 5).
9 Of 25
Configuring Plugins
The configura on of the plugins can be done from the "Configure Plugins" dialog (see Figure 5). Not
all plugins can be configured as they have no se ngs that can be customized. For the plugins that can be
configured a "configure" plugin bu on is available to the right of the plugin descrip on. When the
configure bu on is pressed it will launch the configura on dialog supplied by the Plugin author. The
configura on of the device must be done before the devices IO can be accessed or used by Mach4. The
configura on of the plugins incorporated in the installer will be covered in appendixes to this document.
All configura on se ngs can be found in the "Mach Configura on" dialog (see Figure 7). The following is
a descrip on of the se ngs that can be changed in the dialog (see Table 1).
Se ng Descrip on
Units Mode Inch G20 / G21 Millimeters, The default units the machine is setup in such as
Traverse Mode Rapid G00 / Feed G01
11 Of 25
Mo on Mode Exact Stop G61 / Constant Velocity G64
Number of lines the interpreter can chain together to get to the programmed
Look Ahead Lines
Feedrate
Distance Mode Absolute G90 / Incremental G91, Distance mode used by default
Absolute G90.1 / Incremental G91.1, Distance mode for the IJK circle centers. R
Arc Center Mode
type centers are not effected.
Feed Per Rev G95 / Feed Per Min G94, feed mode used by linear and arc feed
Feed Mode
moved. Feed per rev must have true spindle RPM to be used.
XY Plane G17 / XZ Plane G18 / YZ Plane G19, The plane selec on used for Drill
Ac ve Plane
cycles, Arcs and cu er comp
Ini al Z G98 / Rapid Plane G99, Selects the can cycle posi on for the moves in
Cycle Retract
the working axis. The working axis is perpendicular to the current ac ve plane.
Constant RPM G97 / Constance surface Speed G96, Selects the default spindle
Spindle Mode
speed mode.
The init codes are run when the program starts and also when the reset is
Ini aliza on Codes
pressed
Coolant Delay Time to wait for the Coolant to turn on
Mist Delay Time to wait for the Mist to turn on
Jog Increments Increments used for Incjog register
Gcode File The Gcode extensions for files to be executed. This sets the open able extensions
Extensions of the file open dialog.
Include Comments Enabling the selec on will add all comments in the Gcode file to the messages
in Message log.
Deref Axis In E-
stop Enabling sets the axis homing to be false when in E-stop is ac ve
Cycle Stop is Enabling will set the axis to do a controlled decelera on when a Cycle Stop is
Controlled Stop commanded. A very slight delay will be seen as the axis comes to a stop.
Table 1: General Se ngs
Motor Tuning
Motor tuning is one of the most important se ngs in configuring a machine. The se ngs available in
the motor tuning dialog (see Figure 8) will allow the motor to be setup for the appropriate Counts per
Unit, Max Velocity, Accelera on, Backlash, Direc on Reversal and delay for enable signal. A detailed
descrip on of each of the se ngs will be given in the following sec on.
Ou t p utG e a r
( )* C o u n t P e r R e v
I n put G ea r
=C o u n t s p e r I n c h
PitchDia
15
( )* 2000
40
=6971.67756C o u n t s P e r I n c h
. 765
Example 2: CNC Lathe with a lead screw
Lead of screw .25 inch Per Rev
Belt Reduc on 15 tooth (Input Gear), 30 tooth (Output Gear)
Servo drive with 5000 encoder counts per rev
13 Of 25
Ou t p utGe a r
( )* E n c o d e r C o u n t p e r R e v
I n put G ea r
=C o u n t s P e r I n c h
S cr ew P itc h
15
( )* 5000
30
=40,000 C o u n t s P e r I n c h
. 25
As a rule of thumb an inch machine should have the steps per unit greater then 5000 (200 for MM). A
value of 5000 will give a resolu on of .0002 inches. A greater number of steps per unit will give be er
performance as well as finer resolu on. The only issue with a very high count per unit is that the max
velocity can become limited. The mo on controller may only be able do deal with a limited number of
counts or steps per sec. Please check your mo on controllers documenta on to see get the max
frequency of the motors. If you would like to predict the max frequency this can also be done with
mathema cs.
M a xV el oci t y *C ou nt s P er U ni t
=O u t p u t F r e q u e n c y
60
In the next examples we will consider the max velocity to be 200 Inches per minute
Velocity
The Velocity in the dialog is the maximum rate in units per min. This is also the velocity that will be
used for rapid moves when running Gcode.
Se ng a Stepper:
On a stepper machine to set the max velocity a series of test need to be made. The Steps per Unit
must be set before the axis can be tested. Set a value of a max velocity that seems to be reasonable and
test with a jog at 100% jog rate. If the axis is able to move without missing steps (most mes you will
hear a “buzzing” or “squealing” sound when steps are missed, repeat this process un l the upper limit is
found. Once the max velocity is found the max velocity should then be set to 20% - 30% less. To insure
that there are no missed steps during mo on.
Se ng a Servo:
To set the max velocity of a servo machine a small series of tests can be preformed or it can be done
mathema cally with some calcula ons. When tes ng the max rate of a servo and the max velocity is
exceeded the servo may fault from being out of posi on (digital servo) or will not get to max velocity and
make an abrupt stop. If ether one of the following happen the velocity must be lowered un l the
behavior is fixed. Once the motor is fixed the velocity should be lowered by 5% to insure that the best
performance can be obtained.
14 Of 25
Acceleration
The max accelera on sets how quickly the motor can get to speed. The higher the accelera on the
faster the cu ng can be done. The higher the accelera on the quicker an axis can reverse and go around
corners. Cycle mes can be lowered by running higher accelera ons and lowering the max velocity. The
accelera on should not be raised to the point that it causes motor stalling, vibra on in the frame, or
other unwanted vibra on.
Backlash
Backlash is used to take out mechanical wind up in the drive system. The misconcep on is that
backlash can be used to fix “slop” in a screw/ ball-nut or slop in a rack and pinion. This can be used to
help fix the machine but is not the proper way to correct the problem. The only way to truly fix the issue
is to fix the mechanical issue. The backlash should never exceed .005 inches or .1 mm .
Reverse
The reverse sec on is used to reverse the mo on of the motor.
Enable Delay
Enable delay will allow a the enable signals to turn on with a delay. The delay can be used to stage the
enabling of the amps. This can be used to lower the inrush current by enabling the amps one by one.
Axis Mapping
The axis mapping dialog (see Figure 9) is used to set what motors are used for an axis as well as the
homing order and max limits for the axis. The motors can be assigned to an axis with a maximum of 6
motors per axis. The axis will use the lowest max velocity and the lowest accelera on. This is done to
allow slave motors to not have the same motor se ngs as the other motors associated to he axis. The
steps per unit also do not need to be the same for each motor that is part of the axis.
15 Of 25
Home Direction
This sets the direc on to home the axis (see Figure 10). Pos for homing in the posi ve direc on. Neg
for homing in the nega ve direc on.
Home Order
The sequence the axis home in can be controlled by se ng the “Home Order” (see Figure 10). The
first axis to home will be axis with the number 0 and then subsequent axis will home with the next
greatest home order value. For example, if you would like to home the Z axis first then the X and Y at the
same me the values would be as follows:
X=2
Y=2
Z=1
16 Of 25
to shi the home posi on if the home switch is not located at the end of travel.
Home Speed
The home speed is the rate the machine moves to detect the home switch (see Figure 10). The home
switch will set the machine zero posi on with the addi on of any home offset. The Home Speed is set as
a percentage of the max velocity of the axis. Example :
H om e S p ee d
M a x V el *( )=40U n i t s P e r M i n
100
20
200 * ( )=40 U n i t s P e r M i n
100
Home In Place
The Home in Place selec on tells the axis to set the machine zero where it is when a home axis is
requested (see Figure 10). This feature is used on machines that have no home switches or an axis that
has no home switch. On a machine with no home switches the axis can be moved to the end of the
travel and lined up with an indicator mark. With the machine at the home posi on the home can be
triggered for that axis se ng the machine posi on. This will allow the so limits to be used and fixture
offsets.
17 Of 25
Soft Enable
The state of the So Enable tells the core if the axis should be checked against the upper and lower
so limits (see Figure 10). With the so limits ac ve the axis will decelerate to the Max or Min limit if it
is jogging and will prevent any incremental jogs past the limits. When running Gcode any moves panned
past the limits will not be done and the machine will be put into a stop condi on and a so limit error
will be displayed.
Signals in General
The signals are used to represent the internal state of items needed by the controller or items needed
to trigger IO for special func ons. The signals can be triggered by Inputs, Outputs, Plugins, or Lua. When
a signal changes state, a state change event is propagated throughout the system and will be seen by all
plugins, and Lua event scripts. Later in the customiza on of Mach4 the u liza on of Mach4's signals will
be seen. In the sec on the setup of triggering IO with signals will be shown. When se ng up an IO point
the device's plugin must be first setup. A device could be a mo on controller, bussed IO (modbus), Input
device (keyboard), Special Func ons in plugins, etc.. The “Device” is the first selec on and displays all
the registered IO devices to the system (see Figure 11)
when the Input assigned to it changes state, and Outputs are triggered by their associated Output
signals. The high / low state can be inverted by selec ng the Ac ve low state.
19 Of 25
Input Signals
The input signals are used to connect Inputs from devices to Input Signals in the core. Some of the
most important signals are the Homing and Limit inputs. The Homing and Limits are set per motor NOT
per axis. The axis use motors to show what motors drive the axis and to display the state of the limits
and homes. As an example if Motor 1 and Motor 5 where used on the X axis and the + Limit was hit the X
axis would show posi ve limit as being ac ve. The inputs of the motors are or'ed to the axis states.
Below is a complete list of the Input signals (See Table 2).
20 Of 25
Output Signals
The output signals are used to e the device outputs to the output signals. The output signals can be
used to drive outputs directly for things such as Spindle outputs, Coolant, indicator lights on panels and
so on.
22 Of 25
Spindle
The Spindle dialog allows the configura on and setup of up to 20 spindle rages. The spindle ranges can
be gears and or belt se ngs to allow for a change in the range of speeds available.
Motor as Spindle
With this selec on a stepper motor, servo motor, or VFD that can be setup as a motor in the mo on
device. The motor will be treated as an out of band axis and will use the motors accelera on se ngs.
Machine Limits
23 Of 25
The machine limits can be show in the toolpath, showing where the machine can traverse to by
displaying do ed lines.
Extended Functionality
To get more extended func onality and or customiza on, Plugins and or scripts will need to be added
and configured. The Customiza on and scrip ng manual covers topics such as on screen bu ons to
trigger outputs, Tool changers, Bu ons to move the machine to a specific loca on, hardware bu ons for
operator interfaces, etc. Some of the plugins are covered in the appendixes for your convenience. If the
plugin of interest is not covered in the appendix please visit www.machsupport.com and look under
Mach4 plugins for more informa on.
24 Of 25
Appendix A mcKeyboard (how to get keyboard input)
Purpose:
Reading keyboard inputs and ge ng all key presses even if Mach4 is not in focus.
Descrip on:
Mach4 has no na ve way of ge ng the key presses to the “jog” bu ons or any other bu ons for
that ma er. Mach4 is designed to use inputs to trigger event. This is a fundamental difference
from most so ware packages and allows custom operator panels to be made with the
maximum amount of func onality. McKeyboard will consume any key presses that it is mapped
to while it is enabled.
Opera on:
The disabling of the keyboard can be done many ways. The first way is to click on the CNC
Keyboard Icon in the taskbar and when disabled a red X will appear on the keyboard icon.
Setup:
Test:
25 Of 25