diff --git a/PythonicGcodeMachine/Machine/__init__.py b/PythonicGcodeMachine/Machine/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/PythonicGcodeMachine/Machine/data/make-yaml.py b/PythonicGcodeMachine/Machine/data/make-yaml.py new file mode 100755 index 0000000000000000000000000000000000000000..57d34c8c793b031defad74071bb7721b8c7bad26 --- /dev/null +++ b/PythonicGcodeMachine/Machine/data/make-yaml.py @@ -0,0 +1,485 @@ +#! /usr/bin/env python3 + +#################################################################################################### + +import pathlib +import yaml + +#################################################################################################### + +dst_path = pathlib.Path(__file__).parent + +#################################################################################################### + +def split_columns(*columns): + return zip(*[x.strip().split('\n') for x in columns]) + +def write_yaml(filename, data): + dst_file = dst_path.joinpath(filename) + yaml_data = yaml.dump(data, default_flow_style=False) + with (open(dst_file, 'w')) as fh: + fh.write(yaml_data) + print('Dumped', dst_file) + +#################################################################################################### + +# cf. Table 2. Default Parameter File + +parameters = ''' +5161 +5162 +5163 +5164 +5165 +5166 +5181 +5182 +5183 +5184 +5185 +5186 +5211 +5212 +5213 +5214 +5215 +5216 +5220 +5221 +5222 +5223 +5224 +5225 +5226 +5241 +5242 +5243 +5244 +5245 +5246 +5261 +5262 +5263 +5264 +5265 +5266 +5281 +5282 +5283 +5284 +5285 +5286 +5301 +5302 +5303 +5304 +5305 +5306 +5321 +5322 +5323 +5324 +5325 +5326 +5341 +5342 +5343 +5344 +5345 +5346 +5361 +5362 +5363 +5364 +5365 +5366 +5381 +5382 +5383 +5384 +5385 +5386 +''' + +values = ''' +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +''' + +comments = ''' +G28 home X +G28 home Y +G28 home Z +G28 home A +G28 home B +G28 home C +G30 home X +G30 home Y +G30 home Z +G30 home A +G30 home B +G30 home C +G92 offset X +G92 offset Y +G92 offset Z +G92 offset A +G92 offset B +G92 offset C +coord. system number +coord. system 1 X +coord. system 1 Y +coord. system 1 Z +coord. system 1 A +coord. system 1 B +coord. system 1 C +coord. system 2 X +coord. system 2 Y +coord. system 2 Z +coord. system 2 A +coord. system 2 B +coord. system 2 C +coord. system 3 X +coord. system 3 Y +coord. system 3 Z +coord. system 3 A +coord. system 3 B +coord. system 3 C +coord. system 4 X +coord. system 4 Y +coord. system 4 Z +coord. system 4 A +coord. system 4 B +coord. system 4 C +coord. system 5 X +coord. system 5 Y +coord. system 5 Z +coord. system 5 A +coord. system 5 B +coord. system 5 C +coord. system 6 X +coord. system 6 Y +coord. system 6 Z +coord. system 6 A +coord. system 6 B +coord. system 6 C +coord. system 7 X +coord. system 7 Y +coord. system 7 Z +coord. system 7 A +coord. system 7 B +coord. system 7 C +coord. system 8 X +coord. system 8 Y +coord. system 8 Z +coord. system 8 A +coord. system 8 B +coord. system 8 C +coord. system 9 X +coord. system 9 Y +coord. system 9 Z +coord. system 9 A +coord. system 9 B +coord. system 9 C +''' + +#################################################################################################### + +data = {} +for parameter, value, comment in split_columns(parameters, values, comments): + comment = comment.replace('coord.', 'coordinate') + data[int(parameter)] = dict(value=float(value), meaning=comment) +write_yaml('rs274-default-parameter-file.yaml', data) + +#################################################################################################### + +# Table 3. Word-starting Letters + +letters = ''' +A +B +C +D +F +G +H +I +J +K +L +M +N +P +Q +R +S +T +X +Y +Z +''' + +meanings = ''' +A-axis of machine +B-axis of machine +C-axis of machine +tool radius compensation number +feedrate +general function (see Table 5) +tool length offset index +X-axis offset for arcs +X offset in G87 canned cycle +Y-axis offset for arcs +Y offset in G87 canned cycle +Z-axis offset for arcs +Z offset in G87 canned cycle +number of repetitions in canned cycles +key used with G10 +miscellaneous function (see Table 7) +line number +dwell time in canned cycles +dwell time with G4 +key used with G10 +feed increment in G83 canned cycle +arc radius +canned cycle plane +spindle speed +tool selection +X-axis of machine +Y-axis of machine +Z-axis of machine +''' + +#################################################################################################### + +data = {} +for letter, meaning in split_columns(letters, meanings): + data[letter] = dict(meaning=meaning) +write_yaml('rs274-word-starting-letter.yaml', data) + +#################################################################################################### + +# Table 5. G Codes +# Table 7. M Codes +# 3.7 Other Input Codes + +gcodes = ''' +G0 +G1 +G2 +G3 +G4 +G10 +G17 +G18 +G19 +G20 +G21 +G28 +G30 +G38.2 +G40 +G41 +G42 +G43 +G49 +G53 +G54 +G55 +G56 +G57 +G58 +G59 +G59.1 +G59.2 +G59.3 +G61 +G61.1 +G64 +G80 +G81 +G82 +G83 +G84 +G85 +G86 +G87 +G88 +G89 +G90 +G91 +G92 +G92.1 +G92.2 +G92.3 +G93 +G94 +G98 +G99 +M0 +M1 +M2 +M3 +M4 +M5 +M6 +M7 +M8 +M9 +M30 +M48 +M49 +M60 +F +S +T +''' + +meanings = ''' +rapid positioning +linear interpolation +circular/helical interpolation (clockwise) +circular/helical interpolation (counterclockwise) +dwell +coordinate system origin setting +XY-plane selection +XZ-plane selection +YZ-plane selection +inch system selection +millimeter system selection +return to home +return to secondary home +straight probe +cancel cutter radius compensation +start cutter radius compensation left +start cutter radius compensation right +tool length offset (plus) +cancel tool length offset +motion in machine coordinate system +use preset work coordinate system 1 +use preset work coordinate system 2 +use preset work coordinate system 3 +use preset work coordinate system 4 +use preset work coordinate system 5 +use preset work coordinate system 6 +use preset work coordinate system 7 +use preset work coordinate system 8 +use preset work coordinate system 9 +set path control mode: exact path +set path control mode: exact stop +set path control mode: continuous +cancel motion mode (including any canned cycle) +canned cycle: drilling +canned cycle: drilling with dwell +canned cycle: peck drilling +canned cycle: right hand tapping +canned cycle: boring, no dwell, feed out +canned cycle: boring, spindle stop, rapid out +canned cycle: back boring +canned cycle: boring, spindle stop, manual out +canned cycle: boring, dwell, feed out +absolute distance mode +incremental distance mode +offset coordinate systems and set parameters +cancel offset coordinate systems and set parameters to zero +cancel offset coordinate systems but do not reset parameters +apply parameters to offset coordinate systems +inverse time feed rate mode +units per minute feed rate mode +initial level return in canned cycles +R-point level return in canned cycles +program stop +optional program stop +program end +turn spindle clockwise +turn spindle counterclockwise +stop spindle turning +tool change +mist coolant on +flood coolant on +mist and flood coolant off +program end, pallet shuttle, and reset +enable speed and feed overrides +disable speed and feed overrides +pallet shuttle and program stop +set feed rate +set spindle speed +select tool +''' + +#################################################################################################### + +data = {} +for gcode, meaning in split_columns(gcodes, meanings): + data[gcode] = dict(meaning=meaning) +write_yaml('rs274-gcodes.yaml', data) diff --git a/PythonicGcodeMachine/Machine/data/rs274-default-parameter-file.yaml b/PythonicGcodeMachine/Machine/data/rs274-default-parameter-file.yaml new file mode 100644 index 0000000000000000000000000000000000000000..048a92096201090804cbd02d734bb0cd21444f3a --- /dev/null +++ b/PythonicGcodeMachine/Machine/data/rs274-default-parameter-file.yaml @@ -0,0 +1,219 @@ +5161: + meaning: G28 home X + value: 0.0 +5162: + meaning: G28 home Y + value: 0.0 +5163: + meaning: G28 home Z + value: 0.0 +5164: + meaning: G28 home A + value: 0.0 +5165: + meaning: G28 home B + value: 0.0 +5166: + meaning: G28 home C + value: 0.0 +5181: + meaning: G30 home X + value: 0.0 +5182: + meaning: G30 home Y + value: 0.0 +5183: + meaning: G30 home Z + value: 0.0 +5184: + meaning: G30 home A + value: 0.0 +5185: + meaning: G30 home B + value: 0.0 +5186: + meaning: G30 home C + value: 0.0 +5211: + meaning: G92 offset X + value: 0.0 +5212: + meaning: G92 offset Y + value: 0.0 +5213: + meaning: G92 offset Z + value: 0.0 +5214: + meaning: G92 offset A + value: 0.0 +5215: + meaning: G92 offset B + value: 0.0 +5216: + meaning: G92 offset C + value: 0.0 +5220: + meaning: coordinate system number + value: 1.0 +5221: + meaning: coordinate system 1 X + value: 0.0 +5222: + meaning: coordinate system 1 Y + value: 0.0 +5223: + meaning: coordinate system 1 Z + value: 0.0 +5224: + meaning: coordinate system 1 A + value: 0.0 +5225: + meaning: coordinate system 1 B + value: 0.0 +5226: + meaning: coordinate system 1 C + value: 0.0 +5241: + meaning: coordinate system 2 X + value: 0.0 +5242: + meaning: coordinate system 2 Y + value: 0.0 +5243: + meaning: coordinate system 2 Z + value: 0.0 +5244: + meaning: coordinate system 2 A + value: 0.0 +5245: + meaning: coordinate system 2 B + value: 0.0 +5246: + meaning: coordinate system 2 C + value: 0.0 +5261: + meaning: coordinate system 3 X + value: 0.0 +5262: + meaning: coordinate system 3 Y + value: 0.0 +5263: + meaning: coordinate system 3 Z + value: 0.0 +5264: + meaning: coordinate system 3 A + value: 0.0 +5265: + meaning: coordinate system 3 B + value: 0.0 +5266: + meaning: coordinate system 3 C + value: 0.0 +5281: + meaning: coordinate system 4 X + value: 0.0 +5282: + meaning: coordinate system 4 Y + value: 0.0 +5283: + meaning: coordinate system 4 Z + value: 0.0 +5284: + meaning: coordinate system 4 A + value: 0.0 +5285: + meaning: coordinate system 4 B + value: 0.0 +5286: + meaning: coordinate system 4 C + value: 0.0 +5301: + meaning: coordinate system 5 X + value: 0.0 +5302: + meaning: coordinate system 5 Y + value: 0.0 +5303: + meaning: coordinate system 5 Z + value: 0.0 +5304: + meaning: coordinate system 5 A + value: 0.0 +5305: + meaning: coordinate system 5 B + value: 0.0 +5306: + meaning: coordinate system 5 C + value: 0.0 +5321: + meaning: coordinate system 6 X + value: 0.0 +5322: + meaning: coordinate system 6 Y + value: 0.0 +5323: + meaning: coordinate system 6 Z + value: 0.0 +5324: + meaning: coordinate system 6 A + value: 0.0 +5325: + meaning: coordinate system 6 B + value: 0.0 +5326: + meaning: coordinate system 6 C + value: 0.0 +5341: + meaning: coordinate system 7 X + value: 0.0 +5342: + meaning: coordinate system 7 Y + value: 0.0 +5343: + meaning: coordinate system 7 Z + value: 0.0 +5344: + meaning: coordinate system 7 A + value: 0.0 +5345: + meaning: coordinate system 7 B + value: 0.0 +5346: + meaning: coordinate system 7 C + value: 0.0 +5361: + meaning: coordinate system 8 X + value: 0.0 +5362: + meaning: coordinate system 8 Y + value: 0.0 +5363: + meaning: coordinate system 8 Z + value: 0.0 +5364: + meaning: coordinate system 8 A + value: 0.0 +5365: + meaning: coordinate system 8 B + value: 0.0 +5366: + meaning: coordinate system 8 C + value: 0.0 +5381: + meaning: coordinate system 9 X + value: 0.0 +5382: + meaning: coordinate system 9 Y + value: 0.0 +5383: + meaning: coordinate system 9 Z + value: 0.0 +5384: + meaning: coordinate system 9 A + value: 0.0 +5385: + meaning: coordinate system 9 B + value: 0.0 +5386: + meaning: coordinate system 9 C + value: 0.0 diff --git a/PythonicGcodeMachine/Machine/data/rs274-execution-order.yaml b/PythonicGcodeMachine/Machine/data/rs274-execution-order.yaml new file mode 100644 index 0000000000000000000000000000000000000000..74ec8abd6231cd6d01086ddaee6e5b1e8c5e543b --- /dev/null +++ b/PythonicGcodeMachine/Machine/data/rs274-execution-order.yaml @@ -0,0 +1,22 @@ +# Table 8. Order of Execution +1: COMMENT # (includes message] +2: [G93, G94] # set feed rate mode (inverse time or per minute] +3: F # set feed rate +4: S # set spindle speed +5: T # select tool +6: M6 # change tool +7: [M3, M4, M5] # spindle on or off +8: [M7, M8, M9] # coolant on or off +9: [M48, M49] # enable or disable overrides +10: G4 # dwell +11: [G17, G18, G19] # set active plane +12: [G20, G21] # set length units +13: [G40, G41, G42] # cutter radius compensation on or off +14: [G43, G49] # cutter length compensation on or off +15: [G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3] # coordinate system selection +16: [G61, G61.1, G64] # set path control mode +17: [G90, G91] # set distance mode +18: [G98, G99] # set retract mode +19: [G28, G30, G10, G92, G92.1, G92.2, G94] # home or change coordinate system data or set axis offsets +20: ['G0-G3', 'G80-G89', G53] # perform motion, as modified (possibly) by G53 +21: [M0, M1, M2, M30, M60] # stop diff --git a/PythonicGcodeMachine/Machine/data/rs274-gcodes.yaml b/PythonicGcodeMachine/Machine/data/rs274-gcodes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..805fb0fd71890ae011dffe53e0b6aff3897c3bba --- /dev/null +++ b/PythonicGcodeMachine/Machine/data/rs274-gcodes.yaml @@ -0,0 +1,138 @@ +F: + meaning: set feed rate +G0: + meaning: rapid positioning +G1: + meaning: linear interpolation +G10: + meaning: coordinate system origin setting +G17: + meaning: XY-plane selection +G18: + meaning: XZ-plane selection +G19: + meaning: YZ-plane selection +G2: + meaning: circular/helical interpolation (clockwise) +G20: + meaning: inch system selection +G21: + meaning: millimeter system selection +G28: + meaning: return to home +G3: + meaning: circular/helical interpolation (counterclockwise) +G30: + meaning: return to secondary home +G38.2: + meaning: straight probe +G4: + meaning: dwell +G40: + meaning: cancel cutter radius compensation +G41: + meaning: start cutter radius compensation left +G42: + meaning: start cutter radius compensation right +G43: + meaning: tool length offset (plus) +G49: + meaning: cancel tool length offset +G53: + meaning: motion in machine coordinate system +G54: + meaning: use preset work coordinate system 1 +G55: + meaning: use preset work coordinate system 2 +G56: + meaning: use preset work coordinate system 3 +G57: + meaning: use preset work coordinate system 4 +G58: + meaning: use preset work coordinate system 5 +G59: + meaning: use preset work coordinate system 6 +G59.1: + meaning: use preset work coordinate system 7 +G59.2: + meaning: use preset work coordinate system 8 +G59.3: + meaning: use preset work coordinate system 9 +G61: + meaning: 'set path control mode: exact path' +G61.1: + meaning: 'set path control mode: exact stop' +G64: + meaning: 'set path control mode: continuous' +G80: + meaning: cancel motion mode (including any canned cycle) +G81: + meaning: 'canned cycle: drilling' +G82: + meaning: 'canned cycle: drilling with dwell' +G83: + meaning: 'canned cycle: peck drilling' +G84: + meaning: 'canned cycle: right hand tapping' +G85: + meaning: 'canned cycle: boring, no dwell, feed out' +G86: + meaning: 'canned cycle: boring, spindle stop, rapid out' +G87: + meaning: 'canned cycle: back boring' +G88: + meaning: 'canned cycle: boring, spindle stop, manual out' +G89: + meaning: 'canned cycle: boring, dwell, feed out' +G90: + meaning: absolute distance mode +G91: + meaning: incremental distance mode +G92: + meaning: offset coordinate systems and set parameters +G92.1: + meaning: cancel offset coordinate systems and set parameters to zero +G92.2: + meaning: cancel offset coordinate systems but do not reset parameters +G92.3: + meaning: apply parameters to offset coordinate systems +G93: + meaning: inverse time feed rate mode +G94: + meaning: units per minute feed rate mode +G98: + meaning: initial level return in canned cycles +G99: + meaning: R-point level return in canned cycles +M0: + meaning: program stop +M1: + meaning: optional program stop +M2: + meaning: program end +M3: + meaning: turn spindle clockwise +M30: + meaning: program end, pallet shuttle, and reset +M4: + meaning: turn spindle counterclockwise +M48: + meaning: enable speed and feed overrides +M49: + meaning: disable speed and feed overrides +M5: + meaning: stop spindle turning +M6: + meaning: tool change +M60: + meaning: pallet shuttle and program stop +M7: + meaning: mist coolant on +M8: + meaning: flood coolant on +M9: + meaning: mist and flood coolant off +S: + meaning: set spindle speed +T: + meaning: select tool diff --git a/PythonicGcodeMachine/Machine/data/rs274-modal-groups.yaml b/PythonicGcodeMachine/Machine/data/rs274-modal-groups.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8a9f3e6d59c9aa9b2b9d1b053efc0235e5561400 --- /dev/null +++ b/PythonicGcodeMachine/Machine/data/rs274-modal-groups.yaml @@ -0,0 +1,20 @@ +# Table 4. Modal Groups +# The modal groups for G codes are +1: [G0, G1, G2, G3, G38.2, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89] +2 : [G17, G18, G19] # plane selection +3 : [G90, G91] # distance mode +5 : [G93, G94] # feed rate mode +6 : [G20, G21] # units +7 : [G40, G41, G42] # cutter radius compensation +8 : [G43, G49] # tool length offset +10 : [G98, G99] # return mode in canned cycles +12 : [G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3] # coordinate system selection +13 : [G61, G61.1, G64] # path control mode +# The modal groups for M codes are +4 : [M0, M1, M2, M30, M60] # stopping +6 : [M6] # tool change +7 : [M3, M4, M5] # spindle turning +8 : [M7, M8, M9] # coolant (special case: M7 and M8 may be active at the same time) +9 : [M48, M49] # enable/disable feed and speed override switches +# In addition to the above modal groups, there is a group for non-modal G codes +0 : [G4, G10, G28, G30, G53, G92, G92.1, G92.2, G92.3] diff --git a/PythonicGcodeMachine/Machine/data/rs274-word-starting-letter.yaml b/PythonicGcodeMachine/Machine/data/rs274-word-starting-letter.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9a0f94a3d2aec49223527a7f6383e936a4c3af84 --- /dev/null +++ b/PythonicGcodeMachine/Machine/data/rs274-word-starting-letter.yaml @@ -0,0 +1,42 @@ +A: + meaning: A-axis of machine +B: + meaning: B-axis of machine +C: + meaning: C-axis of machine +D: + meaning: tool radius compensation number +F: + meaning: feedrate +G: + meaning: general function (see Table 5) +H: + meaning: tool length offset index +I: + meaning: X-axis offset for arcs +J: + meaning: X offset in G87 canned cycle +K: + meaning: Y-axis offset for arcs +L: + meaning: Y offset in G87 canned cycle +M: + meaning: Z-axis offset for arcs +N: + meaning: Z offset in G87 canned cycle +P: + meaning: number of repetitions in canned cycles +Q: + meaning: key used with G10 +R: + meaning: miscellaneous function (see Table 7) +S: + meaning: line number +T: + meaning: dwell time in canned cycles +X: + meaning: dwell time with G4 +Y: + meaning: key used with G10 +Z: + meaning: feed increment in G83 canned cycle