7 minutes to read - Dec 22, 2023

Can ChatGPT Create Usable G-Code Programs?

VISIT
Can ChatGPT Create Usable G-Code Programs?
Since its debut in late 2022, ChatGPT has been used in many situations, from writing stories to writing code, including G-code. But is it useful to shops? We asked a CAM expert for his thoughts.

Free
Table of Contents
1Early Assesments
2Extra Credit


ChatGPT is a chatbot developed by OpenAI that uses large language model technology, which is a deep learning algorithm that uses very large data sets to recognize, summarize, translate, predict and generate content. Among other tasks, ChatGPT can create G-code programs.

Images provided by CAMInstructor.


In early 2023, ChatGPT was everywhere, writing stories, articles, essays, recipes, poems — and code. The chatbot can create programs in a variety of languages, including G code. But are its programs any good? I spoke to a CAM expert who has tested ChatGPT’s G-code programming abilities. Here’s his take what it can do now, and how AI might affect programming in the future.


Early Assesments


Mike Wearne is an educational content creator at CAMInstructor, which specializes in creating books, videos, and online curricula covering CNC programming, Mastercam, and SolidWorks for educational programs and manufacturers. As part of this, he has produced two videos (so far) on using ChatGPT for G-code programming. The first covered GPT-3, which was the latest version available to the public at the time.

In the first video, he tests GPT-3’s G-code programming capabilities by giving it simple tasks such as facing parts or drilling four holes evenly spaced one inch apart. Once ChatGPT gave him a program, he plotted the program with CIMCO Edit software to visually show the results, along with any issues in the code.

His take on the GPT-3 code? “If we use a basic program that's a drill four holes sort of thing, and compare this to someone who's just learning G code, I would say it's not bad,” he says. “I would give it a low B or a high C.” The overall structure was there — it put the right codes in the right places, such as G20 and G21 to switch between metric and imperial units, and G90 for absolute positioning at the top of the program. “If you're new to G-code programming, those are usually the tough things to remember and to get in the right spot,” he notes. However, it was missing some elements, such as tool changes and spindle speeds.

But GPT-3 has its limits. Notably, it can self-correct itself, but only to a certain point. Wearne says if you prompt ChatGPT to fix an issue in a program, it will make edits. But if you start a new chat or prompt for an entirely new program, you’re starting from scratch. However, he thinks the biggest thing holding GPT-3 back is how much information users need to provide in order to get a good program, and how difficult it is for users to input this information. “For example, if you want to drill holes, you’ve got to tell it where the holes are, which size holes you want, what tool you’re using, what material you’re cutting and what kind of machine you’re using,” he says. “All of that is still very hard to get into a chat interface like ChatGPT.” Users have to manually communicate all the information from a print into ChatGPT in a format it can understand. 


 GPT-4 users can upload a variety of file types (including images and PDFs) into the interface, and from there Wearne says the chatbot can tell what’s been uploaded — the user just has to tell it what to do with the image. For example, if you upload a part file with four holes, you can tell ChatGPT to write a program to drill the holes. Wearne says it currently works for simpler parts and shapes. “Anything beyond that is not doable,” he adds. “At least, not yet.”


Wearne also noticed a marked improvement in the G code ChatGPT produces. “It’s like GPT-4 can think more about its answers and GPT-3.5 just spits out whatever it comes up with as quick as it can,” he explains. With its most recent update, Wearne says it can program simple parts almost perfectly. Whereas GPT-3 was getting a high C or low B as a grade for its code, “For the simple parts, if we’re in G-code 101, GPT-4 is getting an A,” he says.


Extra Credit


According to Wearne, the next step ChatGPT needs to make in G-code programming is tool motion during a cut. He adds that, on its own, this might be too complex for ChatGPT to handle. “I’m not sure it would be able to produce something like a dynamic milling operation on a large pocket,” he notes. “The amount of code it would need to generate would likely be beyond its scope.” But integrating ChatGPT with CAM programming software such as Mastercam could provide the resources needed to generate complex toolpaths. “But then again, I don’t think attempting to cut complex parts with GPT is the best use case for it,” he says.  


Wearne has found other uses for ChatGPT in manufacturing. “It can give you ideas for things to try, especially if you're stuck on something,” he says. He believes ChatGPT is particularly helpful in creating macros, which are a way to store a series of commands in a program and repeat them. “Surprisingly, GPT-4 is pretty good with error codes,” he adds. Instead of Googling the error code and searching for the answer on a website or forum, he says you can give ChatGPT the machine type and error code and it will tell you what the error code is and how to troubleshoot it.


GPT-4 also enables users to create and train their own GPTs. Wearne has used this feature to create a custom chatbot trained on a Haas CNC mill programming manual. “When I asked it to program a part that contained a simple pocket, it was able to tell me I need to program it with a G150 command and also provided the variables for that canned cycle and what they controlled,” he says. He believes that creating the roughing motion for a pocket would be difficult for GPT, but the chatbot knew it could perform the task with Haas’s built-in code. “The custom GPTs are quite useful,” he says. “The limitation is your imagination and the data you can feed it.” For example, GPT-4 users can train a custom GPT using a machine manual and ask it for information such as alarms and G-code variables.



Article source
loading...