CNC Router Programming
Some basics for FIRST Robotics
ROBOTICS ACADEMY: FRC CNC Router
Safety First
Safety glasses at all times in the shop
Router – As with any router, ensure it is unplugged prior to changing or touching the tool.
Mill table – Standard setup practices
Position cross head out of the way
Disable cross head with the E-stop
Mill table – Standard operating practices
Hearing protection
Guards up, hands out of the way
Be prepared to hit the E-stop if something goes awry
ROBOTICS ACADEMY: FRC CNC Router
CNC – Computer Numerical Control
Programming1) It’s not hard
The CNC “G-Code” is simply connect the dotsCommands are lines in a plain text file
2) Attention to detail is essentialSimple programming errors can break things
Operation1) It’s not hard
Just hit the button and go2) Attention to detail is essential
Watch for binding, hot tooling, programming errors
ROBOTICS ACADEMY: FRC CNC Router
Basic Controls
Our CNC mill software has control over:Location of coordinate system originUnits : in or mmX, Y & Z tool locationCutting velocity
Industrial mills also control Cutter selectionCutter rotation start / stopCutter rotational speedCoolant flow rateEtc….
X
YZ
ROBOTICS ACADEMY: FRC CNC Router
Basic G-CodeNamed “G-Code” because most commands begin with “G”
G0 X2.3 Y4.2 Z-0.5
Move at high speed to
Ending Location
G1 X2.3 Y4.2 Z-0.5
Move at controlled speed
to Ending Location
Each G1 command creates a single line segment
The ending location “X”, “Y” and “Z” only need to be specified if they are different than the current location
Used for positioning, not cutting
Used for cutting or positioning
Green numbers are for illustration. The red and black are keywords
X
YZ
ROBOTICS ACADEMY: FRC CNC Router
Connect the dot example
(0, 0) (0.5, 0)
(0.5, 2.0)(1.5, 2.0)
(1.5, 2.5)(-1.0, 2.5)
(-1.0, 2.0)
(0.0, 2.0)
G0 Z0.2G0 X0.0 Y0.0 Z0.2G1 X0.0 Y0.0 Z-0.25G1 X0.5 Y0.0 Z-0.25G1 X0.5 Y2.0 Z-0.25G1 X1.5 Y2.0 Z-0.25G1 X1.5 Y2.5 Z-0.25G1 X-1.0 Y2.5 Z-0.25G1 X-1.0 Y2.0 Z-0.25G1 X0.0 Y2.0 Z-0.25G1 X0.0 Y0.0 Z-0.25G0 X0.0 Y0.0 Z0.2G0 X-2.0 Y4.0 Z0.2
The light colored coordinates can be omitted Hollow “T” shape
ROBOTICS ACADEMY: FRC CNC Router
Connect the dot example
(0, 0) (0.5, 0)
(0.5, 2.0)(1.5, 2.0)
(1.5, 2.5)(-1.0, 2.5)
(-1.0, 2.0)
(0.0, 2.0)
G0 Z0.2G0 X0.0 Y0.0G1 Z-0.25G1 X0.5G1 Y2.0G1 X1.5G1 Y2.5G1 X-1.0G1 Y2.0G1 X0.0G1 Y0.0G0 Z0.2G0 X-2.0 Y4.0
Raise toolGet tool out of the way
Raise toolSet at starting pointLower tool
Unneeded coordinates omitted Hollow “T” shape
ROBOTICS ACADEMY: FRC CNC Router
Circles and arcs in G-CodeCircular arcs are the other basic shape that can be cut
G2 X2.3 Y4.2 Z-0.5 I1.1 J2.3 K-0.5
Clockwise arc
to Ending Location
Starting point for arc is previous tool location
The “K” center location will always be omitted for the CNC router
with Arc center
G3 X2.3 Y4.2 Z-0.5 I1.1 J2.3 K-0.5
Counter clockwise arc
to Ending Location
with Arc center
ROBOTICS ACADEMY: FRC CNC Router
-3 -2 -1 0 1 2 3
-6
-4
-2
0
2
4
6
G0 Z0.2G0 X1.0 Y4.0414518G1 Z-0.25G3 X-1.0 Y0.57735034 I0.0 J2.3094118G1 X1.0 Y-0.57735034G2 X-1.0 Y-4.0414518 I0.0 J-2.3094118 G0 Z0.2G0 X0.0 Y5.0G1 Z-0.25G1 Y-5.0G0 Z0.2G0 X-4 Y6
Example with arcs and linesCircular arcs have radius 2 and centers
€
0, ± 4 / 3( )
Raise toolInitial positionLower tool
Raise toolGo to top of lineLower toolVertical lineRaise toolGet out of the way
Top arcLineBot arc
ROBOTICS ACADEMY: FRC CNC Router
Tool speed control (Non-”G”-Code)Rotation speed of the router
Use the manual speed control on the router
Translation speed for cuttingUse the “F” commandSets speed in “inches/minute”Example
G0 Z0.2G0 X0.0 Y0.0F5.0 Lower slowlyG1 Z-0.25F15.0 Cut fasterG1 X0.5G1 Y2.0G1 X1.5
….
“F” speed remains in effect until changed
Affects G1, G2 & G3
Does not affect G0
Rotation and translation speeds are coupled by the amount of material that can be removed by the cutter without stalling or overheating.
If it smokes, melts or grunts, STOP!!
ROBOTICS ACADEMY: FRC CNC Router
Standard commands in the control file
%G20 G40 G50 G53 G90 G90.1( Use parentheses to add comments)……Machining related code ……M0 M30%
Use “%” at top and bottom
First line of code sets operating modes and will likely be the same for all programs. Look them up as an exercise.
The “M-Code” numbers says stop and end of program.
TIP: The M-codes and % can be used as an incremental debugging tool. Place within a large code to terminate the code early.
“Boilerplate” commands for all codes
ROBOTICS ACADEMY: FRC CNC Router
G-Code programming is simply a connect the dots text file with a few standard lines at the top and bottom of the file
Our mill cuts wood and can cut aluminum with a sharp tool and coolant Tool can only cut as deep as the cutting flutes on the tool bit Dull tools can make wood smoke and melt aluminum The mill program provides a picture of the tool path and lists the
minimum and maximum coordinates found in the program. Use these to double check the program.
Test new code with router off and tool elevated above the workpiece. Remember to zero the mill coordinates with respect to the workpiece. Most common error we have encountered is using a G0 instead of a
G1. This causes rapid motion which breaks the tool, ruins the part, and scares the operator.
Odds and ends
ROBOTICS ACADEMY: FRC CNC Router
Questions?
???