thinkyhead

G0-G1 - Linear Move

1.0.0-beta motion Add a straight line movement to the planner

Description

The G0 and G1 commands add a linear move to the queue to be performed after all previous moves are completed. These commands yield control back to the command parser as soon as the move is queued, but they may delay the command parser while awaiting a slot in the queue.

A linear move traces a straight line from one point to another, ensuring that the specified axes will arrive simultaneously at the given coordinates (by linear interpolation). The speed may change over time following an acceleration curve, according to the acceleration and jerk settings of the given axes.

A command like G1 F1000 sets the feedrate for all subsequent moves.

By convention, most G-code generators use G0 for non-extrusion movements (those without the E axis) and G1 for moves that include extrusion. This is meant to allow a kinematic system to, optionally, do a more rapid uninterpolated movement requiring much less calculation.

For Cartesians and Deltas the G0 (rapid linear movement) command is (and must be) a direct alias for G1 (rapid movement). On SCARA machines G0 does a fast non-linear move. Marlin 2.0 introduces an option to maintain a separate default feedrate for G0. Note: Slicers tend to override firmware feedrates!

Notes

Coordinates are given in millimeters by default. Units may be set to inches by G20.

In Relative Mode (G91) all coordinates are interpreted as relative, adding onto the previous position.

In Extruder Relative Mode (M83) the E coordinate is interpreted as relative, adding onto the previous E position.

A single linear move may generate several smaller moves to the planner due to kinematics and bed leveling compensation. Printing performance can be tuned by adjusting segments-per-second.

Developer Notes

Developers: Keep using G0 for non-print moves. It makes G-code more adaptable to lasers, engravers, etc.

Usage

G0 [A<pos>] [B<pos>] [C<pos>] [E<pos>] [F<rate>] [S<power>] [U<pos>] [V<pos>] [W<pos>] [X<pos>] [Y<pos>] [Z<pos>]
G1 [A<pos>] [B<pos>] [C<pos>] [E<pos>] [F<rate>] [S<power>] [U<pos>] [V<pos>] [W<pos>] [X<pos>] [Y<pos>] [Z<pos>]

Parameters

[A<pos>]
2.0.9
I_DRIVER_TYPE AXIS4_NAME 'A'

An absolute or relative coordinate on the A axis (in current units).

    [B<pos>]
    2.0.9
    J_DRIVER_TYPE AXIS5_NAME 'B'

    An absolute or relative coordinate on the B axis (in current units).

      [C<pos>]
      2.0.9
      K_DRIVER_TYPE AXIS6_NAME 'C'

      An absolute or relative coordinate on the C axis (in current units).

        [E<pos>]

        An absolute or relative coordinate on the E (extruder) axis (in current units). The E axis describes the position of the filament in terms of input to the extruder feeder.

          [F<rate>]

          Set the requested movement rate for this move and any following moves. As with other rate parameters this value is specified in current units per minute.

          By default this feedrate is interpreted according to the specification for LinuxCNC default state (trivial kinematics, CANON_XYZ feed reference mode, Units-Per-Minute mode). For details, refer to the LinuxCNC documentation (https://linuxcnc.org/docs/html/gcode/machining-center.html#sub:feed-rate).

            [S<power>]
            2.1.1
            LASER_FEATURE

            Set the laser power for the move.

              [U<pos>]
              2.1
              U_DRIVER_TYPE AXIS7_NAME 'U'

              An absolute or relative coordinate on the U axis (in current units).

                [V<pos>]
                2.1
                V_DRIVER_TYPE AXIS8_NAME 'V'

                An absolute or relative coordinate on the V axis (in current units).

                  [W<pos>]
                  2.1
                  W_DRIVER_TYPE AXIS9_NAME 'W'

                  An absolute or relative coordinate on the W axis (in current units).

                    [X<pos>]

                    An absolute or relative coordinate on the X axis (in current units).

                      [Y<pos>]

                      An absolute or relative coordinate on the Y axis (in current units).

                        [Z<pos>]

                        An absolute or relative coordinate on the Z axis (in current units).

                          Examples

                          The most basic move sets a feedrate and moves the tool to the given position.

                          G0 X12         ; Move to 12mm on the X axis
                          G0 F1500       ; Set the feedrate to 1500 mm/min
                          G1 X90.6 Y13.8 ; Move to 90.6mm on the X axis and 13.8mm on the Y axis

                          There are some caveats related with feedrates. Consider the following:

                          G1 F1500           ; Set the feedrate to 1500 mm/min
                          G92 E0
                          G1 X50 Y25.3 E22.4 ; Move while extruding

                          In the above example the feedrate is set to 1500 mm/min, then the tool is moved 50mm on the X axis and 25.3mm on the Y axis while extruding 22.4mm of filament between the two points.

                          G1 F1500
                          G92 E0
                          G1 X50 Y25.3 E22.4 F3000

                          However, in the above example, we set a feedrate of 1500 mm/min on line 1 then do the move described above, accelerating to a feedrate of 3000 mm/min (if possible). The extrusion will accelerate along with the X and Y movement, so everything stays synchronized.