Tuesday, June 28, 2022
HomeToolsHow to Use the Simplify3D G-Code Scripts

How to Use the Simplify3D G-Code Scripts

Hello Machine Bros!
Today we will talk about a slightly more advanced topic in the use of Simplify3D, the Simplify3D G-Code Scripts.

What are the G-Code Scripts of a Slicer?

These are scripts in the G-Code language, which is interpreted by the 3D printer to perform certain actions.

The Slicers are in charge of generating the G-Code according to the configuration of the printing and the 3D model.

With the Scripts we can execute additional functions, for example, tell the 3D printer to cool the extruder at the end of the 3D printing.

What is the G-Code?

It is a numerical control programming language, which is used mainly by computer-aided manufacturing machines and tools such as CNC machines and 3D printers.

For 3D printers, the instructions in G-Code contain all the printing information such as Printing speed, how much filament will be extruded, temperature of the heated bed, height of the layers, and much more information.

All these parameters are generally configured in a slicer software.

The G-Code is read and executed in order, line by line, from top to bottom.

To learn and know about the most used terms in 3D printing, we recommend that you visit our article Most Used 3D Printing Terms.

The Most Common G-Code Commands

G28 – Go to Origin

With G28 we tell the 3D printer to go to the origin, we can also specify exactly which axis we want to go to the origin, for example:

G28; Sends all axes to the origin
G28 X Y; Sends the X-axis and the Y-axis to the origin
G28 Z; Sends the Z-axis to the origin

G90 y G91 – Absolute or Relative Coordinates for Axes and Extruder

With these commands we tell the 3D printer whether to use absolute or relative coordinates, this can be alternated and changed at any time or place within the G-Code.

G90; Uses absolute coordinates in all axes, including the extruder.
G91; Uses relative coordinates in all axes, including the extruder.

With the absolute coordinates, we move to a certain position on the bed.

With the relative coordinates, we will move according to the position that we are at a certain moment.

That is if for example, we are in the X10 coordinate, and we want to move to the X20 coordinate, we can do it in the following two ways.

With Absolute Coordinates:

Starting from that we are in X10

G90; Uses absolute coordinates in all axes
G1 X20; Moves to X20
G1 X10; Moves back to X10

With Relative Coordinates:

Starting from that we are in X10

G91; Uses relative coordinates in all axes
G1 X10; Moves to X20
G1 X-10; Moves back to X10

The following video could help you better understand the difference between using absolute or relative coordinates.

Video showing the difference between using absolute (G90) and relative (G91) coordinates

G1 – Linear Motion

With this command, we tell the 3D printer to perform a linear movement in any of the axes or the extruder.

It can be done jointly or individually.

Let’s see some examples assuming that we are working with absolute coordinates (G90):

G1 X10 Y10; Moves X and Y to the coordinates X 10mm and Y 10mm
G1 Z10; Moves Z to the 10mm coordinate
G1 E5; Extrudes 5mm of filament
G1 E-2; Retracts 2mm of filament
G1 X30 E10; Moves to the X coordinate 30mm and extrude 10mm of filament, all at the same time

NOTE: Usually is most comfortable to work the extrusions and retractions with relative coordinates.

You need to know that we can also indicate the speed of the movements using the letter “F”. In case you do not indicate a speed (as in the previous examples), the speed already pre-established in previous lines of the G-Code will be used.

Speed is usually indicated in mm/min (millimeters per minute).

Next, let’s look at some examples.

G1 X10 Y10 F2400; Moves X and Y to the coordinates X 10mm and Y 10mm at a speed of 2400mm/min
G1 Z10 F1500; Moves Z to the 10mm coordinate at a speed of 1500mm/min
G1 E5 F1000; Extrudes 5mm of filament at a speed of 1000mm/min

G92 – Adjust to the Current Coordinate

This command is used to assign a new position value to the current coordinate of some of your axes (set an offset). This command is useful when we work with absolute coordinates (G90) for the extruder.

Suppose that we start with the extrusion coordinate at zero, that we are with absolute coordinates (G90), and now we want to extrude 5mm of filament, for this, we send the following command.

G1 E5 F1000; Extrudes 5mm of filament at a speed of 1000mm/min

Suppose that now we want to extrude 2mm more of filament, in this case we could not simply write G1 E2, since we are using absolute coordinates, therefore, the current position of the extruder is 5mm, it is no longer zero as at the beginning.

For this reason, if we now send the G1 E2 code, we would actually be executing a 3mm retraction, since 5mm-2mm = 3mm.

There are two ways to make another 2mm extrusion using absolute coordinates (G90).

The first is simply to send the G1 E7 code, since before we were in the 5mm position, and now we want to extrude two more millimeters, it would be 5mm + 2mm = 7mm. But what if we do not know the previous position?

This command that we mention (G92) comes into play here, managing to adjust the current position of the extruder as if this were the new origin.

Let’s look at a complete example.

G1 E5 F1000; Extrudes 5mm of filament at a speed of 1000mm/min
G92 E0; Sets the current extruder position as the new origin or zero (0)
G1 E2 F1000; Extrudes 2mm of filament at a speed of 1000mm/min

For this reason, we previously told you that it was a little easier to work extrusions and retractions with relative coordinates.

If you want to work only the coordinates of the extruder in relative mode, and the other axes in absolute mode, the following codes will help you.

M82 y M83 – Absolute or Relative Coordinates for Extruder Only

It is necessary that you have learned how the previous commands work so that you can understand the following two commands without much difficulty and explanation.

M82; Allows the extruder to work in absolute mode regardless of the mode in which the other axes are.
M83; Allows the extruder to work in relative mode regardless of the mode in which the other axes are.

This way you could adjust the X, Y, and Z axes in absolute mode and the extruder in relative mode. Since it is usually a bit easier to work the extrusions and retractions in relative mode.

NOTE: You should know that when using G90 or G91, the M82 or M83 is canceled.

Let’s see an example of how to properly use absolute coordinates (G90) for the X, Y, and Z-axes. But, using relative coordinates for the extruder.

G-Code SyntaxComments
G90; Uses absolute coordinates in all axes
M83; Uses relative coordinates in the extruder
 GoodIt does NOT cancel the M83
M83; Uses relative coordinates in the extruder
G90; Uses absolute coordinates in all axes
 WrongIt cancels the M83

Remember, every time you use the G90 or G91 command, you are overriding the M82 and M83, therefore, you must resend the command if you want it to take effect.

Let’s see a real example.

G90; Uses absolute coordinates in all axes
M83; Uses relative coordinates in the extruder
G28; Sends all axes to the origin
G1 Z0.24 F3000; Raise the nozzle to 0.24mm
G1 X4.0 F2000; Moves X to 4mm
G1 Y120 E10 F600; Extrudes 10mm of filament while moving at 120mm in Y at a speed of 600mm/min
G1 Y150 F5000; Moves Y to 150mm at a speed of 5000mm/min to try to clean the nozzle

M104 y M109 – Commands to Control Extruder Temperature

Both commands allow you to heat the extruder to a certain temperature, the difference is as follows, with M104 you can indicate the temperature, and continue executing the commands after this.

With M109, we wait for the extruder to reach the desired temperature before executing subsequent commands.

On 3D printers that read x3g files, you may need to use M133 instead of M109 to stabilize the extruder temperature.

Some variants of the FlashForge Dreamer or Dremel 3D printers use M6 instead of M109.

The temperature is indicated in degrees Celsius, and on the left side of the temperature we put a letter “S”.

In case you have multiple extruders, with the letter “T” we indicate which extruder we want to heat. Generally, “T0” is used for the right extruder and “T1” for the left extruder.

If you have a single extruder, you can omit this parameter.

Let’s look at some examples.

M104 S210; Heats the extruder to 210 degrees Celsius
M104 S210 T0; Heats the T0 extruder (usually the one on the right side) to 210 degrees Celsius
M109 S210; Heats the extruder to 210 degrees Celsius, and wait until it reaches the desired temperature before executing more commands
M109 S210 T1; Heats the T1 extruder (usually the one on the left side) to 210 degrees Celsius, and wait until it reaches the desired temperature before executing more commands

M140 y M190 – Commands to Control the 3D Printer Bed Temperature

The argument and explanation are the same as for M104 and M109, but in this case, what we control is the temperature of the bed.

With M190 we wait to reach the desired temperature and with M140 we do not wait.

If your 3D printer reads 3xg files, you can use M134 instead of M190.

For the FlashForge Dreamer or Dremel 3D printer variants, they use M7 instead of M190.

The temperature is indicated in degrees Celsius, and on the left side of the temperature we put the letter “S”. Next, we will show you some examples.

M140 S70; Heats the bed to 70 degrees Celsius
M190 S70; Heats the bed to 70 degrees Celsius, and waits until it reaches the desired temperature before executing more commands

M106 – Command to Control Layer Fan Speed

With this command, we can decide what speed we want the layer fan to have.

Values from 0 to 255 are used for this command, where “0” is off, and “255” is the maximum speed.

This command is accompanied by the letter “S” on the left side.

Let’s look at some examples.

M106 S255; Sets the layer fan to its maximum speed
M106 S127; Sets the layer fan at a medium speed, approximately 50%.
M106 S0; Turns off the layer fan.

M400 – Waits for All the Movements and Commands to Execute

This command is used to wait until the previous commands and movements have finished before executing the next command.

Let’s look at an example.

G1 Y140 F2400; Moves Y to 140mm, at a speed of 2400mm/min
M400; Waits for all the moves to be completed
G1 X220 F2400; Moves X to 220mm, at a speed of 2400mm/min

G4 – Adds a Delay or Waits

With this command, we can add a delay or pause for a certain time, before continuing to execute the following commands.

If we use the letter “P”, the time is indicated in milliseconds (ms), when using the letter “S”, the time is indicated in seconds (s).

Look at the following examples.

G1 Y140 F2400; Moves Y to 140mm, at a speed of 2400mm/min
G4 P500; Pauses for 500 milliseconds before executing the following command
G1 X220 F2400; Moves X at 220mm, at a speed of 2400mm/min
G4 S2; Makes 2 seconds pause before executing the following command
G28; Sends all axes to the origin

M18, M48 – Command to Disable Motors

Both commands perform the same function, which is to disable the stepper motors so that you can move them manually.

In case one command doesn’t work for you, try the other one.

In this command, we can indicate exactly which axis we want to deactivate.

Let’s look at some examples.

M18; Disables all engines
M18 X; Deactivates the X-axis motor
M18 X Y; Disables the X-axis and Y-axis motors

Add Comments Within the G-Code

Using the semicolon symbol (;) we can add comments to the lines of the code. These comments are not interpreted as commands.

We have been showing it in all the previous examples.

G-Code Comments
Comments are added after the semicolon symbol (;) and they are not taken into account as commands.

More G-Code Commands

Find next some links where more commands are shown in G-Code language.

It is important that you know that depending on the 3D printer you have, these commands may vary.

Simplify 3D Scripts Tab

This is the section where we will place the Scripts that we want to be executed in Simplify3D.

The most used Tab Scripts are Starting Script and Ending Script.

You will find the option to place these Scripts in the next tab.

Scripts Tab en Simplify3D
Scripts Tab en Simplify3D

Next, we will explain each one of them.

Starting Script

In this section, you can place all the code that you want to be executed before starting the 3D printing.

Normally, all the axes are sent to the origin before printing, in addition, a little filament is also usually extruded before starting printing.

Next, we will show you an example of the code that we use.

G28 ; Sends all axes to origin
G1 Z0.24 F3000 ; Raises the nozzle to 0.24mm
G92 E0 ; Resets the extruder position
G1 X4.0 F2000 ; Moves in X to 4mm
G1 Y120 E10 F600 ; Extrudes 10mm of filament while moving Y to 120mm at a speed of 600mm/min
G1 Y150 F5000 ; Moves Y to 150mm at a speed of 5000mm/min to try to clean the nozzle
Starting Script Simplify 3D
Starting Script

Layer Change Script

In this section, we can place the code that will be executed every time we make a layer change in Simplify3D.

For us, it is useful to take photos and create our Time-Lapses of the 3D prints.

We will show you an example.

M400 ; Waits for all the moves to be completed
G1 Y140 F2400 ; Moves Y to position it for the photo
M400 ; Waits for all the moves to be completed
G1 X228 F3400 ; Moves X to focus the photo (we touch a switch with the extruder)
M400 ; Wait for all the moves to be completed
G4 P1000 ; Waits 1000 milliseconds for the photo to focus
G1 X231 F3400 ; Moves X to take the photo (we touch a switch with the extruder)
M400 ; Waits for all the moves to be completed
G4 P1500 ; Waits 1500 milliseconds for the photo to be taken
G1 X120 F3400 ; Move X to the center of the bed
M400 ; Waits for all the moves to be completed
Layer Change Script Simplify3D
Layer Change Script

Retraction Script

In this section, we can place the code that will be executed each time we do a retraction.

In our case, for the creation of the Time-Lapses, we do not use this section.

Tool Change Script

In this section, we can place the code that will be executed every time we change from one extruder to another.

Obviously, this only applies to 3D printers with multiple extruders.

If you have a single extruder, nothing is usually placed here.

If you have two or more extruders, and the options that Simplify3D brings by default are enough to work with multiple extruders, it is not necessary to place a G-Code in this Script.

It is not mandatory to place a code here when you use more than one extruder, but more advanced users could put a specific G-Code that helps them work better with multiple extruders.

Ending Script

In this section, you can place all the code that you want to be executed after finishing the 3D printing.

Generally, the extruder, the bed, and the layer fan are commanded to turn off, it is also possible to send the X-axis to the origin and move the bed a little forward in the direction of the Y-axis.

In addition to this, it is usually ordered to deactivate the stepper motors.

G91 ; Uses relative coordinates
G1 Z0.6 ; Raises the extruder 0.6mm
G90 ; Uses absolute coordinates
G28 X ; Send the X-axis to the origin
G1 Y170 ; Moves the bed forward at 170mm in Y
M106 S0 ; Turns off the layer fan
M104 S0 ; Turns off the extruder
M140 S0 ; Turns off the hot bed
M84 ; Deactivates the stepper motors
Ending Script Simplify3D
Ending Script

Options Within Post Processing

Export File Format

Allows you to select the format in which the file will be exported. Generally, this option is left at “Standard G-Code”, unless you have a 3D printer that requires another format.

For example, some MakerBot 3D printers can use files of type xg3.

Export file format option Fimplify3D
Export file format option

Add Celebration to End of Build

With this option, we can add a piece of celebration music at the end of the 3D printing.

It is only possible to activate this option when it is exported in x3g file.

Next, we will leave you the link to an example video:

https://youtu.be/Y64z4WdjR2g

Add celebration to end of build option Simplify3D
Add celebration to end of build option

Additional Terminal Commands

This tool, rarely an average user will feel the need to use it.

It is for advanced options, for example, suppose your 3D printer does not interpret the letter “E” as an extruder, instead, it needs to use the letter “A”.

In this box, we could specify Simplify3D to replace the letters “E” with letters “A” when generating the G-Code.

This is done in the following way.

{REPLACE “E” “A”}
Using the Additional Terminal Commands Option to replace the letters "E" with letters "A"
Using the Additional Terminal Commands Option to replace the letters “E” with letters “A”
Example of how we replace the letters “E” by letters “A” in the G-Code when using the Additional Terminal Commands Option
Example of how we replace the letters “E” by letters “A” in the G-Code when using the Additional Terminal Commands Option

Conclusions About G-Code Commands

So, you already know the Simplify3D Scripts and in the links contained in this article, you can also find more commands.

Remember that for some 3D printers the commands may vary.

In this article we use some terminologies that if you don’t know them yet, you can visit our article Most used 3D Printing Terms, there you can further expand your knowledge about 3D printing.

If you are starting out in 3D printing, or are already familiar with it, these two articles can be very useful:

Any questions you have, do not hesitate to leave it in our comments section, as well as any contribution or suggestion you wish to make, we are here to grow together in this wonderful world of 3D printing.

Greetings.

See you soon Machine Bros!

OTHER ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular