CNC Milling Optimization via Intelligent Algorithms: An AI-Based Methodology
Open Access
Abstract
Artificial intelligence (AI) is becoming more and more integrated into manufacturing processes, revolutionizing conventional production, like CNC (Computer Numerical Control) machining. This study analyzes how large language models (LLMs), exemplified by ChatGPT, behave when tasked with G-code optimization for improving surface quality and productivity of automotive metal parts, with emphasis on systematically documenting failure modes and limitations that emerge when general-purpose AI encounters specialized manufacturing domains. Even if software programming remains essential for highly regulated sectors, free AI tools will be increasingly used due to advantages like cost-effectiveness, adaptability, and continuous innovation. The condition is that there is sufficient technical expertise available in-house. The experiment carried out involved milling three identical parts using a Haas VF-3 SS CNC machine. The G-code was generated by SolidCam and was optimized using ChatGPT considering user-specified criteria. The aim was to improve the quality of the part’s surface, as well as increase productivity. The measurements were performed using an ISR C-300 Portable Surface Roughness Tester and Axiom Too 3D measuring equipment. The experiment revealed that while AI-generated code achieved a 37% reduction in cycle time (from 2.39 to 1.45 min) and significantly improved surface roughness (Ra—arithmetic mean deviation of the evaluated profile—decreased from 0.68 µm to 0.11 µm—an 84% improvement), it critically eliminated the pocket-milling operation, resulting in a non-conforming part. The AI optimization also removed essential safety features including tool length compensation (G43/H codes) and return-to-safe-position commands (G28), which required manual intervention to prevent tool breakage and part damage. Critical analysis revealed that ChatGPT failures stemmed from three factors: (1) token-minimization bias in LLM training leading to removal of the longest code block (31% of total code), (2) lack of semantic understanding of machining geometry, and (3) absence of manufacturing safety constraints in the AI model. This study demonstrates that current free AI tools like ChatGPT can identify optimization opportunities but lack the contextual understanding and manufacturing safety protocols necessary for autonomous CNC programming in production environments, highlighting both the potential, but also the limitation, of free AI software for CNC programming.Keywords
This publication has 23 references indexed in Scilit:
- AI-based optimisation of total machining performance: A reviewCIRP Journal of Manufacturing Science and Technology, 2024
- A comprehensive literature review of the applications of AI techniques through the lifecycle of industrial equipmentDiscover Artificial Intelligence, 2023
- Optimal toolpath planning strategy prediction using machine learning techniqueEngineering Applications of Artificial Intelligence, 2023
- Mechanical analysis and optimized performance of G-Code driven material extrusion componentsAdditive Manufacturing, 2022
- Energy prediction for CNC machining with machine learningCIRP Journal of Manufacturing Science and Technology, 2021
- A generic energy prediction model of machine tools using deep learning algorithmsApplied Energy, 2020
- Adaptive machining framework for the leading/trailing edge of near-net-shape integrated impellerThe International Journal of Advanced Manufacturing Technology, 2020
- Supervision controller for real-time surface quality assurance in CNC machining using artificial intelligenceComputers & Industrial Engineering, 2019
- Smart Machining Process Using Machine Learning: A Review and Perspective on Machining IndustryInternational Journal of Precision Engineering and Manufacturing-Green Technology, 2018
- Automated part programming for CNC milling by artificial intelligence techniquesJournal of Manufacturing Systems, 1985