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
| Code | Meaning | Notes |
|---|---|---|
G0, G1 | Rapid move, linear feed | |
G2, G3 | Arc clockwise, counter-clockwise (I J K or R), helix | The tool follows the true circle. An R-form arc with no chord in its plane answers error:33. |
G4 P | Dwell, P seconds | The dwell lasts as long as programmed. |
G5, G5.1 | Cubic spline, quadratic spline | A G5 without I and J continues in the direction the previous move ended. |
G7, G8 | Lathe diameter mode, radius mode | Lathe mode only ($32=2). |
G10 L2, G10 L20 | Set a work offset | |
G10 L1, G10 L10, G10 L11 | Set the tool table | 32 tools. The table is kept when the controller is off. |
G17, G18, G19 | Select the plane | |
G20, G21 | Inch units, millimetre units | |
G28, G30 | Go to a stored position through an intermediate point | |
G28.1, G30.1 | Store the current position | |
G33, G33.1, G76 | Spindle-synchronized motion, rigid tapping, threading cycle | These need a spindle encoder. The MC-1 has none, so they answer error:20. |
G38.2–G38.5 | Probe | The result is the point where the probe triggered, reported as [PRB:]. Set zero from that point, not from where the axes stopped. |
G40 | Cutter compensation off | |
G41, G42, G41.1, G42.1 | Cutter radius compensation: D from the tool table, or .1 with a diameter | G17 plane only. Entry and exit moves as in LinuxCNC. A move that would gouge is refused. |
G43 Hn, G43.2 Hn | Tool length offset from the tool table, added offset | |
G43.1 | Dynamic tool length offset | |
G49 | Tool length offset off | |
G50, G51 | Scaling off, on | |
G52 | Local coordinate system | Shares its offset with G92, as in LinuxCNC. |
G53 | Machine coordinates for this line | |
G54–G59, G59.1–G59.3 | Work coordinate systems | $486 can lock G59.1–G59.3. |
G61 | Exact path | |
G61.1 | Exact stop | The axes stop at the end of every programmed move. |
G64 P Q | Path blending | Where 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–P6 | Built-in macros | Settings, tool offsets, parameters, machine state, probe choice, spindle wait. P7 (Modbus messages) is not supported. |
G65 P100 and up, G66, G66.1, G67 | File macros, modal macro calls | P must be an integer. No other command may share the line (error:21). |
G73, G81, G82, G83 | Drilling cycles, peck drilling | Each hole gets the pecks it needs. |
G84, G85, G86, G89 | Tapping and boring cycles | |
G80 | Cycle off | |
G90, G91 | Absolute distances, incremental distances | |
G91.1 | Incremental arc centres | |
G92, G92.1, G92.2, G92.3 | Coordinate offset: set, clear, suspend, restore | |
G93, G94, G95 | Inverse time, units per minute, units per revolution | Arcs in inverse time take the programmed time. |
G96, G97 | Constant surface speed, constant spindle speed | Lathe mode only. |
G98, G99 | Cycle 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
| Code | Meaning | Notes |
|---|---|---|
M0, M1 | Program pause, optional pause | The 0x88 real-time command switches M1 pauses on or off. |
M2, M30 | Program end | |
M3, M4, M5 | Spindle clockwise, counter-clockwise, off | |
M6 | Tool change | $341 sets what M6 does. M6 and a motion in one line answer error:40. |
M7, M8, M9 | Coolant: mist, flood, off | On the MC-1, M8 runs the spindle's water cooling. |
M25 | Z up to the homed height | Centroid's code, written by some CAM post-processors. |
M48, M49 | Overrides on, off | |
M50–M53 | Feed override, spindle override, adaptive feed, feed hold: on or off | |
M56 | Parking on or off | |
M60 | Pallet change pause | |
M61 | Set the current tool without a change | |
M62–M65 | Digital output on or off, with the next move or at once | On boards with auxiliary outputs. |
M66 | Wait for an input | The wait starts when the moves before it have ended. |
M70–M73 | Save and restore the modal state | |
M98 P L, M99 | Call a subroutine, return | In 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#5599is on.- Block delete
/, line numbersNand%lines (with or without a name) are allowed. - Case does not matter, and spaces inside words are ignored.
Parameters and expressions
- Numbered parameters
#1–#5000belong to the program. They read 0 until the program sets them. #5001and up, and the named system parameters, can only be read.- Named parameters
#<name>: reading a name that was never set answerserror: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,doandrepeat. - 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.