Custom G-code Tutorial: Dots, Lines, Lattices and Thin Films

Wikis > Custom G-code Tutorial: Dots, Lines, Lattices and Thin Films

Overview

While most prints can and should be easily prepared without developing custom gcode through the use of Slic3r, manually editing print files allows users the versatility to adjust and create unique print processes. Slic3r is suggested to prepare print files before attempting custom g-code. Custom g-code is designed for specific use-case scenarios when slic3r is not able to achieve the desired tool path for a print.

Common Commands

Below are some common gcode commands used with the BioBot 1. More information on gcode commands can be found in this RepRapWiki article.

  • G1
    • G1 [X{X position}] [Y{Y position}] [Z{Z position}] [E{Extruder position}] [F{Feedrate}]  will move the extruder in a line to the given position
    • Feedrate is in units of mm/min and positions of X,Y and Z are in mm
    • For the BioBot 1, a line of G1 with an extruder position included will cause the printer to extrude material
      • example: 
        G1 X1 Y1 Z1 E0.1 F200 ; will move extruder to the position X1 Y1 Z1 at a rate of 200 mm/min
    • A line of G1 code without an extruder position will move the extruder without depositing material
      • example: 
        G1 X1 Y1 Z1 F200; will move extruder to the position X1 Y1 Z1 at a rate of 200 mm/min without extruding material
  • G4
    • G4 pauses the printer in its current state for a given amount of time
    • G4 PXX will pause the printer for XX millseconds
    • G4 SXX will pause the printer for XX seconds
  • G92
    • G92 sets the position of the extruder
    • the line G92 E0is used for BioBots printers to start the extrusion process
  • T0/T1
    • T0 selects extruder 1
    • T1 selects extruder 2
  • Formatting
    • the semicolon ; can be used to create comments in your gcode
    • As you create continuous lines of code to extrude, your number after E must continuously increase. You can reset this sequence with G92 E0.

Example Code Sequence: Lines

Let’s say we are trying to create a 2 layer 10 mm line, starting at X,Y and Z positions of (0,0,0.2), with a layer height of 0.2  mm and speed of 2 mm/s. For this example, a code like the one below could be used.

; Sample Code – I can label my code and create comments by writing text after a semicolon
T0 ; select left extruder for this print
G92 E0 ; set position of extruder
G1 X0 Y0 Z0.2 F120 ; Move extruder to  (0,0,0.2) at a rate of 120 mm/min without extruding material
G1 X5 Y0 Z0.2 E0.1 F120 ; Move extruder to  (5,0,0.2) at rate of 120 mm/min and extrude material
G1 X10 Y0 Z0.2 E0.2 F120 ; Move extruder to (10,0,0.2) at rate of 120 mm/min and continue to extrude
G92 E0 ; I am finished my first layer, so I use this command as a reset
G1 X10 Y0 Z0.4 F120 ; move extruder to (10,0,0.4) at rate of 120 mm/min without extruding material
G1 X5 Y0 Z0.4 E0.1 F120 ; move extruder to (5,0,0.4) at rate of 120 mm/min and extrude material
G1 X0 Y0 Z0.4 E0.2 F120 ; move extruder to (0,0,0.4) at rate of 120 mm/min and extrude material
G92 E0 ;
Download this gcode file: lines-example.

Example Code Sequence: Lattice

Let’s say we are trying to create a 4 layer lattice that has a 6 mm width and length and a 0.4 mm height, with 2 mm spacing between lines.  For this example, a code like the one below could be used.

;Sample Code – I can label my code and create comments by writing text after a semicolon 

G21 ; set units to millimeters
G90 ; use absolute coordinates
M82 ; use absolute distances for extrusion

G92 E0 ; set position of extruder
;print layer 1 of lattice
G1 Z0.100 F240.000; Move extruder to Z position of 0.100 without extruding material
G1 X3 Y-3 F240.000 ; Move extruder to X,Y position of (3,-3) without extruding material
G1 X3 Y-3 F240.000 E0.013; Begin extruding material at position (3,-3, 0.1)
G1 X3 Y3 E0.02271 F240.000; move to (3,3,0.1) and extrude material
G1 X1 Y3 E0.02748; move to (1,3,0.1) and extrude material
G1 X1 Y-3 E0.05005; move to (1,-3,0.1) and extrude material
G1 X-1 Y-3 E0.0548; move to (-1,-3,0.1) and extrude material
G1 X-1 Y3 E0.07738; move to (-1,3, 0.1) and extrude material
G1 X-3 Y3 E0.08216; move to (-3,3, 0.1) and extrude material
G1 X-3 Y-3 E0.10567; move to (-3,-3, 0.1) and extrude material

G92 E0; reset position of extruder
;print layer 2 of lattice

G1 Z0.200 F240.000
G1 X-3 Y-3 F240.000
G4 S0.1 E0.010
G1 X-3 Y-3 F240.000 E0.012
G1 X3 Y-3 E0.02090 F240.000
G1 X3 Y-1 E0.02514
G1 X-3 Y-1 E0.04584
G1 X-3 Y1 E0.05008
G1 X3 Y1 E0.07078
G1 X3 Y3 E0.07501
G1 X-3 Y3 E0.09705
G92 E0

; print layer 3 of lattice

G1 Z0.300 F240.000
G1 X-3 Y3 E0.09705
G1 X3 Y-3 F240.000
G1 X3 Y3 E0.02271 F240.000
G1 X1 Y3 E0.02748
G1 X1 Y-3 E0.05005
G1 X-1 Y-3 E0.05482
G1 X-1 Y3 E0.07738
G1 X-3 Y3 E0.08216
G1 X-3 Y-3 E0.10567
G92 E0

;print layer 4 of lattice
G1 Z0.400 F240.000
G1 X-3 Y-3 F240.000
G4 S0.1 E0.010
G1 X3 Y-3 E0.02090 F240.000
G1 X3 Y-1 E0.02514
G1 X-3 Y-1 E0.04584
G1 X-3 Y1 E0.05008
G1 X3 Y1 E0.07078
G1 X3 Y3 E0.07501
G1 X-3 Y3 E0.09705
G92 E0

;Download this gcode file: lattice_good_f240.

Example Code Sequence: Dots

Let’s say we are trying to extrude 9 dots, starting at (0,0,0.2), all spaced 1 mm apart. For this example, a code like the one below could be used.

; Sample Code – I can label my code and create comments by writing text after a semicolon
T0; choose extruder 1
G92 E0 ; set position of extruder

;dot 1
G1 X0 Y0 Z0.2 F600; move to position (0,0,0.2) at speed of 600 mm/min without extruding material
G1 X0 Y0 E0.1; begin extruding material
G4 S1 E0.2; continue to extrude material for 1 second
G92 E0; stop extruding material

;dot 2
G1 X0 Y1
G1 X0 Y1 E0.1
G4 S1 E0.2
G92 E0

;dot 3
G1 X0 Y2
G1 X0 Y2 E0.1
G4 S1 E0.2
G92 E0

;dot 4
G92 E0
G1 X1 Y2 Z0.2
G1 X1 Y2 E0.1
G4 S1 E0.2
G92 E0

;dot 5
G1 X1 Y1
G1 X1 Y1 E0.1
G4 S1 E0.2
G92 E0

;dot 6
G1 X1 Y0
G1 X1 Y0 E0.1
G4 S1 E0.2
G92 E0

;dot 7
G1 X2 Y0
G1 X2 Y0 E0.1
G4 S1 E0.2
G92 E0

;dot 8
G1 X2 Y1
G1 X2 Y1 E0.1
G4 S1 E0.2
G92 E0

;dot 9
G1 X2 Y2
G1 X2 Y2 E0.1
G4 S1 E0.2
G92 E0



;Download this gcode file: dots.

Example Code Sequence: Thin Films

Let’s say we are trying to create a single thin film by extruding material for 20 seconds. For this example, a code like the one below could be used.

; Sample Code – I can label my code and create comments by writing text after a semicolon
T0 ; select left extruder for this print
G92 E0; set position of extruders
G1 Z0; move extruders to Z-height of 0 without extruding
G1 X0 E0.1; move extruders to x location of 0 and begin extruding
G4 S20 E0.2; continue extruding for 20 seconds
G92 E0

Download this gcode file:20-second-extrusion .