This is the manual of Studio 1.1.0, an earlier version. The manual of the latest version

Documentation 1.1.0 Technical manual

G-code and M-code

The Twinwright controller (kernel) runs the G-code below. The codes follow RS274/NGC and LinuxCNC. A code the controller does not support answers error:20, and the line does nothing.

For the real-time commands (single bytes such as ?, ! and ~), see Protocol. For how the controller differs from other Grbl controllers, see The Twinwright controller.

G-code

CodeMeaningNotes
G0, G1Rapid move, linear feed
G2, G3Arc clockwise, counter-clockwise (I J K or R), helixThe tool follows the true circle. An R-form arc with no chord in its plane answers error:33.
G4 PDwell, P secondsThe dwell lasts as long as programmed.
G5, G5.1Cubic spline, quadratic splineA G5 without I and J continues in the direction the previous move ended.
G7, G8Lathe diameter mode, radius modeLathe mode only ($32=2).
G10 L2, G10 L20Set a work offset
G10 L1, G10 L10, G10 L11Set the tool table32 tools. The table is kept when the controller is off.
G17, G18, G19Select the plane
G20, G21Inch units, millimetre units
G28, G30Go to a stored position through an intermediate point
G28.1, G30.1Store the current position
G33, G33.1, G76Spindle-synchronized motion, rigid tapping, threading cycleThese need a spindle encoder. The MC-1 has none, so they answer error:20.
G38.2–G38.5ProbeThe result is the point where the probe triggered, reported as [PRB:]. Set zero from that point, not from where the axes stopped.
G40Cutter compensation off
G41, G42, G41.1, G42.1Cutter radius compensation: D from the tool table, or .1 with a diameterG17 plane only. Entry and exit moves as in LinuxCNC. A move that would gouge is refused.
G43 Hn, G43.2 HnTool length offset from the tool table, added offset
G43.1Dynamic tool length offset
G49Tool length offset off
G50, G51Scaling off, on
G52Local coordinate systemShares its offset with G92, as in LinuxCNC.
G53Machine coordinates for this line
G54–G59, G59.1–G59.3Work coordinate systems$486 can lock G59.1–G59.3.
G61Exact path
G61.1Exact stopThe axes stop at the end of every programmed move.
G64 P QPath blendingWhere it saves time, the corner between two straight moves becomes an arc within P of the corner. Q is accepted and not used.
G65 P1–P6Built-in macrosSettings, tool offsets, parameters, machine state, probe choice, spindle wait. P7 (Modbus messages) is not supported.
G65 P100 and up, G66, G66.1, G67File macros, modal macro callsP must be an integer. No other command may share the line (error:21).
G73, G81, G82, G83Drilling cycles, peck drillingEach hole gets the pecks it needs.
G84, G85, G86, G89Tapping and boring cycles
G80Cycle off
G90, G91Absolute distances, incremental distances
G91.1Incremental arc centres
G92, G92.1, G92.2, G92.3Coordinate offset: set, clear, suspend, restore
G93, G94, G95Inverse time, units per minute, units per revolutionArcs in inverse time take the programmed time.
G96, G97Constant surface speed, constant spindle speedLathe mode only.
G98, G99Cycle retract to the start height, to the R plane

These G-codes are not supported (error:20):

  • G5.2, G5.3 (NURBS);
  • G17.1–G19.1 (UVW planes);
  • G70–G72 (lathe cycles);
  • G90.1.

M-code

CodeMeaningNotes
M0, M1Program pause, optional pauseThe 0x88 real-time command switches M1 pauses on or off.
M2, M30Program end
M3, M4, M5Spindle clockwise, counter-clockwise, off
M6Tool change$341 sets what M6 does. M6 and a motion in one line answer error:40.
M7, M8, M9Coolant: mist, flood, offOn the MC-1, M8 runs the spindle's water cooling.
M25Z up to the homed heightCentroid's code, written by some CAM post-processors.
M48, M49Overrides on, off
M50–M53Feed override, spindle override, adaptive feed, feed hold: on or off
M56Parking on or off
M60Pallet change pause
M61Set the current tool without a change
M62–M65Digital output on or off, with the next move or at onceOn boards with auxiliary outputs.
M66Wait for an inputThe wait starts when the moves before it have ended.
M70–M73Save and restore the modal state
M98 P L, M99Call a subroutine, returnIn programs run from the controller's file system. An M98 sent line by line answers error:39. An M99 in the main program ends it.

These M-codes are not supported (error:20):

  • M19 (spindle orientation);
  • M67, M68 (analog outputs; the MC-1 has none);
  • M100–M199 (user M-codes).

Words, syntax and parameters

Line structure

  • Comments ( … ) and ; are allowed.
  • (MSG,…) sends the text to the sender as a message.
  • (PRINT,…) sends a message with the values of the parameters it names.
  • (DEBUG,…) does the same while #5599 is on.
  • Block delete /, line numbers N and % lines (with or without a name) are allowed.
  • Case does not matter, and spaces inside words are ignored.

Parameters and expressions

  • Numbered parameters #1–#5000 belong to the program. They read 0 until the program sets them.
  • #5001 and up, and the named system parameters, can only be read.
  • Named parameters #<name>: reading a name that was never set answers error:39. EXISTS[#<name>] tells whether it was.
  • Expressions in [ ] use the operators and functions of LinuxCNC. Angles are in degrees.
  • A value that a line sets cannot be read in the same line.

O-words

  • Programs run from the controller's file system can use subroutines, if, elseif, else, while, do and repeat.
  • Subroutines and loops sent line by line are collected, then run when they are complete.
  • A subroutine can also be a file of its own: <name>.ngc, or <name>.macro.

Polar coordinates

@ is the radius and ^ the angle, in the XY plane around the work origin.

Errors in a line

  • Two codes of the same modal group in one line answer error:21.
  • Two commands that both use the axis words in one line answer error:24.
  • The full list of error codes is in Error codes.