Tech

How ChatGPT Scanned 170,000 Lines of Code in Seconds and Saved Me Hours of Work


bench

David Gewirtz/ZDNET

This is an article about using artificial intelligence (AI) as a tool and how to apply it to your unique, specialized needs. It offers some interesting lessons for everyone. I’ve also updated it with feedback from readers.

Also: The Most Popular Programming Languages ​​in 2024 (and What That Means)

You will learn how to use a tool like ChatGPT to solve complex problems quickly, as long as you have the right hints and a little skepticism.

First, a brief 3D printing rabbit hole

The context of this lesson is 3D printing. A special experiment in 3D printing is called 3DBenchy printer performance test. It helps 3D printer users check the speed and Various print quality measures. Most printers take about an hour or two to print a single page.

I recently tested a new printer that is supposed to be much faster than others. On this printer, the Benchy took 42 minutes, while on other 3D printers in the Fab Lab, it took 60 to 70 minutes. But here’s the thing: the test version provided by the printer company took 16 minutes. What a big difference.

Also: The Rise and Fall of Programming Language Popularity Since 2016 — and What It Tells Us

3D printers are controlled by G-code, a program created specifically by a tool called a slicer, that controls how the printer moves the print head and print bed, heats, feeds, and withdraws molten plastic filament.

The factory cut G-code provided for the printer I am testing prints in 16 minutes. The G-code I created using the company’s cutter prints in 42 minutes. I would like to know why.

Unfortunately, no one from the company’s support team could answer my question. Despite multiple attempts, I still did not get an answer on what slicer settings I should change to get the G-code I generated using their slicer to work as well as the G-code generated using their slicer.

Also: 6 Ways to Write Better ChatGPT Prompts — and Get the Results You Want Faster

After much web searching and reading frustrated Reddit posts, it became clear that other customers were having the same problem. This was a machine that was capable of doubling the performance, but none of us were able to successfully replicate that performance.

Can AI help?

This is the place ChatGPT appears in the image. The G-code consists of thousands of lines that look like this:

G1 X122.473 Y140.422 E4.23368 G1 X122.222 Y140.6 E4.24443 G0 F14400 X122.703 Y140.773 G1 F3600 X122.117 Y141.251 E4.27083 G1 X121.767 Y141.66 E4.28963 G1 X121.415 Y142.139 E4.31039 G1 X121.105 Y142.641 E4.33099

Both Benchy G-code files have over 170,000 lines of code. I wasn’t about to spend a Saturday afternoon manually sifting through that stuff. But I thought, maybe AI could help.

Also: How to Use ChatGPT to Digitize Your Handwritten Notes for Free

I have G code that I generated using the cutter. I can also export and save the factory provided G code. Using ChatGPT PlusI have put both files into AI.

I started by confirming that ChatGPT could read the files. After I uploaded each file, I asked:

Can you read this content?

ChatGPT confirmed and said, “I can read the contents of the file. It looks like it’s a G-code file, commonly used to control 3D printers.” That’s a good start.

To make sure we clearly distinguish which file is which, I’ve assigned some labels to the files on ChatGPT:

Let’s call the first uploaded file “regular print” and the second uploaded file “express print”. Okay?

AI agreed, so I told it:

Describes the differences between the files.

Aside from naming one of the files “fast print”, I didn’t tell ChatGPT what I was looking for. However, the bot still identified one print as having a higher print speed, even though the temperature settings were the same.

Then I asked AI:

Why is “express printing” so much faster?

At this point, ChatGPT started to annoy me. Instead of giving me specifics from the code I provided, it speculated. The AI ​​used phrases containing “likely,” “may,” and “might” to describe why the print was faster.

Also: If These Chatbots Could Talk: The Most Common Ways People Are Using AI Tools

But I’ve given it G-code files that describe exactly what the printer is doing, so I want an exact answer about what the printer is doing. As usual with ChatGPT, the conversation is like talking to a brilliant but somewhat stubborn and uncooperative graduate student.

Why the right reminder makes all the difference

I finally found this prompt, which gives possible answers:

The G-code provided in both files is the only thing that is different about these prints. Using only the G-code provided for comparison, what slicer settings would be different? Don’t speculate about what the other settings might be. Just rely on the code provided for analysis.

ChatGPT has identified three main factors:

  • Regular print G-codes display paper feed speeds that typically range from 2400 mm/min to 3400 mm/min. Fast print G-codes display much higher paper feed speeds, with some commands reaching as high as 14400 mm/min. This is a significant increase in speed, directly contributing to reduced print times.
  • Compared to the layer height of 0.2 mm for conventional printing, the fast printing mode sets the layer height to 0.25 mm, reducing the number of layers required to complete the print.
  • Fast G-code mode includes more powerful acceleration settings, allowing the printer to reach high speeds faster and maintain this speed, contributing to faster printing.

That result is interesting. However, I wanted to know if the company manually optimized the G-code or generated the code directly in the slicer. So I asked ChatGPT:

Can you tell if the quick print command was hand-coded or generated by a slicer? Perhaps look for inconsistent commands or non-standard comments.

AI responded with three interesting considerations:

  • Variations in G-code commands such as changing feed rates, switching between different motion commands, and changing other parameters are typical of cutter-generated code. These changes are designed to optimize the printing process and match the cutter’s behavior.
  • If the G-code were coded manually, we would see more irregular and unpredictable patterns, but these transitions follow a logical sequence, characteristic of the slicer’s optimization process.
  • Therefore, the presence of these commands does not indicate manual coding; instead, it supports the conclusion that this G-code was generated by a slicer.

These results tell me that users can modify their cutter settings to get similar performance.

Some thoughts from the comments

We received some very positive comments on this article. For the most part, I have been answering questions as they come up. I encourage you to visit the comments section to participate and read what other readers have to say about this topic.

Here’s a quick list of some thoughts inspired by the comments:

  • You don’t have to use AI to solve these problems. But it can be useful to see how AI handles solving different types of problems, so I encourage you to use chatbots, even if just to see what they can do. Then you’ll have a tool to use in the future.
  • I usually use ChatGPT Plus for these tests. The free version can get some work done, but since it limits usage after too many interactions, if I want to finish an article on time I need full access to the chatbot.
  • When trying to coax a response from a chatbot, I often think of it as a student or a talented employee. Sometimes I’ll even use “please” and “thank you” to maintain a conversational tone. But since whoever you’re talking to may be distracted or stubbornly refusing to understand your point, keep trying, vary your questions, ask them in different ways, and clarify, even if you think what you’re clarifying should be obvious.
  • Using AI can be lazy, sure. But it can also be a time saver. Almost anything you can do with power tools in the shop, you can also do with hand tools. Sometimes you want to focus on art. Sometimes you just want to get it done so you can get three hours of sleep that night. Never hesitate to use a tool if it can help you get further. But remember that if your work output specifically doesn’t allow for the use of those tools (like we NEVER use AI to write our articles here on ZDNET), then don’t use that tool.
  • Definitely be careful what you upload to AI. Not everything is corporate or confidential. But some is. Most of what I upload is my own data or, in this case, something that is already public.

I don’t always get a chance to respond to comments, but I try. Sometimes people post days, weeks, or even months after the article was published and I’ve moved on to other articles. But I always welcome reader comments. Since most ZDNET readers are professionals, the comments are often informative (though sometimes frustrating to read). I’ve learned a lot from ZDNET comments, and I’m sure you will too.

What have we learned?

We already know that ChatGPT understands G-code. That’s not surprising because, in my first tests we learned that ChatGPT is capable of using even the most obscure programming languages ​​quite well.

We also know that ChatGPT can sift through and compare over 170,000 lines of machine code and come up with actionable conclusions in just a few seconds.

Also: How I Tested AI Chatbots’ Programmability — and You Can Too

Finally, we learned that we can use AI like ChatGPT to explore complex problems from multiple angles. ChatGPT can not only explain the large speed difference between two files, but can also validate whether the factory-supplied file is manually tuned.

In short, Don’t accept what AI tells you as absolute truth.. Don’t make important decisions based on its answers. And remember that sometimes you have to negotiate with the AI ​​before it’s ready to give you a useful answer.

This test is another case where I can turn to AI and find the answer to a very personal question of mine without having to code in minutes.

If you have a question that requires a lot of text or numerical analysis, consider running it through ChatGPT or one of the other AIs. You can get a useful answer in minutes.

Also: Midjourney’s AI image-generating site is now officially open to everyone – for free

Writing this article on the subject took me a few hours. The actual analysis, from start to finish, took me less than 10 minutes. That’s some serious productivity, right there.


You can follow my daily project updates on social media. Be sure to subscribe. my weekly updateand follow me on Twitter/X at @DavidGewirtzon Facebook at Facebook.com/DavidGewirtzon Instagram at Instagram.com/DavidGewirtzand on YouTube at YouTube.com/DavidGewirtzTV.

News7f

News 7F: Update the world's latest breaking news online of the day, breaking news, politics, society today, international mainstream news .Updated news 24/7: Entertainment, Sports...at the World everyday world. Hot news, images, video clips that are updated quickly and reliably

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button