Usbcnc: User Manual
Usbcnc: User Manual
Usbcnc: User Manual
User Manual
Document History
ACKNOWLEDGEMENTS
The G-Code part of this user manual has been derived from the full report of
the RS274/NGC language. Parts that are less relevant to USBCNC users or
parts that are not supported are left out.
USBCNC Manual
Table of contents
Table of contents 4
1 Introduction 8
1.1 Context and scope 8
1.2 Definitions, acronyms and abbreviations 9
1.3 Minimum PC requirements 9
1.4 Installation of USBCNC 10
1.4.1 USB 10
1.4.2 Ethernet 11
1.4.3 Set admin mode 15
2.2.5.2 Homing 37
2.2.5.3 Load and run a g-code file 37
2.3 Program Page, DXF and HPGL import 42
2.4 Tools Page 45
2.4.1 Milling 45
2.4.2 Tool change 45
2.4.3 Automatic user defined Tool change ATC 45
2.4.4 Turning 46
2.5 The variable Page 47
2.6 IO Page 48
2.7 homing and coordinate systems 49
2.7.1 Manual homing the machine 50
2.7.2 Automatic homing the machine and HomeIsEstop 51
2.7.3 Tandem axes homing 51
2.7.4 Work versus Machine coordinate system and zeroing 52
2.8 Keyboard shortcuts 54
2.9 Zero tool macro 55
2.10 Tool measurement Macro 56
4 Language extensions 97
4.1 Flow control 97
4.2 supported operations on expressions 97
4.2.1 unary operations 97
4.2.2 binary operations: 98
4.2.3 An example: 99
4.2.4 Special interpreter commands, non G-Code 99
4.2.5 Special interpreter MDI commands. 100
4.3 Macro file and automatic tool change 100
1 Introduction
This manual describes the usage of the CNC control system. Most hardware details can be found in the
hardware documentation on the Eding CNC download page.
1. Operator
2. PC connected via USB or Ethernet to electronic cabinet which contains the USBCNC CPU.
The PC runs the USBCNC Control Software.
3. Electronics cabinet, with power supplies, drives and USNCNC CPU.
4. USBCNC CPU
5. CNC Machine
The connection from CPU to the PC is USB or Ethernet depending on the CPU model.
The CPU delivers STEP/Direction signals to the power stage of each motor (drive), the motor connections of
the drive go to the motors inside the machine.
The Scope of the USBCNC product is the USBCNC software on the PC and the USBCNC CPU.
Windows XP and Windows 7 is proven to work fine with USBCNC. Windows Vista is not.
USBCNC requires soft-real-time behavior of your PC. Sometimes a bad driver of your video-card,
sound etc may be the cause of problems with USBCNC. USBCNC requires a USB communication
speed of about 150 times/second to and from the USBCNC CPU.
There are PC’s with bad USB chipset on which cannot handle this. One of such PC’s is the ACER
notebook time-line series. From the better brand notebooks like Dell, HP, Sony, Toshiba I have not
yet heard problems. When you encounter this, you may be able to solve it by adding a PCI USB card.
For setup of the hardware, check the hardware technical flyers for your CPU type. They are on the
download page of the website.
1.4.1 USB
During installation be sure to check "Install USB drivers":
After installation reboot the PC, when it is rebooted connect the CPU, after 10 – 60 seconds, you will
see that windows has found an USBCNC COM port if you are using and USB based CPU board.
You can check that the USB driver is correctly installed in windows device manager, press Windows
start button==>my computer, click with right mouse button and select "properties".
Select Device Manager:
If you see this, the USB driver is correctly installed. The COM17 number may be different on your
system.
1.4.2 Ethernet
For Ethernet you need a free Ethernet connection on the PC, Add a 2nd network card if needed.
Connect the CPU using a 100 MBit UTP Cross cable. Then setup the Ethernet adapter. Go to the
windows network settings, the network adapter with No network access is one for the CPU:
Click on the adapter with no network access, here: "LAN-verbinding 4" here, the text in your PC may
be different.
Press Properties:
Press OK, now you can test if the network is working, click the Windows Start button, select all
programs ==> accessories==>command prompt.
In the command prompt, enter ping 172.22.2.100, when connection OK, you should see:
If you have this, check you cable and your network settings again. Also check that the yellow led on
the CPU is flashing at approximately 1Hz.
After the install you will have the program ICON on your desktop. Do not start it yet, read further.
USBCNC must be started as Administrator and the user starting it must have admin rights. The first
This can be done by right clicking the mouse on the USBCNC Icon and then select run as
Administrator on Windows 7. The second must be done in the user account settings. On XP this is
generally not needed because most of the time you are already Administrator. The Admin rights are
needed because USBCNC needs real-time priority.
To avoid having to do this every time, you can change the properties of the ICON by right clicking on
the ICON and set the check “Run this program as Administrator”.
You can start USBCNC now by clicking the shortcut and begin setting the connection parameters.
When you start USBCNC for the first time you will get the Terms/Guarantee page click the language
you read the text. Then click agree if you agree. The operate page is shown. This is the main screen
to do all machine operation’s from. But first some settings must be filled in before you can start, so go
to the setup page.
Running a program and fast jogging is only possible after the machine is correctly homed, so
this must be setup first. The reason is that collision prevention is not active when the machine
isn’t homed, so damage to the machine may happen when homing is not performed.
Setup Page 1:
Connection to CPU: If you have 1 board connected to your PC, leave the setting at AUTO, the
software will find the board automatically. Otherwise choose the here the CPU
you want to work with. For CPU's with USB, you see the COMx ports here, in
case of a CPU5 with Ethernet, you will see the IP-Address here.
Ethernet: If you have a CPU with Ethernet, check the Ethernet checkbox.
Language setup: Speaks for itself. After it is set, save the changes, then close USBCNC and
restart so that everything will be in the correct language. The translations are in
2 files, cncgui-lang.txt and cncserver-lang.txt, if you find translation mistakes you
can correct this here. Please send the corrected file to Eding CNC, the
corrections will then be incorporated into new versions.
Password: You can protect the setup parameters from being modified by unauthorized
persons by using a password. Leave empty if no password is desired.
Steps/AppUnit : Fill in number of steps per millimeter for millimeter mode or number of steps per
inch for inch mode. Fill in a negative number to reverse the motor direction.
Example: Suppose your driver is set to 1600 steps/revolution (1/8 micro step)
and you have coupled the motor directly to a spindle with 5mm pitch. The
number to be filled in here = 1600 / 5 = 320.
If the movement direction is wrong, change it to -320.
Vel : Maximum axis velocity, all velocities, whether jogging, G0/G1/G2/G3 are limited
to this value.
Acc: Maximum acceleration.
Home Vel/Dir: Homing velocity, a negative number reverses the homing direction.
When the velocity is set to 0, the axis is homed manually, see the homing and
coordinate systems chapter.
Home Position: Machine position at the moment the home switch activated. This determines the
machine coordinates. It is not really relevant where the machine zero point lies,
it should only match with the MIN/MAX position.
Homing sensors should be setup such that they remain active until the mechanical end of the
machine. The space from home sensor activation to mechanical end is required to ramp down the
movement.
HomeSensorIsEStop:
The home sensors can also be used as limit switch which generate an E-Stop
when activated. When this function is required, the sensors should be mounted
outside the normal machine area.
Check this option if the home sensors work as EStop when activated. This
option will work after homing is complete. The reason is that otherwise homing
itself will generate an E-Stop.
EStopInputSenseLevel:
use this if you have an external emergency button connected.
HomeInputSenseLevel:
Defines EStop input behavior,
0 = low active (normally open switch),
1 = high active, (normally closed switch).
set the level of your end of stroke switches, these are used for homing the
machine. First check that the home sensors or switches are working, activate
them and look at the home-LED's at the lower left side of the main Operate
screen. If you see it working, take care that the machine axes are at the working
area, so that none of the sensors are activated. Look at GUI "LEDs"
EStopInputSenseLevel1:
Defines EStop input behavior,
0 = low active (normally open switch),
1 = high active, (normally closed switch).
2 = OFF
EStopInputSenseLevel2:
Defines EStop input behavior for second EStop input (CPU5B only),
0 = low active (normally open switch),
1 = high active, (normally closed switch).
2 = OFF
The polarity settings for the home inputs, E-stop's and Extern error can be automatically determined
by pressing the "Auto detect polarity" button.
Backlash: Set the amount of backlash for each axis that the software should compensate.
Experiment with velocities and acceleration, the backlash compensation
demands more from your motors than without backlash compensation. Do not
try to compensate more than 0.1 millimeters. If there is more backlash, try to
reduce it mechanically first. The backlash compensation superimposes a second
movement (the backlash) on top of the normal movement when the direction
reverses. You can see the impact on the motion profile in the figures below.
Here you can see the extra demands on the motors. Especially look at the extra
acceleration that is caused by the backlash compensation. A non micro step
drive in combination with a relative good motor may not be able to follow the
profile.
50
40
40
30
30
20
20
10
p0 p0
10
v0 v0
0 acc
acc 0
1 9 17 25 33 41 49 57 65 73 81 89 97 105 113 121 129 137 backlash
backlash 1 9 17 25 33 41 49 57 65 73 81 89 97 105 113 121 129 137
-10
-10
-20
-20
-30 -30
-40 -40
A movement from 0 to 10 mm without direction The next figure shows the same movement with
reversal. It is a beautiful 3rd order profile as you direction reversal. The compensation value is
can see. The numbers on the X axis are 10 ms 0.25 mm for this measurement, this is a relative
units, total move is about 1.37s. large value.
MAXFREQ: The maximum step frequency that the CPU will generate. It is sometimes
required to lower the maximum frequency, e.g. in case because the drive is
unable to handle the high step rate. For instance, when you build the PICSTEP
driver and want to use it, do not set the max frequency to 50 KHz, because the
PICSTEP driver cannot handle frequencies above 50 KHz.
Trivial kinematics: It is not needed for normal Cartesian machines, leave the Trivial 1:1 kinematics
checked. Please contact Eding CNC if you have a special machine or robot with
non Cartesian axes.
XYZ Limits: By setting the limits here to a value different from zero, the TCA (Tool Change Area)
guard will be activated. Using the values here you define an area on the machine which
is restricted to tool change. A normal work piece program is not allowed to enter this
area.
Z DownToolLength: For machine configurations where the tool chuck does not touch the machine bed when
the machine is at its lowest Z position. Here you specify the tool length of the tool that
fits when Z is at its lowest position.
This information is important for collision guarding.
TanKnife Angle: Tangential Knife is a rotation motor (the C Axis) around Z. Tangential Knife
works with normal G1, G2, G3 without tool-radius compensation G41, G42. The
knife is rotated automatically in the direction of the X-Y move. This parameter
determines the angle which 2 lines/Arcs can make without lifting the Z. If the
angle is greater as this value, the Z will move up (G0), rotate the knife (G0), then
move down again (G1). If the angle is lower, the rotation will take place without
moving Z up.
The tangential knife is switched on by interpreter command tanknife on and
switched off by tanknife off interpreter command. If you wish, you can assigne
those commands to user buttons.
TanKnife Z up distance:
Specifies the distance to lift up Z when detected angle is greater than Tan
Knife Angle.
Safety Input Selection: Select one of the AUX inputs to act as safety input, when active, only low
speeds are possible and the running g code goes to pause (Feedhold,
spindle off). This can only be configured for CPU5B.
Safety Feed: Feed in [mm/s] to be applied when the safety input is active and when the
machine is not homed and homing is mandatory is set.
MaxS: The speed of your PWM controlled spindle when the PWM signal is
at 100%.
MinS: The lowest possible speed for you spindle. If a command for a
lower S values is used, then this minimum value is applied.
Ramp up Time: The software waits this time between switching on the spindle and
starting the further machining.
Proportional Ramp up Time: Ramp up time is proportional with requested speed. Suppose your
Maximum speed is 24000 and ramp up time 10 second. The a
speed command of 12000 will give a ramp up time of 5 second.
ShowRPM: Check this when you want to see the RPM's, this works also if you
have no RPM sensor, a calculated value is displayed in this case.
RPMSensor: Check if you have connected a spindle speed sensor to the Sync
input of the CPU. The sensor should give 1 pulse/revolution,
minimum pulse width 0.5ms.
MistIsSpindleDirection: Special for CPU5A, use mist output for spindle direction if you need
it (CPU5A has no separate spindle direction output, that is why).
Setup Page 2, press ">" button on first setup page to get here:
Invert JogKeys: Inverts the movement of the keyboard keys, for moving bed machines, the bed
moves in the direction you press the arrow.
IsTurningMachine: Check if your machine is a Lathe, this effects mainly the 3D display which
shows the X-Z plane for turning. Also the jog keys operate differently. Futher
the working plane is set to G18 (X-Z).
ShowStartupScreen: When checked, the startup screen is shown when USBCNC starts.
HomingMandatory: When checked, running a job and mdi is not allowed before the machine is
homed. Also the jog speed is limited to 5% speed. This feature prevents
damage to your machine because when the machine isn’t homed, the limit
guards are not working. So, I advise to leave this item checked always.
SimpleZeroing: If checked, the zero buttons (beside the position display), will simply set the
work position to zero. If this item is not checked, a dialog will be shown in
which you can set the position. Default it shows a value which is – tool-radius
of the current tool. This is handy when zeroing from the lower left corner with
the endmill against the material.
AutoToolChange: If checked the running job will not stop when a toolchange is encountered.
Use this when you have a ATC or if you simply always have the tool already
in.
ShutDownOnFatal: If checked software will shutdown automatically when a fatal error such as
disconnected CPU occurs. This may be used when the electrical power is
switched of and connection to the CPU gets lost.
Favorite Editor: Specify your favorite editor here. I recommend notepad++, it is freely
downloadable at internet. E.g. for notepad++, specify
c:\program files\notepad++\notepad++.exe.
The advantage of notepad++ is that the editor jumps to the actual G-Code
line immediately, very handy when programming G-Code.
IconDirectory: The name of the directory where the GUI icons are located.
nu means not used.
If you want to change the Icons on the buttons, you can make first a copy of
the entire icons and name that directory to myIcons. Make your changes an
place the directory name in this field.
OpenGL: Check to use OpenGL graphics. This allows smooth panning, zooming and
rotation using the mouse.
Left mouse key; Pan
Right mouse key: Zoom
Control+Left mouse key: Rotate.
watchFileChanged: If checked USBCNC will watch the loaded g-code file for changes on disk if
USBCNC is not running. When it is changed, e.g. by an editor or because it
is saved by a CAM software, then USBCNC will ask you to reload the file:
load automatically: If this is checked, the file is automatically loaded when it changes on disk, no
dialog will appear.
run automatically: If this is checked and also the load automatically check, then the file will be
loaded and immediately start running when changed on disk.
fileName: This is the name of the file that USBCNC watches at startup. So if USBCNC
is started and this file time/date changes on disk, it will be loaded.
If manually another g-code file is loaded, then USNCNC will watch that one.
2.1.13 IO setup
Invert IO: Check if you want to invert the output, e.g. the PICSTEP 4 card amp is enabled
when the signal is low. Goto the main operate window and press reset, the
amplifiers should be enabled. Try to jog by pressing the arrow key’s. If there is
no movement, go back to the setup screen and check the Amp Enable
inversion. Press save, go back to Operate, press reset and try again to move. If
still not moving, check your hardware.
CPU5B is required to view all colors because other CPU's do not have enough
amount of outputs,
DiameterProgramming:
Check if you want diameter programming for turning, all X-axis values are
interpreted as diameter. The effect is that all movements in the X-axis are
divided by 2.
AbsoluteCenterCoords:
If Checked, the I,J,K value is interpreted as absolute value. Incremental is
used mostly.
LongFileModeCriterion:
Specify a number of Kbytes here. When the loaded job file is larger, the UI
switches to long file mode. The program listbox changes and the graphics
will show only outlines when a program is loaded. This is al needed to
preserve memory and speed for large files.
In this mode the file itself is still executed from memory and allows complex
G-Code constructs (While, If then else, sub routines).
SuperLongFileModeCriterion:
Specify a number of KBytes here where super long file mode starts. This
number should be equal or bigger as LongFileModeCriterion.
For very long files from 20MByte and UP to 4G this mode is required. It also
puts the GUI in the same mode as with LongFileMode, but as extra, the file
itself is no longer executed from memory. The means that complex G-Code
constructs are no longer possible. These type of files generally contain only
G1, sometimes G2, G3, and Tool changes M6Tx. The toolchanges are still
executed from the macro.cnc file, so full automatic toolchange is still
available.
Files with up to 100.000.000 lines of G-Code have been tested with this.
Macro Filename: Name of the macro file, it can be changed, the default is macro.cnc.
2.1.16 JobTimeEstimation
During the Render phase, after loading the job, the job time is estimated. But this is just a quick estimation
because a real calculation of time would take too much time, therefore these parameters:
CorrectionFactor: Correction factor for the time calculations, you can change this if you see that
your type of jobs require a correction.
RestimateRunTime: When checked, you will see the remaining estimated time of job based on
the average speed measured and the total distance to go.
Cnt/Rev: The number of counts of the hand wheel for one revolution, usually 400 for
most CNC hand wheels.
Count: Shows the actual Hand wheel count value, try to turn the hand wheel and
see it change.
V[%]: Percentage of velocity from selected axis, this is the maximum velocity the
axis will move when using the hand wheel.
X1..X100 Vel Mode: In velocity mode the most important is that the movement stops immediately
when the rotation of the hand wheel stops. The position of the hand wheel
will not be maintained if velocity mode is on. The position of the handheld is
maintained if velocity mode is off. This also means that the axis may not
immediately stop if the hand wheel rotation stops. When turning beyond the
limits of the axis, you have to turn back the hand wheel the same amount
before the axis starts moving again.
My own experience is that it works best to use velocity mode at X100 only.
Jus play with it to experience the behavior and make your own choice.
FeedOverride: When checked, hand wheel is used to control the FeedOverride. The feed
override can be controlled from 0% (Stop) to 300%. The maximum velocity
and acceleration specified for the motors will not be violated.
StoreProbePoints: The touch points are stored in a file when this is checked. This is used for
digitizing.
Use Home input 4: If checked home input 4 is used instead of the standard probe input.
File: The file name for storing the touch points. The file is opened at the first probe
touch en closed when a M30 command is encountered, usually at the end of the
G-Code program.
2.1.19 CPUOPT
Note: This activation is not needed if you have after you bought a CPU.
It is needed only to upgrade from 3 to 4 axes on CPU5A.
Do what the dialog tells you, press ok twice, press save changes. and restart.
When you press the CPU-OPT button again, you will see that the 4th axis is
enabled and that it is registered with your name.
In the middle we see the graphics showing the tool path. Blue/Red when loaded and rendered.
Yellow/Green when actually running. So it shows the tool path real-time.
At the left side there are buttons for common used IO:
Spindle on-off,
Flood
Mist Coolant on-off, and
AUX on-off (e.g. for the machine light).
MACHINE ON Button (Below Home C led)
This one has a few colors with different meaning:
o Grey means machine is off, drives switched off.
o Green flashing, machine is on but not all axes are homed, homing required.
o Green, machine ON
o Red flashing, E-Stop button on machine is active.
o Red, E-Stop button released but reset, home required.
o Pressing the button switches off the drives.
The right part of the screen shows the axes positions, when homing you use the machine coordinates
and for all other operations the work coordinates.
The buttons beside the axes positions are for zeroing the work position, on the background a G92
command is executed to perform this. The zero buttons can also be found in the zero submenu,
especially for people who do not like using the mouse at the machine.
Feed/Speed
You see the actual value, set value and percentage.
If you do a G1 in this example, the feed will be 60.
If you switch on the spindle with M3, the spindle speed will be set to 100 rev/minute.
This shows the actual G code and M code status as well as the actual tool number and the machine
state, READY, RUNNING etc.
Here you see the actual running time of a job and also the estimated TOTAL time.
F1, reset
F2 - F7, Home X - Home C
F8, Home all axes
F10, go to g28 park position
F11, go to g30 park position
F12, return to main menu.
For homing setup see homing and coordinate systems chapter.
F1, Reset
F2 - F7, zero x - zero c
F8, zero all
F9, measure rotation and apply G68 R..
F12, back to main menu
F9 measure rotation is a feature that makes life easy. It automatically corrects your work piece/clamp for
rotation. This means that you no longer have to spend time to setup your clamp / material very accurately,
USBCNC will automatically correct for you.
F1, Reset
F2, Load G-Code file
F3, redraw (re-render whole program through g-code interpreter)
F4, run/pause
F5 rewind job
F6 start editor
F7 set start line of job / store current position of job after pause.
F9, +Feed Override
F10, - Feed Override
F11, Show Nesting options.
F12, back to main menu
If you have stopped while Paused, the line number will show the current line of the job.
This happens also when you have pressed reset when paused.
Not that reset when pause is needed when you need to do e.g. a tool change.
During Pause only jog movements are allowed.
You can store and retrieve the stored line number using the Store/Get Stored buttons.
Press search to run the interpreter in Search mode up to the given line number.
When you press the RUN button (F4) after a search or pause, the following popup dialog
appears:
The Axis button show the position according to the interpreter on the searched line, green is
match, red is no match, press the button to move the axis to the correct position, you can do this
for all axes.
If any axis isn't synchronized, it will be done automatically when the start button is pressed.
The S button switches the spindle On with correct S value from the Search status.
F= Plunge rate is the feed rate for the movement towards the work piece, you can change this to
a good value you want.
As last, the Run button, this will start a G1 with F towards the search positions, then restore the Feed to the
search feed and start machining from there.
This way you are able to easily start half way in a g-code program.
F11, Nesting:
Nesting is a feature that allows to produce a product multiple times in X/Y ROWS:
Nesting is reachable if the machine is in READY state, you can always press RESET to get it in ready state if it
isn't.
Material size: set the material size in X and Y, it is shown in the graph.
Start offset: set an offset for starting, play with it and you will see what it does.
Pitch: the distances in X,Y of the products.
Number: Specify the number of products.
Max: USBCNC will determine the max number of products.
The Nest button F11, can be pressed to show/hide the nesting dialog.
Nesting internally uses coordinate system offset G59.3, the coordinate system offsets may not be used in the
program, otherwise nesting will not work, so no G54 .. G59.3 allowed in the program.
G92 is allowed, but if changed must be set back to the original value at the end of the program.
The program must end with M30 otherwise nesting will not work.
The values above can also be set in the G-Code file like so:
%mx=200 Material size X
%my=200 Material size Y
%dx=200 the delta X or pitch X
%dy=200 the delta Y or pitch Y
%ox=200 the offset X
%oy=200 the offset Y
After pressing the App button, the nesting is applied to the program and shown:
Recommended is to create the g-code file for the product such that X0 Y0 is at the lower left side.
If you like to start not at the beginning, use the goto-line function and apply the NX NY values.
2.2.4.5 IO MENU
F1, Reset
F2, drivers on/off
F3, spindle on/off
F4, spindle direction left/right
F5, flood coolant on/off
F6, mist coolant on/off
F7, aux1 output on/off
F9, Speed -
F10, Speed +
F12, back to main menu
F1, reset
F5, switch between 2D X/Y plane and 3D iso-metric view.
F6, zoom fit
F7, zoom out
F8, zoom in
F9, zoom machine
F10, clear
F11, redraw (re-render whole program through interpreter)
The graph view shows a grid of 50mm in mm mode or 2 Inch in inch mode projected on the machine
bed (X-Y surface). For a representative view it is important that the axes limits are correctly filled in
and that the machine is homed manually or automatic. The current work coordinate system origin is
shown as a cyan colored cross in the x-y plane. When you press the preview update button, a
preview is shown of the loaded G-Code program. The preview is created by running the entire g-code
file through the interpreter. So when interpreter errors occur, it shows in the log window and in the
operate view the program list box shows the wrong line in red color. Note that there can be
inaccuracy in what the display shows, this is there because of performance and memory usage
limitation reasons.
Zooming, rotate, pan, 2D/3D view and other possibilities are found in the graph sub-menu, see the
example below.
With OpenGL activated in the setup, real-time pan, rotate and zoom is possible with the mouse also:
pan : left mouse button
rotate : left mouse button + control
zoom : right mouse button.
F1, Reset
F2, jog mode continuous
F3, jog mode step 0.01
F4, jog mode step 0.05
F5, jog mode step 0.1
F6, jog mode step 0.5
F7, jog mode step 1
F8, jog mode step user value
F9, jog mode hand wheel / mpg X1
F10, jog mode hand wheel / mpg X10
F11, jog mode hand wheel / mpg X100
F12, return to main menu
When “Shift Coordinate System” is checked, jog-step functions as normal, the axes move one step at a
time. The work position however remains the same. This is accomplished by modifying the active G92
offset. It is useful when e.g. during engraving you want to run the G-Code program again, but a little
deeper in Z. E.g. you want to run the program 0.1 mm deeper, select jog step 0.1 and check “shift
coordinate system” . Now press de arrow down button to move Z 0.1 mm down. Notice that the axis
moves down but that the position remains the same. When you run your engraving program again the
engraving will be 0.1 mm deeper into the material.
This option is also very handy during turning. Your program has run and you measure the work piece
and see its diameter is still a bit too big. So now use the –X button to compensate the diameter. Run the
program again and your work-piece diameter will be correct.
The amount of shift is shown at the right side. To reset the value to 0, which has no influence on the
active offset nor machine position, uncheck, and then check “shift coordinate system”.
F1, Reset
F2, Zero the Z coordinate using a flexible toolsetter positioned on top of the material, see ZERO
TOOL MACRO chapter.
F3, measure the tool length and put the length in the tool-table using a fixed toolsetter, see
TOOL MEASUREMENT MACRO chapter.
F4 - F11, user function user_3 .. user_10, user defined functions in macro.cnc
F12, return to main menu.
2.2.5.1 STARTUP
When you just started the application you have to press reset F1.
This will enable the drives, the machine on button left will be green flashing, this means the machine is ready
but must be homed first.
2.2.5.2 HOMING
Homing is the next step to perform, this can be done via main->f2.
There you can do individual axis homing or home all axes art once.
For homing setup see homing and coordinate systems chapter.
All axes home at once can also be done using ctrl-h or the home all button beside the status:
The file is fully parsed through the g-code interpreter and the tool path is shown in the graphic window:
Using the mouse (ctrl+left mouse), you can rotate the tool-path and see it 3D.
Using the left mouse, you can PAN.
Using the right mouse you can ZOOM:
It can be that while loading you get a collision error, this means that the tool-path does not fit on the machine,
so a shift of the work coordinate system is needed:
The yellow rectangle shows the first place where the collision is discovered. We see here clearly that a part of
the tool-path is outside the machine area, a message is given showing the line number L9 in this case where the
collision occurred.
The easiest way to shift now is to jog to the place where you want to have the origin, the actual place of the
work-coordinate system origin is shown as the cyan lines for X and Y.
We jog about 200 mm to the left (X-) and the Z axis about 10mm up so that our first attempt will be milling in
the air.
The we press the zero buttons beside the coordinate display for X and Y, this sets the coordinate system to the
current position. Now we need to press redraw, to show the tool-path again, now with shifted coordinate
system:
We see that the tool path fits without collision and we see the delta's in X, Y, Z, which is the size of the tool
path.
Control F3 is also possible, this redraws and zooms to fit:
Now we can press run (F4) to run the program. We have no automatic tool changer, so the program stops when
a tool change is encountered asking us to put in the tool.:
The tool is already in, so we press F4 again, the program will continue and our machine is working.
We see the tool path being drawn real-time on the screen:
USBCNC uses a build in CAD/CAM library for these advanced import functions. You
can load a file and then perform one of these operations:
Select engraving, this is milling over the lines from the drawing.
Select profiling, this is for milling out objects and taking the tool
diameter into account.
After loading a DXF file, all layers will be visible. You can unselect layers at the right
side, such that you see only the part that you want to use.
You also can change the origin of the drawing by pressing the appropriate button
under the layer selection list box. The positions of the buttons give the positions of
the origin. So e.g. when you press the upper right button, then the most upper right
position of the drawing will become x=0, y=0 when milling.
Parameters involved:
Save-Z When moving from one region to another, the machine goes to
this height.
Start-Z Z value where the tool touches the material to be machined.
Final-Z Z value specifying the milling depth lowest Z value.
Final Z must be lower than Start Z.
Z Increment This specifies the step size when machining in passes.
Feed rate Milling feed (F) in mm/min
Plunge rate Feed (F) that the Z moves down into the material also mm/min
Spindle S value for spindle.
speed
CW/CCW Spindle direction (M3/M4)
Tool number This is only used for the M6 tool change command
Tool Diameter of the tool for the offset and pocketing calculations.
Diameter
Method Outside/inside/clockwise/counterclockwise operation
Finish Material that is left for the finishing pass when pocketing. This
allowance. finishing pass is at full depth for getting a clean edge.
Step size Step oversize for pocketing, this value should be lower than
the tool diameter.
Laser mode For profiling, when switched on, the tool will be switched off
when moving from one region to another.
Make bridges Leave small pieces of material, that prevent you object from
falling out (and get damaged) when profiling.
Bridge Approx distance, the exact distance is calculated such that all
distance bridges have equal distance.
BridgeFinalZ Lowest Z value for bridge, this value should be between startZ
and finalZ
BridgeWidth The width of a bridge.
When the parameters are set, press calculate tool path, it will be visualized on the
screen.
Note: The offset and pocket calculation might not always work, this is usually
because of small errors in the drawing like lines over each other or not connecting
lines. Experimenting with the Calculation Accuracy might help. Also check/correction
of your drawing may help.
2.4.1 Milling
In this view you can define 99 tools with a length diameter and description.
For Lathe operation there is additional and X-Offset and tool Orientation parameter.
The tool information is used when you use the tool radius and or tool length
compensation functions of the G-Code interpreter commands (G40 – G43). See
chapter 3.6. and further.
suproutine then calls further subroutines drop_tool_x and pick_tool_x, if you have a
toolchanger, you can add extra movements to the right tool position and control I/O
for actually changing the tool.
2.4.4 Turning
As you can see, there are 2 additional parameters for turning, X-Offset and
Orientation.
This page shows the standard variables used by the G-Code interpreter.
It also contains 4 watches to show your own variables if you are going to use the
extended programming features. You will understand the meaning of this window
after reading the G-Code interpreter functions and extended programming with
variables.
The G68 rotation can be reset with the reset button under G68 Rotation.
This is the same as entering G69 in MDI.
The G54 .. G59.3 offsets can be set by entering values and pressing enter.
The G54.. G59.3 X,Y values can be defined as zero at current machine position by pressing the
button. This works similar to G92 offset.
The MDI equivalent for setting G55 offsets is G10 L20 P2 X0 Y0.
G92 is normally used for zeroing the machine at work piece coordinates. you can reset all offsets
here to zero.
The G28 and G30 positions can be defined at current location by pressing the associated button.
2.6 IO PAGE
At this page you can monitor and set the I/O signals.
The page shows only the I/O that are applicable for the attached hardware.
The Advantronix part is only available when you have an Advantronix USB I/O card
connected.
When your machine is switched on, all axes can be at any position, these positions
are unknown by the software. The software however needs to know the position to
show a correct graphic in the graph screen and also for preventing damage to your
machine by running beyond the machine limits. The process to match the machine
position with the software is called homing. Homing can be done either manually or
automatic if end of stroke switches are mounted. This tutorial describes homing.
What happens is that a few subroutines are called. The subroutines are in the
macro.cnc file in your USBCNC installation folder. They look like this:
;Homing per axis
Sub home_x
home x
Endsub
Sub home_y
home y
Endsub
Sub home_z
home z
Endsub
A good reader has seen that the order of homing is defined by the home_all
subroutine and can be customized to your own needs.
Set the Home velocity to 0 for all axes that have no EOS switch.
Mark a point somewhere on the machine that you want to use as home reference
point, let’s say X= -200.0mm, which is 100.0mm from the left edge and Y= -150,
which is 50.0 mm from the lower edge. For Z we take to bottom of the bed at Z=0
mm. This position x=-250, Y=-150, Z=0 is entered in the Home Position values in the
set up screen, this need to be done once.
Using the arrow keys, jog the X,Y axes to the marked position on the bed and move
the Z completely up to the surface of the machine. When the machine is at the
position press the Home button in the Home submenu, F2-F7 for X-C.
Be sure that you have set the home velocities of the axes to zero, otherwise the
axes will start to move. Now click the buttons X, Y, Z, and A if you have an A-axis.
That is all, the axes are now homed and the software now knows the machine
position.
As a side effect, now also the software limit switches are enabled which protect you
from jogging further than the machine can go. Also the Software limit guard is on
that will stop a running program when going beyond the limits.
You may also have noticed that the position mode is set to “machine”, this is
because homing directly affects the machine coordinate system. From this point the
machine coordinate system, is not changed any more, it stays as is.
HINT: Move your machine always back to the home position if you are done with the
machine. You don’t have to move manually to this point next time when you switch
back on the machine. You can do a fast move in machine coordinates like this: g53
g0 x0 y0 z0, or first undo the preset (preset dialog, undo preset) and then do a
regular G0.
The machine needs a homing sensor or switch for each axis connected the its home
input on the CPU board.
The homing switch is placed at a small distance of the mechanical end of the
machine. This distance is needed to ramp down the velocity after the switch is
activated.
The sensor should be mounted such that it remains active until the mechanical limit
of the machine.
For automatic homing the home velocity needs to be set to another value than zero,
use an equal or lower speed than the axis maximum speed. The axis should start to
move in the direction where your homing switch is mounted, when it is needed to
reverse the direction add a minus sign to the homing velocity. Setup the
HomeInputSenseLevel correctly. When the led’s are green when the input is not
activated put a 1 here, when the led’s are red when the switch is not activated, put a
0. This depends whether you have used normally open or normally closed switch. I
recommend normally closed switches here.
Use the homing sub menu to home your axes.
1st Move: The machine first moves until the switch activates, then ramps down and
stops.
2nd Move: Then the direction reverses and ramps down when the switch releases.
At the moment of the release of the switch, the position is captured and used to set
your machine position correctly.
PrepareTandemHome
MoveStaveToMaster
HomeTandem
For the explanation, I assume that the master axis is X and the Slave axis is A.
axis reaches the home sensor first, this one is stopped and the other moves
further. This movement is done when both axes have reached.
2. Home X, home the X, the slave will just follow. Because the axes are on the
sensor, the move will be off the sensor. The position is latched at the moment
the sensor de-activates. Then the movement stops and then the correct
position is calculated end set for the X.
3. Home A, exactly the same, but now the A is master temporarily and X will
follow. At the end the position is calculated and set for the A.
4. At this point both master and slave have a correct known position. It is very
important that the home position in the setup matches the actual machine.
Now we can straighten the bridge by the command MoveSlaveToMaster A.
The slave will move to the same position as the master. The bridge is set
straight and we are done. (If the bridge is not straight, the home positions in
the setup are not correct).
To make this whole sequence more easy, the HomeTandem X can be used to do it
all at once.
So if X has a slave Axis, then modify the macro.cnc so that subroutine home_x
contains:
Sub home_x
homeTandem X
Endsub
The machine coordinate system does not change, however we want to be able to do
the milling of our part anywhere we want on the machine. We will normally use the
“work” coordinate system, we can shift it anywhere we want. This can be done with
several G-Codes, which are explained in chapter 3, it can also be done using the
“preset” button on the operator screen, we’ll see this in a minute.
Suppose our g-code file containing the work piece is created with an origin of X=0,
Y=0, Z=0. This is because you have drawn your part in a CAD program beginning
from these coordinates and then converted to G-Code.
Now you have put your raw material somewhere on the machine, probably not at
coordinates X=0, Y=0, Z=0.
By the way, I prefer to define the upper surface of the material as Z=0, such that a
negative Z value goes into the material.
Just move to the zero point of the work piece and there press the zero buttons in the
operate screen besides the position display.
For the advanced users: The zeroing can also be done using a measuring probe
connected to the probe input. An example is provided in the standard macro.cnc file.
Under user_1 you find automatic zeroing. Under user_2 you find interactive tool
length measurement.
If you want to do it a more advanced way, look at G55 .. G59.3 and also at the G92
variants.
When the program is loaded, go to the graphics screen (Alt-g) and press update
preview, you will now see exactly where the part is going to be milled at the surface
of you machine bed.
Now press the F4 key or the run button to start milling, go to the graphic screen and
switch real time graph on to see what the machine is doing.
The idea is to use a flexible position tool setter and put it on top of the workpiece.
Start this function and when done, the Z coordinate is set to 0 at the surface of the workpiece.
The feed is set slow F30. A probe move G38.2 is started towards -Z, when the tool setter is touched
the position is stored and the movement is stopped. The machine moves exactly to the touch point.
G92 is used with a Z value that specifies the height of you tool setter 43 mm in this case. Change to
match your tool setter. An incremental movement is started 5 mm upwards, so you can remove the
tool setter. The machine goes back to absolute mode and is done.
WARNING: Take care that you fully understand this macro before using it and that you have adapted
it for your own tool setter.
Tool #16 is used as reference tool and should have filled in its tool length before you start. This tool length can
be 0 if you use the tool-chuck itself instead of a calibration tool.
The values #4996 .. #4999 are to be determined once. This can be done using the calibrate_tool_setter
function below. Make sure the machine is homed before you start this.
When done jogging, press The machine will move down to touch the tool setter, The measured tool-chuck
RUN. height is stored into #4999.
Then the Z is moved up to safe height.
Calibration DONE
When all calibrated, the user button F2 can be used to measure the tool length.
Make sure the correct tool is loaded before you start.
Type correct values for tool number, tool length and The machine moves to the correct X,Y
diameter. The machine moves 10 mm above the tool setter.
Press OK. So make sure the approx tool length above is OK.
Sub calibrate_tool_setter
warnmsg "close MDI, check correct calibration tool nr 16 data in tool table"
warnmsg "jog to toolchange safe height, when done press RUN"
#4996=#5073 ;Store toolchange safe height machine coordinates
warnmsg "insert calibrationtool 16 length=" #5416 ", jog just above tool setter, when done press RUN"
;store x y in non volatile parameters (4000 - 4999)
#4997=#5071 ;machine pos X
#4998=#5072 ;machine pos Y
;Determine minimum toochuck height and store into #4999
g38.2 g91 z-20 f30
#4999=[#5053 - #5416] ;probepos Z - calibration tool length = toolchuck height
g90
g0 g53 z#4996
msg "calibration done safe height="#4996 " X="#4997 " Y="#4998 " Chuck height="#4999
endSub
sub m_tool
;Check if toolsetter is calibrated
if [[#4996 == 0] and [#4997 == 0] and [#4998 == 0] and [#4999 == 0]]
errmsg "calibrate toolsetter first open mdi, enter gosub calibrate_tool_setter"
else
g0 g53 z#4996 ; move to safe z
dlgmsg "enter tool dimensions" "tool number" 5016 "approx tool length" 5017 "tool diameter" 5018
3.1 OVERVIEW
The RS274/NGC language is based on lines of code. Each line (also called a
"block") may include commands to a machining center 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," and "X3" provides an argument value (the value of X should
be 3 at the end of the move). Most RS274/NGC commands start with either G or M
(for miscellaneous). The words for these commands are called "G codes" and "M
codes."
The RS274/NGC language has no indicator for the start of a program. The
RS274/NGC language has two commands (M2 or M30), either of which ends a
program.
The RS274/NGC language contains commands that change the way subsequent
commands are to be interpreted, but do not tell the machining center to do anything.
These are not covered in this section, but are dealt with as they arise in Section
3.5.17, Section 3.5.19, and Section 3.5.20.
3.2.1 Parameters/Variables
In the RS274/NGC language view, a machining center maintains an array of 5400
numerical parameters. Many of them have specific uses. The parameter array
should persist over time, even if the machining center is powered down. USBCN
stores the parameters that have specific use only. This is performed when the user
presses the “Save Fixtures” button in the variable view. The specific parameters are
listed in the table below. Other parameters in range of 1..5400 are free to use in
your G-Code program.
When the G18 plane (X-Z) is selected, special LATHE tool radius compensation can be used (G41, G42).
Depending on the tool orientation and tool radius an extra offset is applied.
You can set the offsets of the nine program coordinate systems using G10 L2 Pn (n
is the number of the coordinate system) with values for the axes in terms of the
absolute coordinate system.
You can select one of the nine systems by using G54, G55, G56, G57, G58, G59,
G59.1, G59.2, or G59.3 (see Section 3.5.13). It is not possible to select the absolute
coordinate system directly.
You can offset the current coordinate system using G92 or G92.3. This offset will
then apply to all nine program coordinate systems. This offset may be cancelled with
G92.1 or G92.2. See Section 3.5.18.
You can make straight moves in the absolute machine coordinate system by using
G53 with either G0 or G1.
Data for coordinate systems is stored in parameters, see the previous section.
During initialization, the coordinate system is selected that is specified by parameter
5220. A value of 1 means the first coordinate system (the one G54 activates), a
value of 2 means the second coordinate system (the one G55 activates), and so on.
It is an error for the value of parameter 5220 to be anything but a whole number
between one and nine.
Any input not explicitly allowed is illegal and will cause the Interpreter to signal an
error.
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 34y 7" is equivalent to "g0 x+0.1234 y7", for
example.
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.
3.3.2 Word
A word is a letter other than N followed by a real value.
Words may begin with any of the letters shown in Table 3-2. The table includes N for
completeness, even though, as defined above, line numbers are not words. Several
letters (I, J, K, L, P, and R) may have different meanings in different contexts.
Letter Meaning
A A-axis of machine
D Tool radius compensation number
F Feed rate
G General function (see Table 3-4)
H Tool length offset index
I X-axis offset for arcs X offset in G87 canned cycle
J Y-axis offset for arcs Y offset in G87 canned cycle
K Z-axis offset for arcs Z offset in G87 canned cycle
L number of repetitions in canned cycles key used with G10
M miscellaneous function (see Table 3-6)
N line number
P dwell time in canned cycles dwell time with G4 key used with G10
Q feed increment in G83 canned cycle
R arc radius, clear_z distance in canned cycle
S spindle speed
T tool selection
X X-axis of machine
Y Y-axis of machine
Z Z-axis of machine
A A-axis of machine
B B-axis of machine
C C-axis of machine
A real value is some collection of characters that can be processed to come up with
a number. A real value may be an explicit number (such as 341 or -0.8807), a
parameter value, an expression, or a unary operation value. Definitions of these
follow immediately. Processing characters to come up with a number is called
"evaluating". An explicit number evaluates to itself.
3.3.2.1 NUMBER
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.
Binary operations appear only inside expressions. Nine binary operations are
defined. 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 binary operations are divided into three groups. The first group is: power. The
second group is: multiplication, division, and modulus. The third group is: addition,
subtraction, logical non-exclusive or, logical exclusive or, and logical and. If
operations are strung together (for example in the expression [2.0 / 3 * 1.5 - 5.5 /
11.0]), operations in the first group are to be performed before operations in the
second group and operations in the second group before operations in the third
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 simplifies 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.
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.
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=6 G1 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.
A comment contains a message if "MSG," appears after the left parenthesis and
before any other printing characters. Variants of "MSG," which include white space
and lower case characters are allowed. The rest of the characters before the right
parenthesis are considered to be a message. Messages should be displayed on the
message display device. Comments not containing messages need not be
displayed there.
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 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.
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.
"Non-modal" codes have effect only on the lines on which they occur. For example,
G4 (dwell) is non-modal.
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 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.
3.5 G CODES
G codes of the RS274/NGC language are shown in Table 3-4 and described in this
Section.
The descriptions contain command prototypes, set in bold type.
In the command prototypes, three dots (…) stand for a real value. As described
earlier, a real value may be (1) an explicit number, 4, for example, (2) an
expression, [2+2], for example, (3) a parameter value, #88, for example, or (4) a
unary function value, acos[0], for example.
In most cases, if axis words (any or all of X…, Y…, Z…, A…, B…, C…) 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 command prototypes not explicitly described as optional are required. It
is an error if a required item is omitted.
In the prototypes, 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. Using real values which are not explicit
numbers as just shown in the examples is rarely useful.
If L… is written in a prototype the "…" will often be referred to as the "L number".
Similarly the "…" in H… may be called the "H number", and so on for any other
letter.
It is an error if:
• All axis words are omitted.
If cutter radius compensation is active, the motion will differ from the above; see
Appendix A. If G53 is programmed on the same line, the motion will also differ; see
Section 3.5.12.
It is an error if:
All axis words are omitted.
If cutter radius compensation is active, the motion will differ from the above; see
Appendix A. If G53 is programmed on the same line, the motion will also differ; see
Section 3.5.12.
If a line of RS274/NGC code makes an arc and includes rotational axis motion, the
rotational axes turn at a constant rate so that the rotational motion starts and
finishes when the XYZ motion starts and finishes. Lines of this sort are hardly ever
programmed.
If cutter radius compensation is active, the motion will differ from what is described
here. See Appendix A.
Two formats are allowed for specifying an arc. We will call these the center format
and the radius format. In both formats the G2 or G3 is optional if it is the current
motion mode.
It is an error if:
both of the axis words for the axes of the selected plane are omitted,
the end point of the arc is the same as the current point.
It is not good practice to program radius format arcs that are nearly full circles or are
semicircles (or nearly semicircles) because a small change in the location of the end
point will produce a much larger change in the location of the center of the circle
(and, hence, the middle of the arc). The magnification effect is large enough that
rounding error in a number can produce out-of-tolerance cuts. Nearly full circles are
outrageously bad, semicircles (and nearly so) are only very bad. Other size arcs (in
the range tiny to 165 degrees or 195 to 345 degrees) are OK.
That means to make a clockwise (as viewed from the positive Z-axis) circular or
helical arc whose axis is parallel to the Z-axis, ending where X=10, Y=15, and Z=5,
with a radius of 20. If the starting value of Z is 5, this is an arc of a circle parallel to
the XY-plane; otherwise it is a helical arc.
In the center format, the coordinates of the end point of the arc in the selected plane
are
specified along with the offsets of the center of the arc from the current location. In
this format, it is OK if the end point of the arc is the same as the current point. It is
an error if:
When the arc is projected on the selected plane, the distance from the
current point to the center differs from the distance from the end point to the
center by more than 0.0002 inch (if inches are being used) or 0.002 millimeter
(if millimeters are being used).
That means to make a clockwise (as viewed from the positive z-axis) circular or
helical arc whose axis is parallel to the Z-axis, ending where X=10, Y=16, and Z=9,
with its center offset in the X direction by 3 units from the current X location and
offset in the Y direction by 4 units from the current Y location. If the current location
has X=7, Y=7 at the outset, the center will be at X=10, Y=11. If the starting value of
Z is 9, this is a circular arc; otherwise it is a helical arc. The radius of this arc would
be 5.
In the center format, the radius of the arc is not specified, but it may be found easily
as the distance from the center of the circle to either the current point or the end
point of the arc.
3.5.4 Dwell - G4
For a dwell, program G4 P… . This will keep the axes unmoving for the period of
time in seconds specified by the P number. It is an error if:
the P number is negative.
It is an error if:
the P number does not evaluate to an integer in the range 1 to 9.
If origin offsets (made by G92 or G92.3) were in effect before G10 is used, they will
continue to be in effect afterwards.
The coordinate system whose origin is set by a G10 command may be active or
inactive at the time the G10 is executed.
Example:G10 L2 P1 x 3.5 y 17.2 sets the origin of the first coordinate system (the
one selected by G54) to a point where X is 3.5 and Y is 17.2 (in absolute
coordinates). The Z coordinate of the origin (and the coordinates for any rotational
axes) are whatever those coordinates of the origin were before the line was
executed.
G10 L20 P.. X.. Y.. Z.. A..
All the axis words are optional, except that at least one must be used.
It is an error if:
all axis words are omitted.
the spindle is not turning when this command is executed.
the requested linear motion exceeds machine velocity limits due to the
spindle speed.
In response to this command, the machine moves the controlled point (which should
be at the end of the probe tip) in a straight line at the current feed rate toward the
programmed point. If the probe trips, the probe is retracted slightly from the trip point
at the end of command execution. If the probe does not trip even after overshooting
the programmed point slightly, an error is signaled.
After successful probing, parameters 5061 to 5066 will be set to the program
coordinates of the location of the controlled point at the time the probe tripped. The
variables 5051 to 5056 will contain the machine coordinates. Useful for measuring
tools in absolute machine positions. G53 G38.2 will move in machine coordinates.
The example does not include a tool change to put a probe in the spindle. Add the
tool change code at the beginning, if needed.
It is an error if:
To use dynamic tool compensation (not from the tool-table), use G43.1 I.. K.. where
I.. gives the tool X offset (turning) and K.. gives the tool Z offset (for turning and
milling)
To use no tool length offset, program G49. It is OK to program using the same offset
already in use. It is also OK to program using no tool length offset if none is currently
being used.
It is an error if:
G53 is used without G0 or G1 being active,
G53 is used while cutter radius compensation is on.
It is an error if:
one of these G-codes is used while cutter radius compensation is on.
Some work pieces require absolute accuracy and some other require nonstop
milling for best surface quality. One must understand that it is physically impossible
to move around sharp corners without a standstill at the corner. This isn’t possible
with a car and also not with a CNC machine, since that would require infinite
acceleration. The user can make a choice here, absolute accuracy with standstill at
every corner (G61) or no standstill and corner round off with specified accuracy
(G64Px.x).
G61 puts the machining center into exact path mode, In G61, the motion velocity
between motion segments goes to zero, the end position in corners is exactly
reached, use this if you require maximum accuracy. When a work piece consists of
many small lines this gives a quite vibrating machine because of the continuous
acceleration-deceleration-stop behavior.
G64 Px.x for continuous mode. In G64, subsequent moves are blended, when
previous move starts to decelerate and reaches a velocity such that the specified
accuracy isn’t violated, the next move starts to accelerate, the two motions are
added. The result is smooth motion with highest possible speed to achieve required
accuracy. The corners however are rounded. specifies the distance reached to the
corner while blending. The next move is blended with current such that the tool path
remains no more than P from the corner. The figure below is a rectangle of 10x10
milled with F 2000. This is done with P values from 0.1 to 1, you can see the
impact. This gives the best compromise between accuracy and smooth motion.
To make a move from stand still we need to accelerate, then have a certain cruising speed and after
decelerate. Short moves typically never reach the requested velocity the accelerate and then at half
the distance the decelerate.
This table shows the distance traveled so that the given speed is reached. When the line segments
generated by the CAD/CAM program are shorter, the actual speed on the machine will be lower than
requested value. Example, you want a milling speed of 900 mm/minute, then the segments
generated by the CAD/CAM program must be smaller than 1.88 mm. If the lines are only 0.21 mm,
the feed will go down to 300
If you machine has higher accelerations which requires bigger motors, also higher milling velocities
are possible. The values given here are for a moderate hobby machine. This illustrates that when the
G-Code file exists of small segments, e.g. 0.08 mm, that with an acceleration of 120 a feed can be
reached of 180 mm/minute at most.
The road maximum velocity signs have to be obeyed and you have to drive your car exactly over the
white line in the middle of the road. You will try to reach the maximum allowed velocity where
possible. When you see a curve coming up ahead, you will brake so that you will not drift off the road.
You will try to look ahead as far as you can see and you take care that you can stop in time if the
road suddenly stops.
When you would maintain your speed in sharp curves, you will drift off the road resulting possibly into
a car accident. When the road has many short curves, then you will not be able to reach the desired
speed. The more PS you have in the car, the higher speed you will reach because you can
accelerate faster.
I think this is a good comparison with a CNC machine, the same issues apply. A machine cannot
suddenly change velocity, to reach a velocity the motors must accelerate first for a certain time to
reach the velocity.
LAF behaves like the ideal racecar driver, it will reach the highest possible velocity without violating
the maximum motor accelerations.
There is one additional problem while running CNC programs, some programs consists of short line
pieces. When the line pieces connect tangentially (are in line), then LAF will accelerate through over
the lines, reaching the maximum allowed speed.
The angle to which LAF considers the segments in line is a setup parameter. The theoretical ideal
value would be very small, so that no acceleration value occurs.
More practical values are in the range of 1 to 4 degrees, the experience learns that most machines
can handle acceleration spikes up to a certain limit.
The value can be set up to 180 degrees in this case you must know what you are doing, it can be
useful during e.g. foam cutting wing profiles. Be aware however that if the curve contains real sharp
angles that step pulse loss may be the result when using large minimum LAF angles.
In practice we have seen that milling times of complex 3D work pieces can be done in 50% of the
time compared to competitors who do not have LAF.
G76 P- Z- I- J- R- K- Q- H- E- L-
P Pitch
Z driveline endpoint
I Outside thread diameter, always positive.
J First cut is J beyond I, always positive.
R Depth regression, use 1.0 for constant cutting depths or leave parameter away.
K Full thread depth beyond thread peak, always positive.
Q Compound slide angle, typical 30.
H Additional spring passes at full depth, use 0 for none.
E Taper distance along drive line.
L Taper place, none, enter, exit, both.
;Create a thread from z=20 to z=10, outside diameter=15, inside diameter=14, 10 passes.
G0 X20 Z20
G76 P1.0 Z10 I15 J0.1 K1.0
It is an error if:
The “drive line” is a safe line outside the thread material. The “drive line” goes from the initial location
to the Z- value specified with G76. The Z extent of the thread is the same as the drive line.
The “thread peak” is given by the I- value, which is an offset from the drive line. Negative I values
indicate external threads, and positive I values indicate internal threads. Generally the material has
been turned to this size before the G76 cycle.
The “initial cut depth” is given by the J- value. The first threading cut will be J beyond the “thread
peak” position. J- is positive, even when I- is negative.
The “full thread depth” is given by the K- value. The final threading cut will be K beyond the “thread
peak” position. K- is positive, even when I- is negative.
The “depth degression” is given by the R- value. R1.0 selects constant depth on successive
threading passes. R2.0 selects constant area. Values between 1.0 and 2.0 select decreasing depth
and increasing area. Values above 2.0 select decreasing area. Beware that unnecessarily high
degression values will cause a large number of passes to be used.
The “compound slide angle” Q- is the angle (in degrees) describing to what extent successive passes
should be offset along the drive line. This is used to cause one side of the tool to remove more
material than the other. A positive Q value causes the leading edge of the tool to cut more heavily.
Typical values are 29, 29.5 or 30.
The number of “spring passes” is given by the H- value. Spring passes are additional passes at full
thread depth. If no additional passes are desired, program H0.
Tapered entry and exit moves can be programmed using E- and L-. E- gives a distance along the
drive line used for the taper. E0.2 will give a taper for the first/last 0.2 length units along the thread. L-
is used to specify which ends of the thread get the taper. Program L0 for no taper (the default), L1 for
entry taper, L2 for exit taper, or L3 for both entry and exit tapers.
The tool will pause briefly for synchronization before each threading pass, so a relief groove will be
required at the entry unless the beginning of the thread is past the end of the material or an entry
taper is used.
Unless using an exit taper, the exit move (traverse to original X) is not synchronized to the spindle
speed. With a slow spindle, the exit move might take only a small fraction of a revolution. If the
spindle speed is increased after several passes are complete, subsequent exit moves will require a
larger portion of a revolution, resulting in a very heavy cut during the exit move. This can be avoided
by providing a relief groove at the exit, or by not changing the spindle speed while threading.
The sample program g76.ngc shows the use of the G76 canned cycle, and can be previewed and
executed on any machine using the sim/lathe.ini configuration.
3) The CPU programmed such that a movement is started on the spindle pulse.
6) Before the treading starts, the spindle-rate is measured, averaged and the feed is calculated
from this.
Not that the inside and outside thread diameter are determined by the start position, the position
before G76 and the I, K parameters.
It is an error if:
Axis words are programmed when G80 is active, unless a modal group 0 G code is
programmed which uses axis words.
All canned cycles are performed with respect to the currently selected plane. Any of the three planes
(XY, YZ, and ZX) may be selected. Throughout this section, most of the descriptions assume the XY-
plane has been selected. The behavior is always analogous if the YZ or XZ-plane is selected.
Rotational axis words are allowed in canned cycles, but it is better to omit them. If rotational axis
words are used, the numbers must be the same as the current position numbers so that the rotational
axes do not move.
All canned cycles use X, Y, R, and Z numbers in the NC code. These numbers are used to determine
X, Y, R, and Z positions. The R (usually meaning retract) position is along the axis perpendicular to
the currently selected plane (Z-axis for XY-plane, X-axis for YZ-plane, Y-axis for XZ-plane). Some
canned cycles use additional arguments.
For canned cycles, we will call a number "sticky" if, when the same cycle is used on several lines of
code in a row, the number must be used the first time, but is optional on the rest of the lines. Sticky
numbers keep their value on the rest of the lines if they are not explicitly programmed to be different.
The R number is always sticky.
In incremental distance mode: when the XY-plane is selected, X, Y, and R numbers are treated as
increments to the current position and Z as an increment from the Z-axis position before the move
involving Z takes place; when the YZ or XZ-plane is selected, treatment of the axis words is
analogous. In absolute distance mode, the X, Y, R, and Z numbers are absolute positions in the
current coordinate system.
The L number is optional and represents the number of repeats. L=0 is not allowed. If the repeat
feature is used, it is normally used in incremental distance mode, so that the same sequence of
motions is repeated in several equally spaced places along a straight line. In absolute distance mode,
L > 1 means "do the same cycle in the same place several times," Omitting the L word is equivalent
to specifying L=1. The L number is not sticky.
When L>1 in incremental mode with the XY-plane selected, the X and Y positions are determined by
adding the given X and Y numbers either to the current X and Y positions (on the first go-around) or
to the X and Y positions at the end of the previous go-around (on the repetitions). The R and Z
positions do not change during the repeats.
The height of the retract move at the end of each repeat (called "clear Z" in the descriptions below) is
determined by the setting of the retract mode: either to the original Z position (if that is above the R
position and the retract mode is G98, OLD_Z), or otherwise to the R position. See Section 3.5.20
It is an error if:
X, Y, and Z words are all missing during a canned cycle,
a P number is required and a negative P number is used,
an L number is used that does not evaluate to a positive integer,
rotational axis motion is used during a canned cycle,
inverse time feed rate is active during a canned cycle,
cutter radius compensation is active during a canned cycle.
When the XY plane is active, the Z number is sticky, and it is an error if:
the Z number is missing and the same canned cycle was not already active,
the R number is less than the Z number.
When the XZ plane is active, the Y number is sticky, and it is an error if:
the Y number is missing and the same canned cycle was not already active,
the R number is less than the Y number.
When the YZ plane is active, the X number is sticky, and it is an error if:
the X number is missing and the same canned cycle was not already active,
the R number is less than the X number.
In addition, at the beginning of the first cycle and each repeat, the following one or two moves are
made:
1. a straight traverse parallel to the XY-plane to the given XY-position,
2. a straight traverse of the Z-axis only to the R position, if it is not already at the R position.
If the XZ or YZ plane is active, the preliminary and in-between motions are analogous.
Example: Suppose the current position is (1, 2, and 3) and the XY-plane has been selected, and the
following line of NC code is interpreted.
This calls for absolute distance mode (G90) and OLD_Z retract mode (G98) and calls for the G81
drilling cycle to be performed once. The X number and X position are 4. The Y number and Y position
are 5. The Z number and Z position are 1.5. The R number and clear Z are 2.8. Old Z is 3. The
following moves take place.
1. a traverse parallel to the XY-plane to (4,5,3)
2. a traverse parallel to the Z-axis to (4,5,2.8)
3. a feed parallel to the Z-axis to (4,5,1.5)
4. a traverse parallel to the Z-axis to (4,5,3)
Example: Suppose the current position is (1, 2, and 3) and the XY-plane has been selected, and the
following line of NC code is interpreted.
This calls for incremental distance mode (G91) and OLD_Z retract mode (G98) and calls for the G81
drilling cycle to be repeated three times. The X number is 4, the Y number is 5, the Z number is -0.6
and the R number is 1.8. The initial X position is 5 (=1+4), the initial Y position is 7 (=2+5), the clear Z
position is 4.8 (=1.8+3), and the Z position is 4.2 (=4.8-0.6). Old Z is 3.
The first move is a traverse along the Z-axis to (1,2,4.8), since old Z < clear Z.
The first repeat consists of 3 moves.
1. a traverse parallel to the XY-plane to (5,7,4.8)
2. a feed parallel to the Z-axis to (5,7, 4.2)
3. a traverse parallel to the Z-axis to (5,7,4.8)
The second repeat consists of 3 moves. The X position is reset to 9 (=5+4) and the Y position to 12
(=7+5).
1. a traverse parallel to the XY-plane to (9,12,4.8)
2. a feed parallel to the Z-axis to (9,12, 4.2)
3. a traverse parallel to the Z-axis to (9,12,4.8)
The third repeat consists of 3 moves. The X position is reset to 13 (=9+4) and the Y position to 17
(=12+5).
1. a traverse parallel to the XY-plane to (13,17,4.8)
2. a feed parallel to the Z-axis to (13,17, 4.2)
3. a traverse parallel to the Z-axis to (13,17,4.8)
It is an error if:
• the Q number is negative or zero.
The spindle must be turning before this cycle is used. It is an error if:
the spindle is not turning before this cycle is executed.
The situation, as shown in Figure 3-1, is that you have a through hole and you want to counter bore
the bottom of hole. To do this you put an L-shaped tool in the spindle with a cutting surface on the
UPPER side of its base. You stick it carefully through the hole when it is not spinning and is oriented
so it fits through the hole, then you move it so the stem of the L is on the axis of the hole, start the
spindle, and feed the tool upward to make the counter bore. Then you stop the tool, get it out of the
hole, and restart it.
This cycle uses I and J numbers to indicate the position for inserting and removing the tool. I and J
will always be increments from the X position and the Y position, regardless of the distance mode
setting. This cycle also uses a K number to specify the position along the Z-axis of the controlled
point top of the counter bore. The K number is a Z-value in the current coordinate system in absolute
distance mode, and an increment (from the Z position) in incremental distance mode.
When programming this cycle, the I and J numbers must be chosen so that when the tool is stopped
in an oriented position, it will fit through the hole. Because different cutters are made differently, it
may take some analysis and/or experimentation to determine appropriate values for I and J.
To go into absolute distance mode, program G90. In absolute distance mode, axis numbers (X, Y, Z,
A, B, C) usually represent positions in terms of the currently active coordinate system. Any
exceptions to that rule are described explicitly in this Section 3.5.
To go into incremental distance mode, program G91. In incremental distance mode, axis numbers (X,
Y, Z, A, B, C) usually represent increments from the current values of the numbers.
I and J numbers always represent increments, regardless of the distance mode setting. K numbers
represent increments in all but one usage (see Section 3.5.16.8), where the meaning changes with
distance mode.
It is an error if:
all axis words are omitted.
When G92 is executed, the origin of the currently active coordinate system moves. To do this, origin
offsets are calculated so that the coordinates of the current point with respect to the moved origin are
as specified on the line containing the G92. In addition, parameters 5211 to 5216 are set to the X, Y,
Z, A, B, and C-axis offsets. The offset for an axis is the amount the origin must be moved so that the
coordinate of the controlled point on the axis has the specified value.
Here is an example. Suppose the current point is at X=4 in the currently specified coordinate system
and the current X-axis offset is zero, then G92 x7 sets the X-axis offset to -3, sets parameter 5211 to
-3, and causes the X-coordinate of the current point to be 7.
The axis offsets are always used when motion is specified in absolute distance mode using any of
the nine coordinate systems (those designated by G54 - G59.3). Thus all nine coordinate systems
are affected by G92.
Non-zero offsets may already be in effect when the G92 is called. If this is the case, the new value of
each offset is A+B, where A is what the offset would be if the old offset were zero, and B is the old
offset. For example, after the previous example, the X-value of the current point is 7. If G92 x9 is then
programmed, the new X-axis offset is -5, which is calculated by [[7-9] + -3].
To reset axis offsets to zero, program G92.1 or G92.2. G92.1 sets parameters 5211 to 5216 to zero,
whereas G92.2 leaves their current values alone.
To set the axis offset values to the values given in parameters 5211 to 5216, program G92.3.
You can set axis offsets in one program and use the same offsets in another program. Program G92
in the first program. This will set parameters 5211 to 5216. Do not use G92.1 in the remainder of the
first program. The parameter values will be saved when the first program exits and restored when the
second one starts up. Use G92.3 near the beginning of the second program. That will restore the
offsets saved in the first program. If other programs are to run between the program that sets the
offsets and the one that restores them, make a copy of the parameter file written by the first program
and use it as the parameter file for the second program.
In units per minute feed rate mode, an F word (no, not that F word; we mean feed-rate) is interpreted
to mean the controlled point should move at a certain number of inches per minute, millimeters per
minute, or degrees per minute, depending upon what length units are being used and which axis or
axes are moving.
In inverse time feed rate mode, an F word means the move should be completed in [one divided by
the F number] minutes. For example, if the F number is 2.0, the move should be completed in half a
minute.
When the inverse time feed rate mode is active, an F word must appear on every line which has a
G1, G2, or G3 motion, and an F word on a line that does not have G1, G2,
or G3 is ignored. Being in inverse time feed rate mode does not affect G0 (rapid traverse) motions.
It is an error if:
inverse time feed rate mode is active and a line with G1, G2, or G3 (explicitly or implicitly)
does not have an F word.
To use option (1), program G99. To use option (2), program G98. Remember that the R word has
different meanings in absolute distance mode and incremental distance mode.
M Code Meaning
M0 program stop
M1 optional program stop
M2 program end
M3 turn spindle clockwise
M4 turn spindle counterclockwise
M5 stop spindle turning
M6 tool change
M7 mist coolant on
M8 flood coolant on
M9 mist and flood coolant off
M30 program end, spindle and coolants off and rewind.
M48 enable speed and feed overrides
M49 disable speed and feed overrides
M60 program stop, use this with nesting in stead of M60, so that the spindle/coolants remain on
during transition from one to the next run.
M64 set general purpose output for Advantronix USB IO card (support is depricated)
M65 clear general purpose output for Advantronix USB IO card (support is depricated)
M66 read general purpose input for Advantronix USB IO card (support is depricated)
3.6.1 Program Stopping and Ending - M0, M1, M2, M30, M60
To stop a running program temporarily (regardless of the setting of the optional stop switch), program
M0 or M1. If a program is stopped by an M0, M1, or M60, pressing the cycle start button will restart
the program at the following line, so the program will continue.
To end a program, program M2.
program M30 for next effects:
Selected plane is set to CANON_PLANE_XY (like G17).
Distance mode is set to MODE_ABSOLUTE (like G90).
Feed rate mode is set to UNITS_PER_MINUTE (like G94).
No more lines of code in an RS274/NGC file will be executed after the M2 or M30 command is
executed. Pressing cycle start will start the program back at the beginning of the file.
The tool change may include axis motion while it is in progress. It is OK (but not useful) to program a
change to the tool already in the spindle. It is OK if there is no tool in the selected slot; in that case,
the spindle will be empty after the tool change. If slot zero was last selected, there will definitely be no
tool in the spindle after a tool change.
The tool change command will call the change_tool subroutine inside macro.cnc.
You can adapt the behavior for your own needs in this function e.g:
Perform automatic tool-length measurement
Perform tool change with an automatic tool changer.
For a (non functional) example of how to implement automatic tool change for a 16-tool changer.
see the contents of the default_macro.cnc file at the end of this document. It checks whether current
tool is already in the spindle. It check that the tool number is in range of 1-4. Then it first drops
current tool and picks the new tool:
3.6.6 IO M Functions
To control the outputs, these functions have been added besides the standard M-Functions.
M54 Px
Set output x.
M54 Ex Qy
Set PWM output x to % value y (0 <= y <= 100)
M55 Px
Clear output x.
M56 Px
Read input x.
M56 Px Ly Qx.xx
Read digital input and specify wait mode
Px: x is input number
L0: do not wait
L1, L3: Wait mode High
L2, L4: Wait mode Low
Qx: x is timeout
M56 Ex Ly Qx.xx
==========
Read analogue input and specify wait mode
Ex: x is input number
L0: do not wait
L1, L3: Wait mode High
For all M56 variants, the input value is stored into #5399
For the general purpose I/O of CPU5, use M54, M55, M56 in stead of M64, M65, M66.
It is an error if:
the S number is negative.
As described in Section 3.5.16.5, if a G84 (tapping) canned cycle is active and the feed and speed
override switches are enabled, the one set at the lower setting will take effect. The speed and feed
rates will still be synchronized. In this case, the speed may differ from what is programmed, even if
the speed override switch is set at 100%.
It is an error if:
a negative T number is used,
a T number larger than the number of slots in the carousel is used.
On some machines, the carousel will move when a T word is programmed, at the same time
machining is occurring. On such machines, programming the T word several lines before a tool
change will save time. A common programming practice for such machines is to put the T word for
the next tool to be used on the line after a tool change. This maximizes the time available for the
carousel to move.
4 Language extensions
To provide additional flexibility, I created some extensions in the language that allow for
programming.
round round
sin sine
sqrt square root
tan tangent
not logical not
4.2.3 An example:
sub do_circle_holes
#1=0
g0 z1 x0 y0
while [#1 <> 360]
#2 = [10 * sin[#1]]
#3 = [10 * cos[#1]]
g0 x[#3] y[#2]
g1 z-1
g1 z1
#1 = [#1 + 30]
if [#1 == 360]
msg "Done"
else
msg "processing at angle "#1
endif
endwhile
endsub
gosub do_circle_holes
m30
This example drills holes at a circle with a radius of 10, each 30 degrees. The code that performs this
is put in a subroutine, which can be called as many times as needed in the main program.
ErrMsg
Same as Msg, but this one generates an error
Store position
SP <filename> [0 or 1]
This command stores the actual position in given file name.
The extra parameter 0 means create the file.
1 means add to existing file.
If only file name is given, the position is added to existing file.
DlgMsg
Gives a dialog message for an interactive g-code program.
DlgMsg <dialog message> <par1Name> <par1ParNumber> ... <par12Name> <par12ParNumber>
Example:
DlgMsg "Give parameters" par1 100 par2 101
The dialog woll have an OK and a Cancel button.
When the user selects OK, variable #5398 is set to 1 and the program automatically continues.
When the user selects CANCEL, variable #5398 is set to -1, program continues.
Just try and you will see what this is about.
if <dialog message>.png picture exist it will be show.
;dlgmsg will pop up a dialog with picture usbcnc.png from c:\program files\usbcnc4\dialogPictures directory
dlgmsg "usbcnc" "A" 1 "B" 2 "C" 3 "D" 4 "E" 5 "F" 6 "G" 7 "H" 8 "I" 9 "J" 10 "K" 11 "L" 12
if [#5398 == 1]
msg "OK #1="#1 "#2="#2 "#3="#3 "#4="#4 "#5="#5 "#6="#6 "#7="#7 "#8="#8 "#9="#9 "#10="#10 "#11="#11 "#12="#12
else
msg "CANCEL #1="#1 "#2="#2 "#3="#3 "#4="#4 "#5="#5 "#6="#6 "#7="#7 "#8="#8 "#9="#9 "#10="#10 "#11="#11 "#12="#12
endif
Endsub
LogFile, LogMsg
Log anything to a file..
LogFile <fileName> <1=append, 0=open new>
LogMsg your message
Example:
LogFile “text.txt” 1
LogMsg “Hi, the current position of X is “#5001
Gosub subname moves the interpreter to the first line off the subroutine, allowing you to execute the
subroutine without calling it from the main program. This is good for testing subroutines. In combination with
DlgMsg you can give your own input parameters.
The tool change area can be guarded for collision, if it is defined the rendering process will detect eventual
collisions and report it. So a normal workpiece program is not allowed to go through the Tool change Area.
The tool change itself is allowed to go to this area. Therefor the change_tool subroutine contains the statement
References
[Albus]
Albus, James S; et al; NIST Support to the Next Generation Controller Program: 1991 Final
Technical Report; NISTIR 4888; National Institute of Standards and Technology,
Gaithersburg, MD; July 1992
[Allen-Bradley]
Allen-Bradley; RS274/NGC for the Low End Controller; First Draft; Allen-Bradley; August
1992
[EIA]
Electronic Industries Association; EIA Standard EIA-274-D Interchangeable Variable Block
Data Format for Positioning, Contouring, and Contouring/Positioning Numerically Controlled
Machines; Electronic Industries Association; Washington, DC; February 1979
[Fanuc]
Fanuc Ltd.; Fanuc System 9-Model A Operators Manual; Pub B-52364E/03; Fanuc Ltd; 1981
[Kramer1]
Kramer, Thomas R.; Proctor, Frederick M.; Michaloski, John L.; The NIST RS274/NGC
Interpreter, Version 1; NISTIR 5416; National Institute of Standards and Technology,
Gaithersburg, MD; April 1994
[Kramer2]
Kramer, Thomas R.; Proctor, Frederick M.; The NIST RS274KT Interpreter; NISTIR 5738;
National Institute of Standards and Technology, Gaithersburg, MD; October 1995
[Kramer3]
Kramer, Thomas R.; Proctor, Frederick M.; The NIST RS274/NGC Interpreter -Version 2;
NISTIR 5739; National Institute of Standards and Technology, Gaithersburg, MD; October
1995
[Kramer4]
Kramer, Thomas R.; Proctor, Frederick M.; The NIST RS274/VGER Interpreter; NISTIR
5754; National Institute of Standards and Technology, Gaithersburg, MD; November 1995
[K&T]
Kearney and Trecker Co.; Part Programming and Operating Manual, KT/CNC Control, Type
C; Pub 687D; Kearney and Trecker Corp.; 1980
[NCMS]
National Center for Manufacturing Sciences; The Next Generation Controller Part
Programming Functional Specification (RS-274/NGC); Draft; NCMS; August 1994
[Proctor]
Proctor, Frederick M.; Kramer, Thomas R.; Michaloski, John L.; Canonical Machining
Commands; NISTIR 5970; National Institute of Standards and Technology, Gaithersburg,
MD; January 1997
A.1 INTRODUCTION
The cutter radius compensation capabilities of the Interpreter enable the programmer to
specify that a cutter should travel to the right or left of an open or closed contour in the XY-
plane composed of arcs of circles and straight line segments.
Cutter radius compensation is performed only with the XY-plane active. All the figures in this
appendix, therefore, show projections on the XY-plane.
Where the adjacent sides of remaining material meet at a corner, there are two common ways
to handle the tool path. The tool may pass in an arc around the corner, or the tool path may
continue straight in the direction it was going along the first side until it reaches a point where
it changes direction to go straight along the second side. Figure A-1 shows these two types of
path. On Figure A-1:
Uncut material is shaded in the figures. Note that the inner triangles have the same
shape with both tool paths.
The white areas are the areas cleared by the tool.
The lines in the center of the white areas represent the path of the tip of a cutting tool.
The tool is the cross-hatched circles.
Both paths will clear away material near the shaded triangle and leave the shaded triangle
uncut. When the Interpreter performs cutter radius compensation, the tool path is rounded at
the corners, as shown on the left in Figure A-1. In the method on the right (the one not used),
the tool does not stay in contact with the shaded triangle at sharp corners, and more material
than necessary is removed.
There are also two alternatives for the path that is programmed in NC code during cutter
radius compensation. The programmed path may be either (1) the edge of the material to
remain uncut (for example, the edge of the inner triangle on the left of Figure A-1), or (2) the
nominal tool path (for example, the tool path on the left side of Figure A-1). The nominal tool
path is the path that would be used if the tool were exactly the intended size. The Interpreter
will handle both cases without being told which one it is. The two cases are very similar, but
different enough that they are described in separate sections of this manual. To use the
material edge method, read Section A.3. To use the nominal path method, read Section A.4.
Figure A-1
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, following the contour to
the next point at which machining should be done, and re-extending the Z-axis. These skip
motions may be performed at feed rate (G1) or at traverse rate (G0). The Z motion will not
interfere with the XY path following. The sample NC code in this appendix does not include
moving the Z-axis. In actual programs, include Z-axis motion wherever you want it.
Rotational axis motions (A, B, and C axes) are allowed with cutter radius compensation, but
using them would be very unusual.
Inverse time feed rate (G93) or units per minute feed rate (G94) may be used with cutter
radius compensation. Under G94, the feed rate will apply to the actual path of the cutter tip,
not to the programmed contour.
To start cutter radius compensation keeping the tool to the right of the contour, program G42
D… .
In Figure A-1, for example, if G41 were programmed, the tool would move clockwise around
the triangle, so that the tool is always to the left of the triangle when facing in the direction of
travel. If G42 were programmed, the tool would stay right of the triangle and move counter
clockwise around the triangle.
4.3.4 Sequencing
If G40, G41, or G42 is programmed on the same line as tool motion, cutter
compensation will be turned on or off before the motion is made. To make the motion come
first, the motion must be programmed on a separate, previous line of code.
Figure A-2, Cutting radius compensation entry moves (for material edge contour)
First, pick a point A on the contour where it is convenient to attach an entry arc. Specify an
arc outside the contour which begins at a point B and ends at A tangent to the contour (and
going in the same direction as it is planned to go around the contour). The radius of the arc
should be larger than half the diameter given in the tool table. Then extend a line tangent to
the arc from B to some point C, located so that the line BC is more than one tool radius long.
After the construction is finished, the code is written in the reverse order from the
construction. The NC code is shown in Table A-1; the first three lines are the entry moves just
described.
Cutter radius compensation is turned on after the first pre-entry move and before the second
pre-entry move (including G41 on the same line as the second pre-entry move turns
compensation on before the move is made). In the code above, line N0010 is the first pre-
entry move, line N0020 turns compensation on and makes the second pre-entry move, and
line N0030 makes the entry move.
First, pick a convex corner. There is only one corner in Figure A-3. It is at A, and it is convex.
Decide which way you want to go along the contour from A. In our example we are keeping
the tool to the left of the remaining material and going clockwise. Extend the side to be cut
(DA in the figure) to divide the area outside the material near A into two regions; DA extended
is the dotted line AC on the figure. Make a pre-entry move to anywhere in the region on the
same side of DC as the remaining material (point B on the figure) and not so close to the
remaining material that the tool is cutting into it. Anywhere in the diagonally shaded area of
the figure (or above or to the left of that area) is OK. If the tool is already in region, no pre-
entry move is needed. Write a line of NC code to move to B, if necessary. Then write a line of
NC code for a straight entry move that turns compensation on and goes to point A.
If B is at (1.5, 4), the two lines of code for the pre-entry and entry moves would be:
These two lines would be followed by four lines identical to lines N0050 to N0080 from Table
A-1, but the end of the program would be different since the shape of remaining material is
different.
It would be OK for B to be on line AC. In fact, B could be placed on the extension outside the
part of any straight side of the part. B could be placed on EF extended to the right (but not to
the left, for going clockwise), for example.
If DA were an arc, not a straight line, the two lines of code above would still be suitable. In this
case, the dotted line extending DA should be tangent to DA at A.
Figure A-3 Simpler cutter radius compensation entry move (for material edge contour)
For a nominal path contour, the value for the cutter diameter in the tool table will be a small
positive number if the selected tool is slightly oversized and will be a small negative number if
the tool is slightly undersized. If a cutter diameter value is negative, the Interpreter
compensates on the other side of the contour from the one programmed and uses the
absolute value of the given diameter. If the actual tool is the correct size, the value in the table
should be zero. Suppose, for example, the diameter of the cutter currently in the spindle is
0.97, and the diameter assumed in generating the tool path was 1.0. Then the value in the
tool table for the diameter for this tool should be -0.03.
The nominal tool path needs to be programmed so that it will work with the largest and
smallest tools expected to be actually used. We will call the difference between the radius of
the largest expected tool and the intended radius of the tool the "maximum
radius difference." This is usually a small number.
The method includes programming two pre-entry moves and one entry moves. See Figure A-
4. The shaded area is the remaining material. The dashed line is the programmed tool path.
The solid line is the actual path of the tool tip. Both paths go clockwise around the remaining
material. The actual path is to the right of the programmed path even though G41 was
programmed, because the diameter value is negative. On the figure, the distance between
the two paths is larger than would normally be expected. The 1-inch diameter tool is shown
part way around the path. The black dots mark points at the beginning or end of programmed
moves. The corresponding points on the actual path have not been marked. The actual path
will have a very small additional arc near point B unless the tool diameter is exactly the size
intended. The figure shows the second pre-entry move but not the first, since the beginning
point of the first pre-entry move could be anywhere.
First, pick a point A on the contour where it is convenient to attach an entry arc. Specify an
arc outside the contour which begins at a point B and ends at A tangent to the contour (and
going in the same direction as it is planned to go around the contour). The radius of the arc
should be larger than the maximum radius difference. Then extend a line tangent to the arc
from B to some point C, located so that the length of line BC is more than the maximum
radius difference. After the construction is finished, the code is written in the reverse order
from the construction. The NC code is shown in Table A-2; the first three lines are the entry
moves just described.
Cutter radius compensation is turned on after the first pre-entry move and before the second
pre-entry move (including G41 on the same line as the second pre-entry move turns
compensation on before the move is made). In the code above, line N0010 is the first pre-
entry move, line N0020 turns compensation on and makes the second pre-entry move, and
line N0030 makes the entry move.
Most of these are self-explanatory. For those that require explanation, an explanation is given
below.
Changing a tool while cutter radius compensation is on is not treated as an error, although it
is unlikely this would be done intentionally. The radius used when cutter radius compensation
was first turned on will continue to be used until compensation is turned off, even though a
new tool is actually being used.
A.4.1 Concave Corner and Tool Radius Too Big (10 and 16)
When cutter radius compensation is on, it must be physically possible for a circle whose
radius is the half the diameter given in the tool table to be tangent to the contour at all points
of the contour. In particular, the Interpreter treats concave corners and concave arcs into
which the circle will not fit as errors, since the circle cannot be kept tangent to the contour in
these situations. See Figure A-5. This error detection does not limit the shapes which can be
cut, but it does require that the programmer specify the actual shape to be cut (or path to be
followed), not an approximation. In this respect, the NIST
RS274/NGC Interpreter differs from interpreters used with many other controllers, which often
allow these errors silently and either gouge the part or round the corner.
In both examples, the line represents a contour, and the circle represents the cross section of
a tool following the contour using cutter radius compensation (tangent to one side of the
path.)
The function that locates the destination point actually takes a computational shortcut based
on the fact that the line (not drawn on the figure) from the current point to the programmed
point is the hypotenuse of a right triangle having the destination point at the corner with the
right angle.
If the first move after cutter radius compensation has been turned on is an arc, the arc which
is generated is derived from an auxiliary arc which has its center at the programmed center
point, passes through the programmed end point, and is tangent to the cutter at its current
location. If the auxiliary arc cannot be constructed, an error is signaled. The generated arc
moves the tool so that it stays tangent to the auxiliary arc throughout the move. This is shown
in Figure A-7.
Figure A-7 shows the conceptual approach for finding the arc. The actual computations differ
between the center format arc and the radius format arc (see Section 3.5.3).
After the entry moves of cutter radius compensation, the Interpreter keeps the tool tangent to
the programmed path on the appropriate side. If a convex corner is on the path, an arc is
inserted to go around the corner. The radius of the arc is half the diameter given in the tool
table.
When cutter radius compensation is turned off, no special exit move takes place. The next
move is what it would have been if cutter radius compensation had never been turned on and
the previous move had placed the tool at its current position.
To prevent this miss function due to EMC, the USBCNC CPU should be build in correctly according these general
EMC rules:
Route motor cables nicely along the cabinet edge, as far as possible away from the CPU. This way the cables
noise radiation can flow away to the cabinet.
Use shielded cables for the motor connections, both inside the cabinet and outside the cabinet. Connect the
shield at one side to the central ground point, leave the other side un-connected.
Use a professional USB2 cable, double shielded with ferrites like this:
Keep all GND cables especially short and use thick flexible cable
If not possible to keep it short, then connect it to the metal GND plate.
Here a picture of my own system, it contains various EMC problem makers, like 2 Switched mode power supplies
and a frequency inverter for a HF spindle. Check the routing of the Motor and drive supply wires.
Also there a 4 stepper-motor drives working at 75 Volt, motor currents 4,2 Amp.