ChatGPT CNC Programming: How to Create Machining Programs for CNC Lathes with ChatGPT

Recently, the word “AI” has been used a lot. But can we use ChatGPT to create machining programs for CNC lathes and do some actual machining? This article explores the potential of ChatGPT in CNC programming by detailing one user’s journey to create a working turning program entirely through AI interaction.

ChatGPT Guide

ChatGPT is not limited to just generating text or answering questions, it can also be used for programming tasks. Specifically, it can generate code and explain programming concepts. This is possible because it has been trained on a large corpus of text that includes code and technical documents, allowing it to acquire relevant knowledge. In other words, it can generate G-code as well.

How to Create Machining Programs for CNC Lathes?

This is the state in which ChatGPT is set up. First, we can ask ChatGPT if it is possible to create a machining program for LinuxCNC. And here’s the answer:

Then we ask “What kind of instructions do you need to give me to make the program the way I want it”? The answer will be:
To create a G-code program tailored to your specific needs, I’ll need some information from you, such as: The type of machine you are using and its specifications, including the number of axes, the workpiece size and material, and the tool type and dimensions. The type of operation you want to perform, such as milling, drilling, or cutting, and any specific requirements for that operation, such as the cutting depth, feed rate, and spindle speed. The starting position and orientation of the tool, and the ending position and orientation of the tool. Any specific paths or shapes you want the tool to follow, such as circles, arcs, or straight lines. Any additional requirements, such as coolant on/off, tool changes, or pauses for tool measurement.

Once we have this information, we can use it to generate a custom G-code program that will work with LinuxCNC and meet your specific requirements. We gave the information according to ChatGpt’s instructions, and this is the program that ChatGPT created:

The first thing that can surprise you is that each G-code has a brief explanation. Even those who do not know G-code can generally understand what the program is about. The first thing we can notice is that the program is changing tools after the tool has moved to the start of machining. If the machine is run as is, there is a high possibility that the machine will crash. We need to tell ChatGPT to fix this.
Tool change and tool length compensation before the machine starts operating:

We have now rearranged the order of these. The next thing is we need to add tool change and tool length compensation before operation. As anyone who knows how to use G-code and CNC lathes can tell you, there are still other parts of the machining program that ChatGPT created that are problematic.

We can teach ChatGPT in writing until we can actually run the CNC lathe with the program without any problems. This process felt similar to teaching a novice programmer. Certainly, the processing program that ChatGPT is now creating is a very simple program, so it would be much faster if we wrote the G-code directly.

However, AI technology is expected to spread rapidly in various fields in the future. We believe that AI specialized for creating machining programs will also be possible. At that time, the AI will be like an experienced machining programmer who is a great veteran and knows everything. All we have to do is give simple instructions to the AI, and it will generate a perfect machining program. In other words, the person giving instructions to the AI will not need to have any specialized knowledge, because AI will do all the specialized work for us. Humans will be more focused on ideas and emotions. At any rate, the machining program is ready.

Then you can run it on LinuxCNC. The program could be installed on LinuxCNC without any errors. If you find any problems, you can let ChatGPT fix them. After using ChatGPT, people are convinced that this technology will have a great impact on the CNC industry.

You may also like...