Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align types with gcode spec #42

Closed
8 tasks done
giannissc opened this issue May 9, 2023 · 3 comments · Fixed by #49
Closed
8 tasks done

Align types with gcode spec #42

giannissc opened this issue May 9, 2023 · 3 comments · Fixed by #49
Labels
quality Achievement unlocked: Shoe polish

Comments

@giannissc
Copy link
Contributor

giannissc commented May 9, 2023

  • Missing module-level documentation (see comments below)
  • spindle -> speed
  • common.py -> groups.py
  • Create address.py with XYZ and IJK classes move print_xyz() and print_ijk()
  • GCodeEnum -> GCodeAddress
  • GCodeEnum.to_gcode() -> GCodeEnum.__repr__() and GCodeEnum._str_()
  • Remove precision parameter and choose precision based on selected Unit address
  • Introduce class FeedRate(GCodeEnum) and create print_feed()
@giannissc giannissc mentioned this issue May 9, 2023
4 tasks
@giannissc
Copy link
Contributor Author

giannissc commented May 9, 2023

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:

  • A <inch/mm> - 4th Axis: G0, G1, G2, G3 (out of scope)
  • B <inch/mm> - 5th Axis: G0, G1, G2, G3 (out of scope)
  • C <inch/mm> - 6th Axis: G0, G1, G2, G3 (out of scope)
  • D <0-200> - Radius Offset: G41, G42
  • E <0.0001-0.25>- Engraving Feed Rate: G187 (out of scope)
  • G <0-187> - Preparatory Function:
  • F <inch/mm> - Feed Rate: G1, G2, G3, G73, G74, G76, G81, G82, G83, G84, G85, G86, G87, G88, G89
  • H <0-200> - Tool Length Offset: G43, G44
  • I <inch/mm> - Arc Center in X Axis: G2, G3
  • J <inch/mm> - Arc Center in Y Axis: G2, G3
  • K <inch/mm> - Arc Center in Z Axis: G2, G3
  • L <0-32767> - Canned Cycle Loop Count: G81, G82, G83, G84, G85, G86, G88, G89
  • M <> - Miscllanesous Functions
  • N <0-99999> - Number of Block
  • O <0-99999> - Program Number
  • P <0.001-1000.0> - Dwell Time: G4, G73, G76, G85, G86, G88, G89
  • Q <0.001-100.0> - Canned Cycle Optional Data: G73, G76, G83, G87,
  • R <inch/mm> - Circular Interpolation/Canned Cycle Data:, G73, G74, G76, G81, G82, G83, G84, G85, G86, G87, G88, G89
  • S <1-99999> - Spindle Speed: M3, M4
  • T <1-20>- Tool Selection: M6
  • X <inch/mm> - X Axis: G0, G1, G2, G3
  • Y <inch/mm> - Y Axis: G0, G1, G2, G3
  • Z <inch/mm> - Y Axis: G0, G1, G2, G3

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:

  • Group 0 - Non-modal codes: G4, G10 G28, G30, G52, G53, G92, G92.1, G92.2, G92.3
  • Group 1 - Motion: G0, G1, G2, G3, G33, G38.n, G73, G74, G76, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89
  • Group 2 - Plane: G17, G18, G19, G17.1, G18.1, G19.1
  • Group 3 - Distance Mode: G90, G91
  • Group 4 - Arc Distance Mode: G90.1, G91.1
  • Group 5 - Feed Rate Mode: G93, G94, G95
  • Group 6 - Units: G20, G21
  • Group 7 - Cutter Diameter Compensation: G40, G41, G42, G41.1, G42.1
  • Group 8 - Tool Length Offset: G43, G43.1, G49
  • Group 10 - Canned Cycle Return Mode: G98, G99
  • Group 12 - Coordinate System: G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3
  • Group 13 - Planner Control Mode: G61, G61.1, G64
  • Group 14 - Spindle Speed Mode: G96, G97

M-code Modal Groups:

  • Group 4 - Stopping: M0, M1, M2, M30, M60
  • Group 7 - Spindle: M3, M4, M5
  • Group 8 - Coolant: M7, M8, M9

@giannissc
Copy link
Contributor Author

giannissc commented May 9, 2023

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:

  • XYZ - End Position: G0, G1, G2, G3
  • IJK - Center Position: G3, G3
  • F - Feed Rate: G1, G2, G3

G-code Command Formats:

  • G00 X<inch/mm> Y<inch/mm> Z<inch/mm>
  • G01 X<inch/mm> Y<inch/mm> Z<inch/mm> F<inch/mm>
G02 X<inch/mm> Y<inch/mm> Z<inch/mm>            I<inch/mm> J<inch/mm> K<inch/mm> F<inch/mm> (preferred)
                                     R<inch/mm>                                  F<inch/mm>
  • `G03 X<inch/mm> Y<inch/mm> Z<inch/mm> I<inch/mm> J<inch/mm> K<inch/mm> F<inch/mm> (preferred)
  • `G03 X<inch/mm> Y<inch/mm> Z<inch/mm> R<inch/mm> F<inch/mm>
  • `G04 P<0.001-1000.0>
  • Fixed Cycle
    • `G73
    • `G74
    • `G76
    • `G80
  • Canned Cycle
G98 G81 X<inch/mm> Y<inch/mm> Z<inch/mm> R<inch/mm>                 F<inch/mm>
G99 G82                                             P<0.001-1000.0>
    G83
    G84
    G85
    G86
    G87
    G88
    G89

@giannissc
Copy link
Contributor Author

giannissc commented May 9, 2023

G-code Program Structure (fluent.py)

  • Header/Prelude
    • Safety Block
    • Start Sequence
  • Main
    • Tool Change
    • Operation
  • Footer/Postlude
    • Stop Sequence
    • Home Position
    • Safety Block
    • Program End

@voneiden voneiden added the quality Achievement unlocked: Shoe polish label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality Achievement unlocked: Shoe polish
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants