{"id":1488,"date":"2026-05-30T15:55:16","date_gmt":"2026-05-30T07:55:16","guid":{"rendered":"https:\/\/reliablecncmachining.com\/?p=1488"},"modified":"2026-05-30T15:55:16","modified_gmt":"2026-05-30T07:55:16","slug":"basic-methods-of-manual-g-code-programming-for-cnc-machining","status":"publish","type":"post","link":"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/","title":{"rendered":"Basic Methods of Manual G-Code Programming for CNC Machining"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Inhoudsopgave<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Schakel inhoudstabel in\/uit\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Schakelaar<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#CNC_Machining_Manual_G-Code_Programming_The_Foundation_Every_Machinist_Needs_to_Actually_Write_Code\" title=\"CNC Machining Manual G-Code Programming: The Foundation Every Machinist Needs to Actually Write Code\">CNC Machining Manual G-Code Programming: The Foundation Every Machinist Needs to Actually Write Code<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Why_Learn_Manual_G-Code_When_CAM_Software_Exists\" title=\"Why Learn Manual G-Code When CAM Software Exists\">Why Learn Manual G-Code When CAM Software Exists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#The_Core_G-Codes_You_Cannot_Avoid\" title=\"The Core G-Codes You Cannot Avoid\">The Core G-Codes You Cannot Avoid<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Movement_Codes_G00_G01_G02_G03\" title=\"Movement Codes: G00, G01, G02, G03\">Movement Codes: G00, G01, G02, G03<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Positioning_Codes_G90_G91_G54_G55_G56\" title=\"Positioning Codes: G90, G91, G54, G55, G56\">Positioning Codes: G90, G91, G54, G55, G56<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Feed_and_Speed_Codes_F_S_M03_M04_M05\" title=\"Feed and Speed Codes: F, S, M03, M04, M05\">Feed and Speed Codes: F, S, M03, M04, M05<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Structuring_a_Program_The_Skeleton_That_Holds_Everything_Together\" title=\"Structuring a Program: The Skeleton That Holds Everything Together\">Structuring a Program: The Skeleton That Holds Everything Together<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Program_Start_and_Safety_Lines\" title=\"Program Start and Safety Lines\">Program Start and Safety Lines<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Tool_Change_and_Tool_Offset\" title=\"Tool Change and Tool Offset\">Tool Change and Tool Offset<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#The_Cutting_Block_and_Retract\" title=\"The Cutting Block and Retract\">The Cutting Block and Retract<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Program_End_and_Reset\" title=\"Program End and Reset\">Program End and Reset<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Canned_Cycles_The_Shortcuts_That_Save_Hours\" title=\"Canned Cycles: The Shortcuts That Save Hours\">Canned Cycles: The Shortcuts That Save Hours<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Drilling_Cycle_G81\" title=\"Drilling Cycle: G81\">Drilling Cycle: G81<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Peck_Drilling_Cycle_G83\" title=\"Peck Drilling Cycle: G83\">Peck Drilling Cycle: G83<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Boring_Cycle_G76\" title=\"Boring Cycle: G76\">Boring Cycle: G76<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Tool_Compensation_G41_G42_G40\" title=\"Tool Compensation: G41, G42, G40\">Tool Compensation: G41, G42, G40<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#How_Cutter_Compensation_Actually_Works\" title=\"How Cutter Compensation Actually Works\">How Cutter Compensation Actually Works<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Lead-In_and_Lead-Out_with_Compensation\" title=\"Lead-In and Lead-Out with Compensation\">Lead-In and Lead-Out with Compensation<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Common_Mistakes_That_Crash_Parts_on_the_First_Run\" title=\"Common Mistakes That Crash Parts on the First Run\">Common Mistakes That Crash Parts on the First Run<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Forgetting_the_Decimal_Point\" title=\"Forgetting the Decimal Point\">Forgetting the Decimal Point<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Mixing_Modal_and_Non-Modal_Codes\" title=\"Mixing Modal and Non-Modal Codes\">Mixing Modal and Non-Modal Codes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Wrong_Plane_Selection_G17_G18_G19\" title=\"Wrong Plane Selection: G17, G18, G19\">Wrong Plane Selection: G17, G18, G19<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Debugging_Your_First_Programs_A_Practical_Approach\" title=\"Debugging Your First Programs: A Practical Approach\">Debugging Your First Programs: A Practical Approach<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Single_Block_and_Dry_Run\" title=\"Single Block and Dry Run\">Single Block and Dry Run<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Override_and_Rapid_Traverse\" title=\"Override and Rapid Traverse\">Override and Rapid Traverse<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#The_Air_Cut_Test\" title=\"The Air Cut Test\">The Air Cut Test<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/reliablecncmachining.com\/nl\/basic-methods-of-manual-g-code-programming-for-cnc-machining\/#Building_Simple_Programs_A_Walkthrough\" title=\"Building Simple Programs: A Walkthrough\">Building Simple Programs: A Walkthrough<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"CNC_Machining_Manual_G-Code_Programming_The_Foundation_Every_Machinist_Needs_to_Actually_Write_Code\"><\/span>CNC Machining Manual G-Code Programming: The Foundation Every Machinist Needs to Actually Write Code<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>Most machinists learn to operate a CNC machine long before they learn to program one. They push buttons, they load programs, they hit cycle start. But the day comes when the program crashes, the post-processor throws an error, or the part geometry is just unusual enough that no canned cycle handles it. That is the day you need to write G-code by hand. And if you have never done it, it feels like learning a foreign language where one wrong letter ruins the entire part. The good news is that manual G-code programming is not magic. It is a set of rules that, once you internalize them, become second nature. This is how you start from zero and write your first program without burning anything down.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Why_Learn_Manual_G-Code_When_CAM_Software_Exists\"><\/span>Why Learn Manual G-Code When CAM Software Exists<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>CAM software is powerful. It generates toolpaths, it optimizes feeds and speeds, it simulates the entire cut before you ever touch the machine. So why bother learning G-code?<\/p>\n<p>Because CAM does not always give you what you need. A CAM program might generate a toolpath that is inefficient for your specific machine. The post-processor might not support a particular canned cycle your controller uses. You might need to make a quick edit on the shop floor and opening the CAM file, regenerating the toolpath, and re-post-processing takes 20 minutes when you could fix the code in 30 seconds.<\/p>\n<p>Manual G-code also teaches you what the machine is actually doing. When you write G01 X50.0 F200, you understand that the tool is moving in a straight line at 200 mm per minute. When CAM generates that same line, it is abstract. You do not feel the machine. Learning manual programming builds an intuition that makes you a better machinist regardless of whether you ever write a full program by hand again.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"The_Core_G-Codes_You_Cannot_Avoid\"><\/span>The Core G-Codes You Cannot Avoid<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are over 100 G-codes in the full standard. You do not need all of them. You need about 15 to get started, and another 10 to handle most real-world situations.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Movement_Codes_G00_G01_G02_G03\"><\/span>Movement Codes: G00, G01, G02, G03<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G00 is rapid traverse. The machine moves at maximum speed from one point to another. No cutting happens during G00. You use it to position the tool above the part, to clear the cut, or to move between features.<\/p>\n<p>G01 is linear interpolation. The tool moves in a straight line at the feed rate you specify with F. This is the workhorse of every program. Every cut you make is a G01 move unless you are using a canned cycle.<\/p>\n<p>G02 is clockwise circular interpolation. G03 is counterclockwise. You use these for arcs, pockets, and any curved feature. The arc is defined by either the radius (R) or the endpoint coordinates (I, J, K). I and J are the incremental distances from the start point to the center of the arc. K is used for helical moves.<\/p>\n<p>The trick most beginners miss is that G02 and G03 require the arc to be less than 180 degrees if you use R. If the arc is more than 180 degrees, you must use I, J, K because R only works for arcs up to 180. This is not intuitive until you have crashed a tool into a part because you used R for a 270-degree arc.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Positioning_Codes_G90_G91_G54_G55_G56\"><\/span>Positioning Codes: G90, G91, G54, G55, G56<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G90 is absolute positioning. Every coordinate you write is relative to the program zero. G91 is incremental positioning. Every coordinate is relative to the current position. G91 is useful for drilling patterns or repetitive features where you do not want to calculate every absolute position.<\/p>\n<p>G54, G55, G56 are work offset selectors. G54 is usually the main vise offset. G55 might be a second vise or a fixture offset. G56 could be a third setup. You set these offsets on the machine by probing a reference point on the part and entering the values into the offset table. The program then calls G54 and the machine knows where zero is.<\/p>\n<p>Never assume G54 is set correctly. Always verify the offset before running a new program. A G54 that is off by 0.5 mm will move the tool 0.5 mm away from where you think it is. That is enough to crash into a vise or leave material uncut.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Feed_and_Speed_Codes_F_S_M03_M04_M05\"><\/span>Feed and Speed Codes: F, S, M03, M04, M05<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>F sets the feed rate in mm per minute for G01 moves or mm per revolution for G94 mode. S sets the spindle speed in RPM. M03 starts the spindle clockwise. M04 starts it counterclockwise. M05 stops the spindle.<\/p>\n<p>The feed rate you choose depends on the operation. For roughing steel, you might run F300 to F500. For finishing aluminum, you might drop to F100 to F200. The spindle speed depends on the material and the tool diameter. A good starting point for a 10 mm end mill in aluminum is S8000 to S12000. In steel, drop to S2000 to S4000.<\/p>\n<p>These numbers are starting points, not gospel. Adjust based on how the cut sounds, how the chips look, and how the tool wears. But having a starting point is better than guessing.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Structuring_a_Program_The_Skeleton_That_Holds_Everything_Together\"><\/span>Structuring a Program: The Skeleton That Holds Everything Together<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A G-code program is not a random list of commands. It has a structure. Break the structure and the program will not run, or worse, it will run and do something you did not expect.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Program_Start_and_Safety_Lines\"><\/span>Program Start and Safety Lines<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Every program should start with a safety block. This is the first thing the machine reads and it sets the initial state.<\/p>\n<p>A typical start block looks like this: G21 (metric units), G90 (absolute positioning), G17 (XY plane), G40 (cutter compensation cancel), G49 (length compensation cancel), G80 (canned cycle cancel), G54 (work offset). Then M03 S2000 to start the spindle.<\/p>\n<p>This block ensures that no matter what state the machine was left in from the previous program, your program starts clean. If you skip this and the previous program left G41 active, your tool will move off by the radius of the cutter the moment it starts cutting. That is a crash waiting to happen.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Tool_Change_and_Tool_Offset\"><\/span>Tool Change and Tool Offset<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>After the start block, you load the tool and set the length offset. T01 M06 loads tool 1 and changes the tool. G43 H01 Z50.0 applies the length offset from register 01 and moves the tool to Z50.0 clearance height.<\/p>\n<p>The H number must match the offset register where you stored the tool length. If you measured the tool and stored it in H05 but the program calls H01, the Z position will be wrong by the difference between the two offsets. Always double-check the H number against the offset table.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"The_Cutting_Block_and_Retract\"><\/span>The Cutting Block and Retract<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>After positioning, you make your cut with G01 or G02\/G03. Then you retract with G00 to a safe height. The retract is just as important as the cut. If you retract to Z0.0 instead of Z50.0, the tool might drag across the part on the way out and leave a scratch.<\/p>\n<p>A simple cutting block: G00 X10.0 Y10.0 (rapid to start point), G01 Z-5.0 F100 (plunge), G01 X50.0 Y10.0 F300 (cut), G00 Z50.0 (retract). That is a complete profile cut in five lines of code.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Program_End_and_Reset\"><\/span>Program End and Reset<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>End every program with a reset block. G00 Z50.0 (retract to safe height), M05 (stop spindle), M30 (end of program and rewind). M30 tells the controller the program is done and resets the cursor to the beginning. If you use M02 instead, the program ends but the cursor stays at the end. For manual programming, always use M30 so you can re-run the program immediately.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Canned_Cycles_The_Shortcuts_That_Save_Hours\"><\/span>Canned Cycles: The Shortcuts That Save Hours<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Canned cycles are pre-programmed sequences that handle drilling, pecking, boring, and tapping without you writing every individual move. They are the single biggest time-saver in manual programming.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Drilling_Cycle_G81\"><\/span>Drilling Cycle: G81<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G81 is the simplest drilling cycle. You give it an X, Y position, a Z depth, an R clearance plane, and a feed rate. The cycle drills to Z, retracts to R, and moves to the next position.<\/p>\n<p>G81 X10.0 Y10.0 Z-15.0 R2.0 F100 means drill at X10 Y10 to a depth of 15 mm, retract to 2 mm above the part, and feed at 100 mm per minute. One line of code replaces what would be five or six lines of individual G00 and G01 moves.<\/p>\n<p>The R plane is critical. If you set R too close to the part surface, the tool will crash into the part on retract. Set R at least 2 to 3 mm above the surface for safety.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Peck_Drilling_Cycle_G83\"><\/span>Peck Drilling Cycle: G83<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G83 is for deep holes where chips need to clear. The tool pecks down a small amount, retracts to clear chips, then pecks again. This prevents chip packing and tool breakage.<\/p>\n<p>G83 X10.0 Y10.0 Z-30.0 R2.0 Q5.0 F100 means drill to 30 mm deep, pecking 5 mm at a time, retracting to R between each peck. The Q value is the peck depth. Set it based on the hole diameter \u2014 typically 2 to 3 times the diameter for steel, up to 5 times for aluminum.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Boring_Cycle_G76\"><\/span>Boring Cycle: G76<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G76 is a fine boring cycle with a dwell at the bottom. The dwell lets the tool finish cutting the bottom of the hole for a better surface finish and tighter diameter control.<\/p>\n<p>G76 X10.0 Y10.0 Z-20.0 R2.0 Q0.1 F80 means bore to 20 mm deep with a 0.1 mm cut at the bottom and a dwell at full depth. The Q value is the finish cut amount. A small Q gives a better finish but takes more time. For clearance holes, Q0.5 is fine. For precision bores, drop to Q0.05.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tool_Compensation_G41_G42_G40\"><\/span>Tool Compensation: G41, G42, G40<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Tool compensation lets you program to the part geometry and let the controller adjust for the tool radius. Without it, you have to calculate the tool center path manually, which is tedious and error-prone.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_Cutter_Compensation_Actually_Works\"><\/span>How Cutter Compensation Actually Works<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G41 is compensation to the left of the programmed path. G42 is compensation to the right. G40 cancels compensation.<\/p>\n<p>When you write G41 G01 X50.0 Y0.0 F200, the controller does not move the tool to X50 Y0. It moves the tool to a position that is one tool radius to the left of that point, so the cutting edge follows the programmed path.<\/p>\n<p>The direction matters. G41 and G42 are determined by the direction of travel. If you are moving in the positive X direction, G41 puts the tool below the path (negative Y side). If you are moving in the negative X direction, G41 puts the tool above the path (positive Y side). This is counterintuitive at first. The rule is: imagine you are walking along the programmed path in the direction of travel. G41 puts the tool on your left. G42 puts it on your right.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Lead-In_and_Lead-Out_with_Compensation\"><\/span>Lead-In and Lead-Out with Compensation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You cannot engage G41 or G42 mid-cut. The tool will jump to the offset position instantly, which can gouge the part. You need a lead-in move \u2014 a short linear move that brings the tool into the compensated path smoothly.<\/p>\n<p>A typical engagement: G00 X0.0 Y0.0 (rapid to start), G01 X10.0 Y0.0 F100 (lead-in along the path), G41 D01 (engage compensation, D01 is the tool radius offset register), G01 X50.0 Y30.0 F200 (cut the profile), G40 G01 X60.0 Y30.0 (cancel compensation on a linear move away from the part), G00 Z50.0 (retract).<\/p>\n<p>The lead-in and lead-out must be long enough for the controller to build up the compensation gradually. A lead-in of at least 2 times the tool diameter is a safe rule of thumb.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Common_Mistakes_That_Crash_Parts_on_the_First_Run\"><\/span>Common Mistakes That Crash Parts on the First Run<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Every programmer crashes something. The difference between a good programmer and a bad one is that the good programmer crashes something small and learns from it. Here are the mistakes that catch beginners every single time.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Forgetting_the_Decimal_Point\"><\/span>Forgetting the Decimal Point<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G-code is picky about decimals. If you write X50 instead of X50.0, some controllers interpret it as 0.050 mm instead of 50 mm. That is a 1000x error. Always use the decimal point. X50.0, Y25.0, Z-10.0. Make it a habit.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Mixing_Modal_and_Non-Modal_Codes\"><\/span>Mixing Modal and Non-Modal Codes<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Modal codes stay active until you change them. G01 is modal \u2014 once you write it, every subsequent move is linear until you write G00 or G02. Non-modal codes execute once and then deactivate. G04 (dwell) is non-modal.<\/p>\n<p>The danger is forgetting that a modal code is still active. If the previous block ended with G02 and you start the next block with G01 without realizing G02 is still active, the first move of your new block will be an arc, not a line. That arc can drive the tool straight into a clamp.<\/p>\n<p>Always assume the machine is in the last modal state you left it. Explicitly set G01, G17, G90 at the start of every program to clear any lingering modal codes.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Wrong_Plane_Selection_G17_G18_G19\"><\/span>Wrong Plane Selection: G17, G18, G19<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>G17 selects the XY plane. G18 selects XZ. G19 selects YZ. If you are cutting a profile on the top of a part, you need G17. If you accidentally leave G18 active from a previous program, your G01 X and Y moves will actually be X and Z moves. The tool will plunge into the part instead of moving across the top.<\/p>\n<p>Always include G17 in your start block. It takes one line of code and it prevents a crash that could cost you a tool and a part.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Debugging_Your_First_Programs_A_Practical_Approach\"><\/span>Debugging Your First Programs: A Practical Approach<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You wrote the code. It looks right. Now you need to run it without destroying anything.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Single_Block_and_Dry_Run\"><\/span>Single Block and Dry Run<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Put the machine in single block mode. The controller will execute one line of code at a time, waiting for you to press cycle start after each line. This lets you watch every move and catch errors before they happen.<\/p>\n<p>Run the program with the spindle off and the Z axis raised. Watch the tool position on the machine display. Verify that every X, Y, Z move goes where you expect. If a move looks wrong, hit the feed hold, check the code, fix it, and continue.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Override_and_Rapid_Traverse\"><\/span>Override and Rapid Traverse<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Use feed override to slow the machine down to 5 percent or less. Use rapid override to slow rapid moves. This gives you time to react if something goes wrong. Full-speed runs are for production, not for debugging a new program.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"The_Air_Cut_Test\"><\/span>The Air Cut Test<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Before cutting actual material, run the program with the tool 50 mm above the part. This is called an air cut. The tool follows the entire path without touching anything. Watch the motion. Does it look smooth? Are there any sudden jumps? Does the tool retract to a safe height between features?<\/p>\n<p>If the air cut looks good, lower the tool to 5 mm above the part and run it again. Watch closely. If that looks good, start cutting. Three steps instead of one. It takes five extra minutes and it saves you from a crash that could take an hour to clean up.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Building_Simple_Programs_A_Walkthrough\"><\/span>Building Simple Programs: A Walkthrough<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Let us put it all together with a simple part. A 50 mm square pocket, 5 mm deep, in a 60 mm by 60 mm aluminum block.<\/p>\n<p>Start block: G21 G90 G17 G40 G49 G80 G54. Safety line, check.<\/p>\n<p>Tool load: T01 M06. G43 H01 Z50.0. Tool is loaded and positioned at safe height.<\/p>\n<p>Spindle: M03 S8000. Spindle on at 8000 RPM for aluminum.<\/p>\n<p>Rapid to start: G00 X5.0 Y5.0. Position above the pocket corner. We start 5 mm in from the edge because the tool has a radius. If we start at X0 Y0, the tool center would be at the edge and the cutter would overcut by its radius.<\/p>\n<p>Plunge: G01 Z-5.0 F100. Cut down to 5 mm depth at 100 mm per minute.<\/p>\n<p>Cut the pocket: G01 X55.0 F300. G01 Y55.0. G01 X5.0. G01 Y5.0. Four lines cut the square. The feed rate is 300 mm per minute for aluminum finishing.<\/p>\n<p>Retract: G00 Z50.0. Pull the tool up.<\/p>\n<p>End: M05 M30. Stop and rewind.<\/p>\n<p>That is a complete pocket program in about 15 lines of code. No CAM. No post-processor. Just G-code and a clear understanding of what each line does. Once you can write this, you can write anything. The rest is just more lines and more features.<\/p>","protected":false},"excerpt":{"rendered":"<p>CNC Machining Manual G-Code Programming: The Foundation Every Machinist Needs to Actually Write Code Most machinists learn to operate a CNC machine long before they learn to program one. They push buttons, they load programs, they hit cycle start. But the day comes when the program crashes, the post-processor throws an error, or the part [\u2026]<\/p>","protected":false},"author":1,"featured_media":840,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[106],"class_list":["post-1488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-cnc-machining-services"],"acf":[],"_links":{"self":[{"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/posts\/1488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/comments?post=1488"}],"version-history":[{"count":0,"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/posts\/1488\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/media\/840"}],"wp:attachment":[{"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/media?parent=1488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/categories?post=1488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reliablecncmachining.com\/nl\/wp-json\/wp\/v2\/tags?post=1488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}