CNC Tutorial: Isaac Jo Washington State University Tri-Cities
CNC Tutorial: Isaac Jo Washington State University Tri-Cities
Part 1 ~ Coordinates
First, you have to get coordinates that will tell the CNC machine where to go. Either a sketch on graph paper or Solidworks can be used. I went with Solidworks because it is easy to quickly get coordinates.
Step 1
Open a new le in Solidworks. For this tutorial, the units are inches. Make sure that Solidworks is in IPS units. (Inches - Pounds - Seconds) Click Sketch. Click on the front plane. This will open up a sketch on the front plane (xy plane). For this tutorial, you dont need to get z coordinates because that will be your vertical distance and is determined by the depth of cut. I am going to etch a capital R and small q on a 5 x 5 blank and 0.5 depth. The R and q are made using straight lines two arcs one full circle
Using the rectangle tool, sketch the rectangle with the bottom left corner at the origin as shown.
Step 2
Now that the blank is drawn, we can start the letters starting with the straight edges rst. Use the line tool. The dimensions dont matter yet.
Step 3
Click on the circle to select it. Hold down Shift and click the line as shown to select both. Under Add Relations, click Tangent.
Step 3 contd.
Using the 3-Point Arc tool sketch two semi circles. Then dimension as shown using Smart Dimensions.
Step 4
Click on any point to display coordinates. Click on an arc or circle to display both radius and center coordinates. Record all these points in Notepad or Excel.
When recording the coordinates, record the points in a systematic way like left to right. Think how you would write it out by hand. For example, I wouldnt start the top line of the R and then move to the q on the next coordinates. It would be better to make the vertical line on the R and follow as shown.
Step 5 contd.
Now that the coordinates have been found, you have to compile a g-code le.
Part 2 ~ G-code
CNC machines use G-code to run through set of coordinates in specic order. Command G0 G1 G2 G3 Description Rapid movement, only for positioning tool Cutting on specied path at specied feed Clockwise cutting Counter clockwise cutting
Introduction
In this tutorial, we are using a 3-Axis CNC machine. This means for all code, most of the coordinates are in the XY plane (horizontal plane) with ONLY the depth of cut determined by the Z direction (vertical). So all lines and arcs are 2D for this tutorial. The rst lines of code are typed in Notepad. Im assuming that z = 0 at the top face of the 5 x 5 blank throughout this tutorial. Example G20 x0 y0 z0.25 (G20 species inch units, the x y z tells where the tool starts at, in this case 0.25 inch above the top face.) The next line of code is t1 m6 m3 f0.01 s200 (t1 tells the CNC machine its using tool #1, we will specify the tool diameter later, f0.01 species the feed rate and s200 species the spindle speed.) Note that the feed rate and speed is arbitrary and any value can be used. After those commands, the rest of the code looks like this: N01 x0.0 y0.0 z0.0 N02 x2.0 N03 x2.5 y2 z-0.250 .... N species the line number of code and x, y, and z are the coordinates. I will go into detail each type of code for straight line, arc, and full circle.
10
Arc Command
For Arcs, the CNC machine will either follow a clockwise path or counter clockwise path as dened by G2 and G3. There are three elements to any arc in g-code. Start Point Arc Center End point Besides X,Y, and Z, we dene the arc center with i and j. Note that the arc center can be either relative to the start point or absolute coordinates. For this tutorial, absolute coordinates will be used. Example N01 G0 x3.00 y2.50 z0.5 N02 G1 z-0.01 (So the starting point is at (3.00,2.50,-0.01) ) N03 G2 x4.00 y2.50 i3.50 j2.50 (G2 signies clockwise motion, end point is at (4.00,2.50,-0.01), center of arc at (3.50,2.50,-0.01) )
11
Full circles can be drawn simply by setting the start coordinate equal to the nish coordinate. Example N01 G0 x3.00 y2.50 z0.5 N02 G1 z-0.01 N03 G2 x3.00 y2.50 i3.50 j2.50 CNC machines have limitations on deep the cut per pass. To achieve deeper cuts, the XY path must be repeated with a slightly bigger Z value. For example if a 0.1 inch deep line is to be machined and the maximum depth of cut is 0.02 inch/pass, the XY code would have to be repeated 5 times (0.1 divided by 0.02). The code can be easily copy and pasted to repeat and the Z coordinate modied. Example N01 G0 x3.00 y2.50 z0.5 N02 G1 z-0.02 N03 G2 x3.00 y2.50 i3.50 j2.50 N04 G1 x3.00 y2.50 z0.5 N05 G1 z-0.04 N06 G2 x3.00 y2.50 i3.50 j2.50 N07 G1 x3.00 y2.50 z0.5 N08 G1 z-0.06 N09 G2 x3.00 y2.50 i3.50 j2.50 N10 G1 x3.00 y2.50 z0.5 N11 G1 z-0.08 N12 G2 x3.00 y2.50 i3.50 j2.50 N13 G1 x3.00 y2.50 z0.5 N14 G1 z-0.10 N15 G2 x3.00 y2.50 i3.50 j2.50 N16 G1 x3.00 y2.50 z0.5 Notice that the tool returns to a height of 0.5 each time then goes in for a deeper cut, increasing by 0.02 each time. When writing code, make sure you know where the tool is at all times or damage to the machine is a possibility. To test the code we write, we will use a free program called NCSim. For installation and operation of the program, see Part 3: NCSim.
Depth of Cut
12
Part 3 ~ NCSim
NCSim Install Guide
Go to http://www.cs.technion.ac.il/~gershon/NCSim/
13
Click Run.
14
15
16
17
18
Now you should see both the NCSim icon and folder on your desktop. Do not delete the folder.
19
From Part 1 and Part 2 of the tutorial, the actual g-code is:
G20 G00 x0 y0 z0.25 t1 m6 m3 f0.01 s200 N01 G0 x0.83 y1.52 z0.50 N02 G1 z-0.02 N03 y3.77 N04 G1 x1.25 N05 G2 x1.25 y2.77 i1.25 j3.27 N06 G1 x0.83 N07 x1.25 N08 x2.33 y1.52 N09 G0 z0.50 N10 G0 x0.83 y1.52 z0.50 N11 G1 z-0.04 N12 y3.77 N13 G1 x1.25 N14 G2 x1.25 y2.77 i1.25 j3.27 N15 G1 x0.83 N16 x1.25 N17 x2.33 y1.52 N18 G0 z0.50 N19 G0 x0.83 y1.52 z0.50 N20 G1 z-0.06 N21 y3.77 N22 G1 x1.25 N23 G2 x1.25 y2.77 i1.25 j3.27 N24 G1 x0.83 N25 x1.25 N26 x2.33 y1.52 N27 G0 z0.50 N28 G0 x0.83 y1.52 z0.50 N29 G1 z-0.08 N30 y3.77 N31 G1 x1.25 N32 G2 x1.25 y2.77 i1.25 j3.27 N33 G1 x0.83 N34 x1.25 N35 x2.33 y1.52 N36 G0 z0.50N01 G0 x0.83 y1.52 z0.50 N37 G1 z-0.1 N38 y3.77 N39 G1 x1.25 N40 G2 x1.25 y2.77 i1.25 j3.27 N41 G1 x0.83 N42 x1.25 N43 x2.33 y1.52 N44 G0 z0.50 N45 x3.45 y3.50 N46 G1 z-0.02 N47 x3.45 y3.00 N48 G2 x3.45 y3.00 i3.07 j3.00 N49 G1 y1.50 N50 G3 x3.95 y1.50 i3.70 j1.50 N51 y1.75 N52 G0 z0.5 N52 x3.45 y3.50 N53 G1 z-0.04
Saving a G-Code le
20
N54 x3.45 y3.00 N55 G2 x3.45 y3.00 i3.07 j3.00 N56 G1 y1.50 N57 G3 x3.95 y1.50 i3.70 j1.50 N58 y1.75 N59 G0 z0.5 N60 x3.45 y3.50 N61 G1 z-0.06 N62 x3.45 y3.00 N63 G2 x3.45 y3.00 i3.07 j3.00 N64 G1 y1.50 N65 G3 x3.95 y1.50 i3.70 j1.50 N66 y1.75 N67 G0 z0.5 N68 x3.45 y3.50 N69 G1 z-0.08 N70 x3.45 y3.00 N71 G2 x3.45 y3.00 i3.07 j3.00 N72 G1 y1.50 N73 G3 x3.95 y1.50 i3.70 j1.50 N74 y1.75 N75 G0 z0.5 N76 x0 y0 M00
Copy and paste your code into a Notepad le. Click Save As. Type in cnclab.nc and click the drop down list under the title and select all les Note that the le extension can be either .nc or .gcode Now you are ready to test your code in NCSim.
21
NCSim Simulation
Open NCSim. Click le, then open the cnclab.nc le
Make sure Relative arc centers and Reverse Z direction are not checked. The units are Inches. NCSim should look like this:
22
Now, click State then Simulation Parameters or use a Alt+P key combination. You will see the following.
NC Z-buffer should be checked. Change the tool type to Flat-End with a tool diameter of 1/8 in or 0.125 We need to change the stock dimensions to whatever dimensions the blank workpiece is going to be. In this case, we dened the top face as 0 in PART 1 of the tutorial. For the Min XYZ Dim, that is (0,0,-0.5). The -0.5 means the blank is 0.5 in thick. Maximum XYZ dimensions are (5,5,0)
23