voneiden / cq-cam

CQ-CAM aims to become a free, parametric CAM solution for 3-axis CNC mills closely integrating with CadQuery.
https://cq-cam.readthedocs.io/en/latest/
Apache License 2.0
25 stars 5 forks source link

Align types with gcode spec #42

Closed giannissc closed 1 year ago

giannissc commented 1 year ago
giannissc commented 1 year ago

G-code Letter and Word Address Syntax (common.py)

G-code (also RS-274) is the most widely-used computer numerical control (CNC) programming language. It is used mainly in computer-aided manufacturing to control automated machine tools, as well as from a 3D-printing slicer app. Here we concentrate on a subset of G-code relevant for 3-axis CNC machining. Explanations of commands that are out of scope will be included for completeness and it will be indicated that they are out of scope.

A G-code command (word address) is formed by single letter (letter address) followed by 2 digits. Multiple G-code commands on the same line are called command blocks

 G 01 XYZ
⌊ ⌋  letter address
⌊   ⌋  word  address
⌊       ⌋  command block

G-code word addresses are used to configure the machine state and control the motors. The two primary letter addresses are M-codes and G-codes. M-codes are known as machine codes (or more accurately miscellaneous codes) and G-codes are called preparatory codes. M-codes allow for state changes of the machine components and the running program. G-codes control the motion of the motors and the internal configuration of the machine. In addition to the G and M address there are other letter addresses that are used in conjunction with them

Below is a comprehensive list of the available letter addresses:

inch: 4 fractional positions mm: 3 fractional positions

G-code commands can be categorized as modal or non-modal. Modal commands remain in effect until they are replaced or cancelled by another command. Non-modal commands execute in their block scope. M-code and G-code are further organized into modal groups

G-code Modal Groups:

M-code Modal Groups:

giannissc commented 1 year ago

G-code Block Syntax (command.py)

Letter Address Order: N G X Y Z R P Q I J K F M S T

Word Address Groups:

G-code Command Formats:

giannissc commented 1 year ago

G-code Program Structure (fluent.py)