How I Manually Modified the G-Code for My 3D Printer

by jiovine in Workshop > 3D Printing

265 Views, 1 Favorites, 0 Comments

How I Manually Modified the G-Code for My 3D Printer

Picture1.jpg

Back in 2017, I purchased a Monoprice Mini 3D printer V1 from Amazon. Last month, yup, Feb 2024 (several years later, not figurative, literal), I decided to get the printer going (or throw it out.) I read the instructions, installed an older version of Cura (15.04.6) on my computer, and downloaded the 3DBency STL file from Thingiverse. I used Cura to slice the STL model and stored the G-Code file on an SD card for the Mini. When I ran the G-code on the Monoprice printer printed a 3D model, Voila’.

The printed model wasn’t 100 percent; the cabin columns were string and not completely filled. I start adjusting the temperature of the filament, density, layer thickness, and speed. I obtained some improvements in the printed model, but still not 100%.

Adjustments to Cura

Picture2.jpg

If I increased density to 30%, reduced print speed to 10mm, and a layer thickness of 0.1 mm I could get a good model. It just took five-plus hours to print.

Using Cura again, I could see the layers in which the printer was struggling to print. I imagined if I could slow the printer while printing those layers, I might be able to obtain a good model in a faster time.

Learning to Hack G-Code

Picture3.jpg

The method I used is ugly and brute force, but it worked. I’m not a printer or G-code expert; if you follow the method I used, consider yourself forewarned. There also may be better ways to accomplish what I did. Remember, I literally started printing 3D less than a week back. I read up a bit about the G-code, and I had Cura write two G-code files. One G-code file printed at 8mm/sec (SLOW) and the other G-Code file at 25mm/sec.

Picture4.jpg

If you open the G-Code in Notepad, the individual layers are identified at the beginning of the G-Code for that layer. Using Cura, I scanned the layers and felt the layers between 114 and 148 were giving the printer difficulties.

In the 25mm G-code file, I erased the G-code for layers 114 to 148. This is a lot of code. There are over 2000 lines of code for each layer.

In the 8mm G-code file, I copied the G-code for layers 114 to 148. I then I cut and pasted this G-code into the 25mm G-code file.

Results

Picture5.jpg

It worked. Unfortunately, In my first go around, I didn’t count the layers I needed properly; I ought to have replaced all the layers from 100 to 160. 

By the Way

Picture6.jpg

When looking at the end of the G-Code file in Notepad, it appears like a random string of characters. I didn’t touch this string. I suggest you don’t either, see image..

Save and Replace

Save and Replace

Before I decided to cut and paste layers between files, I had thought about using Notepad’s find and replace. Simple enough job, find the code for printer’s 25mm/sec speed; F900 and replace it with a slower 8mm/sec speed; F480.

However, there are 2000 lines of code between each layer. So, manually changing code for 120,000 or so lines of code is a bit daunting. You could use the Notepad command to replace all, but then you're altering the speed on layers you want to retain.

Select Save and Replace.

While Notepad doesn’t have a select save and replace function, Notepad++ does.

On my next go around I thought, I will use Notepad ++ to highlight the code between layers 100 and 160, and do a “Select” save and replace of F900 to F480.

Cura Plug-Ins

Picture7.jpg

Before I had a chance to use Notepad ++ to alter my G-code, I happened across Cura’s plug-ins. This one plug-in I used in was able to lower the printer speed in the layers I defined. I reprinted the model and obtained a much-improved 3D print. See the lead photograph.

Conclusion

Picture8.jpg

Do I regret working with Notepad and manually adjusting the G-Code? Not at all. 

I was happy to discover I could do that without disrupting the file in such a way as to make the file unprintable. The above picture is not entirely accurate. I must have thrown out at least four models before I started keeping the models to mark my progression.

Because of my “embrace the suck” work with 3DBency, I am more comfortable with my ability to print 3D objects successfully.