[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-732689-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-732689-en":130,"doc-similar-732689":191},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","m-and-g-code-sample-files-m-and-g-code-examples","M-and G-Code Sample Files - M and G Code Examples","","M-and G-code sample files demonstrate how M and G codes drive CNC motions for different machining setups. Examples cover a single-head system with manual tool change, an ATC system using tool change commands, and an ATC case selecting specific tool numbers for a circular contour. Additional samples show a boring drill sequence with drill bank engagement, coordinated X/Y positioning, Z plunging, retract behavior, and program start/end control for repeatable job execution.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/m-and-g-code-sample-files-m-and-g-code-examples/732689/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/m-and-g-code-sample-files-m-and-g-code-examples/732689.png","ImageObject",300,407,{"name":42,"@type":43},"Jasmine","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-26","2026-11-22",true,{"@type":52,"interactionType":53,"userInteractionCount":30},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What do M90, M12, and M22 represent in these samples?","Question",{"text":62,"@type":63},"M90 marks program start, M12 is called before the Z-axis to lower the tool into the material or start a new contour, and M22 is called after the tool lifts to complete the current contour.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"How does Sample File 1 differ from the ATC samples?",{"text":67,"@type":63},"Sample File 1 uses a manual tool change approach indicated by an asterisk (*) and includes optional manual tool change lines, while the ATC samples rely on ATC tool change behavior without a “G00 C” command.",{"name":69,"@type":60,"acceptedAnswer":70},"How is drilling handled in the Sample Boring File?",{"text":71,"@type":63},"The file lowers the drill bank, turns on the drill motor, then engages drill sets with commands like G98 P300 D... while moving X/Y to centered boring locations and controlling Z plunge and retract between holes.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},732689,1795381731,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":30,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":79,"read_time":144,"preview_page_count":145,"preview_urls":146},2336478487870,"https://ap-avatar.wpscdn.com/davatar_085a072bc5b1113ac321206ff7593b45","M-and G-Code Sample Files  \nThe following sample files illustrate how M and G Codes are used to create a file. Click here for additional information on M and G Codes.  \nSample File 1  \nThe following file is for a single head system with manual tool change to complete a 5\" square. Rapid level 0.5\" above material, feed down 60 IPM, cut feed 200 IPM, rapid down to 0.1 above material, depth 0.25\" . The manual tool change is indicated with an asterisk (*) below and is optional.  \nM90 Program Start  \nG90 Absolute Coordinate Mode  \nG75 Follow the XY coordinate arc mode (Standard) .  \nG97 S18000 Set Spindle Speed to 18,000 RPM.  \nG00 T1 Tool \\#1 call. Following moves will use Tool \\#1 .  \n*G00 CE-MILL .2500 2FL. The keypad will display \"E-MILL .2500 2FL.\" The user will now be able to load  \nthe tool manually and Z reference the tool. This line can be sent multiple times in the same file to support manual  \ntool changes.  \nG00 Z-0.5 Position the Z-axis 0.5\" above Z=0 or above the material.  \nG00 X0 . Y0 . Position X=0 .0 and Y=0 .0.  \nM12 The M12 command should be called before the Z-axis. This lowers the tool into the material or at the start of a  \nnew contour.  \n-The Auxiliary output for the selected tool is turned on. (This output can be wired to operate a tool misting or  \ncooling unit.)  \n-The Motion will change from Slew mode (high speed rapid) to Machine mode (Cutting Mode) .  \n-If this is the first M12 called in the program, the spindle output will come on for the current selected tool.  \nG00 Z-0.1 Position the Z-axis 0. 1\" above Z=0 .0 or above the material.  \nG01 Z0 .25 F1 . Position the Z-axis 0.25\" below Z=0 .0 or into the material at the feedrate of 1\"/sec (60\"/min) .  \nG01 X5 . F3 .333 Position the X-axis 5.0\" at the feedrate of 3.333\"/sec (200\"/min) .  \nG01 Y5. Position the Y-axis 5.0\" (feedrate will continue at last set speed) .  \nG01 X0 . Position the X-axis 0.0\".  \nG01 Y0 . Position the Y-axis 0.0\".  \nG00 Z-0.5 Position the Z-axis 0.5\" above Z=0 .0 or above the material.  \nM22 The M22 command should be called after the Z-axis lifts the tool out of the material and complete the current  \ncontour.  \n-The Auxiliary output for the selected tool is turned off..  \n-The Motion will change from Machine mode (Cutting Mode) to Slew mode (high speed rapid) .  \nG00 X0 . Y0 . Position X=0 .0 and Y=0 .0.  \nM02 End of job code. Spindle is turned off.  \nSample File 2 (ATC or Single Tool)  \nThis is the same file for an ATC system with the ATC tool change command. There is no \"G00 C\" command.  \nM90  \nG90  \nG75  \nG97 S18000  \nG00 T1  \nG00 Z-0.5  \nG00 X0 . Y0 .  \nM12  \nG00 Z-0.1  \nG01 Z0 .25 F1 .  \nG01 X5 . F3 .333  \nG01 Y5 .  \nG01 X0 .  \nG01 Y0 .  \nG00 Z-0.5  \nM22  \nG00 X0 . Y0 .  \nM02  \nSample File 3 (ATC Tool 3)  \nThe following is a 5\" circle clockwise, center at 2.5,2.5, 0.5 rapid level, feed down 60 IPM, cut feed 120 IPM, rapid down to 0.1 , depth of 0.4\" . ATC system uses Tool \\#3 .  \nM90  \nG90  \nG75  \nG97 S18000  \nG00 T3  \nG00 Z-0.5  \nG00 X2 .5 Y5 .  \nM12  \nG00 Z-0.1  \nG01 Z0 .4 F1 .  \nG02 I2 .5 J2 .5 F2 .  \nG00 Z-0.5  \nM22  \nG00 X0 . Y0 .  \nM02  \nSample File 4 (Sample Files 2 and 3 together)  \nM90  \nG90  \nG75  \nG97 S18000  \nG00 T1  \nG00 Z-0.5  \nG00 X0 . Y0 .  \nM12  \nG00 Z-0.1  \nG01 Z0 .25 F1 .  \nG01 X5 . F3 .333  \nG01 Y5 .  \nG01 X0 .  \nG01 Y0 .  \nG00 Z-0.5  \nM22  \nG97 S18000  \nG00 T3  \nG00 Z-0.5  \nG00 X2 .5 Y5 .  \nM12  \nG00 Z-0.1  \nG01 Z0 .4 F1 .  \nG02 I2 .5 J2 .5 F2 .  \nG00 Z-0.5  \nM22  \nG00 X0 . Y0 .  \nM02  \nSample Boring File  \nM90  \nG90  \nG75  \nG00 X6 .0394 Y6 .0394  \nM38 Lowers the drill bank into place and turns on the drill motor.  \nG00 X6.0394 Y6.0394 Z-0.5 Moves X and Y so that boring drill 1 is centered at X = 6.0394 Y = 6.0394 and  \nZ is 0.5\" above the material surface.  \nG98 P300 D496 Engages drills 5, 6, 7, 8, and 9.  \nG00 Z-0.1 Slew move in Z to 0. 1\" above the material.  \nG01 Z0.4 F1.333 Plunge the Z axis 0.4\" into the material at 80 IPM.  \nG00 Z-0.5 Slew move in Z to 0.5\" above the material.  \nG00 X6 .0394 Y8 .55","cbCaicv7HcUSqLra","https://ap.wps.com/l/cbCaicv7HcUSqLra","pdf",806091,102,"English","# M-and G-Code Sample Files\n## Sample File 1 - Single head with manual tool change\n## Sample File 2 - ATC or single tool\n## Sample File 3 - ATC Tool 3\n## Sample File 4 - Sample Files 2 and 3 together\n## Sample Boring File\n## Cutter Comp G40/G41/G42 File","[{\"question\":\"What do M90, M12, and M22 represent in these samples?\",\"answer\":\"M90 marks program start, M12 is called before the Z-axis to lower the tool into the material or start a new contour, and M22 is called after the tool lifts to complete the current contour.\"},{\"question\":\"How does Sample File 1 differ from the ATC samples?\",\"answer\":\"Sample File 1 uses a manual tool change approach indicated by an asterisk (*) and includes optional manual tool change lines, while the ATC samples rely on ATC tool change behavior without a “G00 C” command.\"},{\"question\":\"How is drilling handled in the Sample Boring File?\",\"answer\":\"The file lowers the drill bank, turns on the drill motor, then engages drill sets with commands like G98 P300 D... while moving X/Y to centered boring locations and controlling Z plunge and retract between holes.\"}]","M-and G-Code Sample Files - M and G Code Examples | PDF",257,11,[147,151,155,159,163,167,171,175,179,183,187],{"page_no":22,"url":148,"width":149,"height":150},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/d21f7a214afb47e39f047804d5d0c8fa.webp",983,1272,{"page_no":26,"url":152,"width":153,"height":154},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/83f5d777e3ac5df24a05dff4cad5bc1f.webp",982,1270,{"page_no":30,"url":156,"width":157,"height":158},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/a255634c2cb8f32881bb6b36315b67a5.webp",981,1269,{"page_no":33,"url":160,"width":161,"height":162},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/16fb7248591e216a0884f04f8d74b1b5.webp",980,1268,{"page_no":96,"url":164,"width":165,"height":166},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/b22e3f3e3082c10687754df8f8c5856a.webp",979,1267,{"page_no":101,"url":168,"width":169,"height":170},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/8abecd28dd7afb449f130c4f9e08638a.webp",978,1265,{"page_no":105,"url":172,"width":173,"height":174},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/4c35171f6eb4e0ab7b3a142193007a0a.webp",977,1264,{"page_no":110,"url":176,"width":177,"height":178},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/76ad4932b8d3dd465cb6d534dde7aa04.webp",976,1263,{"page_no":115,"url":180,"width":181,"height":182},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/e92a6cb9d5bf7241c1d1927b1ee53f55.webp",975,1261,{"page_no":123,"url":184,"width":185,"height":186},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/9f28e887be4fb5bbe038a2d47f902b08.webp",974,1260,{"page_no":145,"url":188,"width":189,"height":190},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/4fd81aa0ce36102efa3ad9b76d0cb69a.webp",973,1259,{"list":192,"token":11},[193,199,205,211,217,223,229,235,241,248],{"doc_id":194,"doc_title":195,"file_type":137,"home_preview_img_url":196,"slug":197,"view_count":96,"category_name":29,"create_tm":198},732766,"LNC-MILL Programming Manual - V4.00 - Version 4.00","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031411638/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=k%2FSYLRWOOzp8v%2BZtfHOOp8jX1Fs%3D","lnc-mill-programming-manual-v400-version-400",1795382199,{"doc_id":200,"doc_title":201,"file_type":137,"home_preview_img_url":202,"slug":203,"view_count":96,"category_name":29,"create_tm":204},732716,"Study of G Codes and M Codes Used in CNC Lathe HMT CNC-T70 - CNC Machining Centre Codes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031778452/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=SP0k8Anagwr1Pfbvicuc30%2FdPD4%3D","study-of-g-codes-and-m-codes-used-in-cnc-lathe-hmt-cnc-t70-cnc-machining-centre-codes",1795381890,{"doc_id":206,"doc_title":207,"file_type":137,"home_preview_img_url":208,"slug":209,"view_count":33,"category_name":29,"create_tm":210},732765,"Machinists Handbook - G-Code Tutor","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031411639/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=%2BZSNfbReDqNojCkf66G%2BrorzYCg%3D","machinists-handbook-g-code-tutor",1795382198,{"doc_id":212,"doc_title":213,"file_type":137,"home_preview_img_url":214,"slug":215,"view_count":96,"category_name":29,"create_tm":216},732703,"Basic ISO Programming Exercise 3 - Turning - ISO G code turning and boring tutorial","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031410491/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=DXCLAxUdslkP9%2B88%2FjIVx0NhIzI%3D","basic-iso-programming-exercise-3-turning-iso-g-code-turning-and-boring-tutorial",1795381774,{"doc_id":218,"doc_title":219,"file_type":137,"home_preview_img_url":220,"slug":221,"view_count":110,"category_name":29,"create_tm":222},662729,"The ultimate CNC machining guide - Introduction to CNC machining","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229981688989/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=A%2FzY0XJEC7s2ciEak%2BPk8ev8sKU%3D","the-ultimate-cnc-machining-guide-introduction-to-cnc-machining",1793222148,{"doc_id":224,"doc_title":225,"file_type":137,"home_preview_img_url":226,"slug":227,"view_count":30,"category_name":29,"create_tm":228},732694,"G and M Programming for CNC Milling Machines - G and M programming manual","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031410410/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=OS%2BNxGQOtv8%2FfWCRcHzZ3Gy38%2BU%3D","g-and-m-programming-for-cnc-milling-machines-g-and-m-programming-manual",1795381742,{"doc_id":230,"doc_title":231,"file_type":137,"home_preview_img_url":232,"slug":233,"view_count":33,"category_name":29,"create_tm":234},732691,"SHOP NOTES - Pocket Guide and Reference Charts for CNC Machinists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031777989/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=vKcZy5wAuyTtctTlJeIiaZbHRyc%3D","shop-notes-pocket-guide-and-reference-charts-for-cnc-machinists",1795381736,{"doc_id":236,"doc_title":237,"file_type":137,"home_preview_img_url":238,"slug":239,"view_count":123,"category_name":29,"create_tm":240},649941,"CNC Machining Design Guide - Part MFG","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229972249659/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=VzrkJWpZbWoc%2BETDOte8gGVn9mY%3D","cnc-machining-design-guide-part-mfg",1792811857,{"doc_id":242,"doc_title":243,"file_type":137,"home_preview_img_url":244,"slug":245,"view_count":246,"category_name":29,"create_tm":247},651400,"CNC 8055 M Examples Manual","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229973785359/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=VGbnWYfqjENqGzatfUPpo0jUAb8%3D","cnc-8055-m-examples-manual",16,1792873863,{"doc_id":249,"doc_title":250,"file_type":137,"home_preview_img_url":251,"slug":252,"view_count":33,"category_name":29,"create_tm":253},693682,"CNC GUIDE - ISSUE No-6 - ST-10 Turning Centre","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230007411850/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=myfq0pX3eVlw65gLreAuAXJCqz0%3D","cnc-guide-issue-no-6-st-10-turning-centre",1794341192]