How ChatGPT scanned 170k lines of code in seconds and saved me hours of work

David Gewirtz/ZDNET

That is an article about utilizing artificial intelligence (AI) as a device and methods to apply it to your distinctive, specialised wants. It offers some attention-grabbing classes for everybody. I’ve additionally up to date it with suggestions from readers.

Additionally: The most popular programming languages in 2024 (and what that even means)

You may study you should utilize a device like ChatGPT to unravel complicated issues shortly, as long as you will have the suitable prompts and a touch of skepticism. 

First, a short 3D printing rabbit gap

Our context for this lesson is 3D printing. A particular take a look at in 3D printing referred to as a 3DBenchy checks printer efficiency. It helps 3D printer customers take a look at velocity and various print-quality measures. The Benchy takes most printers an hour or two to print out.

I not too long ago examined a brand new printer that is presupposed to be sooner than many others. On this printer, the Benchy took 42 minutes, whereas on different 3D printers within the Fab Lab, it took 60 to 70 minutes. However this is the factor: the take a look at model offered by the corporate that makes the printer took 16 minutes. That is a heck of a distinction.

Additionally: The rise and fall in programming languages’ popularity since 2016 – and what it tells us

3D printers are managed with G-code, a program custom-generated by a device referred to as a slicer that controls how the printer strikes its print head and print platform, heats up, and feeds and retracts molten filament.

The pre-sliced G-code offered by the manufacturing facility for the printer I used to be testing resulted in a 16-minute print. The G-code I generated utilizing the corporate’s slicer resulted in a 42-minute print. I wished to know why.

Sadly, nobody on the corporate’s help workforce may reply my query. Regardless of quite a few tries, I could not get a solution about what slicer settings to alter to get the G-code I produced utilizing their slicer to carry out in addition to the G-code generated utilizing their slicer.

Additionally: 6 ways to write better ChatGPT prompts – and get the results you want faster

After many internet searches and studying posts from annoyed Reddit posts, it was clear that different clients had the identical downside. Here is a machine able to greater than double the efficiency, but none of us may reproduce that efficiency efficiently.

Can AI assist?

That is the place ChatGPT comes into the image. G-code consists of 1000’s of strains that appear to be 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

Collectively, each Benchy G-code recordsdata had 170,000+ strains of code. I did not intend to spend a Saturday afternoon sifting via that stuff manually. However I believed, maybe, AI may assist.

Additionally: How to use ChatGPT to digitize your handwritten notes for free

I had the G-code I generated utilizing the slicer. I may additionally export and save the G-code offered by the manufacturing facility. Utilizing ChatGPT Plus, I fed each recordsdata into the AI.

I began by confirming ChatGPT may learn the recordsdata. After I uploaded every file, I requested:

Are you able to learn this?

ChatGPT confirmed, stating, “I can learn the contents of the file. It seems to be a G-code file, sometimes used to regulate 3D printers.” That was a superb begin.

To make sure we have been clear on which file was which, I gave ChatGPT some labels for the recordsdata:

Let’s name the primary file uploaded “common print” and the second file uploaded “quick print”. Okay?

The AI agreed, so then I advised it:

Describe how the recordsdata differ.

Aside from naming one of many recordsdata “quick print”, I gave ChatGPT no indication of what I used to be on the lookout for. Even so, the bot recognized that one print had increased print speeds, though the temperature settings have been the identical.

I then requested the AI:

Why is “quick print” a lot sooner?

It was at this level that ChatGPT began to harass me. As an alternative of giving me particulars from the code I offered, it speculated. The AI used phrases containing “seemingly”, “might”, and “would possibly” to explain why the print was sooner.

Additionally: If these chatbots could talk: The most popular ways people are using AI tools

However I had given it G-code recordsdata that described precisely what the printer was doing, so I wished an actual reply about what the printer was doing. As is usually the case with ChatGPT, the dialog was rather a lot like speaking to a superb grad pupil who’s considerably cussed and uncooperative.

Why the suitable immediate makes all of the distinction

I lastly landed on this immediate, which teased out workable solutions:

The G-code offered in each recordsdata is the one factor that’s completely different for these prints. Utilizing solely the G-code offered as comparisons, what slicer settings can be completely different? Do not speculate on what different settings is likely to be. Base your evaluation solely on the code offered.

ChatGPT recognized three key elements:

  • The common print G-code exhibits feed charges sometimes between 2400 mm/min and 3400 mm/min. The quick print G-code exhibits a lot increased feed charges, with some instructions reaching as much as 14400 mm/min. This price is a big enhance in velocity, straight contributing to the diminished print time.
  • In comparison with a layer top of 0.2 mm for the common print, the quick print set layer top to 0.25 mm, lowering the variety of layers wanted to finish the print.
  • The quick print G-code contains far more aggressive acceleration settings, permitting the printer to succeed in increased speeds faster and preserve them, contributing to sooner printing.

That end result was attention-grabbing. Nevertheless, I wished to know whether or not the corporate hand-optimized the G-code or generated it straight within the slicer. So, I requested ChatGPT:

Are you able to inform if quick print has been hand-coded or was generated by a slicer? Maybe search for inconsistent instructions or non-standard feedback.

The AI responded with three attention-grabbing concerns:

  • The variations in G-code instructions like adjustments in feed charges, switching between completely different motion instructions, and alterations in different parameters are typical of slicer-generated code. These adjustments are designed to optimize the print course of and are in step with the conduct of a slicer.
  • If the G-code have been hand-coded, we might anticipate to see extra irregular and unpredictable patterns, however these transitions comply with a logical sequence, attribute of a slicer’s optimization course of.
  • Subsequently, the presence of those instructions doesn’t point out hand-coding; moderately, it helps the conclusion that this G-code was generated by a slicer.

What these outcomes inform me is that it’s most likely potential for customers to switch their slicer settings to get related efficiency.

Some ideas from the feedback

We have had some very lively feedback for this text. For probably the most half, I’ve gone in and answered questions as they got here up. I encourage you to go to the feedback to take part and skim what different readers need to say on this matter. 

Here is a fast checklist of some ideas that the feedback impressed:

  • You do not have to make use of AI to unravel these issues. However it may be instructive to see how AI handles fixing many classes of various issues, so I encourage you to make use of chatbots, even when simply to see what they’ll do. Then, you will have a device for future use.
  • I am typically utilizing ChatGPT Plus for these checks. The free model can do among the work, however as a result of it throttles utilization after an excessive amount of interplay, if I am to get an article carried out on deadline, I have to have full entry to the chatbot.
  • When making an attempt to wheedle a solution from a chatbot, I normally consider it as a proficient pupil or worker. Typically, I will even use “please” and “thanks” to maintain the conversational tone going. However as anybody you discuss with would possibly get distracted or stubbornly refuse to see your level, preserve making an attempt, change up your questions, ask questions in several methods, and make clear, even once you assume what you are clarifying must be apparent.
  • Utilizing AIs will be laziness, certain. However they’ll additionally save time. Nearly something you are able to do with energy instruments in a workshop, you can too do with hand instruments. Typically you wish to give attention to the artwork. Typically, you simply wish to get carried out so you will have time for 3 hours of sleep that evening. Do not ever hesitate to make use of a device if it may give you a leg up. However do remember that in case your work output particularly precludes using these instruments (like we NEVER use AI to write down our articles right here on ZDNET), then do not use the device.
  • Undoubtedly take care what you add to the AI. Not every thing is corporate or in any other case confidential. However some is. Most of what I add is my very own knowledge, or, as on this case, one thing that is already revealed within the open.

I do not at all times get the possibility to reply to feedback, however I attempt. Typically, individuals publish days, weeks, and even months after the articles go up and I’ve moved onto different articles. However I at all times welcome reader feedback. As a result of most ZDNET readers are professionals, the feedback are sometimes wealthy with helpful (if often painful to learn) info. I’ve realized rather a lot from ZDNET feedback, and I am certain you’ll, too.

What have we realized?

We have realized that ChatGPT understands G-code. That is unsurprising as a result of, in my earliest tests, we learned that ChatGPT has a reasonably good command of even probably the most obscure programming languages.

We additionally realized that ChatGPT can sift via and examine 170,000+ strains of machine directions and attain actionable conclusions in seconds.

Additionally: How I test an AI chatbot’s coding ability – and you can, too

Lastly, we realized we will use AIs like ChatGPT to discover complicated issues from a number of angles. Not solely did ChatGPT clarify the huge velocity distinction between the 2 recordsdata, nevertheless it was additionally in a position to validate whether or not or not the factory-provided file had been hand-tweaked.

In conclusion, don’t accept what the AI tells you as absolute truth. Do not make essential selections based mostly on its solutions. And keep in mind that you typically have to barter with the AI earlier than it is prepared to present you useful solutions.

This take a look at is yet another case the place I have been in a position to flip to the AI and discover a solution for a really me-specific query with out coding in minutes.

You probably have a query that requires numerous textual content or numerical evaluation, contemplate operating it by ChatGPT or one of many different AIs. You would possibly get a helpful reply in minutes.

Additionally: Midjourney’s AI-image generator website is now officially open to everyone – for free

Writing this text about the issue took me a number of hours. The precise evaluation course of, from begin to end, took me lower than 10 minutes. That is some severe productiveness, proper there.


You may comply with my day-to-day venture updates on social media. Make sure you subscribe to my weekly update newsletter, and comply with me on Twitter/X at @DavidGewirtz, on Fb at Facebook.com/DavidGewirtz, on Instagram at Instagram.com/DavidGewirtz, and on YouTube at YouTube.com/DavidGewirtzTV.

Sensi Tech Hub
Logo