G Code Example: How To Run Your First CNC Program

Visualization from Universal gCode Sender of the g code example program.

Congratulations, you machine is under its own power. By now you have spent some time jogging the machine around using the keyboard or the buttons on Universal G-Code Sender. This is all well and good, but the real power of your CNC machine lies in its ability to run long complex gcode programs. The following is a step by step guide on how to run a CNC program. We even include a gcode example program to run that will draw a circle. If you don’t have your machine running just yet and would like some guidance, check out How to setup your Arduino CNC Machine.

G Code Example

The following is exactly what is saved in the circle.nc file. Click the link below to download the file.

Download the g code example file

G17 G20 G90 G94 G54 G0 Z0.25 X-0.5 Y0. Z0.1 G01 Z0. F5. G02 X0. Y0.5 I0.5 J0. F2.5 X0.5 Y0. I0. J-0.5 X0. Y-0.5 I-0.5 J0. X-0.5 Y0. I0. J0.5 G01 Z0.1 F5. G00 X0. Y0. Z0.25

This simple program will draw a 1” diameter circle about the origin. Use this program to test your CNC machine and confirm your axis directions are set correctly.

Note all gcode programs a simple text files save with a “.nc” extension. You can open the “circle.nc” file downloaded above in a text editor like Notepad. You can also copy and past the above lines into a text editor and create your very own CNC program. Simply save the file with a .nc extension.

Start Here

Use the following steps to run the program… If you are more of a visual learner, scroll down and click on the video below for walk through of the process.

1. Load a marker into the spindle (Keep the spindle off!) Markers work better than pens or pencils because the tip is softer and more forgiving. Also setup a piece of paper or other material on which to draw near the center of your machine’s work envelop. 2. Power on your machine 3. Connect to the machine with Universal gCode Sender

Set Your Zero Position

4. Jog (move) the spindle to the center of your machine table

a. Under the “Machine Control” Tab enter “.1” into the “Step Size” box & press enter b. Ensure “inches” is selected c. Use the X+,X-,Y+ and Y- buttons to move the machine close to the center of your work table (You can also use the arrow keys on the keyboard) d. Press the “Reset X Axis” button (This tells the machine to remember this position as your X zero location) e. Press the “Reset Y Axis” button (This tells the machine to remember this position as your Y zero location) f. Now slowly use the “Z-“ button to lower the marker tip. When the marker tip gets close to the paper, stop. g. Adjust the “Step Size” to .01 (Remember to hit enter after you enter your value) h. Continue lowering the marker until it touches the paper by tapping the “Z-“ button. i. Press the “Reset Z Axis” button (This tells the machine to remember this position as your Z zero location) j. Retract the marker from the paper using the “Z+” button. Go at least .1” above the paper. This is equal to 10 clicks of the “Z+” button when your step size is set to .01

Load the CNC Program

5. Ok, now the machine is almost ready. 6. Go to the “File Mode” tab 7. Select “Browse” and search for the “circle.nc” file (If you have not downloaded the file click here) 8. Click “Open” 9. The next button press will send the “circle.nc” g Code program to your machine and it will start to move. As soon as I hit “Send” I like to move my mouse cursor over the “Pause” button. If anything goes wrong, all I have to do is click the mouse to stop the program since it’s over the pause button. 10. This is for all the marbles. Click the “Send” button. 11. The machine will start moving. a. First, it will move the Z axis to .25” b. Next, the machine will move to X = -0.5 and Y = 0.0 (Note the marker should not be touching the paper yet) c. Now the machine will lower to Z = 0.0 and then marker should touch the paper) d. The machine will slowly draw a clockwise circle. e. When the circle is complete, the machine will move the Z axis up to .1” f. Now that machine will return to the X & Y zero position. g. Finally the z axis will move back up to the original .25” starting position.

Video Walk Through

Click here to watch the video on YouTube.

Conclusion

That’s it! You just ran your first CNC program. As you run more programs, this process will become second nature. Again you can download the g code example by clinking the link below.

Download the g code example file

If you run into any problems, contact me at [email protected] or in the comment section.

What CNC program are you going to run next? Leave a comment and let me know.

Thanks for reading. Until next time…

Tim

P.S.

Now that your machine is running, check out the following options for tooling. Note, these are affiliate links and DIY Machining earns a commission if you purchase using the links below. However, there is no additional cost to you.

← Previous post

Next post →

Tag » Cnc 3018 G Code Example