Introduction To G-Code Commands
Now that you are familiar with the coordinate system of the Promega, its orientation and direction, we can get started with learning and sending G-code commands. G-code commands are sent one line at a time, with one command per line. When you send a print file to your printer in order to print something, you are sending the printer a long list of G-code commands. It will look something like this (but way longer!):
Basic Commands
The command, G1
, you are see above is called the move command. This is arguably the most important G-code as it allows you to move the printer. Each G-code command consists of a letter followed by a number. G31
, M564
and T0
are all valid G-code commands as well. The Duet Maestro control board runs RepRap Firmware. This firmware determines what commands are valid, and which commands are not. You can find all the valid commands that you can send in a long list on the RepRap Wiki G-codes Page. After the initial letter-number combination of the G-code command a parameter can follow. This is also visible with the G-code commands listed above, the command G1 X248.843 Y182.581 E0.0438
has X248.843 Y182.581 E0.0438
as parameters. Many different G-code commands have optional parameters that can be entered after the initial command.
Absolute vs. Relative in Commands
With the G1
command you can move the printer. However, where the G1
command moves your printer depends on whether you are in absolute or relative mode. Absolute mode is enabled whenever you send the command G90
, relative mode is enabled when you send the command G91
. Whenever you are printing absolute mode is typically enabled. If you restart your printer, absolute mode will also be enabled. If you send the command G1 X150 Y120 Z100
in absolute mode (G90
), the printer will move to the position X = 150mm, Y = 120mm and Z = 100mm, relative to the origin. If you send the same command in relative mode (G91
), it will send the printer 150 mm in the positive X-direction, 120 mm in the positive Y-direction and 100 mm in the Z-direction relative to where the printer currently is positioned. The same command can send the printer to two completely different places depending on what mode you are in. As you saw in one of the commands above, the move command, G1
, can also have an E
parameter, this allows for a movement of the extruder motor.
Feedrate
Aside from the X
, Y
, Z
and E
parameters which allow the printer to move each of the motors, there is one other important parameter F
. F
is the feedrate of the motor, or is simple terms, the speed that the motor will travel at. The units of the X
, Y
, Z
and E
parameters is mm. However for F
or feedrate the units are mm/min
. A normal travel feedrate (speed) would be 3000mm/min, but for printing the feedrates are typically much lower.
The Movement Buttons
In one of the steps above you used the buttons in Machine Control to move the printer. What is really happening here is that when you press a button a list of G-code commands are sent to the printer. For example, if you press the X+10 button to move the printer 10mm in the positive X-direction this is what is actually sent:
You might be familiar with two of the G-code commands here G91
and G1
. G91
enables relative mode, so the next move command that is sent will be with respect to the printers current position and not the origin. After the G91
command, the move command G1
is sent. This sends the printer 10mm in the positive X-direction at a feedrate of 6000mm/min. The M120
and M121
commands are stack push and pop. If you are not familiar with these two programming terms, then don't worry, they are not important to know for a beginning user. All you have to know is that it will disable relative mode G91
and return to absolute mode G90
. This is because you want the printer to be back in absolute mode after pressing the move buttons.
Sending G-code Commands
Now that you are more familiar with G-code commands you can try to complete the steps below in order to see how the printer responds to you sending G-code commands directly to the printer itself.
Find the G-code Console tab in the Duet Web Console.
This tab allows you to send commands to the printer using the textfield as seen above. Once you enter a command in the text field you can press Enter or press the dark-blue send button. The printer will then process the command and execute it. If the command executed successfully you will see a print out of the command you send in the Printer Printout terminal with a green background. If the firmware encountered an error while trying to process the command, it will printout the command with a red background and more information about the error. 3. This step assumes you have the printer homed from the previous steps. If you have not yet homed your printer, click the Home All button in the Machine Control tab. Try sending the command G1 X200 Y200
. This will move the printer to 200 mm X and 200 mm Y. Send the command G1 Z150
. This will move the bed to about 150 mm from the nozzle. 4. You can keep sending commands to move the printer around the build space. The table below represents the limits of the printer, the firmware should prevent you from going past these limits. Still, try to keep your move commands within the build space of the printer. You can also try to change the feedrate of the printer to see how the speed of the printer changes as the printer moves around.
Axes Limits
Max (mm)
Min (mm)
X - Axis
388
0
Y - Axis
388
0
Z - Axis
377
0
Other G-code Commands
Of course there are many more RepRap supported G-code commands (as you might have seen on the RepRap Wiki). You will come across some of them as you follow this guide. Whenever you have questions about what a command does, you can look up the command in the wiki.
Throughout the different guides you will find G-code in this format
. That typically means you can execute the G-code command. Comments are denoted by any text following a semi-colon ";". A new line will end the comment.
G1 X100 ; This is a comment!
Last updated