Gcode

From Hyrel3D
Revision as of 20:50, 2 January 2018 by Davo (talk | contribs) (T Variables)
Jump to: navigation, search

Everything your Hyrel 3D Printer does is done by executing GCode, whether you are aware of it or not. While most of it is specified in your gcode file, some of it is sent to the printer before the file is executed; this includes setting flow rates, prime/unprime (advance/retract) settings, and default speeds.

Below, I will explain those gcodes about which we get the most questions.

Understanding the T

The T command (lines starting with a T) and the T variable in M commands (lines starting with an M) use different addressing. Here's how they're used:

T Commands

A T command starts with a T, and indicates a tool change, or a change of focus from one tool position (print head) to another. A T command also invokes the variables (nozzle diameter, motor pulses per unit volume, flow multiplier, prime and unprime values, and X/Y(/Z) offsets) which were sent from Repetrel to the Motion Controller at job start. These are numbered 0-3 from left to right. Examples:

T0 ; tool change to the first (far left) tool position, including variables
T1 ; tool change to the second tool position, including variables
T2 ; tool change to the third tool position, including variables
T3 ; tool change to the fourth tool position, including variables

T Variables

A T variable is a parameter (sometimes optional) sent as part of an M command, starting with an M, and indicates which tool position these settings should be applied to. If left out, these settings are applied to the head which currently has focus (is printing). On Yoke 1, these are labeled 11-14, left to right, with 10 being a wildcard, sending this command to every head on Yoke 1. Examples:

M221 T11 S1.0 P.58 W1.6 Z0.3 ; apply flow settings (M221) to the head in the first slot (T11) 
                             a flow modifier of 1.0 (S1.0), pulses per 10 nanoliters of 0.58 (P0.58), 
                             nozzle width of 1.6mm (W1.6), and a layer thickness of 0.3 (Z0.3) 
                             - note that the layer thickness will be later overwritten by the M756 command.

M104 T14 S435                ; apply temperature (M104) to the head in the fourth slot (T14) to 435C (S435).

M106 S25                     ; set cooling fan (M106) to 25% power (S25); since no head is specified, 
                             this will be sent to the head currently in use.

M104 T10 S0                  ; apply temperature (M104) to all heads on yoke 1 (T10) to 0C (S0).

Controlling Movement

G0 Rapid Move

G0 is a rapid positioning move. It is not a working move, meaning that your equipment will not be printing, milling, lasering, or doing any other active work during a G0 move. G0 is intended to move your tool to a new position, where the work will happen. Accordingly, G0 movement speeds are set in your configuration settings, rather than being specified in your gcode file (although you could specify this with the M203 command). A G0 command will not make use of an F (feed rate, or movement speed) value, even if specified.

  • X is the new X position to move to;
  • Y is the new Y position to move to; and
  • Z is the new Z position to move to.

G1 Working Move

G1 is a working move, during which you may be printing, milling, lasering, or doing other active work - provided an E (extrude) value is given; the value of Extrusion rate E will be ignored, but E will trigger a working or printing move. G1 moves are made at the rate indicated by the F (feed rate) value; if no F value is specified, the last F value set will be used. Small non-working moves are often generated by a G1 move with no E value; these will use the specified (or inherited) F value, rather than using the G0 speed.

  • X is the new X position to move to;
  • Y is the new Y position to move to;
  • Z is the new Z position to move to; and
  • F is the Feed rate (travel speed) at which to execute this move.
  • E indicates a working or printing move; E values are not interpreted.

If the X, Y, Z, or F values are not stipulated, they are inherited.

G2 Clockwise Arc

A G2 move specifies a clockwise arc (or complete circle) from the current position to position X, Y by following an arc about the center point I (X position), J (Y position). As with a G1 move, a Feed rate F may be specified. As with a G1 move, the value of Extrusion rate E will be ignored, but E will trigger a working or printing move.

  • X is the new X position to move to;
  • Y is the new Y position to move to;
  • I is the RELATIVE X position of the center about which to arc;
  • J is the RELATIVE Y position of the center about which to arc; and
  • F is the Feed rate (travel speed) at which to execute this move.
  • E indicates a working or printing move; E values are not interpreted.

If the X, Y, Z, or F values are not stipulated, they are inherited. Note that as all STL models are, by definition, a series of triangles, your slicer will not generate G2 commands.

G3 Counter-Clockwise Arc

A G3 move specifies a counter-clockwise or anti-clockwise arc (or complete circle) from the current position to position X, Y by following an arc about the center point I (X position), J (Y position). As with a G1 move, a Feed rate F may be specified. As with a G1 move, the value of Extrusion rate E will be ignored, but E will trigger a working or printing move.

  • X is the new X position to move to;
  • Y is the new Y position to move to;
  • I is the X position of the center about which to arc;
  • J is the Y position of the center about which to arc; and
  • F is the Feed rate (travel speed) at which to execute this move.
  • E indicates a working or printing move; E values are not interpreted.

If the X, Y, Z, or F values are not stipulated, they are inherited. Note that as all STL models are, by definition, a series of triangles, your slicer will not generate G3 commands.

G4 Pause (Timed)

G4 is a pause for a set number of seconds (S) or milliseconds (P). Please note, if you pause after a printing move, material will still be flowing. It is recommended that you pause after a non-printing move for this reason.

  • S is the number of Seconds to pause.

M0 Stop Until Resume

M0 is a stop until resume command; text listed after a semicolon will be displayed, and clicking the Play button (which replaces the Pause button) will cause the job to resume. Print heads will NOT resume during an M0, and will not prime/unprime in response to the M0. It is recommended to have a non-printing move before and after an M0.

  • ; All text following the ; will be echoed to the print mask (Control Tab).

M203 Set G0 Speed

M203 will redesignate the rate at which G0 movements are executed. If undeclared, the values stored in Repetrel for your equipment will be used. These can be changed under Settings > Printer, on the Printer tab. The values set on your unit are set based on testing; exceed them at your own risk.

  • X is the new speed in the X axis for G0 moves;
  • Y is the new speed in the Y axis for G0 moves; and
  • Z is the new speed in the Z axis for G0 moves.

Examples

Controlling Movement
Actual Code Behavior Notes
G0 X50 Y50 Z10 Makes a (rapid) non-printing move from the current position to X50, Y50, Z10 at the rate specified in your settings. These can be absolute or relative distances, depending on your environment - see Positioning, below. G0 may have X, Y and/or Z values for the new position; undeclared values will not change (ex: if no Z value provided, no Z movement executed).
G1 X50 Y50 E1 F1800 Makes a working (printing) move from the current position to X50, Y50 at 1800 mm/min while extruding material. See "Flow Commands" below for details on flow calculation. If no F value, last declared F value is used. If no E value, this would be a non-printing move. G1 may have X, Y and/or Z values for the new position; undeclared values will not change (ex: if no Z value provided, no Z movement executed).
G2 X5 Y10 I15 J20 E1 F1200 Makes a clockwise arc from the current position to X5, Y10 while maintaining a constant distance from a point +15mm in the X and +20mm in the Y from the current position; this is a printing move at a speed of 1200 mm/min. Note that I, J coordinates are always relative from the current position. Note that as all STL models are, by definition, a series of triangles, your slicer will not generate G2 commands.
G3 X5 Y10 I15 J20 Makes a counter-clockwise arc from the current position to X5, Y10 while maintaining a constant distance from a point +15mm in the X and +20mm in the Y from the current position; this is a non-printing move at the last F Feed rate (speed) specified. Note that I, J coordinates are always relative from the current position. Note that as all STL models are, by definition, a series of triangles, your slicer will not generate G3 commands.
G4 S60 Pauses the job for 60 seconds (use P for milliseconds). If the head was extruding before the pause, it will continue to extrude; use a non-printing move before a G4.
M0 ;comment Stops the job, displays everything following the semicolon (;) at the top of the Control window (in this example, the word "comment"), and resumes after the operator clicks the Play button. The head will NOT extrude during an M0 (stop) interlude; use a non-printing move before and after an M0 to initiate prime/unprime activities.
M203 X2000 Y1500 Specifies G0 speed of 2000 mm/min in the X axis and 1500 in the Y axis. Subsequent moves will be made at the newly specified rate. The values set on your unit are set based on testing; exceed them at your own risk.

Controlling Temperature

M104 Set Extruder Temperature

M104 sets the extruder temperature, but does not pause the printer.

  • S is the new Set temperature in °C; and
  • T is the Tool assignment for this temperature command.

M106 Set Cooling Fan (or LEDs)

M106 sets the cooling fan (or crosslinking LEDs) speed (or intensity).

  • S is the (percent of duty cycle, 0-100) for the cooling fan (or LEDs); and
  • T is the Tool assignment for this cooling command.

M107 Stop Cooling Fan (or LEDs)

M107 turns off the cooling fan (or crosslinking LEDs); this is essentially the same as an M206 S0 (setting it to 0 percent).

M109 Set Extruder Temp, Wait

M109 sets the extruder temperature and pauses the printer until the extruder reaches that temperature.

  • S is the new Set temperature in °C; and
  • T is the Tool assignment for this temperature command.

M116 UNUSED

M116 is not recognized by Repetrel as of November, 2016. On some other printers, this will cause the printer to pause until all set temperatures are reached.

M140 Set Bed Temperature

M140 sets the bed temperature.

  • S is the new Set temperature in °C.

M190 UNUSED

M190 is not recognized by Repetrel as of November, 2016. On some other printers, this will cause the printer to pause until a bed temperature is reached.

M191 UNUSED

M191 is not recognized by Repetrel as of November, 2016. On some other printers, this will cause the printer to pause until a chamber temperature is reached.

Examples

Controlling Temperature
Actual Code Behavior Notes
M104 S235 T10 Sets the extruder temperature to 235 on all extruders.
M104 S235 T12 Sets the extruder temperature to 235 on the head in slot 2.
M104 S235 Sets the extruder temperature to 235 on the currently active head. Currently active head is explained below.
M106 S100 T10 Sets the cooling fan to 100% on all extruders.
M106 S25 T12 Sets the cooling fan to 25% on the head in slot 2.
M106 S0 Sets the cooling fan to 0% (off) on the currently active head. Currently active head is explained below.
M107 T10 Turns off the cooling fan on all extruders.
M107 T12 Turns off the cooling fan on the head in slot 2.
M107 Turns off the cooling fan on the currently active head. Currently active head is explained below.
M109 S235 T12 Sets the extruder temperature to 235 on the head in slot 2 and waits for the temperature to be reached. M109 is ignored if there is no T11, T12, T13 or T14 provided.
M140 S80 Sets the bed temperature to 80.
The Currently Active Head defaults to the highest numbered head found; or it is the last head selected with a tool change command during this Repetrel session (if a T command has been used).

Controlling Material Flow

While you can specify flow rate variables in your gcode, we do not do this by default, and we actually don't recommend this. With our recipes the slicing program generates gcode which dictates temperature and movement commands, and indicates which moves should dispense material (a G1 move with an E value).

However, we do not use that E value (except to distinguish printing from non-printing moves; we draw our flow calculation numbers from elsewhere. When a head is loaded, it sends this flow data (how to calculate flow, as well as how much to prime and unprime (advance and retract) material when transitioning between printing and non-printing moves - and even how many primes or unprimes to do in conjunction with a tool change.

In this way, the very same gcode (with temperature changes) can be used with any material, provided you are using the same nozzle size the model was sliced for.

M82 UNUSED

M82 is not used by Repetrel as of November, 2016. On some other printers, this will cause the printer to absolute E values to calculate extrusion.

M83 UNUSED

M83 is not used by Repetrel as of November, 2016. On some other printers, this will cause the printer to relative E values to calculate extrusion.'

M221 Set Flow Rate

M221 sends information to the printer about material flow:

  • P is the number of pulses on the motor to dispense 10 nl of material;
  • S is the direct flow multiplier (to allow for undersized or oversized stock;
  • W is the width of the cross section of the volume to fill;
  • Z is the height of the cross section of the volume to fill; and
  • T is the tool (head) to which these values will be applied.

M721 Set Unprime Values

M721 sends information to the printer about how much material to unprime when a transition from printing move to non-printing move is detected:

  • S is the speed at which unprime moves should be executed; this is normally 10,000;
  • E is the number of pulses on the feed (extrusion) motor to execute; this varies greatly among materials;
  • P is the number of milliseconds to pause before enabling the flow rate for the following move;
  • T is the tool (head) to which these values will be applied; and
  • I is the flag for executing an Immediate action; so M721 I1 would execute an unprime with the previously specified values at that point in the gcode.

M722 Set Prime Values

M722 sends information to the printer about how much material to prime when a transition from non-printing move to printing move is detected:

  • S is the speed at which prime moves should be executed; this is normally 10,000;
  • E is the number of pulses on the feed (extrusion) motor to execute; this varies greatly among materials;
  • P is the number of milliseconds to pause before enabling the flow rate for the following move;
  • T is the tool (head) to which these values will be applied; and
  • I is the flag for executing an Immediate action; so M721 I1 would execute a prime with the previously specified values at that point in the gcode.

M756 Set Height for Flow

M756 will overwrite the Z value from the M221 command, allowing you to calculate flow for thinner or thicker layers. We declare M756 at the beginning of every layer; normally, they are all the same (unless you sliced for varying layer thicknesses).

  • S is the layer thickness in mm for flow calculations.

Examples

Controlling Material Flow
Actual Code Behavior Notes
M221 S1.0 T12 P0.80 W0.5 Z0.3 Sets flow rate for the head in slot 2 to 0.8 (p/10nl) with a flow modifier of 1.0; also specifies the cross section of the area to be filled to a width of 0.5 and height of 0.3 (mm). These values are normally not hardcoded, but are sent from the actual print head to the Repetrel program, and then sent to the printer when the job starts. Hardcode these at your own risk.
M721 S10000 E300 P80 T12 Sets the unprime values for the head in slot 2 to 300 pulses, executed at a rate of 10,000 per minute, with a 80 millisecond dwell (before enacting the next flow rate). As the next flow rate is necessarily 0 (for a non-printing move), the E value is relatively meaningless here. These values are normally not hardcoded, but are sent from the actual print head to the Repetrel program, and then sent to the printer when the job starts. Hardcode these at your own risk.
M721 I1 Executes an immediate unprime on the head the printer is currently in communication with, using previously defined values for that head.
M722 S10000 E300 P105 T12 Sets the prime values for the head in slot 2 to 300 pulses, executed at a rate of 10,000 per minute, with a 105 millisecond dwell (before enacting the next flow rate). These values are normally not hardcoded, but are sent from the actual print head to the Repetrel program, and then sent to the printer when the job starts. Hardcode these at your own risk.
M722 I1 Executes an immediate prime on the head the printer is currently in communication with, using previously defined values for that head.
M756 S0.2 Sets layer thickness (for flow calculations) to 0.2mm Use caution if editing this value.
To make this a little easier to understand:
To determine flow we consider:

1. Path Width, as specified in the nozzle diameter parameter on the data for that print head (NOT path width in the slicer) [unless you manually hard code a value in your gcode];

2. Path Height (or Layer Thickness), as specified in your gcode by an M756 command with an S (slice thickness) value (NOT on the print head);

- 1 and 2 - these two define the cross section to fill during this move.

3. Print Speed, as specified in your gcode by a G1 command with an F (feed rate) value (which should be set by your slicer, but may be edited afterward);

- 1 and 2 and 3 - cross section times linear speed gives us volume per unit time (in nl/sec) to be dispensed.

4. Pulses per Nanoliter (actually, pulses for 10 nanoliters), as specified on the data for that print head (NOT path width in the slicer) [unless you manually hard code a value in your gcode];

- 1 and 2 and 3 and 4 - volume per unit time times pulses per unit volume gives us how fast in pulses per second to dispense.

5. Feed Rate %, as specified on the data for that print head (NOT path width in the slicer) [unless you manually hard code a value in your gcode];

- 1 and 2 and 3 and 4 and 5 - pulses per second is modified by this feed rate percentage (default of 1) to account for over/under sized filament or slippage due to gummy material.

Controlling Position and Offsets

The following commands define if new positioning data is defined in inches (G20) or mm (G21); or from the origin (G90) or from the present location (G91). They also stipulate the offsets from one head to another (M6), and how to invoke that offset (T).

G10 UNUSED

G10 is not recognized by Repetrel as of November, 2016. On some other printers, this will set tool offsets; we do this via M6.


G20 Set Units to Inches

G20 declares that henceforth, measurements will be given in inches.

G21 Set Units to Millimeters

G21 declares that henceforth, measurements will be given in mm.

G28 Send X, Y to Physical Home

G28 sends the X and Y axes to the sensor-defined physical home position, regardless of logically set 0,0.

G90 Set Absolute Coordinates

G90 stipulates that henceforth, absolute measurements will be given - calculated from the origin (0,0 point).

G91 Set Relatative Coordinates

G91 stipulates that henceforth, relative measurements will be given - calculated from the current position.

G92 Reset Coordinates

G92 resets the current position to the specified coordinates; without X, Y, or Z values, all axes are reset to 0 at the present point.

  • X is the new X position of record;
  • Y is the new Y position of record; and
  • Z is the new Z position of record.

M6 Declare Offsets

M6 declares that a particular head holds a set of X, Y, and/or Z offsets, which will be invoked during a T (tool change) command. Repetrel reads this data from the heads, and sends it to the printer before the gcode file is loaded.

  • T is the Tool position for which these offsets are being set;
  • O is the Offset position where these are being stored;
  • X is the offset in the X axis;
  • Y is the offset in the Y axis; and
  • Z is the offset in the Z axis.

T Tool Change

T executes a tool change, invoking the parameters specified in the M6 sent from Repetrel to the printer at the job start.

Examples

Controlling Position and Offsets
Actual Code Behavior Notes
G20 All subsequent distances will be specified in inches. This is our NOT our standard state.
G21 All subsequent distances will be specified in mm. This is our standard state.
G28 Sends the X and Y axes to the sensor-defined physical home position, regardless of logically set 0,0. A standard part of our start gcode so that previous settings will be overwritten.
G90 All subsequent distances will be specified as absolute distances from the currently recorded X0 Y0 Z0 position. This is our standard behavior.
G91 All subsequent distances will be specified as relative distances from the current position. This is often handy, especially for hand coding, but is not our default.
G92 The current position will be logically reset to be the position specified. We often use this at the beginning of a gcode file.
G92 X0 Y0 The current position will be logically reset to be the X0, Y0 origin. This is useful for reusing sections of code when hand coding. Remember, this is persistent until respecified. Can be neutralized by sending to physical 0,0 and resetting:
G28 X0 Y0
G92 X0 Y0
M6 T12 O2 X0 Y35 Z0 Stores these offsets for T12 in register O2, which will be applied whenever a T1 command (activating the second head) is given. This info is rarely hard coded, but is sent from Repetrel before the gcode file is queued for execution.
T0 Switches from the current head to T0, the head in slot 1. Note that the appropriate M6, M221, M721, and M722 values will be activated at this time. Values are T0, T1, T2, or T3.

Other

Other commands.

M3 Turn On Spindle (CW)

M3 tells the printer to activate (start) the spindle motor in the clockwise direction on the current head (if it has one), using the value set on the head for RPM.

M3 T26 S50 ; turns the 3-phase spindle tool on at 50%
M3 T1 S100 ; turns the 1-phse spindle tool in slot 1 (far left) on at 100%'

M5 Turn Off Spindle

M5 tells the printer to deactivate (stop) the spindle motor on the current head (if it has one).

M5 T26 ; turns the 3-phase spindle tool off
M5 T4 ; turns the 1-phase spindle tool in slot 4 off

M7 Turn On Aux 1

M7 tells the printer to activate whatever is connected to auxiliary connection one. It takes no parameters.

M8 Turn On Aux 2

M8 tells the printer to activate whatever is connected to auxiliary connection two. It takes no parameters.

M9 Turn Off All Aux

M9 tells the printer to deactivate both auxiliary connections. It takes no parameters.

M17 Engage Motors

M17 will apply power to all motors (positioning and extruder motors), locking them at their current postion; this prevents the bed and yoke from being pushed manually in the X and Y. This is the opposite of M17 and M84, and takes no parameters.

M18 Disengage Motors

M18 will cut power to all motors (positioning and extruder motors), unlocking them; this allows the motors to cool down (as they normally lock in place while still), as well as allowing one to manually push the bed and yoke in the X and Y. This is the opposite of M17 and identical to M84, and takes no parameters.

M30 End of Program

M30 tells the printer that this job is complete. It takes no parameters.

M84 Disable Motors

M84 will cut power to all motors (positioning and extruder motors), unlocking them; this allows the motors to cool down (as they normally lock in place while still), as well as allowing one to manually push the bed and yoke in the X and Y. This is the opposite of M17 and identical to M18, and takes no parameters.

M673 Set Y-arm Light

M673 sets the intensity of the Y-arm LEDs.

  • S is the (percent of duty cycle, 0-100) for the LEDs

M790 New Layer Actions

M790 will trigger any associated new layer actions, which can include capturing an image from the designated camera. It takes no parameters.