Compare commits

...

7 Commits

Author SHA1 Message Date
Thaddeus Hughes
55d0704e0f recomment 2026-04-11 11:01:32 -05:00
Thaddeus Hughes
96e6fcad01 dsfg 2026-04-11 10:58:57 -05:00
Thaddeus Hughes
16c03621bd lf ? 2026-04-11 10:55:46 -05:00
Thaddeus Hughes
f0404bb24d Create CLAUDE.md 2026-04-11 10:54:30 -05:00
Thaddeus-Maximus
c84cf74c18 x 2026-04-11 05:47:18 -05:00
Thaddeus Hughes
0847110969 Merge branch 'master' of ppi.ddns.net:thad/linuxcnc 2026-04-05 20:52:03 -05:00
Thaddeus Hughes
ad1f8719d6 big overhaul 2026-04-05 20:51:43 -05:00
126 changed files with 2531 additions and 1708 deletions

View File

@@ -5,7 +5,16 @@
"Bash(where pdftotext:*)",
"Bash(where python:*)",
"Bash(where python3:*)",
"Bash(where py:*)"
"Bash(where py:*)",
"Bash(xargs grep:*)",
"WebFetch(domain:linuxcnc.org)",
"WebSearch",
"WebFetch(domain:www.linuxcnc.org)",
"WebFetch(domain:github.com)",
"WebFetch(domain:raw.githubusercontent.com)",
"WebFetch(domain:forum.linuxcnc.org)",
"WebFetch(domain:www.forum.linuxcnc.org)",
"Bash(file:*)"
]
}
}

47
CLAUDE.md Normal file
View File

@@ -0,0 +1,47 @@
# CLAUDE.md
## Project
LinuxCNC configuration and custom G-code macro library for a Lagun milling machine.
## Structure
- `configs/lagun_gmoccapy/` — machine config (INI, HAL, tool table, pendant)
- `nc_files/subs/` — macro subroutines (auto-loaded via SUBROUTINE_PATH)
- `nc_files/programs/` — standalone part programs
- `nc_files/HEMA/`, `HEMS/`, `HEQJ/` — project-specific part programs
- `nc_files/*.ngc` — older part programs (root level)
- `datasheets/` — Mesa board PDFs
## Key docs
- `nc_files/MACROS.md` — macro API reference
- `nc_files/OFFSETS.md` — work offsets, tool offsets, cutter comp quick reference
- `nc_files/TOOLS.md` — deep dive on tool changes and GMOCCAPY interface
- `configs/lagun_gmoccapy/README.md` — machine config, wiring, HAL, pendant mapping
## Macro conventions
- All macros in `nc_files/subs/` use lowercase filenames (LinuxCNC matches `o<name>` to `name.ngc`)
- Mode bitmask is always the FIRST positional arg (#1) for macros that accept it
- Z heights come from globals `#<_z_top>` and `#<_z_bot>`, not positional args
- Tool diameter comes from `#5410` (built-in LinuxCNC param, requires T M6 G43 first)
- Optional globals: `#<_z_clearance>`, `#<_rampang>`, `#<_stepover>`
- M101/M102 enable/disable Z-axis CNC control (for manual quill operation)
## When editing macros
- Do not change functional behavior without asking — these run on a real mill
- The `o<number>` labels (o1, o101, etc.) must be unique within each file
- LinuxCNC G-code uses `[expressions]` for math, `#<name>` for named params, `#N` for positional args
- `G90.1` = absolute arc centers (I/J), `G91.1` = incremental arc centers — check which mode each macro uses
- Test calls should never appear after `endsub` (they execute on every load)
## When editing caller programs
- Programs set `#<_z_top>` and `#<_z_bot>` before macro calls
- Mode arg is first: `o<pocket_circ> call [0] [x][y] [d] [fincut]`
- Commented-out calls (`;o<...>`) should keep their format consistent with active calls
## Machine details
- 3-axis mill: X (+-24"), Y (+-12"), Z (-4" to +1")
- Mesa 5i24 FPGA + 7i52 servo interface + 7i37-TA isolated I/O
- Dual PID on X and Y (motor encoder + linear scale, outputs summed)
- Z has special override mechanism (M101/M102 via logic AND gate)
- GMOCCAPY GUI, XHC WHB04B-6 wireless pendant
- Units: inches
- Manual tool change (no ATC)

View File

@@ -59,6 +59,8 @@ PARAMETER_FILE = linuxcnc.var
# Startup: G20=inch, G40=cancel cutter comp, G90=absolute, G94=feed/min,
# G97=RPM mode, G64 P0.001=path blending tolerance 0.001"
RS274NGC_STARTUP_CODE = G20 G40 G90 G94 G97 G64 P0.001
# Subroutine search path (colon-separated list, searched before PROGRAM_PREFIX)
SUBROUTINE_PATH = /home/linuxcnc/linuxcnc/nc_files/subs
# --- Motion controller ---
[EMCMOT]

View File

@@ -27,9 +27,9 @@
5218 0.000000
5219 0.000000
5220 1.000000
5221 7.046981
5222 0.266575
5223 -2.928337
5221 -6.512164
5222 3.676288
5223 -3.122360
5224 0.000000
5225 0.000000
5226 0.000000

View File

@@ -27,9 +27,9 @@
5218 0.000000
5219 0.000000
5220 1.000000
5221 7.046981
5222 0.266575
5223 -2.928337
5221 -6.512164
5222 3.676288
5223 -3.122360
5224 0.000000
5225 0.000000
5226 0.000000

View File

@@ -75,6 +75,6 @@ show_preview_on_offset = False
use_keyboard_shortcuts = True
offset_axis_y = 0.0
offset_axis_x = 0.0
offset_axis_z = 0.0
tool_in_spindle = 3
offset_axis_z = -0.003
tool_in_spindle = 5

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = 0.5
#<_rampang> = 5
#<_td> = [3/16]
;#<_overlap> = 0
; +1: Conventional milling
@@ -22,15 +21,17 @@ F20
; pockets
;o101 repeat [2]
; o<frame_rect> call [0.813][-0.575] [1.438][-1.200] [#<zt>][#<zb>] [0] [.1]
; o<frame_rect> call [1.613][-0.575] [2.238][-1.200] [#<zt>][#<zb>] [0] [.1]
; o<frame_rect> call [2.413][-0.575] [3.038][-1.200] [#<zt>][#<zb>] [0] [.1]
; o<frame_rect> call [2.413][-1.675] [3.038][-2.300] [#<zt>][#<zb>] [0] [.1]
; o<frame_rect> call [1.613][-1.675] [2.238][-2.300] [#<zt>][#<zb>] [0] [.1]
; o<pocket_circ> call [0.975][-1.838] [.240] [#<zt>][#<zb>] [0] [0+4]
; o<pocket_circ> call [0.975][-2.138] [.240] [#<zt>][#<zb>] [0] [0+4]
; o<pocket_circ> call [1.275][-2.138] [.240] [#<zt>][#<zb>] [0] [0+4]
; o<pocket_circ> call [1.275][-1.838] [.240] [#<zt>][#<zb>] [0] [0+4]
; #<_z_top> = #<zt>
; #<_z_bot> = #<zb>
; o<frame_rect> call [0] [0.813][-0.575] [1.438][-1.200] [.1]
; o<frame_rect> call [0] [1.613][-0.575] [2.238][-1.200] [.1]
; o<frame_rect> call [0] [2.413][-0.575] [3.038][-1.200] [.1]
; o<frame_rect> call [0] [2.413][-1.675] [3.038][-2.300] [.1]
; o<frame_rect> call [0] [1.613][-1.675] [2.238][-2.300] [.1]
; o<pocket_circ> call [0+4] [0.975][-1.838] [.240] [0]
; o<pocket_circ> call [0+4] [0.975][-2.138] [.240] [0]
; o<pocket_circ> call [0+4] [1.275][-2.138] [.240] [0]
; o<pocket_circ> call [0+4] [1.275][-1.838] [.240] [0]
; #<zt> = [#<zt>-0.15]
; #<zb> = [#<zb>-0.15]
;o101 endrepeat
@@ -39,15 +40,17 @@ F20
#<zt> = 0.01
#<zb> = -0.16
;o<pocket_circ> call [0.250][-0.250] [.23] [#<zt>][#<zb>]
;o<pocket_circ> call [5.462][-0.250] [.23] [#<zt>][#<zb>]
;o<pocket_circ> call [5.462][-2.625] [.23] [#<zt>][#<zb>]
;o<pocket_circ> call [0.250][-2.625] [.23] [#<zt>][#<zb>]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [0.250][-0.250] [.23]
;o<pocket_circ> call [0] [5.462][-0.250] [.23]
;o<pocket_circ> call [0] [5.462][-2.625] [.23]
;o<pocket_circ> call [0] [0.250][-2.625] [.23]
;o<drill> call [0.625][-0.538] [#<zt>][#<zb>]
;o<drill> call [0.625][-2.338] [#<zt>][#<zb>]
;o<drill> call [3.225][-2.338] [#<zt>][#<zb>]
;o<drill> call [3.225][-0.538] [#<zt>][#<zb>]
;o<drill> call [0.625][-0.538]
;o<drill> call [0.625][-2.338]
;o<drill> call [3.225][-2.338]
;o<drill> call [3.225][-0.538]
o<pocket_rect_lin> call [0.738][-0.5] [3.113][-2.375] [0.01][-0.1]

View File

@@ -3,8 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 6
#<_rampang> = 20
#<_td> = 6.35
; mode refernce
; +1: Conventional milling
; +2: Both-ways milling
@@ -13,9 +11,11 @@ G54 ; absolute coordinates
F150 ; inch or mm/min (300 mm/min = about 1 ft/min)
o<pocket_circ> call [-20][-10] [8.2] [1][-9]
o<pocket_circ> call [-20][-40] [8.2] [1][-9]
o<pocket_circ> call [+30][-25] [8.2] [1][-9]
#<_z_top> = 1
#<_z_bot> = -9
o<pocket_circ> call [0] [-20][-10] [8.2]
o<pocket_circ> call [0] [-20][-40] [8.2]
o<pocket_circ> call [0] [+30][-25] [8.2]
o<end_round> call [0] [+30][-25] [28] [1][-9] [0.5]

View File

@@ -32,18 +32,30 @@ F20 ; feedrate in mm/min or in/min
#20 = 31.5
o<m6cb> sub
o<pocket_circ> call [#1/25.4][#2/25.4] [0.415] [+.02][-.26] [0][+4]
o<pocket_circ> call [#1/25.4][#2/25.4] [0.250] [-.20][-.53] [0][+4]
#<_z_top> = +.02
#<_z_bot> = -.26
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [0.415] [0]
#<_z_top> = -.20
#<_z_bot> = -.53
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [0.250] [0]
o<m6cb> endsub
o<m5cb> sub
o<pocket_circ> call [#1/25.4][#2/25.4] [0.35] [+.02][-.20] [0][+4]
o<pocket_circ> call [#1/25.4][#2/25.4] [0.20] [-.19][-.53] [0][+4]
#<_z_top> = +.02
#<_z_bot> = -.20
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [0.35] [0]
#<_z_top> = -.19
#<_z_bot> = -.53
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [0.20] [0]
o<m5cb> endsub
o<m5cb_b> sub
o<pocket_circ> call [#1/25.4][#2/25.4] [0.40] [+.02][-.30] [0][+4]
o<pocket_circ> call [#1/25.4][#2/25.4] [0.20] [-.29][-.53] [0][+4]
#<_z_top> = +.02
#<_z_bot> = -.30
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [0.40] [0]
#<_z_top> = -.29
#<_z_bot> = -.53
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [0.20] [0]
o<m5cb_b> endsub
o<carray> sub
@@ -84,7 +96,7 @@ o10 if [#<side> EQ 1]
o11 endwhile
#<tr> = [#<_td>/2]
#<tr> = [#5410/2]
#<xe> = [-605/25.4]
#<y> = [-2.9]
@@ -112,9 +124,13 @@ o10 elseif [#<side> EQ 2]
o<dhole> sub
F20
o<pocket_circ> call [#1/25.4][#2/25.4] [17.0/25.4] [+.02][-.086] [0.02] [+4]
#<_z_top> = +.02
#<_z_bot> = -.086
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [17.0/25.4] [0.02]
F10
o<pocket_circ> call [#1/25.4][#2/25.4] [10.0/25.4] [-.08][-.530] [0.005] [+4]
#<_z_top> = -.08
#<_z_bot> = -.530
o<pocket_circ> call [+4] [#1/25.4][#2/25.4] [10.0/25.4] [0.005]
o<dhole> endsub
o<dhole> call [#<x>][#<y>]

View File

@@ -1,22 +0,0 @@
#<_z_clearance> = 0.4
#<_rampang> = 5
; mode reference
; +1: Conventional milling
; +2: Both-ways milling
; +4: Plunge entry
; +8: Outside
G21 ; mm
G10 L1 P1 Z0.0 R5.0 ; set tool
T1 ; set tool to T1
M06 ; manual toolchange
G54 ; absolute coordinates
F3000 ; mm/min (300 mm/min = about 1 ft/min)
o<drill> call [20][-10] [1][-8] [3]
o<drill> call [20][-40] [1][-8] [3]
M2 ; end program

View File

@@ -15,22 +15,42 @@ M06 ; manual toolchange
G54 ; absolute coordinates
;F10 ; mm/min (300 mm/min = about 1 ft/min)
;o<pocket_circ> call [0][0] [2.05] [.1][-.5] [.01] [0+4]
;o<frame_circ> call [0][0] [2.055] [.1][-.5] [0] [0]
;#<_z_top> = .1
;#<_z_bot> = -.5
;o<pocket_circ> call [0+4] [0][0] [2.05] [.01]
;#<_z_top> = .1
;#<_z_bot> = -.5
;o<frame_circ> call [0] [0][0] [2.055] [0]
F3
;o<pocket_circ> call [+0.394][-.394] [5.2/25.4] [0.1][-0.25] [0][+4]
;o<pocket_circ> call [+1.181][-.394] [5.2/25.4] [0.1][-0.25] [0][+4]
;o<pocket_circ> call [-0.394][-.394] [5.2/25.4] [0.1][-0.25] [0][+4]
;o<pocket_circ> call [-1.181][-.394] [5.2/25.4] [0.1][-0.25] [0][+4]
;#<_z_top> = 0.1
;#<_z_bot> = -0.25
;o<pocket_circ> call [+4] [+0.394][-.394] [5.2/25.4] [0]
;#<_z_top> = 0.1
;#<_z_bot> = -0.25
;o<pocket_circ> call [+4] [+1.181][-.394] [5.2/25.4] [0]
;#<_z_top> = 0.1
;#<_z_bot> = -0.25
;o<pocket_circ> call [+4] [-0.394][-.394] [5.2/25.4] [0]
;#<_z_top> = 0.1
;#<_z_bot> = -0.25
;o<pocket_circ> call [+4] [-1.181][-.394] [5.2/25.4] [0]
F8
;o<pocket_circ> call [-.787][-1.181] [.551] [0.1][-0.25]
;o<pocket_circ> call [+.787][-1.181] [.551] [0.1][-0.25]
;#<_z_top> = 0.1
;#<_z_bot> = -0.25
;o<pocket_circ> call [0] [-.787][-1.181] [.551]
;#<_z_top> = 0.1
;#<_z_bot> = -0.25
;o<pocket_circ> call [0] [+.787][-1.181] [.551]
o<frame_circ> call [-.787][-1.181] [.553] [0.1][-0.25]
o<frame_circ> call [+.787][-1.181] [.553] [0.1][-0.25]
#<_z_top> = 0.1
#<_z_bot> = -0.25
o<frame_circ> call [0] [-.787][-1.181] [.553]
#<_z_top> = 0.1
#<_z_bot> = -0.25
o<frame_circ> call [0] [+.787][-1.181] [.553]
M30

View File

@@ -19,8 +19,12 @@ G54 ; absolute coordinates
F20 ; inch or mm/min (300 mm/min = about 1 ft/min)
o10 sub
o<pocket_circ> call [#1][#2] [.39] [0.05][-0.197]
o<drill> call [#1][#2] [-.15][-0.5]
#<_z_top> = 0.05
#<_z_bot> = -0.197
o<pocket_circ> call [0] [#1][#2] [.39]
#<_z_top> = -.15
#<_z_bot> = -0.5
o<drill> call [#1][#2]
o10 endsub
o10 call [-22/25.4][-0.394]

View File

@@ -1,40 +0,0 @@
#<_z_clearance> = 0.5
#<_rampang> = 10
;#<_stepover> = 0.1
;#<_overlap> = 0
; mode refernce
; +1: Conventional milling
; +2: Both-ways milling
; +4: Plunge entry
; +8: Outside
G20 ; G21 mm / G20 inch
G10 L1 P1 Z0.0 R[1/4/2] ; set tool
T1 ; set tool to T1
M06 ; manual toolchange
G54 ; absolute coordinates
F15 ; inch or mm/min (300 mm/min = about 1 ft/min)
; 12 mm holes
o<pocket_circ> call [.591] [-.433] [12/25.4] [0.1][-.3] [0][4]
o<pocket_circ> call [.591] [-.984] [12/25.4] [0.1][-.3] [0][4]
o<pocket_circ> call [3.937] [-.433] [12/25.4] [0.1][-.3] [0][4]
o<pocket_circ> call [3.937] [-.984] [12/25.4] [0.1][-.3] [0][4]
; m5 holes
;o<drill_man> call [1.634] [-.315]
;o<drill_man> call [1.634] [-.709]
;o<drill_man> call [1.634] [-1.102]
;o<drill_man> call [2.894] [-.315]
;o<drill_man> call [2.894] [-.709]
;o<drill_man> call [2.894] [-1.102]
M2 ; end program

View File

@@ -23,35 +23,75 @@ F6 ; inch or mm/min (300 mm/min = about 1 ft/min)
o1 if [#1 EQ 1]
; 12 mm holes
o<pocket_circ> call [.591] [-.433] [12/25.4] [0.1][-.1] [0][4]
o<pocket_circ> call [.591] [-.433] [12/25.4] [0.1][-.2] [0][4]
o<pocket_circ> call [.591] [-.433] [12/25.4] [0.1][-.3] [0][4]
o<pocket_circ> call [.591] [-.433] [12/25.4] [0.1][-.41] [0][4]
#<_z_top> = 0.1
#<_z_bot> = -.1
o<pocket_circ> call [4] [.591] [-.433] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.2
o<pocket_circ> call [4] [.591] [-.433] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.3
o<pocket_circ> call [4] [.591] [-.433] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<pocket_circ> call [4] [.591] [-.433] [12/25.4] [0]
o<pocket_circ> call [.591] [-.984] [12/25.4] [0.1][-.1] [0][4]
o<pocket_circ> call [.591] [-.984] [12/25.4] [0.1][-.2] [0][4]
o<pocket_circ> call [.591] [-.984] [12/25.4] [0.1][-.3] [0][4]
o<pocket_circ> call [.591] [-.984] [12/25.4] [0.1][-.41] [0][4]
#<_z_top> = 0.1
#<_z_bot> = -.1
o<pocket_circ> call [4] [.591] [-.984] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.2
o<pocket_circ> call [4] [.591] [-.984] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.3
o<pocket_circ> call [4] [.591] [-.984] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<pocket_circ> call [4] [.591] [-.984] [12/25.4] [0]
o<pocket_circ> call [3.937] [-.433] [12/25.4] [0.1][-.1] [0][4]
o<pocket_circ> call [3.937] [-.433] [12/25.4] [0.1][-.2] [0][4]
o<pocket_circ> call [3.937] [-.433] [12/25.4] [0.1][-.3] [0][4]
o<pocket_circ> call [3.937] [-.433] [12/25.4] [0.1][-.41] [0][4]
#<_z_top> = 0.1
#<_z_bot> = -.1
o<pocket_circ> call [4] [3.937] [-.433] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.2
o<pocket_circ> call [4] [3.937] [-.433] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.3
o<pocket_circ> call [4] [3.937] [-.433] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<pocket_circ> call [4] [3.937] [-.433] [12/25.4] [0]
o<pocket_circ> call [3.937] [-.984] [12/25.4] [0.1][-.1] [0][4]
o<pocket_circ> call [3.937] [-.984] [12/25.4] [0.1][-.2] [0][4]
o<pocket_circ> call [3.937] [-.984] [12/25.4] [0.1][-.3] [0][4]
o<pocket_circ> call [3.937] [-.984] [12/25.4] [0.1][-.41] [0][4]
#<_z_top> = 0.1
#<_z_bot> = -.1
o<pocket_circ> call [4] [3.937] [-.984] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.2
o<pocket_circ> call [4] [3.937] [-.984] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.3
o<pocket_circ> call [4] [3.937] [-.984] [12/25.4] [0]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<pocket_circ> call [4] [3.937] [-.984] [12/25.4] [0]
o1 elseif [#1 EQ 2]
#2 = [12/25.4]
o<frame_circ> call [.591] [-.433] [#2] [0.1][-.41] [0][4]
o<frame_circ> call [.591] [-.984] [#2] [0.1][-.41] [0][4]
o<frame_circ> call [3.937] [-.433] [#2] [0.1][-.41] [0][4]
o<frame_circ> call [3.937] [-.984] [#2] [0.1][-.41] [0][4]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<frame_circ> call [4] [.591] [-.433] [#2] [0]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<frame_circ> call [4] [.591] [-.984] [#2] [0]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<frame_circ> call [4] [3.937] [-.433] [#2] [0]
#<_z_top> = 0.1
#<_z_bot> = -.41
o<frame_circ> call [4] [3.937] [-.984] [#2] [0]
o1 elseif [#1 EQ 3]

View File

@@ -43,15 +43,25 @@ o10 elseif [#<prog> EQ 2]
o<spquircle_pocket> call [#<w>/2][-#<w>/2] [.937] [-.19][-.45] [0.01] [+4]
; cleanup the corners
o<drill> call [#<w>/2+.38][-#<w>/2+.38] [0.02][-0.45]
o<drill> call [#<w>/2-.38][-#<w>/2+.38] [0.02][-0.45]
o<drill> call [#<w>/2-.38][-#<w>/2-.38] [0.02][-0.45]
o<drill> call [#<w>/2+.38][-#<w>/2-.38] [0.02][-0.45]
#<_z_top> = 0.02
#<_z_bot> = -0.45
o<drill> call [#<w>/2+.38][-#<w>/2+.38]
#<_z_top> = 0.02
#<_z_bot> = -0.45
o<drill> call [#<w>/2-.38][-#<w>/2+.38]
#<_z_top> = 0.02
#<_z_bot> = -0.45
o<drill> call [#<w>/2-.38][-#<w>/2-.38]
#<_z_top> = 0.02
#<_z_bot> = -0.45
o<drill> call [#<w>/2+.38][-#<w>/2-.38]
o10 elseif [#<prog> EQ 3]
F10
#<b> = .96
o<frame_rect> call [#<w>/2+#<b>/2][-#<w>/2+#<b>/2] [#<w>/2-#<b>/2][-#<w>/2-#<b>/2] [0.02][-.45]
#<_z_top> = 0.02
#<_z_bot> = -.45
o<frame_rect> call [0] [#<w>/2+#<b>/2][-#<w>/2+#<b>/2] [#<w>/2-#<b>/2][-#<w>/2-#<b>/2]
o10 endif

View File

@@ -1,59 +0,0 @@
#<_z_clearance> = 0.5
#<_rampang> = 5
;#<_stepover> = 0.08
;#<_overlap> = 0
; +1: Conventional milling
; +2: Both-ways milling
; +4: Plunge entry
; +8: Outside
G20 ; G21 mm / G20 inch
G10 L1 P1 Z0.0 R.125 ; set tool
T1 ; set tool to T1
M06 ; manual toolchange
G54 ; absolute coordinates
;F5 ; inch or mm/min (300 mm/min = about 1 ft/min)
#<prog> = 3
#<w> = 3.0
#<bolt_r> = [40/25.4]
o10 if [#<prog> EQ 1]
F3
o<drill_man> call [#<w>/2][-#<w>/2] [0.1][-0.5]
o<drill_man> call [#<w>/2+#<bolt_r>/SQRT[2]][-#<w>/2+#<bolt_r>/SQRT[2]] [0.1][-0.5]
o<drill_man> call [#<w>/2+#<bolt_r>/SQRT[2]][-#<w>/2-#<bolt_r>/SQRT[2]] [0.1][-0.5]
o<drill_man> call [#<w>/2-#<bolt_r>/SQRT[2]][-#<w>/2-#<bolt_r>/SQRT[2]] [0.1][-0.5]
o<drill_man> call [#<w>/2-#<bolt_r>/SQRT[2]][-#<w>/2+#<bolt_r>/SQRT[2]] [0.1][-0.5]
o10 elseif [#<prog> EQ 2]
F8
; exterior
o<spquircle_boss> call [#<w>/2][-#<w>/2] [#<w>][40/25.4] [0.02] [-0.125] [0.01]
; center pocket
o<spquircle_pocket> call [#<w>/2][-#<w>/2] [.937] [0.02][-.19] [0.01] [0]
o<spquircle_pocket> call [#<w>/2][-#<w>/2] [.937] [-.19][-.45] [0.01] [+4]
; cleanup the corners
o<drill> call [#<w>/2+.38][-#<w>/2+.38] [0.02][-0.45]
o<drill> call [#<w>/2-.38][-#<w>/2+.38] [0.02][-0.45]
o<drill> call [#<w>/2-.38][-#<w>/2-.38] [0.02][-0.45]
o<drill> call [#<w>/2+.38][-#<w>/2-.38] [0.02][-0.45]
o10 elseif [#<prog> EQ 3]
F10
#<b> = .96
o<frame_rect> call [#<w>/2+#<b>/2][-#<w>/2+#<b>/2] [#<w>/2-#<b>/2][-#<w>/2-#<b>/2] [0.02][-.45]
o10 endif
M2 ; end program

View File

@@ -37,15 +37,25 @@ o10 if [#<prog> EQ 1]
o10 elseif [#<prog> EQ 2]
F12
; exterior
o<pocket_circ> call [#<w>/2][-#<w>/2] [3.0] [0.02][-0.002]
#<_z_top> = 0.02
#<_z_bot> = -0.002
o<pocket_circ> call [0] [#<w>/2][-#<w>/2] [3.0]
F8
o<spquircle_boss> call [#<w>/2][-#<w>/2] [#<w>][2.8125] [0.02] [-0.125] [0.01]
; ream the holes
o<pocket_circ> call [#<w>/2+#<bolt_r>/SQRT[2]][-#<w>/2+#<bolt_r>/SQRT[2]] [.45] [0.1][-0.6] [0][+4]
o<pocket_circ> call [#<w>/2+#<bolt_r>/SQRT[2]][-#<w>/2-#<bolt_r>/SQRT[2]] [.45] [0.1][-0.6] [0][+4]
o<pocket_circ> call [#<w>/2-#<bolt_r>/SQRT[2]][-#<w>/2-#<bolt_r>/SQRT[2]] [.45] [0.1][-0.6] [0][+4]
o<pocket_circ> call [#<w>/2-#<bolt_r>/SQRT[2]][-#<w>/2+#<bolt_r>/SQRT[2]] [.45] [0.1][-0.6] [0][+4]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<pocket_circ> call [+4] [#<w>/2+#<bolt_r>/SQRT[2]][-#<w>/2+#<bolt_r>/SQRT[2]] [.45] [0]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<pocket_circ> call [+4] [#<w>/2+#<bolt_r>/SQRT[2]][-#<w>/2-#<bolt_r>/SQRT[2]] [.45] [0]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<pocket_circ> call [+4] [#<w>/2-#<bolt_r>/SQRT[2]][-#<w>/2-#<bolt_r>/SQRT[2]] [.45] [0]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<pocket_circ> call [+4] [#<w>/2-#<bolt_r>/SQRT[2]][-#<w>/2+#<bolt_r>/SQRT[2]] [.45] [0]
; center pocket
@@ -55,16 +65,28 @@ o10 elseif [#<prog> EQ 2]
; cleanup the corners
o<drill> call [#<w>/2+.38][-#<w>/2+.38] [0.02][-0.6]
o<drill> call [#<w>/2-.38][-#<w>/2+.38] [0.02][-0.6]
o<drill> call [#<w>/2-.38][-#<w>/2-.38] [0.02][-0.6]
o<drill> call [#<w>/2+.38][-#<w>/2-.38] [0.02][-0.6]
#<_z_top> = 0.02
#<_z_bot> = -0.6
o<drill> call [#<w>/2+.38][-#<w>/2+.38]
#<_z_top> = 0.02
#<_z_bot> = -0.6
o<drill> call [#<w>/2-.38][-#<w>/2+.38]
#<_z_top> = 0.02
#<_z_bot> = -0.6
o<drill> call [#<w>/2-.38][-#<w>/2-.38]
#<_z_top> = 0.02
#<_z_bot> = -0.6
o<drill> call [#<w>/2+.38][-#<w>/2-.38]
o<frame_rect> call [#<w>/2+#<b>/2][-#<w>/2+#<b>/2] [#<w>/2-#<b>/2][-#<w>/2-#<b>/2] [0.02][-.55]
#<_z_top> = 0.02
#<_z_bot> = -.55
o<frame_rect> call [0] [#<w>/2+#<b>/2][-#<w>/2+#<b>/2] [#<w>/2-#<b>/2][-#<w>/2-#<b>/2]
o10 elseif [#<prog> EQ 3]
F8
o<frame_rect> call [#<w>/2+#<b>/2][-#<w>/2+#<b>/2] [#<w>/2-#<b>/2][-#<w>/2-#<b>/2] [0.02][-.55]
#<_z_top> = 0.02
#<_z_bot> = -.55
o<frame_rect> call [0] [#<w>/2+#<b>/2][-#<w>/2+#<b>/2] [#<w>/2-#<b>/2][-#<w>/2-#<b>/2]
o10 endif

View File

@@ -15,8 +15,12 @@ M06 ; manual toolchange
G54 ; absolute coordinates
F13 ; mm/min (300 mm/min = about 1 ft/min)
;o<pocket_circ> call [0][0] [2.05] [.1][-.5] [.01] [0+4]
o<frame_circ> call [0][0] [2.055] [.1][-.5] [0] [0]
;#<_z_top> = .1
;#<_z_bot> = -.5
;o<pocket_circ> call [0+4] [0][0] [2.05] [.01]
#<_z_top> = .1
#<_z_bot> = -.5
o<frame_circ> call [0] [0][0] [2.055] [0]

View File

@@ -15,10 +15,18 @@ M06 ; manual toolchange
G54 ; absolute coordinates
F4 ; mm/min (300 mm/min = about 1 ft/min)
o<drill> call [5-3][-1] [.1][-.7] [.2]
o<drill> call [8-3][-1] [.1][-.7] [.2]
o<drill> call [5-3][-3] [.1][-.7] [.2]
o<drill> call [8-3][-3] [.1][-.7] [.2]
#<_z_top> = .1
#<_z_bot> = -.7
o<drill> call [5-3][-1] [.2]
#<_z_top> = .1
#<_z_bot> = -.7
o<drill> call [8-3][-1] [.2]
#<_z_top> = .1
#<_z_bot> = -.7
o<drill> call [5-3][-3] [.2]
#<_z_top> = .1
#<_z_bot> = -.7
o<drill> call [8-3][-3] [.2]
M30
M2 ; end program

View File

@@ -18,18 +18,38 @@ F10 ; 10 ft/min
#1 = 1
o10 if [#1 EQ 1]
o<drill> call [ .325][-.25] [0.1][-0.3]
o<drill> call [ .325][-3.0] [0.1][-0.3]
o<drill> call [7.675][-3.0] [0.1][-0.3]
o<drill> call [7.675][-.25] [0.1][-0.3]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [ .325][-.25]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [ .325][-3.0]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [7.675][-3.0]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [7.675][-.25]
o10 else if [#1 EQ 2]
o<drill> call [1.4][-.75] [0.1][-0.3]
o<drill> call [4.0][-.75] [0.1][-0.3]
o<drill> call [4.0][-2.5] [0.1][-0.3]
o<drill> call [1.4][-2.5] [0.1][-0.3]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [1.4][-.75]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [4.0][-.75]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [4.0][-2.5]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [1.4][-2.5]
o<drill> call [5.4][-.525] [0.1][-0.3]
o<drill> call [6.4][-2.725] [0.1][-0.3]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [5.4][-.525]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [6.4][-2.725]
o10 endif

View File

@@ -1,34 +0,0 @@
#<_z_clearance> = 0.4
#<_rampang> = 5
;#<_overlap> = 0
; +1: Conventional milling
; +2: Both-ways milling
; +4: Plunge entry
; +8: Outside
G10 L1 P1 Z0.0 R[8/25.4 /2] ; set tool
T1 ; set tool to T1
M06 ; manual toolchange
G54 ; absolute coordinates
F10 ; 10 ft/min
#1 = 1
o10 if [#1 EQ 1]
o<drill> call [ 0.75][-.75] [0.1][-0.45]
o<drill> call [ 2.35][-.75] [0.1][-0.45]
;o<drill> call [ 3.35][-.75] [0.1][-0.45]
o<drill> call [ 4.35][-.75] [0.1][-0.45]
;o<drill> call [ 5.35][-.75] [0.1][-0.45]
o10 else if [#1 EQ 2]
o<slot_chop> call [2.35][-.75] [3.35][-.75] [.35] [0.1][-0.45] [0.01] [+4]
o<slot_chop> call [3.35][-.75] [4.35][-.75] [.35] [0.1][-0.45] [0.01] [+4]
o10 endif
M2 ; end program

View File

@@ -27,7 +27,9 @@ o10 if [#1 EQ 1]
o10 else if [#1 EQ 2]
F10.0
o<pocket_circ> call [0.75][0] [12/25.4] [0.1][-0.45] [0.0] [4]
#<_z_top> = 0.1
#<_z_bot> = -0.45
o<pocket_circ> call [4] [0.75][0] [12/25.4] [0.0]
F5.0
o<slot_chop> call [3.35][0] [2.35][0] [.33] [0.1][-0.45] [0.0] [4]
o<slot_chop> call [5.35][0] [4.35][0] [.33] [0.1][-0.45] [0.0] [4]

View File

@@ -1,21 +1,21 @@
#<_z_clearance> = 0.4
#<rampang> = 10
#<_td> = 0.125
M03
G4 P2
F5
o<pocket_circ> call [ 7/25.4] [-15/25.4] [[4-.7]/25.4] [0.05][-0.3]
o<pocket_circ> call [75/25.4] [-15/25.4] [[4-.7]/25.4] [0.05][-0.3]
#<_z_top> = 0.05
#<_z_bot> = -0.3
o<pocket_circ> call [0] [ 7/25.4] [-15/25.4] [[4-.7]/25.4]
o<pocket_circ> call [0] [75/25.4] [-15/25.4] [[4-.7]/25.4]
o<slot_chop> call [ 7/25.4][-30/25.4] [ 7/25.4][-44/25.4] [6.1/25.4] [.05][-.3]
o<slot_chop> call [75/25.4][-30/25.4] [75/25.4][-44/25.4] [6.1/25.4] [.05][-.3]
G0 Z0.5
G0 X[82/25.4+#<_td>/2] Y0.1
G0 X[82/25.4+#5410/2] Y0.1
G0 Z-0.3
G1 Y-2.1
M05

View File

@@ -1239,7 +1239,9 @@ M06 ; manual toolchange
G54 ; absolute coordinates
F10 ; 10 ft/min
o<frame_circ> call [2.5][-1.0] [1.381] [0.01][-0.3]
#<_z_top> = 0.01
#<_z_bot> = -0.3
o<frame_circ> call [0] [2.5][-1.0] [1.381]
N6080 M30

View File

@@ -15,6 +15,8 @@ M06 ; manual toolchange
G54 ; absolute coordinates
F10 ; 10 ft/min
o<frame_circ> call [2.5][-1.0] [1.381] [0.01][-0.3]
#<_z_top> = 0.01
#<_z_bot> = -0.3
o<frame_circ> call [0] [2.5][-1.0] [1.381]
M2 ; end program

View File

@@ -15,23 +15,43 @@ M06 ; manual toolchange
G54 ; absolute coordinates
F2 ; feedrate
;o<pocket_circ> call [0.317][-0.508] [.165] [0.05][-0.18] [.00] [4]
;o<pocket_circ> call [1.183][-0.508] [.165] [0.05][-0.18] [.00] [4]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [0.317][-0.508] [.165] [.00]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [1.183][-0.508] [.165] [.00]
;o<pocket_circ> call [0.750][-0.508] [.130] [0.05][-0.18] [.00] [4]
;o<pocket_circ> call [0.750][-1.689] [.130] [0.05][-0.18] [.00] [4]
;o<pocket_circ> call [0.258][-1.492] [.130] [0.05][-0.18] [.00] [4]
;o<pocket_circ> call [1.242][-1.492] [.130] [0.05][-0.18] [.00] [4]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [0.750][-0.508] [.130] [.00]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [0.750][-1.689] [.130] [.00]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [0.258][-1.492] [.130] [.00]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [1.242][-1.492] [.130] [.00]
;o<pocket_circ> call [2.625][-1.000] [.200] [0.05][-0.18] [.00] [4]
;o<pocket_circ> call [4.000][-1.000] [.200] [0.05][-0.18] [.00] [4]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [2.625][-1.000] [.200] [.00]
;#<_z_top> = 0.05
;#<_z_bot> = -0.18
;o<pocket_circ> call [4] [4.000][-1.000] [.200] [.00]
F5
#1 = -.010 ; finish cut
o<frame_rect> call [4.748+#1][-.265-#1] [5.578-#1][-1.735+#1] [0.05][-0.2]
#<_z_top> = 0.05
#<_z_bot> = -0.2
o<frame_rect> call [0] [4.748+#1][-.265-#1] [5.578-#1][-1.735+#1]
;F5
;o<frame_rect> call [4.748][-.265] [5.578][-1.735] [0.05][-0.2]
;#<_z_top> = 0.05
;#<_z_bot> = -0.2
;o<frame_rect> call [0] [4.748][-.265] [5.578][-1.735]

View File

@@ -4,8 +4,10 @@
M03 ; Start spindle
F10 ; Feed
o<drill> call [3.25][-0.5] [0.05][-0.35] [0.2]
o<drill> call [11.875][-0.5] [0.05][-0.35] [0.2]
#<_z_top> = 0.05
#<_z_bot> = -0.35
o<drill> call [3.25][-0.5] [0.2]
o<drill> call [11.875][-0.5] [0.2]
M05 ; Stop Spindle
M30 ; End Program

View File

@@ -19,22 +19,20 @@ G54 ; absolute coordinates
o200 sub ;[Y][Z]
G0 Z[#<_z_clearance>]
G0 X[#<_x_start>-#<_td>] Y[#1]
G0 X[#<_x_start>-#5410] Y[#1]
G0 Z[#2]
G1 X[#<_x_end>+#<_td>]
G1 X[#<_x_end>+#5410]
G0 Y[-#1]
G1 X[#<_x_start>-#<_td>]
G1 X[#<_x_start>-#5410]
o200 endsub
#<_td> = 0.75
#<_r_adj> = [#<_r> - #<_td>/2]
#<theta> = ACOS[[#<_z_ctr>-#<_td>/2]/#<_r_adj>]
#<_r_adj> = [#<_r> - #5410/2]
#<theta> = ACOS[[#<_z_ctr>-#5410/2]/#<_r_adj>]
;#<z_bot> = [#<_z_ctr> - #<_r_adj>]
#<y_top> = [#<_r_adj>*SIN[#<theta>]]
o10 if [#<op> EQ 1]
#<_td> = 0.5
F5
o200 call [0][-.35]
@@ -50,7 +48,7 @@ o10 elseif [#<op> EQ 2]
#<t> = #<theta>
; o105 while [#<t> LT #<theta>]
o200 call [SIN[#<t>]*#<_r_adj>][#<_z_ctr>-COS[#<t>]*#<_r_adj>-#<_td>/2]
o200 call [SIN[#<t>]*#<_r_adj>][#<_z_ctr>-COS[#<t>]*#<_r_adj>-#5410/2]
#<t> = [#<t> + 2]
; o105 endwhile
@@ -75,34 +73,35 @@ o10 elseif [#<op> EQ 3]
o101 if [#<i> MOD 2]
G1 X#<x> Y+#<y_top> Z0
G2 X#<x> Y-#<y_top> Z0 J0 K[#<_z_ctr>-#<_td>/2]
G2 X#<x> Y-#<y_top> Z0 J0 K[#<_z_ctr>-#5410/2]
o101 else
G1 X#<x> Y-#<y_top> Z0
G3 X#<x> Y+#<y_top> Z0 J0 K[#<_z_ctr>-#<_td>/2]
G3 X#<x> Y+#<y_top> Z0 J0 K[#<_z_ctr>-#5410/2]
o101 endif
o100 endwhile
o10 elseif [#<op> EQ 11]
#<_td> = [3/16]
F4
#<_z_top> = 0.0
#<_z_bot> = -0.4
;o<slot_chop> call [1.476][-.232] [1.476][+.232] [5.5/25.4] [0.0][-0.4]
o<slot> call [2.264][-.232] [2.264][+.232] [7.0/25.4] [0.0][-0.4]
o<slot> call [2.264][-.232] [2.264][+.232] [8.5/25.4] [0.0][-0.4]
o<slot> call [2.264][-.232] [2.264][+.232] [10.0/25.4] [0.0][-0.4]
o<slot> call [0] [2.264][-.232] [2.264][+.232] [7.0/25.4]
o<slot> call [0] [2.264][-.232] [2.264][+.232] [8.5/25.4]
o<slot> call [0] [2.264][-.232] [2.264][+.232] [10.0/25.4]
;o<slot_chop> call [3.051][-.232] [3.051][+.232] [5.5/25.4] [0.0][-0.4]
o10 elseif [#<op> EQ 12]
#<_td> = [5/25.4]
F4
o<slot> call [1.476][-.232] [1.476][+.232] [9.5/25.4] [0.0][-3.2/25.4]
o<slot> call [2.264][-.232] [2.264][+.232] [14/25.4] [0.0][-3.2/25.4]
o<slot> call [3.051][-.232] [3.051][+.232] [9.5/25.4] [0.0][-3.2/25.4]
#<_z_top> = 0.0
#<_z_bot> = -3.2/25.4
o<slot> call [0] [1.476][-.232] [1.476][+.232] [9.5/25.4]
o<slot> call [0] [2.264][-.232] [2.264][+.232] [14/25.4]
o<slot> call [0] [3.051][-.232] [3.051][+.232] [9.5/25.4]
o10 elseif [#<op> EQ 21]
#<_td> = [7/16]
#<_rc> = 0.3
#<_yr> = 1.005
@@ -111,8 +110,8 @@ o10 elseif [#<op> EQ 21]
#<t> = 0
o300 while [#<t> LT 90]
#<y> = [#<_yr>-#<_rc>+[#<_rc>+#<_td>/2]*COS[#<t>]]
#<z> = [-#<_rc>+[#<_rc>+#<_td>/2]*SIN[#<t>]-#<_td>/2]
#<y> = [#<_yr>-#<_rc>+[#<_rc>+#5410/2]*COS[#<t>]]
#<z> = [-#<_rc>+[#<_rc>+#5410/2]*SIN[#<t>]-#5410/2]
o200 call [#<y>][#<z>]

137
nc_files/OFFSETS.md Normal file
View File

@@ -0,0 +1,137 @@
# Offsets Quick Reference
## Coordinate Stack
```
What you see = machine position + work offset (G54...) + G52/G92 + tool length offset (G43)
```
`G53` bypasses everything and moves in machine coords.
## Work Offsets (G54G59.3)
9 available coordinate systems. G54 is default. Persist across power cycles (stored in `linuxcnc.var`).
### Touching off work zero
**In GMOCCAPY**: Jog to desired zero, click the axis letter (X/Y/Z) in the DRO, enter `0`. Done.
Internally: `G10 L20 P0 <axis> 0`
**Pendant**: Macro 5/6/7 = zero X/Y/Z. Macro 1/2 = halve X/Y (center-finding: zero one edge, jog to other edge, halve).
**In G-code**:
```gcode
G10 L20 P1 X0 Y0 Z0 ; set G54 origin to current position
G10 L20 P0 X0 ; set current system's X to 0
```
### Switching systems
```gcode
G55 ; all coords now relative to work offset 2
```
In GMOCCAPY: Offset page > click row > "Set Active".
### Editing numerically
In GMOCCAPY: Offset page > double-click a cell > type value. This uses `G10 L2` (absolute set), not touch-off.
### Temporary offsets
```gcode
G52 X1 Y1 ; shift on top of active G5x (good for pattern repeats)
G52 X0 Y0 ; cancel
```
Avoid `G92` — it persists across program runs and causes confusion. Use `G92.1` to clear if needed.
## Tool Length
### Setting up a tool (first time)
1. In GMOCCAPY Tool page: set diameter (D column) and any known Z offset. Click "Apply Changes".
2. Or in G-code: `G10 L1 P1 Z-2.5 R0.125` (R = **radius**, stored as D = diameter = 2R)
### Loading a tool
```gcode
T1 M6 ; select + change (pops up dialog, operator confirms)
G43 ; activate its Z offset — REQUIRED or Z is wrong
```
### Touching off tool length
Jog tool tip down to top of workpiece, then in MDI:
```gcode
G10 L10 P1 Z0 ; "tip is at Z=0, calculate and store the offset"
G43 ; activate it
```
Or: GMOCCAPY DRO > click Z letter > enter `0` (but this sets the **work offset**, not the tool offset — different thing).
### Canceling
```gcode
G49 ; cancel tool length offset
```
Standard practice: `G49` before each tool change, `G43` after.
## Cutter Radius Compensation (G41/G42)
Offsets the toolpath left or right of the programmed line by the tool's radius. Program the actual part edge; the machine handles the rest.
```gcode
G41 ; offset LEFT of path (climb milling outside profiles)
G42 ; offset RIGHT
G40 ; cancel
```
The D word in G41/G42 is a **tool number** (not a diameter): `G41 D1` looks up tool 1's diameter from the table. Omit D to use the current tool.
Rules:
- Lead-in move after G41/G42 must be >= tool radius
- Lead-out move with G40 must be >= tool radius
- Must be in G17 (XY plane)
```gcode
G41 ; comp on
G1 X0 Y0 F10 ; lead-in (this IS the first compensated move)
G1 X2 Y0 ; cut along part edge — tool rides 1 radius to the left
G1 X2 Y2
G40 ; comp off (next linear move is lead-out)
G0 X-1 Y-1
```
Dynamic variant: `G41.1 D0.250` — D is a literal diameter value, not a tool number.
**Our macros** handle radius compensation internally via `#<_td>`. Don't use G41/G42 with macro calls.
## Tool Table Columns (mill)
| Column | Meaning |
|--------|---------|
| T | Tool number |
| P | Pocket (we use P = T) |
| Z | Length offset |
| D | Diameter (not radius) |
## DRO Modes (click axis value to cycle)
| Mode | Color | Shows |
|------|-------|-------|
| Relative | Black | Work coords (what G-code sees) |
| Absolute | Blue | Machine coords (G53) |
| DTG | Yellow | Distance to go |
Green digits = homed. Red = unhomed.
## Named Parameters
| Parameter | Value |
|-----------|-------|
| `#<_current_tool>` / `#5400` | Tool in spindle |
| `#5410` | Current tool diameter |
| `#<_td>` | Our macros' tool diameter (user-set, not built-in) |

View File

@@ -1,17 +1,18 @@
#<_z_clearance> = 0.2
#<rampang> = 10
#<_td> = 0.125
#<_z_top> = 0.1
#<_z_bot> = -0.3
M03
G4 P2
F5
;o<drill> call [0.75][+2] [0.1][-0.3]
o<drill> call [0.75][-2] [0.1][-0.3]
o<drill> call [2.25+1.5+.75][+0] [0.1][-0.3]
o<drill> call [2.25+3.0+.75][+0] [0.1][-0.3]
;o<drill> call [2.25+4.5][+0] [0.1][-0.3]
;o<drill> call [0.75][+2]
o<drill> call [0.75][-2]
o<drill> call [2.25+1.5+.75][+0]
o<drill> call [2.25+3.0+.75][+0]
;o<drill> call [2.25+4.5][+0]
M05
M30

View File

@@ -1,7 +1,5 @@
#<_z_clearance> = 0.2
#<rampang> = 10
#<_td> = 0.1875
M03
G4 P2
@@ -11,7 +9,9 @@ F5
#1 = 0.75
o10 while [#1 LT 12]
o<frame_rect> call [#1-.2][-.34/2] [#1+.2][+.34/2] [0.1][-0.3]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<frame_rect> call [0] [#1-.2][-.34/2] [#1+.2][+.34/2]
#1 = [#1+0.75]
o10 endwhile

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = 0.5
#<_rampang> = 10
#<_td> = [9/16]
;#<_stepover> = 0.2
;#<_overlap> = 0
@@ -19,7 +18,9 @@ M03
F30
;o<slot_troch> call [-1.5][-1.5] [.75][-1.5] [1.70] [0.1][-1.1] [0][4]
o<slot> call [.75][-1.5] [-1.5][-1.5] [1.77] [.1][-1.1] [0][4]
#<_z_top> = .1
#<_z_bot> = -1.1
o<slot> call [4] [.75][-1.5] [-1.5][-1.5] [1.77] [0]
M05

View File

@@ -3,7 +3,6 @@
;M03 ; start spindle
F12 ; feedrate
#<_td> = 0.5
M6 T1 ; tool 1: 1/2" endmill
G43
M03
@@ -11,27 +10,27 @@ G4 P1 ; wait 2 sec (spindle start)
; drive end
;G0 Z#<_z_clearance>
;G0 X[#<_td>/2] Y[#<_td>/4]
;G0 X[#5410/2] Y[#5410/4]
;G0 Z-0.65
;G1 Y[-0.5-#<_td>/4]
;G1 Y[-0.5-#5410/4]
; drive flat
G0 Z#<_z_clearance>
G0 X[-.4375+#<_td>/2] Y0.15
G0 X[-.4375+#5410/2] Y0.15
G0 Z-.115
G1 Y-.6
; dead flat
G0 Z#<_z_clearance>
G0 X[-5.625-#<_td>/2] Y0.15
G0 X[-5.625-#5410/2] Y0.15
G0 Z-.08
G1 Y-.6
; drive end
;G0 Z#<_z_clearance>
;G0 X[-5.875-#<_td>/2] Y[-0.5-#<_td>/4]
;G0 X[-5.875-#5410/2] Y[-0.5-#5410/4]
;G0 Z-0.65
;G1 Y[#<_td>/4]
;G1 Y[#5410/4]
M05
G0 X-8

View File

@@ -3,16 +3,17 @@
;M03 ; start spindle
F7 ; feedrate
;#<_td> = 0.5
;M6 T1 ; tool 1: 1/2" endmill
;G43
M03
G4 P1 ; wait 2 sec (spindle start)
o<drill> call [0.30] [0] [0.05] [ -1.15] [0.18]
o<drill> call [1.00] [0] [0.05] [ -1.15] [0.18]
o<drill> call [13.75] [0] [0.05] [ -1.15] [0.18]
o<drill> call [14.45] [0] [0.05] [ -1.15] [0.18]
#<_z_top> = 0.05
#<_z_bot> = -1.15
o<drill> call [0.30] [0] [0.18]
o<drill> call [1.00] [0] [0.18]
o<drill> call [13.75] [0] [0.18]
o<drill> call [14.45] [0] [0.18]
M05 ; stop spindle
G0 X0.3

View File

@@ -3,7 +3,6 @@
;M03 ; start spindle
F12 ; feedrate
;#<_td> = 0.5
;M6 T1 ; tool 1: 1/2" endmill
;G43
M03

View File

@@ -3,7 +3,6 @@
;M03 ; start spindle
F12 ; feedrate
;#<_td> = 0.5
;M6 T1 ; tool 1: 1/2" endmill
;G43
M03

View File

@@ -1,63 +0,0 @@
#<_z_clearance> = +0.200 ; clearance height
;M03 ; start spindle
F12 ; feedrate
#<_td> = 0.5
M6 T1 ; tool 1: 1/2" endmill
G43
M03
G4 P1 ; wait 2 sec (spindle start)
; drive end
;G0 Z#<_z_clearance>
;G0 X[#<_td>/2] Y[#<_td>/4]
;G0 Z-0.65
;G1 Y[-0.5-#<_td>/4]
; drive flat
G0 Z#<_z_clearance>
G0 X[-.4375+#<_td>/2] Y0.15
G0 Z-.115
G1 Y-.6
; dead flat
G0 Z#<_z_clearance>
G0 X[-5.625-#<_td>/2] Y0.15
G0 Z-.08
G1 Y-.6
; drive end
;G0 Z#<_z_clearance>
;G0 X[-5.875-#<_td>/2] Y[-0.5-#<_td>/4]
;G0 Z-0.65
;G1 Y[#<_td>/4]
M05
G0 X-8
M6 T2 ; tool 2: 5/32" drillbit
M03
G43
G4 P0.5
G0 Z#<_z_clearance>
G0 X-.170 Y-.25
G0 Z-.1
G1 Z-.6 F5
G0 Z#<_z_clearance>
G0 X-5.705 Y-.25
G0 Z-.08
G1 Z-.15 F1
G1 Z-.6 F4
G0 Z#<_z_clearance>
M05 ; stop spindle
G0 X-8
M30 ; end program
M2 ; also end program
%

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = 0.5
#<_rampang> = 10
#<_td> = [1/4]
;#<_stepover> = 0.1
;#<_overlap> = 0

View File

@@ -1,5 +1,3 @@
#<_td> = [3/16]
G10 L1 P1 R[#<_td>/2] ; Set tool 1 diameter
#<_z_clearance> = 0.5
#<rampang> = 12
#<_zd> = -0.6
@@ -62,19 +60,33 @@ G90.0
o<peck_and_pocket> sub
#<d> = 0.2
o<drill> call [#1][#2] [0.1] [-0.6] [0.2]
o<pocket_circ> call [#1] [#2] [#<d>] [0.1] [-0.6] [0] [+4]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<drill> call [#1][#2] [0.2]
o<pocket_circ> call [+4] [#1] [#2] [#<d>] [0]
o<peck_and_pocket> endsub
F20
#<d> = 0.315
#<d2> = 0.35
o<pocket_circ > call [0.550][-0.446] [#<d>] [0.02][#<_zd>] [0][4]
o<pocket_circ > call [0.550][-0.446] [#<d2>] [0.02][-0.08] [0][4]
o<pocket_circ > call [0.550][-3.304] [#<d>] [0.02][#<_zd>] [0][4]
o<pocket_circ > call [0.550][-3.304] [#<d2>] [0.02][-0.08] [0][4]
o<pocket_circ > call [3.025][-1.875] [#<d>] [0.02][#<_zd>] [0][4]
o<pocket_circ > call [3.025][-1.875] [#<d2>] [0.02][-0.08] [0][4]
#<_z_top> = 0.02
#<_z_bot> = #<_zd>
o<pocket_circ > call [4] [0.550][-0.446] [#<d>] [0]
#<_z_top> = 0.02
#<_z_bot> = -0.08
o<pocket_circ > call [4] [0.550][-0.446] [#<d2>] [0]
#<_z_top> = 0.02
#<_z_bot> = #<_zd>
o<pocket_circ > call [4] [0.550][-3.304] [#<d>] [0]
#<_z_top> = 0.02
#<_z_bot> = -0.08
o<pocket_circ > call [4] [0.550][-3.304] [#<d2>] [0]
#<_z_top> = 0.02
#<_z_bot> = #<_zd>
o<pocket_circ > call [4] [3.025][-1.875] [#<d>] [0]
#<_z_top> = 0.02
#<_z_bot> = -0.08
o<pocket_circ > call [4] [3.025][-1.875] [#<d2>] [0]
F20
#<d> =0.3
o<peck_and_pocket> call [5.625][-0.375]

View File

@@ -1,4 +1,3 @@
#<_td> = [3/16]
#<_z_clearance> = 0.2
#<rampang> = 4
#<_zd> = 0.6
@@ -51,17 +50,21 @@ o<aperture> endsub
o<aperture> call [1.375][-1.875]
#<d> = 0.315
o<pocket_circ> call [0.550][-0.446] [#<d>] [0.02][#<_zd>]
o<pocket_circ> call [0.550][-3.304] [#<d>] [0.02][#<_zd>]
o<pocket_circ> call [3.025][-1.875] [#<d>] [0.02][#<_zd>]
#<_z_top> = 0.02
#<_z_bot> = #<_zd>
o<pocket_circ> call [0] [0.550][-0.446] [#<d>]
o<pocket_circ> call [0] [0.550][-3.304] [#<d>]
o<pocket_circ> call [0] [3.025][-1.875] [#<d>]
#<d> = 0.20
o<pocket_circ> call [5.625][-0.375] [#<d>] [0.1][-0.6]
o<pocket_circ> call [5.125][-1.125] [#<d>] [0.1][-0.6]
o<pocket_circ> call [5.625][-1.875] [#<d>] [0.1][-0.6]
o<pocket_circ> call [5.125][-2.625] [#<d>] [0.1][-0.6]
o<pocket_circ> call [5.625][-3.375] [#<d>] [0.1][-0.6]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<pocket_circ> call [0] [5.625][-0.375] [#<d>]
o<pocket_circ> call [0] [5.125][-1.125] [#<d>]
o<pocket_circ> call [0] [5.625][-1.875] [#<d>]
o<pocket_circ> call [0] [5.125][-2.625] [#<d>]
o<pocket_circ> call [0] [5.625][-3.375] [#<d>]
M05
G0 Z#<_z_clearance>

View File

@@ -12,10 +12,11 @@ M03
F5.0
#<z> = -0.14
#<_td> = [3/32]
#<_z_clearance> = 0.02
;o<pocket_circ> call [0][0] [0.62] [#<_z_clearance>][#<z>] [0] [0+4]
;#<_z_top> = #<_z_clearance>
;#<_z_bot> = #<z>
;o<pocket_circ> call [0+4] [0][0] [0.62] [0]
G91.1 ; incremental IJK

View File

@@ -1,4 +1,3 @@
#<_td> = 0.1875
#<_z_clearance> = 0.2
M03

View File

@@ -12,10 +12,11 @@ M03
F5.0
#<z> = -0.14
#<_td> = [3/32]
#<_z_clearance> = 0.02
o<pocket_circ> call [0][0] [0.62] [#<_z_clearance>][#<z>] [0] [0+4]
#<_z_top> = #<_z_clearance>
#<_z_bot> = #<z>
o<pocket_circ> call [0+4] [0][0] [0.62] [0]
G91.1 ; incremental IJK

View File

@@ -1,7 +1,5 @@
#<_z_clearance> = 0.4
#<rampang> = 10
#<_td> = 0.125
M03
G4 P0.5

View File

@@ -1,17 +1,20 @@
#<_td> = [3/16]
#<_z_clearance> = 0.5
#<rampang> = 30
M03
F20
o<frame_circ> call [1.375][-1.875] [1.375] [+0.10][-0.6] [0] [+4]
#<_z_top> = +0.10
#<_z_bot> = -0.6
o<frame_circ> call [+4] [1.375][-1.875] [1.375] [0]
F14
o<peck_and_pocket> sub
#<d> = 0.2
o<drill> call [#1][#2] [0.1] [-0.6] [0.2]
o<pocket_circ> call [#1] [#2] [#<d>] [0.1] [-0.6] [0] [+4]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<drill> call [#1][#2] [0.2]
o<pocket_circ> call [+4] [#1] [#2] [#<d>] [0]
o<peck_and_pocket> endsub
#<d> =0.2
o<peck_and_pocket> call [5.625][-0.375]

View File

@@ -1,18 +1,21 @@
#<_td> = [3/16]
#<_z_clearance> = 0.2
#<rampang> = 10
M03
F20
o<pocket_circ> call [1.375][-1.875] [1.375] [+0.10][-0.6]
#<_z_top> = +0.10
#<_z_bot> = -0.6
o<pocket_circ> call [0] [1.375][-1.875] [1.375]
F14
o<pocket_circ> call [5.625][-0.375] [0.20] [0.1][-0.6]
o<pocket_circ> call [5.125][-1.125] [0.20] [0.1][-0.6]
o<pocket_circ> call [5.625][-1.875] [0.20] [0.1][-0.6]
o<pocket_circ> call [5.125][-2.625] [0.20] [0.1][-0.6]
o<pocket_circ> call [5.625][-3.375] [0.20] [0.1][-0.6]
#<_z_top> = 0.1
#<_z_bot> = -0.6
o<pocket_circ> call [0] [5.625][-0.375] [0.20]
o<pocket_circ> call [0] [5.125][-1.125] [0.20]
o<pocket_circ> call [0] [5.625][-1.875] [0.20]
o<pocket_circ> call [0] [5.125][-2.625] [0.20]
o<pocket_circ> call [0] [5.625][-3.375] [0.20]
M05
M30

View File

@@ -8,27 +8,29 @@ G4 P3
; OP 1: Holes in side
; Origin: back middle
o10 if [#<op> EQ 1]
#<_td> = 0.125
F16
o<pocket_circ> call [-.5][-.540] [0.500] [0.05][-0.2] [0.01] [+4]
#<_z_top> = 0.05
#<_z_bot> = -0.2
o<pocket_circ> call [+4] [-.5][-.540] [0.500] [0.01]
o<drill> call [-1.5][-.480] [0.05][-0.2]
o<drill> call [-1.5][-.680] [0.05][-0.2]
o<drill> call [-1.5][-.880] [0.05][-0.2]
o<drill> call [-1.5][-.480]
o<drill> call [-1.5][-.680]
o<drill> call [-1.5][-.880]
; OP 2: PG holes in bottom
; Origin: back middle
o10 elseif [#<op> EQ 2]
#<_td> = 0.125
F16
o<frame_circ> call [0.00][-3.150+1.920] [.84] [+0.10][-0.25] [0.01] [+4]
o<frame_circ> call [-1.6][-3.150+2.230] [.84] [+0.10][-0.25] [0.01] [+4]
o<frame_circ> call [+1.6][-3.150+2.230] [.84] [+0.10][-0.25] [0.01] [+4]
#<_z_top> = +0.10
#<_z_bot> = -0.25
o<frame_circ> call [+4] [0.00][-3.150+1.920] [.84] [0.01]
o<frame_circ> call [+4] [-1.6][-3.150+2.230] [.84] [0.01]
o<frame_circ> call [+4] [+1.6][-3.150+2.230] [.84] [0.01]
o<frame_circ> call [0.00][-3.150+1.920] [.89] [+0.10][-0.25] [0.01] [+4]
o<frame_circ> call [-1.6][-3.150+2.230] [.89] [+0.10][-0.25] [0.01] [+4]
o<frame_circ> call [+1.6][-3.150+2.230] [.89] [+0.10][-0.25] [0.01] [+4]
o<frame_circ> call [+4] [0.00][-3.150+1.920] [.89] [0.01]
o<frame_circ> call [+4] [-1.6][-3.150+2.230] [.89] [0.01]
o<frame_circ> call [+4] [+1.6][-3.150+2.230] [.89] [0.01]
G0 Z1.5
o10 endif

View File

@@ -8,20 +8,20 @@ M03
; OP 1: Holes
; Origin: center
o10 if [#<op> EQ 1]
#<_td> = 0.25
F5
o<drill> call [+2.913][+2.913] [0.05][-0.15]
o<drill> call [-2.913][+2.913] [0.05][-0.15]
o<drill> call [-2.913][-2.913] [0.05][-0.15]
o<drill> call [+2.913][-2.913] [0.05][-0.15]
#<_z_top> = 0.05
#<_z_bot> = -0.15
o<drill> call [+2.913][+2.913]
o<drill> call [-2.913][+2.913]
o<drill> call [-2.913][-2.913]
o<drill> call [+2.913][-2.913]
; OP 2: Outline
; Origin: center
o10 elseif [#<op> EQ 2]
#<_td> = 0.2
#<_tr> = [#<_td>/2]
#<_tr> = [#5410/2]
F5
@@ -29,8 +29,10 @@ o10 elseif [#<op> EQ 2]
G90.1
o<slot> call [0][+2.375] [0][+1.625] [0.252] [0.05][-0.15]
o<slot> call [0][-2.375] [0][-1.625] [0.252] [0.05][-0.15]
#<_z_top> = 0.05
#<_z_bot> = -0.15
o<slot> call [0] [0][+2.375] [0][+1.625] [0.252]
o<slot> call [0] [0][-2.375] [0][-1.625] [0.252]
G0 Z0.2

View File

@@ -2,7 +2,6 @@
#<_z_clearance> = 0.2
#<_td> = [3/16]
#<_rampang> = 8
#<x> = 1.05
@@ -30,7 +29,7 @@ G0 Z#<_z_clearance>
; outline
F12
G10 L1 P1 R[#<_td>/2] ; Set tool 1 diameter
G10 L1 P1 R[#5410/2] ; Set tool 1 diameter
G0 X1.25 Y0.25
G41 D1

View File

@@ -1,4 +1,3 @@
#<_td> = 0.25
#<_z_clearance> = 0.2
#<rampang> = 6
@@ -10,7 +9,9 @@ F9
G90.1 ; absolute arc centers
o<pocket_circ> call [0][0] [.540] [+.05][-.2]
#<_z_top> = +.05
#<_z_bot> = -.2
o<pocket_circ> call [0] [0][0] [.540]
G0 Z1.0
@@ -28,7 +29,9 @@ G2 I[#<x>-#<o>] J0 X[#<x>-.84356-#<o>] Y[+.61679]
G1 Y[+1.0]
G0 Z1.0
;o<pocket_circ> call [0][0] [.540] [+0.10][-0.25]
;#<_z_top> = +0.10
;#<_z_bot> = -0.25
;o<pocket_circ> call [0] [0][0] [.540]
M05

View File

@@ -1,9 +1,5 @@
#<_z_clearance> = 0.5
#<_rampang> = 5
#<_td> = [1/4]
M03
#<op> = 2
@@ -13,11 +9,19 @@ M03
;o10 if [#<op> EQ 1]
F10
;o<pocket_circ> call [-1][0] [1.5] [0.05][-0.15]
;#<_z_top> = 0.05
;#<_z_bot> = -0.15
;o<pocket_circ> call [0] [-1][0] [1.5]
o<frame_circ> call [0.25][-0.375] [0.353*2] [.05][-0.4]
o<frame_circ> call [0.25][-0.375] [0.353*2] [.05][-0.8]
o<frame_circ> call [0.25][-0.375] [0.353*2] [.05][-1.25]
#<_z_top> = .05
#<_z_bot> = -0.4
o<frame_circ> call [0] [0.25][-0.375] [0.353*2]
#<_z_top> = .05
#<_z_bot> = -0.8
o<frame_circ> call [0] [0.25][-0.375] [0.353*2]
#<_z_top> = .05
#<_z_bot> = -1.25
o<frame_circ> call [0] [0.25][-0.375] [0.353*2]
;o<drill_man> call [-1][+1]
;o<drill_man> call [-1][-1]

View File

@@ -5,9 +5,9 @@ M03
F7
#<_td> = [7/16]
o<pocket_circ> call [-0.5] [0] [18/25.4] [0.03][-0.3]
#<_z_top> = 0.03
#<_z_bot> = -0.3
o<pocket_circ> call [0] [-0.5] [0] [18/25.4]
M05
M30

View File

@@ -5,11 +5,13 @@ M03
F4
#<_td> = [1/2]
;#<_z_top> = +0.10
;#<_z_bot> = -0.25
;o<frame_circ> call [+4] [0.00][-3.150+1.920] [.84] [0.01]
;o<frame_circ> call [0.00][-3.150+1.920] [.84] [+0.10][-0.25] [0.01] [+4]
o<frame_circ> call [-1][0] [1.262] [0.01][-0.450]
#<_z_top> = 0.01
#<_z_bot> = -0.450
o<frame_circ> call [0] [-1][0] [1.262]
M05

View File

@@ -5,7 +5,6 @@ M03
F10
#<_td> = [5/16]
;o<drill_man> call [-5.45][-0.446]
;o<drill_man> call [-2.975][-1.875]
;o<drill_man> call [-5.45][-3.304]
@@ -16,7 +15,9 @@ F10
;o<drill_man> call [-16.25][0]
;o<drill_man> call [-16.75][0]
;o<drill_man> call [-17.25][0]
o<frame_circ> call [-4.625][-1.875][1.720][0.05][-0.6]
#<_z_top> = 0.05
#<_z_bot> = -0.6
o<frame_circ> call [0] [-4.625][-1.875][1.720]
M05
M30

View File

@@ -1,5 +1,3 @@
#<_td> = [1/2]
G10 L1 P1 R[#<_td>/2] ; Set tool 1 diameter
#<_z_clearance> = 0.5
#<rampang> = 12
@@ -8,8 +6,12 @@ G4 P2
F10
;o<frame_circ> call [0][0] [1.750] [.01][0] [0][4]
o<frame_circ> call [0][0] [1.382] [.01][-0.6] [0][4]
;#<_z_top> = .01
;#<_z_bot> = 0
;o<frame_circ> call [4] [0][0] [1.750] [0]
#<_z_top> = .01
#<_z_bot> = -0.6
o<frame_circ> call [4] [0][0] [1.382] [0]
M05
G0 Z#<_z_clearance>

18
nc_files/THF-AIRPANEL.ngc Normal file
View File

@@ -0,0 +1,18 @@
#<_z_clearance> = 0.500
M03 ; Start spindle
F10 ; Feed
#<_z_top> = 0.25
#<_z_bot> = 0.0
#<d> = 0.5
o<frame_circ> call [+4] [1.25][-4.025] [#<d>]
o<frame_circ> call [+4] [4.00][-4.025] [#<d>]
o<frame_circ> call [+4] [4.00][-1.805] [#<d>]
o<frame_rect> call [+4+8] [-.175][.175] [5.425][-4.425]
M05 ; Stop Spindle
M30 ; End Program
%

View File

@@ -1,24 +1,31 @@
#<_td> = [3/16]
#<_z_clearance> = 0.5
#<rampang> = 30
M03
F20
;o<pocket_circ> call [1.375][-1.875] [1.375] [+0.10][-0.6] [0] [+4]
;#<_z_top> = +0.10
;#<_z_bot> = -0.6
;o<pocket_circ> call [+4] [1.375][-1.875] [1.375] [0]
;o<pocket_circ> call [0.9] [-1.576] [0.277] [0.05][-0.2] [0][4]
;o<pocket_circ> call [5.4] [-1.576] [0.277] [0.05][-0.2] [0][4]
;o<frame_rect> call [1.93][-0.789] [4.370][-2.363] [0.05][-0.2]
;#<_z_top> = 0.05
;#<_z_bot> = -0.2
;o<pocket_circ> call [4] [0.9] [-1.576] [0.277] [0]
;o<pocket_circ> call [4] [5.4] [-1.576] [0.277] [0]
;o<frame_rect> call [0] [1.93][-0.789] [4.370][-2.363]
;o<pocket_circ> call [2.399][-0.575] [.2] [.05][-0.2] [0][4]
;o<pocket_circ> call [3.899][-0.575] [.2] [.05][-0.2] [0][4]
;o<pocket_circ> call [4.921][-0.778] [.2] [.05][-0.2] [0][4]
;o<pocket_circ> call [4.921][-1.575] [1.063] [.05][-0.2] [0][4]
;o<pocket_circ> call [4.921][-2.372] [.2] [.05][-0.2] [0][4]
;o<pocket_circ> call [3.899][-2.575] [.2] [.05][-0.2] [0][4]
;o<pocket_circ> call [2.399][-2.575] [.2] [.05][-0.2] [0][4]
;o<pocket_circ> call [1.024][-1.575-.75] [.27] [.05][-0.2] [0][4]
o<pocket_circ> call [1.274][-1.575+.50] [.80] [.05][-0.2] [0][4]
;#<_z_top> = .05
;#<_z_bot> = -0.2
;o<pocket_circ> call [4] [2.399][-0.575] [.2] [0]
;o<pocket_circ> call [4] [3.899][-0.575] [.2] [0]
;o<pocket_circ> call [4] [4.921][-0.778] [.2] [0]
;o<pocket_circ> call [4] [4.921][-1.575] [1.063] [0]
;o<pocket_circ> call [4] [4.921][-2.372] [.2] [0]
;o<pocket_circ> call [4] [3.899][-2.575] [.2] [0]
;o<pocket_circ> call [4] [2.399][-2.575] [.2] [0]
;o<pocket_circ> call [4] [1.024][-1.575-.75] [.27] [0]
#<_z_top> = .05
#<_z_bot> = -0.2
o<pocket_circ> call [4] [1.274][-1.575+.50] [.80] [0]
M05
G0 Z#<_z_clearance>

398
nc_files/TOOLS.md Normal file
View File

@@ -0,0 +1,398 @@
# Tool Changes, Offsets & Work Coordinates in LinuxCNC
Reference for the Lagun mill config (non-random manual toolchanger, GMOCCAPY GUI, inch mode).
---
## Tool Table (`tool.tbl`)
Each line defines a tool:
```
T3 P3 D+0.187500 ;3/16in flat
T1 P1 D+0.187500 I+7.000000 ;0.201in DrillBit
T5 P5 D+0.250000 ;1/4
```
| Column | Meaning |
|--------|---------|
| **T** | Tool number (what programs reference with `T1`, `T5`, etc.) |
| **P** | Pocket number (our setup just uses P = T) |
| **Z** | Tool length offset (distance from spindle reference to tool tip) |
| **D** | Tool **diameter** (full width, not radius) |
| **;** | Comment |
**Important**: The D column stores **diameter**, but `G10 L1` sets it using **radius** (R word). This is a common source of confusion.
---
## Tool Change Sequence
```gcode
T1 ; select tool 1 (prepares it, does NOT load it)
M6 ; execute the change — pops up the manual tool change dialog
G43 ; activate that tool's length offset
```
- `T` alone only **selects** (prepares) a tool. Nothing physical happens.
- `M6` performs the actual change. On our machine this pops up a dialog prompting the operator to insert the tool and click OK.
- `G43` applies the tool's Z offset from the tool table. **Without this line, the machine has no idea how long the tool is.**
- `T1 M6` on one line is fine (and common).
After `M6`, the built-in parameter `#<_current_tool>` holds the loaded tool number, and `#5410` holds its diameter.
---
## Tool Length Offset (G43 / G49)
### Activating
| Command | Effect |
|---------|--------|
| `G43` | Apply TLO of the **currently loaded** tool (from last M6) |
| `G43 H1` | Apply TLO of tool **1** from the table (doesn't have to match spindle tool) |
| `G43.1 Z0.5` | Dynamic TLO: set Z offset to 0.5 directly (doesn't write to table) |
| `G43.2 H1` | Cumulative: **add** tool 1's offset on top of the current offset |
`G43` shifts all subsequent Z moves by the tool's Z offset. No motion occurs on the G43 line itself — the offset applies on the next move.
### Canceling
```gcode
G49 ; cancel tool length offset
```
### Typical multi-tool workflow
```gcode
T1 M6 ; load tool 1
G43 ; activate its TLO
; ... do work ...
G49 ; cancel TLO before next change
T2 M6 ; load tool 2
G43 ; activate tool 2's TLO
```
---
## Setting Tool Offsets with G10
### G10 L1 — Write directly to the tool table
```gcode
G10 L1 P<tool#> Z<length> R<radius>
```
- **P**: tool number to update
- **Z**: tool length offset (direct value)
- **R**: tool **radius** (half the diameter). LinuxCNC stores this as `D = 2 * R` in the tool table.
Examples:
```gcode
G10 L1 P1 Z-2.500 R0.125 ; tool 1: length=-2.5", radius=0.125" (1/4" endmill, D=0.250)
G10 L1 P1 R[3/16/2] ; just update radius: 3/16" tool -> R=0.09375 -> D=0.1875
```
After `G10 L1`, re-issue `G43` to pick up the new offset if that tool is already loaded.
### G10 L10 — Set offset by touching off (work coords as reference)
```gcode
G10 L10 P<tool#> Z<desired_coord>
```
Calculates what Z offset the tool table needs so that, with the current work coordinate system active and the machine at its current position, the Z display would read the specified value.
Touch-off workflow:
1. Load tool, jog Z down until it touches the workpiece surface
2. `G10 L10 P1 Z0` — "the tip is at Z=0, calculate the offset"
### G10 L11 — Touch off using G59.3 as reference
Same as L10 but uses G59.3 (with no G52/G92) as the reference frame. Useful if you have a fixed tool-length probe at a known machine position stored in G59.3.
---
## Cutter Radius Compensation (G41 / G42 / G40)
Cutter comp shifts the toolpath left or right of the programmed path by the tool's radius. This lets you program to the part geometry (the actual edge you want) and let LinuxCNC offset the toolpath by the tool radius automatically.
### Basics
```gcode
G41 ; compensate LEFT of the programmed path (climb milling on outside profiles)
G42 ; compensate RIGHT of the programmed path (conventional milling on outside profiles)
G40 ; cancel compensation — return to programming on centerline
```
"Left" and "right" are from the perspective of looking down the tool axis in the direction of travel.
### The D word
```gcode
G41 D1 ; use tool 1's diameter from the table for the offset amount
G42 ; no D = use the currently loaded tool's diameter
```
**The D word in G41/G42 is a tool number**, not a diameter value. LinuxCNC looks up that tool's D column (diameter), halves it, and uses that as the offset distance.
### Rules and gotchas
- The **lead-in move** (first move after G41/G42) must be **at least as long as the tool radius**. A rapid (G0) is fine.
- The **lead-out move** (move on the same line as G40) must also be linear and at least as long as the tool radius.
- **Inside corners**: the path is shortened to prevent gouging.
- **Outside corners**: the path is extended (the tool wraps around the corner).
- **U-turns and tight inside corners** where the tool can't physically fit will cause an error.
- Cutter comp only works in **G17** (XY plane). For G18/G19 it compensates in the respective plane.
- You **cannot** start cutter comp while already in cutter comp — must G40 first.
### Example: cutting an outside profile
```gcode
G10 L1 P1 R[1/4/2] ; tool 1 = 1/4" endmill (R=0.125, D=0.250)
T1 M6
G43
G0 X-1 Y-1 ; position away from the part
G41 ; turn on left comp (uses current tool's D)
G1 X0 Y0 F10 ; lead-in move to first corner (must be >= tool radius)
G1 X0 Y2 ; cut along left edge
G1 X3 Y2 ; cut along top edge
G1 X3 Y0 ; cut along right edge
G1 X0 Y0 ; cut along bottom edge, back to start
G40 ; cancel comp
G0 X-1 Y-1 ; lead-out / retract
```
The programmed path (X0 Y0 to X3 Y2) is the actual part edge. The tool centerline runs 0.125" outside of it.
### Dynamic variant
```gcode
G41.1 D0.250 ; compensate left by 0.250" diameter (= 0.125" offset) directly
G42.1 D0.250 ; compensate right
```
Here the D word **IS** a diameter value (not a tool number). Useful when you want to specify the offset directly without looking it up from the table.
### Cutter comp vs. our macros
Our macros (`pocket_circ`, `frame_rect`, etc.) do their own tool-diameter compensation internally using `#<_td>`. They do **not** use G41/G42. So:
- Use **G41/G42** when you're writing raw G-code profiles (manually programmed contours).
- Use **`#<_td>`** when calling our subroutines — they handle the offset math themselves.
- Don't use both at the same time on the same toolpath.
---
## Work Offsets (G54G59.3)
Work offsets define where "zero" is on your workpiece relative to the machine's home position.
### Available coordinate systems
| G-code | Name | P number (for G10) |
|--------|------|--------------------|
| G54 | Work offset 1 (default) | P1 |
| G55 | Work offset 2 | P2 |
| G56 | Work offset 3 | P3 |
| G57 | Work offset 4 | P4 |
| G58 | Work offset 5 | P5 |
| G59 | Work offset 6 | P6 |
| G59.1 | Work offset 7 | P7 |
| G59.2 | Work offset 8 | P8 |
| G59.3 | Work offset 9 | P9 |
These **persist across power cycles** — they're stored in `linuxcnc.var`.
### Setting work offsets
**Touch-off method** (most common): jog to where you want zero, then:
```gcode
G10 L20 P1 X0 Y0 ; "right here is G54 X0 Y0"
G10 L20 P0 Z0 ; "right here is Z0 in the currently active system"
```
- `P0` = whichever G5x is currently active
- You only need to specify the axes you want to set
**Direct method**: if you know the machine-coordinate position of your fixture:
```gcode
G10 L2 P1 X-12.500 Y-6.000 Z0.000 ; G54 origin is at machine X-12.5 Y-6.0 Z0.0
```
**Switching** between coordinate systems:
```gcode
G55 ; now all coords are relative to work offset 2
```
### Practical use
- **One fixture, one part**: Just use G54. Touch off XYZ zero on your stock.
- **Multiple fixtures / vises**: G54 for vise 1, G55 for vise 2. Touch off each.
- **Multiple setups on one part**: Flip the part, touch off new Z in G54.
### G52 and G92 (temporary offsets)
`G52 X1 Y1` adds a temporary offset on top of the active G5x. Useful for pattern repeats.
`G92 X0 Y0` says "my current position IS X0 Y0" (like G10 L20 but temporary). **Caution**: G92 offsets persist across program runs until cleared with `G92.1`. This is a common gotcha. Prefer G52 over G92.
### Your pendant buttons
| Button | MDI Command | What it does |
|--------|------------|--------------|
| Macro 5 | `G10 L20 P0 X0` | Zero X in current work offset |
| Macro 6 | `G10 L20 P0 Y0` | Zero Y in current work offset |
| Macro 7 | `G10 L20 P0 Z0` | Zero Z in current work offset |
| Macro 1 | `G10 L20 P0 X[#<_x>/2.0]` | Halve X (center-finding) |
| Macro 2 | `G10 L20 P0 Y[#<_y>/2.0]` | Halve Y (center-finding) |
The halve trick: touch one edge of the stock and zero it, jog to the other edge, press the halve button — now you're at the center.
---
## Coordinate System Hierarchy
```
Displayed position = Machine position
+ G5x work offset (G54, G55, ... set by G10 L2/L20)
+ G52/G92 offset
+ G43 tool length offset
```
`G53` bypasses all offsets and moves in raw machine coordinates (useful for "go to tool change position" moves).
---
## GMOCCAPY Interface
### DRO (Digital Readout)
The DRO has three display modes, toggled by **clicking any axis value**:
| Mode | Background | Shows |
|------|------------|-------|
| **Relative** | Black | Position in current work coordinate system (G5x + tool offset + G92). This is what your G-code program sees. |
| **Absolute** | Blue | Machine coordinates (G53). Position relative to machine home. |
| **DTG** | Yellow | Distance To Go — remaining distance to the programmed endpoint during motion. |
DRO digit colors indicate homing status:
- **Green** = homed (reference established)
- **Red** = unhomed (position is not trustworthy)
### Touch-Off via the DRO
**Click the axis letter** (the "X", "Y", or "Z" label, not the number) to open a popup dialog. Enter the coordinate value you want the current position to represent (usually `0`). This issues `G10 L20 P0 <axis> <value>` internally.
### Offset Page
The Offset page (accessible from the notebook tabs) shows a table of all work coordinate systems (G54G59.3) plus G92 and tool offsets. The currently active system is highlighted.
- **Double-click a cell** to edit a value directly. This issues `G10 L2 P<n> <axis> <value>` (sets the offset to the value you typed, NOT touch-off style).
- **"Zero G92" button**: sends `G92.1` to cancel G92 offsets.
- **"Set Active" button**: switches the active coordinate system (e.g., click the G55 row, then "Set Active" to switch to G55).
**Key distinction**: Editing the offset page sets offsets with `G10 L2` (absolute). Touching off via the DRO uses `G10 L20` (calculated from current position). These are different operations.
### Tool Page
Shows the tool table with columns for tool number, pocket, diameter, and Z offset.
- **Click a cell** to edit. Changes are NOT live until you click **"Apply Changes"**.
- After applying, you must **re-issue `G43`** (in MDI) if the active tool's offset changed. GMOCCAPY does not do this automatically.
- The top of the page shows the currently loaded tool's active offsets (fed by the `gmoccapy.tooloffset-x` and `gmoccapy.tooloffset-z` HAL pins).
### Tool Change Dialog
When a program executes `M6`, GMOCCAPY pops up a dialog showing the tool number and its description from the tool table comment. The operator physically changes the tool and clicks OK (or presses a physical confirm button wired to `gmoccapy.toolchange-confirm`).
Our config currently uses `hal_manualtoolchange` instead of GMOCCAPY's built-in dialog (wired in `lagun.hal`). The behavior is similar — a popup appears, operator confirms.
### Auto Tool Measurement (not currently configured)
GMOCCAPY supports automatic tool length measurement using a fixed probe on the machine table. This requires:
1. A `[TOOLSENSOR]` INI section with the probe's machine coordinates
2. A `[CHANGE_POSITION]` INI section for safe tool-change position
3. Remapping M6 to a `change.ngc` script that probes after each tool swap
4. The probe input wired to `motion.probe-input`
When enabled, every M6 automatically: moves to the change position, swaps the tool, drives to the probe, measures the tool, stores the offset with `G10 L1`, and activates it with `G43`. This eliminates manual tool touch-off.
We don't have this set up yet, but it's a natural next step if a tool setter is installed on the machine.
---
## Named Parameters for Tool Info
| Parameter | Value |
|-----------|-------|
| `#<_current_tool>` | Tool number in the spindle |
| `#<_selected_tool>` | Tool number from last `T` word (before M6) |
| `#5400` | Same as `#<_current_tool>` |
| `#5401``#5409` | Active TLO values (X through W) |
| `#5410` | **Tool diameter** of current tool (D column value) |
### About `#<_td>` in our macros
`#<_td>` is **not** a built-in LinuxCNC parameter. It is a user-defined global that our macros read for tool diameter. Programs must set it manually:
```gcode
#<_td> = [3/16] ; 3/16" endmill
```
A future improvement would be to replace `#<_td>` with `#5410` (the built-in diameter parameter), but this requires proper tool table setup with correct D values and a `T M6 G43` sequence before cutting.
---
## Quick Reference
### Full setup with tool change and cutter comp
```gcode
G10 L1 P1 Z-2.5 R[1/4/2] ; tool 1: Z offset and 1/4" endmill radius
T1 M6 ; load tool 1
G43 ; activate TLO
G41 ; cutter comp left (uses tool 1's D from table)
F10
G1 X0 Y0 ; lead-in (>= tool radius long)
G1 X2 Y0 ; cut along edge
G40 ; cancel comp (with lead-out move)
G0 X-1 Y-1
```
### Touch off tool length
```gcode
T1 M6 ; load tool
; jog Z down until tool touches top of workpiece
G10 L10 P1 Z0 ; store: "this position = Z0"
G43 ; activate the new offset
```
### Touch off work zero
```gcode
; jog to front-left corner of stock
G10 L20 P1 X0 Y0 ; set G54 origin here
; jog Z to top of stock
G10 L20 P1 Z0 ; set G54 Z origin here
```
### Our current macro workflow
```gcode
#<_td> = [1/4] ; tell macros the tool is 1/4"
#<_z_top> = 0.05
#<_z_bot> = -0.25
#<_z_clearance> = 0.2
G10 L1 P1 Z0.0 R[1/4/2] ; also set it in the table for cutter comp
T1 M6
G43
M03
F5
o<pocket_circ> call [0][0] [1.0] [0] [0]
```

View File

@@ -1,36 +0,0 @@
; Helical bore subroutine - cuts a circular hole by helical interpolation
; Params: #1=x, #2=y, #3=diameter, #4=zstart, #5=zend, #6=stepdown
; Uses #<_td> (tool diameter) to compute offset radius
o<bore> sub
; x, y, d, stepdown, zstart, zend
G90
G91.1
G0 X#1 Y#2
G0 Z#4
G1 X[#1+#3/2-#<_td>/2] Y[#2] ; move to bore edge, compensated for tool radius
G17
#<r> = [#3/2-#<_td>/2] ; effective bore radius (bore radius minus tool radius)
#<z> = [#4-#6]
o101 while [#<z> GT #5] ; helical passes, one full circle per stepdown
G3 X[#1+#<r>] Y[#2] I[-#<r>] Z[#<z>] P1
#<z> = [#<z> - #6]
o101 endwhile
o102 if [#4 GT #5] ; partial final pass to reach exact zend
#<ang> = [[#<z>-#5]/#6*360] ; angle where remaining depth is consumed
G3 X[#1+COS[#<ang>]*#<r>] Y[#2+SIN[#<ang>]*#<r>] I[-#<r>] Z[#5]
G3 X[#1+COS[#<ang>]*#<r>] Y[#2+SIN[#<ang>]*#<r>] I[-COS[#<ang>]*#<r>] J[-SIN[#<ang>]*#<r>] Z[#5] ; cleanup pass at final depth
;G3 X#1 Y[#2+#3/2-#<_td>/2] J[-#3/2+#<_td>/2]
o102 endif
G0 X#1 Y#2
G0 Z0
o<bore> endsub
M2

View File

@@ -1,37 +0,0 @@
; Peck drill subroutine - drills with retract cycles to clear chips
; Params: #1=x, #2=y, #3=zstart, #4=zend, #5=peck_depth
o<drill> sub
; x1, y1, zstart, zend, peckdp
; #1 #2 #3 #4 #5
G90 ; absolute x,y,z
M101 ; enable Z-axis (M102 disables)
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>
o1 else
#<z_clearance> = #3
o1 endif
;;;;;;;;;; PROGRAM ;;;;;;;;;
G0 Z#<z_clearance>
G0 X#1 Y#2
G0 Z#3
o104 if [#5 NE 0] ; peck drilling
#<h> = #3
o101 while [#<h> GT #4]
G1 Z#<h> ; drill to current peck depth
G0 Z#3 ; retract to clear chips
G0 Z[#<h>+.02] ; rapid back down, stopping just above previous depth
#<h> = [#<h>-#5]
o101 endwhile
o104 endif
G1 Z#4
G0 Z#<z_clearance>
o<drill> endsub
M2

View File

@@ -1,18 +0,0 @@
; Manual drill positioning - moves to X/Y, disables Z for manual quill, then pauses
; Params: #1=x, #2=y
o<drill_man> sub
; x1, y1
; #1 #2
G90 ; absolute x,y,z
M102 ; disable Z-axis (M101 enables)
;;;;;;;;;; PROGRAM ;;;;;;;;;
G0 X#1 Y#2
M0 ; pause
o<drill_man> endsub
M2

View File

@@ -1,28 +0,0 @@
; Semi-manual drill with Z retract - positions X/Y, retracts Z, pauses for manual drill
; Params: #1=x, #2=y, #3=z_clearance
; BUG: endsub name (drill_man_retract) doesn't match sub name (drill_retr)
o<drill_retr> sub
; x1, y1, z_clr
; #1 #2, #3
G90 ; absolute x,y,z
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>
o1 else
#<z_clearance> = #3
o1 endif
;;;;;;;;;; PROGRAM ;;;;;;;;;
M101 ; enable Z for CNC retract
G0 Z#<z_clearance>
G0 X#1 Y#2
M102 ; disable Z-axis (M101 enables)
M0 ; pause for manual drilling
M101 ; re-enable Z for retract
G0 Z#<z_clearance>
o<drill_man_retract> endsub
M2

View File

@@ -23,7 +23,7 @@ o<end_angle> sub
#<M_INSIDE> = [FIX[#9/8] MOD 2 EQ 0]
#<td> = #<_td>
#<td> = #5410
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>

View File

@@ -32,7 +32,7 @@ o<end_bull> sub
#<M_INSIDE> = [FIX[#<mode>/8] MOD 2 EQ 0]
#<td> = #<_td>
#<td> = #5410
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>

View File

@@ -23,7 +23,7 @@ o<end_cope> sub
#<M_INSIDE> = [FIX[#8/8] MOD 2 EQ 0]
#<td> = #<_td>
#<td> = #5410
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>

View File

@@ -23,7 +23,7 @@ o<end_round> sub
#<M_INSIDE> = [FIX[#8/8] MOD 2 EQ 0]
#<td> = #<_td>
#<td> = #5410
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>

View File

@@ -6,7 +6,7 @@ o<face> sub
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = #<_td>
#<td> = #5410
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>

View File

@@ -1,82 +0,0 @@
; Circle perimeter cut - cuts inside or outside a circular profile
; Params: #1=x, #2=y, #3=diameter, #4=ztop, #5=zbot, #6=fincut, #7=mode
; Mode bitmask: bit0=conventional, bit1=bothways, bit2=plunge(vs helix), bit3=outside
; Uses arc lead-in/lead-out for smooth entry and exit
o<frame_circ> sub
; o<frame_circ> call [x][y] [diameter] [ztop][zbot] [fincut] [mode]
#<M_CONVENTIONAL> = [FIX[#7/1] MOD 2 EQ 1]
#<M_BOTHWAYS> = [FIX[#7/2] MOD 2 EQ 1]
#<M_PLUNGE> = [FIX[#7/4] MOD 2 EQ 1]
#<M_OUTSIDE> = [FIX[#7/8] MOD 2 EQ 1]
#<M_CLIMB> = [FIX[#7/1] MOD 2 EQ 0]
#<M_ONEWAY> = [FIX[#7/2] MOD 2 EQ 0]
#<M_HELIX> = [FIX[#7/4] MOD 2 EQ 0]
#<M_INSIDE> = [FIX[#7/8] MOD 2 EQ 0]
;G10 L0 ; re-read tool data
G90 ; absolute x,y,z
G90.1 ; absolute i,j,k
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = #<_td>
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>
o1 else
#<z_clearance> = #4
o1 endif
#<r_entry> = #<tr> ; lead-in arc radius, capped at 15% of diameter
o10 if [#<r_entry> GT #3*0.15]
#<r_entry> = [#3*0.15]
o10 endif
G0 Z#<z_clearance>
o20 if [#<M_INSIDE> AND #<M_CONVENTIONAL>]
; conventional, inner
G0 X[#1-#<r_entry>] Y[#2 + #3/2 - #<tr> - #<r_entry>]
G0 Z#4
G1 Z#5
G2 X#1 Y[#2 + #3/2 - #<tr>] I#1 J[#2 + #3/2 - #<tr> - #<r_entry>]
G2 X#1 Y[#2 + #3/2 - #<tr>] I#1 J#2
G2 X[#1+#<r_entry>] Y[#2 + #3/2 - #<tr> - #<r_entry>] I#1 J[#2 + #3/2 - #<tr> - #<r_entry>]
o20 elseif [#<M_INSIDE> AND #<M_CLIMB>]
; climb, inner
G0 X[#1+#<r_entry>] Y[#2 + #3/2 - #<tr> - #<r_entry>]
G0 Z#4
G1 Z#5
G3 X#1 Y[#2 + #3/2 - #<tr>] I#1 J[#2 + #3/2 - #<tr> - #<r_entry>]
G3 X#1 Y[#2 + #3/2 - #<tr>] I#1 J#2
G3 X[#1-#<r_entry>] Y[#2 + #3/2 - #<tr> - #<r_entry>] I#1 J[#2 + #3/2 - #<tr> - #<r_entry>]
o20 elseif [#<M_OUTSIDE> AND #<M_CONVENTIONAL>]
; conventional, outer
G0 X[#1+#<r_entry>] Y[#2 + #3/2 + #<tr> + #<r_entry>]
G0 Z#4
G1 Z#5
G2 X#1 Y[#2 + #3/2 + #<tr>] I#1 J[#2 + #3/2 + #<tr> + #<r_entry>]
G3 X#1 Y[#2 + #3/2 + #<tr>] I#1 J#2
G2 X[#1-#<r_entry>] Y[#2 + #3/2 + #<tr>+ #<r_entry>] I#1 J[#2 + #3/2 + #<tr> + #<r_entry>]
o20 elseif [#<M_OUTSIDE> AND #<M_CLIMB>]
; climb, outer
G0 X[#1-#<r_entry>] Y[#2 + #3/2 + #<tr> + #<r_entry>]
G0 Z#4
G1 Z#5
G3 X#1 Y[#2 + #3/2 + #<tr>] I#1 J[#2 + #3/2 + #<tr> + #<r_entry>]
G2 X#1 Y[#2 + #3/2 + #<tr>] I#1 J#2
G3 X[#1+#<r_entry>] Y[#2 + #3/2 + #<tr>+ #<r_entry>] I#1 J[#2 + #3/2 + #<tr> + #<r_entry>]
o20 endif
G0 Z#<z_clearance>
o<frame_circ> endsub
M2

View File

@@ -1,162 +0,0 @@
; Rectangle perimeter cut - cuts inside or outside a rectangular frame
; Params: #1=x1, #2=y1, #3=x2, #4=y2, #5=ztop, #6=zbot, #7=mode, #8=corner_radius
; Mode bitmask: bit0=conventional, bit1=bothways, bit2=plunge(vs helix), bit3=outside
o<frame_rect> sub
; o<frame_rect> call [x1][y1] [x2][y2] [ztop][zbot] [mode] [radius]
#<M_CONVENTIONAL> = [FIX[#7/1] MOD 2 EQ 1]
#<M_BOTHWAYS> = [FIX[#7/2] MOD 2 EQ 1]
#<M_PLUNGE> = [FIX[#7/4] MOD 2 EQ 1]
#<M_OUTSIDE> = [FIX[#7/8] MOD 2 EQ 1]
#<M_CLIMB> = [FIX[#7/1] MOD 2 EQ 0]
#<M_ONEWAY> = [FIX[#7/2] MOD 2 EQ 0]
#<M_HELIX> = [FIX[#7/4] MOD 2 EQ 0]
#<M_INSIDE> = [FIX[#7/8] MOD 2 EQ 0]
;G10 L0 ; re-read tool data
G90 ; absolute x,y,z
G91.1 ; incremental i,j,k
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = #<_td>
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>
o1 else
#<z_clearance> = #4
o1 endif
#<minx> = #1
#<maxx> = #3
o3 if [#3 LT #1]
#<minx> = #3
#<maxx> = #1
o3 endif
#<miny> = #2
#<maxy> = #4
o4 if [#4 LT #2]
#<miny> = #4
#<maxy> = #2
o4 endif
G0 Z#<z_clearance>
o10 if [#<M_INSIDE> AND #<M_CONVENTIONAL>]
; CW inside: plunge in center, traverse to wall, trace perimeter
G0 X[[#1+#3]/2] Y[[#2+#4]/2]
G0 Z#5
G1 Z#6
G1 X[#<maxx>-#<tr>]
o102 if [#8 GT #<tr>]
G1 Y[#<miny>+#8]
G2 X[#<maxx>-#8] Y[#<miny>+#<tr>] J0 I[-#8+#<tr>]
G1 X[#<minx>+#8]
G2 Y[#<miny>+#8] X[#<minx>+#<tr>] I0 J[+#8-#<tr>]
G1 Y[#<maxy>-#8]
G2 X[#<minx>+#8] Y[#<maxy>-#<tr>] J0 I[+#8-#<tr>]
G1 X[#<maxx>-#8]
G2 Y[#<maxy>-#8] X[#<maxx>-#<tr>] I0 J[-#8+#<tr>]
o102 else
G1 Y[#<miny>+#<tr>]
G1 X[#<minx>-#<tr>]
G1 Y[#<maxy>-#<tr>]
G1 X[#<maxx>-#<tr>]
G1 Y[#<miny>+#<tr>]
o102 endif
G1 Y[[#2+#4]/2]
; go to center and pull out
G0 X[[#1+#3]/2] Y[[#2+#4]/2]
G0 Z#5
o10 elseif [#<M_INSIDE> AND #<M_CLIMB>]
; CCW inside: plunge in center, trace perimeter counterclockwise
G0 X[[#1+#3]/2] Y[[#2+#4]/2]
G0 Z#5
G1 Z#6
G1 X[#<maxx>-#<tr>]
o101 if [#8 GT #<tr>]
G1 Y[#<maxy>-#8]
G3 X[#<maxx>-#8] Y[#<maxy>-#<tr>] J0 I[-#8+#<tr>]
G1 X[#<minx>+#8]
G3 Y[#<maxy>-#8] X[#<minx>+#<tr>] I0 J[-#8+#<tr>]
G1 Y[#<miny>+#8]
G3 X[#<minx>+#8] Y[#<miny>+#<tr>] J0 I[+#8-#<tr>]
G1 X[#<maxx>-#8]
G3 Y[#<miny>+#8] X[#<maxx>-#<tr>] I0 J[+#8-#<tr>]
o101 else
G1 Y[#<maxy>-#<tr>]
G1 X[#<minx>+#<tr>]
G1 Y[#<miny>+#<tr>]
G1 X[#<maxx>-#<tr>]
G1 Y[#<maxy>-#<tr>]
o101 endif
G1 Y[[#2+#4]/2]
; go to center and pull out
G0 X[[#1+#3]/2] Y[[#2+#4]/2]
G0 Z#5
o10 elseif [#<M_OUTSIDE> AND #<M_CONVENTIONAL>]
; CW outside: plunge at corner, trace perimeter offset outward
G0 X[#<minx>-#<tr>] Y[#<maxy>+#<tr>]
G0 Z#5
G1 Z#6
o104 if [#8 GT 0]
G1 Y[#<miny>+#8]
G3 X[#<minx>+#8] Y[#<miny>-#<tr>] J0 I[+#8+#<tr>]
G1 X[#<maxx>-#8]
G3 Y[#<miny>+#8] X[#<maxx>+#<tr>] I0 J[+#8+#<tr>]
G1 Y[#<maxy>-#8]
G3 X[#<maxx>-#8] Y[#<maxy>+#<tr>] J0 I[-#8-#<tr>]
G1 X[#<minx>+#8]
G3 Y[#<maxy>-#8] X[#<minx>-#<tr>] I0 J[-#8-#<tr>]
o104 else
G1 Y[#<miny>-#<tr>]
G1 X[#<maxx>+#<tr>]
G1 Y[#<maxy>+#<tr>]
G1 X[#<minx>-#<tr>]
o104 endif
G0 Z#5
o10 elseif [#<M_OUTSIDE> AND #<M_CLIMB>]
; CCW outside: plunge at corner, trace perimeter offset outward
G0 X[#<minx>-#<tr>] Y[#<miny>-#<tr>]
G0 Z#5
G1 Z#6
o103 if [#8 GT 0]
G1 Y[#<maxy>-#8]
G2 X[#<minx>+#8] Y[#<maxy>+#<tr>] J0 I[+#8+#<tr>]
G1 X[#<maxx>-#8]
G2 Y[#<maxy>-#8] X[#<maxx>+#<tr>] I0 J[-#8-#<tr>]
G1 Y[#<miny>+#8]
G2 X[#<maxx>-#8] Y[#<miny>-#<tr>] J0 I[-#8-#<tr>]
G1 X[#<minx>+#8]
G2 Y[#<miny>+#8] X[#<minx>-#<tr>] I0 J[+#8+#<tr>]
o103 else
G1 Y[#<maxy>+#<tr>]
G1 X[#<maxx>+#<tr>]
G1 Y[#<miny>-#<tr>]
G1 X[#<minx>-#<tr>]
o103 endif
G0 Z#5
o10 endif
o<frame_rect> endsub
M2

View File

@@ -16,7 +16,7 @@ o<frame_rect> sub
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = #<_td>
#<td> = #5410
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>

View File

@@ -16,7 +16,7 @@ o<helical_plunge> sub
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = #<_td>
#<td> = #5410
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>
o1 else

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = 0.5
#<_rampang> = 10
#<_td> = [5/8]
;#<_stepover> = 0.1
;#<_overlap> = 0
@@ -17,13 +16,15 @@ G54 ; absolute coordinates
F5
o<drill> call [5][-0.625] [0.1][-0.3]
o<drill> call [3][-0.625] [0.1][-0.3]
o<drill> call [1][-0.625] [0.1][-0.3]
o<drill> call [-1][-0.625] [0.1][-0.3]
o<drill> call [-3][-0.625] [0.1][-0.3]
o<drill> call [-5][-0.625] [0.1][-0.3]
o<drill> call [-7][-0.625] [0.1][-0.3]
o<drill> call [-9][-0.625] [0.1][-0.3]
#<_z_top> = 0.1
#<_z_bot> = -0.3
o<drill> call [5][-0.625]
o<drill> call [3][-0.625]
o<drill> call [1][-0.625]
o<drill> call [-1][-0.625]
o<drill> call [-3][-0.625]
o<drill> call [-5][-0.625]
o<drill> call [-7][-0.625]
o<drill> call [-9][-0.625]
M2 ; end program

View File

@@ -2,9 +2,11 @@
Custom M-codes and G-code subroutines for the Lagun mill LinuxCNC configuration.
All macro `.ngc` files live in `nc_files/subs/` and are loaded automatically via the `SUBROUTINE_PATH` setting in the INI.
## Mode Flags (Bitmask)
Several macros (`pocket_circ`, `pocket_rect`, `frame_rect`, `frame_circ`, `slot`) accept a `mode` parameter as a bitmask:
All material-removal macros (except drill/bore) take `mode` as the **first argument**:
| Bit | Value | Set (1) | Clear (0) |
|-----|-------|---------|-----------|
@@ -17,16 +19,17 @@ Default mode (0) = climb, one-way, helix entry, inside.
## Global Named Parameters
These optional globals configure macro behavior when set before calling:
| Parameter | Description | Required? |
|-----------|-------------|-----------|
| `#<_z_top>` | Top of material / start Z height | **Required** |
| `#<_z_bot>` | Final cut depth | **Required** |
| `#<_z_clearance>` | Safe Z retract height | Optional, falls back to `#<_z_top>` |
| `#<_rampang>` | Helix entry angle in degrees | Optional, defaults to 5.0 |
| `#<_stepover>` | Stepover distance | Optional, defaults to 40% of tool diameter |
| Parameter | Description | Default |
|-----------|-------------|---------|
| `#<_td>` | Tool diameter (from tool table) | **Required** - used by all material-removal macros |
| `#<_z_clearance>` | Safe Z retract height | Falls back to ztop param |
| `#<_rampang>` | Ramp/helix entry angle in degrees | 5.0 |
| `#<_stepover>` | Stepover distance for spiral pocketing | 40% of tool diameter |
Tool diameter is read automatically from `#5410` (the built-in LinuxCNC parameter for the current tool's diameter from the tool table). A tool must be loaded (`T M6 G43`) before calling any material-removal macro.
A negative `fincut` value causes macros to rough only, leaving material for a separate finishing pass.
A negative `fincut` value causes macros to rough only, leaving that amount of material for a separate finishing pass.
## M-Codes (Shell Scripts)
@@ -36,192 +39,117 @@ Sets HAL signal `z-override` to True, enabling CNC control of Z.
### M102 - Disable Z-Axis
Sets HAL signal `z-override` to False, allowing manual quill control.
## Utility Subroutines
### z_home - Rapid to Machine Z0
Rapids the quill to machine Z=0 (fully up) using G53 to bypass all offsets.
```
o<z_home> call
```
## Drilling Subroutines
### drill.ngc - Peck Drill
Fully automatic drilling with optional peck cycle.
### drill - Peck Drill
```
o<drill> call [x][y] [ztop][zbot] [peck]
o<drill> call [x][y] [peck]
```
| # | Name | Description |
|---|------|-------------|
| #1 | X | Hole X position |
| #2 | Y | Hole Y position |
| #3 | Z Start | Top of material / start Z |
| #4 | Z End | Final drill depth |
| #5 | Peck | Depth per peck (0 = no peck) |
Calls M101 to enable Z. Retracts to Z Top between pecks with 0.020" rapid-approach gap.
Calls M101 to enable Z-axis. Retracts to Z Start between pecks with 0.020" rapid-approach gap.
### drill_man.ngc - Manual Drill
Positions XY then pauses for operator to manually plunge.
### drill_man - Manual Drill
```
o<drill_man> call [x][y]
```
Calls M102 to disable Z-axis, then M0 pause.
Calls M102 to disable Z, then M0 pause. No Z globals needed.
### drill_retr.ngc - Semi-Manual Drill with Retract
Positions XY, retracts Z to clearance, disables Z for manual plunge, then re-enables and retracts on resume.
### drill_retr - Semi-Manual Drill with Retract
```
o<drill_retr> call [x][y] [z_clearance]
o<drill_retr> call [x][y]
```
## Material Removal Subroutines
### pocket_circ.ngc - Circular Pocket
Cuts a circular pocket using an outward spiral from center.
### pocket_circ - Circular Pocket
```
o<pocket_circ> call [x][y] [diameter] [ztop][zbot] [fincut] [mode]
o<pocket_circ> call [mode] [x][y] [diameter] [fincut]
```
| # | Name | Description |
|---|------|-------------|
| #1 | X | Center X |
| #2 | Y | Center Y |
| #3 | Diameter | Pocket diameter |
| #4 | Z Top | Start Z |
| #5 | Z Bottom | Final depth |
| #6 | Finish Cut | Finish allowance (negative = rough only) |
| #7 | Mode | Bitmask (see above) |
Supports helix or plunge entry. Spirals outward with stepover, then does a pre-finish circle and optional finish circle at full diameter.
### pocket_rect.ngc - Rectangular Pocket
Cuts a rectangular pocket. Uses helical or straight plunge, then an outward spiral that transitions to linear passes when the spiral hits the rectangle boundary.
### pocket_rect - Rectangular Pocket (Zigzag)
```
o<pocket_rect> call [x1][y1] [x2][y2] [zstart][zend] [fincut] [mode]
o<pocket_rect> call [mode] [x1][y1] [x2][y2] [fincut]
```
| # | Name | Description |
|---|------|-------------|
| #1,#2 | X1, Y1 | First corner |
| #3,#4 | X2, Y2 | Opposite corner |
| #5 | Z Start | Start Z |
| #6 | Z End | Final depth |
| #7 | Finish Cut | Finish allowance |
| #8 | Mode | 0=CCW/helix, 1=CW/helix, 2=CCW/plunge, 3=CW/plunge |
Zigzag along the long axis, stepping by `#<_stepover>`. Perimeter cleanup pass at the end.
Contains internal sub `o<xp>` for filling corners after the spiral exceeds the rectangle bounds.
### frame_rect.ngc - Rectangular Frame
Cuts along the perimeter of a rectangle (inside or outside).
### frame_rect - Rectangular Frame
```
o<frame_rect> call [x1][y1] [x2][y2] [ztop][zbot] [mode] [radius]
o<frame_rect> call [mode] [x1][y1] [x2][y2] [radius]
```
| # | Name | Description |
|---|------|-------------|
| #1,#2 | X1, Y1 | First corner |
| #3,#4 | X2, Y2 | Opposite corner |
| #5 | Z Top | Start Z |
| #6 | Z Bottom | Final depth |
| #7 | Mode | Bitmask |
| #8 | Radius | Corner radius (0 = sharp corners) |
Supports all four combinations of inside/outside and climb/conventional. Plunges at center (inside) or corner (outside), then traces the rectangle with optional corner radii.
### frame_circ.ngc - Circular Frame
Cuts along the perimeter of a circle (inside or outside).
### frame_circ - Circular Frame
```
o<frame_circ> call [x][y] [diameter] [ztop][zbot] [fincut] [mode]
o<frame_circ> call [mode] [x][y] [diameter] [fincut]
```
| # | Name | Description |
|---|------|-------------|
| #1 | X | Center X |
| #2 | Y | Center Y |
| #3 | Diameter | Circle diameter |
| #4 | Z Top | Start Z |
| #5 | Z Bottom | Final depth |
| #6 | Finish Cut | Finish allowance |
| #7 | Mode | Bitmask |
Uses a small arc entry/exit move (capped at 15% of diameter) for smooth engagement.
### slot.ngc - Slot
Cuts a slot (obround/stadium shape) between two points.
### slot - Slot / Obround
```
o<slot> call [x1][y1] [x2][y2] [width] [ztop][zbot] [fincut] [mode]
o<slot> call [mode] [x1][y1] [x2][y2] [width] [fincut]
```
| # | Name | Description |
|---|------|-------------|
| #1,#2 | X1, Y1 | Slot start center |
| #3,#4 | X2, Y2 | Slot end center |
| #5 | Width | Slot width |
| #6 | Z Top | Start Z |
| #7 | Z Bottom | Final depth |
| #8 | Finish Cut | Finish allowance |
| #9 | Mode | Bitmask |
Plunges at start, cuts to end, then traces the obround profile. Supports optional pre-finish pass when fincut > 0.
### bore.ngc - Helical Bore
Helical-interpolation boring subroutine.
### bore - Helical Bore
```
o<bore> call [x][y] [d] [zstart][zend] [stepdown]
o<bore> call [x][y] [d] [stepdown]
```
| # | Name | Description |
|---|------|-------------|
| #1 | X | Center X |
| #2 | Y | Center Y |
| #3 | D | Bore diameter |
| #4 | Z Start | Start Z |
| #5 | Z End | Final depth |
| #6 | Stepdown | Depth per helical pass |
No mode arg. Uses `#<_z_top>`, `#<_z_bot>`, and `#5410`.
Spirals down in full-circle passes, then does a partial-arc cleanup and spring pass at final depth. Returns to center and Z0.
### poly_frame - Polygon Perimeter
```
o<poly_frame> call [mode] [x][y] [n_sides] [apothem] [rotation] [fincut]
```
Apothem = flat-to-flat / 2. Rotation in degrees (0 = first vertex on +X, CCW positive).
### poly_pocket - Polygon Pocket
```
o<poly_pocket> call [mode] [x][y] [n_sides] [apothem] [rotation] [fincut]
```
## Typical Program Header
```
#<_z_clearance> = 0.0
```gcode
#<_z_clearance> = 0.2
#<_rampang> = 5.0
#<_z_top> = 0.05
#<_z_bot> = -0.25
G10 L1 P1 Z0.0 R0.25 ; set tool P1 offset and radius
T1 ; select tool
M06 ; manual toolchange
G10 L1 P1 Z0.0 R0.125 ; set tool 1 offset and 1/4" radius
T1 M6 ; load tool (sets #5410 = 0.250)
G43 ; activate TLO
M101 ; enable z-axis
G90 ; absolute coordinates
G54 ; fixture #1
M101 ; enable z-axis
G90 ; absolute coordinates
G54 ; fixture #1
F5.0 ; feedrate
F5.0 ; feedrate
o<pocket_circ> call [0] [0][0] [1.0] [0]
```
## Known Bugs
## Known Bugs & Limitations
1. **drill_retr.ngc: Sub name mismatch.** Opened as `o<drill_retr>` (line 1) but closed as `o<drill_man_retract>` (line 23). This will cause a runtime error - LinuxCNC requires matching sub/endsub names.
1. **Some combinations of values cause hangs.** LinuxCNC has no stall/timeout detection; a macro stuck in an infinite loop hangs the whole machine. Iteration limits have been added to pocket_circ's spiral loop as a safety measure.
2. **bore.ngc: Parameter comment is wrong.** The inline comment says `; x, y, d, stepdown, zstart, zend` but the actual parameter order used by the code is `x, y, d, zstart, zend, stepdown`. Anyone calling based on the comment would get wrong results.
3. **bore.ngc: Undocumented `#<_td>` dependency.** Uses global `#<_td>` for tool-diameter compensation but never validates it. If unset (defaults to 0), the bore toolpath radius becomes `D/2` instead of `(D - tool_dia)/2`, cutting an oversized bore.
4. **drill.ngc: First peck cycle is a no-op.** The loop initializes `#<h> = #3` (Z Start) then immediately does `G1 Z#<h>` - moving to where the tool already is. First real cut happens on the second iteration. Wastes one retract cycle.
5. **pocket_circ.ngc: Suspicious angle calculation.** Line 66 has a `TODO` comment from the author: `; TODO: what the heck is the denominator here doing?` The finish-plunge angle divides by `[#4-#5]` (ztop - zbot). If ztop is 0 this produces a division by a potentially small number, which may cause unexpected arc endpoints.
6. **pocket_rect.ngc: Incomplete rectangular clearing.** The spiral-to-rectangle transition has commented-out code (lines 141-151) and a note saying "subroutines might be the best way to do this". The `o<xp>` helper sub attempts to fill the remaining area but uses a different algorithm. Corners may not be fully cleared depending on geometry.
7. **slot.ngc: Test code after endsub.** Lines 79-83 contain hardcoded test calls that execute whenever the file is loaded. These should be removed or moved to a separate test file. The test calls also only provide 7 of 9 parameters (fincut and mode default to 0).
8. **frame_circ.ngc: lead-in arcs can be larger than actual pocket size.** this causes overcutting. not good.
9. **some combination of values will cause hangs.** This is in several macros. linuxcnc does not have stall/timeout detection; if a macro gets stuck in an infinite loop, it hangs linuxcnc.
## Other Todos
1. Change macros to use UPPERCASE_WITH_UNDERSCORES naming (both the filenames, and the usage of them in all .ngc files)
2. Purge all .cnc programs
3. Maybe: Use tool diameter instead of the td global. (we will use tool change stuff)
2. **Slot arc directions may be wrong under some combinations** — inverted arc ends seen under certain mode/geometry combinations.

View File

@@ -1,134 +0,0 @@
; Circular pocket - clears a round pocket using spiral toolpath
; Params: #1=x, #2=y, #3=diameter, #4=ztop, #5=zbot, #6=finishcut, #7=mode
; Mode bitmask: bit0=conventional, bit1=bothways, bit2=plunge(vs helix), bit3=outside
o<pocket_circ> sub
; o<pocket_circ> call [x][y] [diameter] [ztop][zbot] [finishcut] [mode]
#<M_CONVENTIONAL> = [FIX[#7/1] MOD 2 EQ 1]
#<M_BOTHWAYS> = [FIX[#7/2] MOD 2 EQ 1]
#<M_PLUNGE> = [FIX[#7/4] MOD 2 EQ 1]
#<M_OUTSIDE> = [FIX[#7/8] MOD 2 EQ 1]
#<M_CLIMB> = [FIX[#7/1] MOD 2 EQ 0]
#<M_ONEWAY> = [FIX[#7/2] MOD 2 EQ 0]
#<M_HELIX> = [FIX[#7/4] MOD 2 EQ 0]
#<M_INSIDE> = [FIX[#7/8] MOD 2 EQ 0]
G90 ; absolute x,y,z
G90.1 ; absolute i,j,k
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = [#<_td>]
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>
o1 else
#<z_clearance> = #4
o1 endif
o2 if [EXISTS[#<_rampang>]]
#<rampang> = #<_rampang>
o2 else
#<rampang> = 5 ; degrees
o2 endif
o3 if [EXISTS[#<_stepover>]]
#<stepover> = #<_stepover>
o3 else
#<stepover> = [#<td>*0.4]
o3 endif
o4 if [#<td> GT #3] ; tool bigger than pocket, bail out
o5 return
o4 endif
#<a> = 0
#<r> = 0
o100 if [#<M_HELIX>] ; helical plunge
#<r> = [#<td>*0.3] ; helix radius = 30% of tool diameter
o115 if [[[#3-#<td>]/2-ABS[#6]] LE #<r>] ; shrink if helix would exceed pocket wall
#<r> = [[[#3-#<td>]/2-ABS[#6]]*0.8]
o115 endif
#<z_step> = [#<r>*2*3.14*TAN[#<rampang>]]
G0 Z#<z_clearance>
G0 X[#1+#<r>] Y[#2]
G0 Z#4
; helical plunge
#<z> = [#4-#<z_step>]
o101 while [#<z> GT #5]
o102 if [#<M_CLIMB>]
G3 X[#1+#<r>] Y[#2] I[#1] J[#2] Z[#<z>] P1
o102 else
G2 X[#1+#<r>] Y[#2] I[#1] J[#2] Z[#<z>] P1
o102 endif
#<z> = [#<z> - #<z_step>]
o101 endwhile
; finish the helical plunge
#<a> = [[#<z>-#5]/[#4-#5]*360] ; TODO: what the heck is the denominator here doing?
o103 if [#<M_CLIMB>]
G3 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>] I[#1] J[#2] Z[#5]
G3 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>] I[#1] J[#2] Z[#5]
o103 else
G2 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>] I[#1] J[#2] Z[#5]
G2 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>] I[#1] J[#2] Z[#5]
o103 endif
o100 elseif [#<M_PLUNGE>] ; straight plunge
G0 Z#<z_clearance>
G0 X[#1] Y[#2]
G0 Z[#4]
G1 Z[#5]
o100 endif
; spiral outward from center to clear pocket, stopping short by finishcut amount
#<r_base> = #<r>
#<a_base> = #<a>
o105 while [#<r> LT [[#3-#<td>]/2-ABS[#6]]]
o106 if [#<M_CLIMB>]
G1 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>]
o106 else
G1 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>]
o106 endif
#<a> = [#<a>+1] ; advance 1 degree per step
#<r> = [#<r_base>+[#<a>-#<a_base>]/360*#<stepover>] ; radius grows by stepover each revolution
o105 endwhile
; pre-finish cut: full circle at pocket wall minus finishcut allowance
#<r> = [[#3-#<td>]/2-ABS[#6]]
o107 if [#<M_CLIMB>]
G1 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>]
G3 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>] I[#1] J[#2]
o107 else
G1 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>]
G2 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>] I[#1] J[#2]
o107 endif
; finish cut: full circle at final pocket wall radius
o104 if [ABS[#6] GT 0.0]
#<r> = [[#3-#<td>]/2]
o108 if [#<M_CLIMB>]
G1 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>]
G3 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>] I[#1] J[#2]
#<r> = [[#3-#<td>]/2*0.9] ; retract slightly inward before rapid out
G1 X[#1+COS[#<a>]*#<r>] Y[#2+SIN[#<a>]*#<r>]
o108 else
G1 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>]
G2 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>] I[#1] J[#2]
#<r> = [[#3-#<td>]/2*0.9] ; retract slightly inward before rapid out
G1 X[#1+COS[#<a>]*#<r>] Y[#2-SIN[#<a>]*#<r>]
o108 endif
o104 endif
G0 Z#<z_clearance>
o<pocket_circ> endsub
M2

View File

@@ -1,228 +0,0 @@
; Rectangular pocket - clears using spiral then corner-clearing helper sub
; Params: #1=x1, #2=y1, #3=x2, #4=y2, #5=zstart, #6=zend, #7=fincut, #8=mode
; Mode: 0=CCW/ramp, 1=CW/ramp, 2=CCW/plunge, 3=CW/plunge
; pre-declare named params used across sub/helper scope
#<a> = 0
#<z> = 0
#<td> = 0
#<z_clearance> = 0
#<rampang> = 0
#<z_down> = 0
#<z_lift> = 0
#<minx> = 0
#<maxx> = 0
#<cx> = 0
#<cy> = 0
#<rx> = 0
#<ry> = 0
o<pocket_rect> sub
; x1, y1, x2, y2, zstart, zend, fincut, mode
; #1 #2 #3 #4 #5 #6 #7 #8
; modes:
; 0: CCW, ramped plunge
; 1: CW, ramped plunge
; 2: CCW, straight plunge
; 3: CW, straight plunge
G90 ; absolute x,y,z
G90.1 ; absolute i,j,k
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = #<_td>
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>
o1 else
#<z_clearance> = #5
o1 endif
o2 if [EXISTS[#<_rampang>]]
#<rampang> = #<_rampang>
o2 else
#<rampang> = 5 ; degrees
o2 endif
o3 if [EXISTS[#<_stepover>]]
#<stepover> = #<_stepover>
o3 else
#<stepover> = [#<td>*0.4]
o3 endif
#<z_down> = #6
#<z_lift> = [#6+#<td>*0.1] ; slight lift for repositioning moves
#<minx> = #1
#<maxx> = #3
o11 if [#3 LT #1]
#<minx> = #3
#<maxx> = #1
o11 endif
#<miny> = #2
#<maxy> = #4
o12 if [#4 LT #2]
#<miny> = #4
#<maxy> = #2
o12 endif
#<cx> = [[#<minx>+#<maxx>]/2] ; pocket center X
#<cy> = [[#<miny>+#<maxy>]/2] ; pocket center Y
#<rx> = [[[#<maxx>-#<minx>]-#<td>]/2] ; half-width minus tool radius
#<ry> = [[[#<maxy>-#<miny>]-#<td>]/2] ; half-height minus tool radius
G0 X#<cx> Y#<cy>
G1 X[#<cx>+#<rx>] Y[#<cy>-#<ry>]
G1 X[#<cx>-#<rx>] Y[#<cy>-#<ry>]
G1 X[#<cx>-#<rx>] Y[#<cy>+#<ry>]
G1 X[#<cx>+#<rx>] Y[#<cy>+#<ry>]
o100 if [[#8 EQ 0] OR [#8 EQ 1]] ; helical plunge
#<r> = [#<td>*0.3]
#<z_step> = [#<r>*2*3.14*TAN[#<rampang>]]
G0 Z#<z_clearance>
G0 X[#<cx>+#<r>] Y[#<cy>]
G0 Z#5
; helical plunge
#<z> = [#5-#<z_step>]
o101 while [#<z> GT #6]
o102 if [#8 EQ 0]
G3 X[#<cx>+#<r>] Y[#<cy>] I[#<cx>] J[#<cy>] Z[#<z>] P1
o102 else
G2 X[#<cx>+#<r>] Y[#<cy>] I[#<cx>] J[#<cy>] Z[#<z>] P1
o102 endif
#<z> = [#<z> - #<z_step>]
o101 endwhile
; finish the helical plunge
#<a> = [[#<z>-#6]/#5*360]
o103 if [#8 EQ 0]
G3 X[#<cx>+COS[#<a>]*#<r>] Y[#<cy>+SIN[#<a>]*#<r>] I[#<cx>] J[#<cy>] Z[#6]
G3 X[#<cx>+COS[#<a>]*#<r>] Y[#<cy>+SIN[#<a>]*#<r>] I[#<cx>] J[#<cy>] Z[#6]
o103 else
G2 X[#<cx>+COS[#<a>]*#<r>] Y[#<cy>-SIN[#<a>]*#<r>] I[#<cx>] J[#<cy>] Z[#6]
G2 X[#<cx>+COS[#<a>]*#<r>] Y[#<cy>-SIN[#<a>]*#<r>] I[#<cx>] J[#<cy>] Z[#6]
o103 endif
o100 elseif [[#8 EQ 2] OR [#8 EQ 3]] ; straight plunge
#<r> = 0
G0 Z#5
G0 X[#<cx>] Y[#<cy>]
G1 Z[#6]
o100 endif
; spiral outward from center until hitting pocket boundary
#<r_base> = #<r>
#<a_base> = #<a>
o105 while [1]
o106 if [[#8 MOD 2] EQ 0]
G1 X[#<cx>+COS[#<a>]*#<r>] Y[#<cy>+SIN[#<a>]*#<r>]
o106 else
G1 X[#<cx>+COS[#<a>]*#<r>] Y[#<cy>-SIN[#<a>]*#<r>]
o106 endif
#<a> = [#<a>+1] ; next angle
#<r> = [#<r_base>+[#<a>-#<a_base>]/360*#<stepover>] ; compute the radius accordingly
o110 if [ABS[COS[#<a>]*#<r>] GE [#<rx>-#7]]
; hit the x limit, y is still 'unbounded'
o105 BREAK
o110 elseif [ABS[SIN[#<a>]*#<r>] GE [#<ry>-#7]]
; hit the y limit, x is still 'unbounded'
o105 BREAK
o110 endif
o105 endwhile
; okay, let's run until we hit a limit
; then based on which limit was hit, run in the perp. direction
; then go into the negative of that direction
; subroutines might be the best way to do this??
; o200 while [#<r> LE 3]
; #<a> = [#<a>+1] ; next angle
;
;
; o201 if [[[COS[#<a>]*#<r> GE -#<rx>] AND [COS[#<a>]*#<r> LE #<rx>]] AND [[SIN[#<a>]*#<r> GE -#<ry>] AND [SIN[#<a>]*#<r> LE #<ry>]]]
; G1 X[#<cx>+COS[#<a>]*#<r>] Y[#<cy>+SIN[#<a>]*#<r>]
; o201 endif
;
; #<a> = [#<a>+0.5] ; next angle
; #<r> = [#<r_base>+[#<a>-#<a_base>]/360*#<stepover>] ; compute the radius accordingly
; o200 endwhile
o<xp> call ; clear corners that the spiral couldn't reach
G0 Z#<z_clearance>
o<pocket_rect> endsub
; if you can come up with a closed-form solution for x*sin(x) = c, you could drastically streamline this code. Until then... Lots of g1s.
; idea: bias the main spiral. then you're left with a section to hog out
; idea 2: make angle arbitrary (blowing up the code so it's not x-y specific). That'll be fun.
; Helper sub: clears rectangular corner material left by circular spiral
; Walks along the X-axis edge, tracing arcs that match the spiral boundary
o<xp> sub
#<ix> = 0
#<lastxx> = 0
#<run> = 1
o202 while [#<run>]
G0 Z#<z_lift>
G0 X#<cx> Y[#<cy> - #<ry>]
G1 Z#<z_down>
#<n_end> = FUP[sqrt[[#<ix>]**2 + [#<ry>]**2]/#<stepover>] ; spiral revolution number at this corner point
#<a> = ATAN[-#<ry>]/[#<ix>]
#<r_end> = [#<n_end>*#<stepover> + #<r_base>+[#<a>-#<a_base>]/360*#<stepover>]
#<r> = [#<ry>]
o200 while [#<r> LT #<r_end>]
G1 X[#<cx>+#<ix>] Y[#<cy>-#<ry>]
#<ix> = [#<ix> + 0.01]
#<a> = ATAN[-#<ry>]/[#<ix>]
#<r> = sqrt[[#<ix>]**2 + [#<ry>]**2]
#<r_end> = [#<n_end>*#<stepover> + #<r_base>+[#<a>-#<a_base>]/360*#<stepover>]
;#<r_end> = [FUP[sqrt[[#<ix>]**2 + [#<ry>]**2]/#<stepover>]*#<stepover>]
o204 if [#<ix> GT #<rx>]
#<run> = 0
o200 BREAK
o204 endif
o200 endwhile
#<lastx> = [COS[#<a>]*#<r>]
o201 while [SIN[#<a>]*#<r> LT #<ry>]
#<xtmp> = [COS[#<a>]*#<r>]
o205 if [#<xtmp> GT #<rx>]
#<xtmp> = [#<rx>]
o205 endif
G1 X[#<cx>+#<xtmp>] Y[#<cy>+SIN[#<a>]*#<r>]
#<a> = [#<a> + 1]
#<r> = [#<n_end>*#<stepover> + #<r_base>+[#<a>-#<a_base>]/360*#<stepover>]
o201 endwhile
G1 X[#<cx>+#<lastxx>] Y[#<cy>+#<ry>]
G0 Z#<z_lift>
G0 X[#<cx>+#<lastx>] Y[#<cy>-#<ry>]
#<ix> = #<lastx>
#<lastxx> = [COS[#<a>]*#<r>]
o202 endwhile
o<xp> endsub
M2

View File

@@ -15,7 +15,7 @@ o<pocket_rect_lin> sub
M101 ; enable Z-axis (M102 disables)
G17 ; select XY plane for arcs
#<td> = #<_td>
#<td> = #5410
#<tr> = [#<td>/2]
o1 if [EXISTS[#<_z_clearance>]]
#<z_clearance> = #<_z_clearance>

View File

@@ -17,9 +17,17 @@ F15 ; inch or mm/min (300 mm/min = about 1 ft/min)
#<zt> = +0.05
#<zb> = -0.3
o<drill> call [0.375][-0.375] [#<zt>][#<zb>]
o<drill> call [0.375+132/25.4][-0.375] [#<zt>][#<zb>]
o<pocket_circ> call [0.375+132/25.4+28/25.4][-0.375] [0.28] [#<zt>][#<zb>]
o<pocket_circ> call [0.375+132/25.4+28/25.4+2.75][-0.375] [0.28] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [0.375][-0.375]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [0.375+132/25.4][-0.375]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [0.375+132/25.4+28/25.4][-0.375] [0.28]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [0.375+132/25.4+28/25.4+2.75][-0.375] [0.28]
M2 ; end program

View File

@@ -19,17 +19,37 @@ F15 ; inch or mm/min (300 mm/min = about 1 ft/min)
#<da> = .250
o<pocket_circ> call [-2.250][+.984] [#<da>] [#<zt>][#<zb>]
o<pocket_circ> call [-2.742+.02][+.205] [#<da>] [#<zt>][#<zb>]
o<pocket_circ> call [-1.758-.02][-.205] [#<da>] [#<zt>][#<zb>]
o<pocket_circ> call [-2.250][-.984] [#<da>] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-2.250][+.984] [#<da>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-2.742+.02][+.205] [#<da>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-1.758-.02][-.205] [#<da>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-2.250][-.984] [#<da>]
o<pocket_circ> call [0.571][-0.151] [.15] [#<zt>][#<zb>] [0][4]
o<pocket_circ> call [2.511][-0.151] [.15] [#<zt>][#<zb>] [0][4]
o<pocket_circ> call [1.225][-1.997] [.15] [#<zt>][#<zb>] [0][4]
o<pocket_circ> call [2.520][-1.997] [.15] [#<zt>][#<zb>] [0][4]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [0.571][-0.151] [.15] [0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [2.511][-0.151] [.15] [0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [1.225][-1.997] [.15] [0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [2.520][-1.997] [.15] [0]
o<frame_rect> call [.723][.307] [2.360][-.609] [#<zt>][#<zb>] [0] [.250]
o<frame_rect> call [1.377][-1.567] [2.368][-2.426] [#<zt>][#<zb>] [0] [.250]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<frame_rect> call [0] [.723][.307] [2.360][-.609] [.250]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<frame_rect> call [0] [1.377][-1.567] [2.368][-2.426] [.250]
M2 ; end program

View File

@@ -1,35 +0,0 @@
#<_z_clearance> = 0.3
#<_rampang> = 20
; mode refernce
; +1: Conventional milling
; +2: Both-ways milling
; +4: Plunge entry
; +8: Outside
G20 ; G21 mm / G20 inch
G10 L1 P1 Z0.0 R[5/32/2] ; set tool
T1 ; set tool to T1
M06 ; manual toolchange
G54 ; absolute coordinates
F15 ; inch or mm/min (300 mm/min = about 1 ft/min)
#<zt> = +0.1
#<zb> = -0.2
#<da> = .250
o<pocket_circ> call [-2.250][+.984] [#<da>] [#<zt>][#<zb>]
o<pocket_circ> call [-2.742][+.197] [#<da>] [#<zt>][#<zb>]
o<pocket_circ> call [-1.758][-.197] [#<da>] [#<zt>][#<zb>]
o<pocket_circ> call [-2.250][-.984] [#<da>] [#<zt>][#<zb>]
o<drill> call [0.571][-0.151] [#<zt>][#<zb>]
o<drill> call [2.511][-0.151] [#<zt>][#<zb>]
o<drill> call [1.225][-1.997] [#<zt>][#<zb>]
o<drill> call [2.520][-2.426] [#<zt>][#<zb>]
o<frame_rect> call [.723][.307] [2.360][-.609] [#<zt>][#<zb>] [0] [.250]
o<frame_rect> call [1.377][-1.567] [2.368][-2.426] [#<zt>][#<zb>] [0] [.250]
M2 ; end program

View File

@@ -19,16 +19,34 @@ F12 ; inch or mm/min (300 mm/min = about 1 ft/min)
#<da> = [12/25.4]
o<pocket_circ> call [-0.394][+.787] [#<da>] [#<zt>][#<zb>] [0][4]
o<pocket_circ> call [-1.181][+.787] [#<da>] [#<zt>][#<zb>] [0][4]
o<pocket_circ> call [-1.181][-.787] [#<da>] [#<zt>][#<zb>] [0][4]
o<pocket_circ> call [-0.394][-.787] [#<da>] [#<zt>][#<zb>] [0][4]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [-0.394][+.787] [#<da>] [0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [-1.181][+.787] [#<da>] [0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [-1.181][-.787] [#<da>] [0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [4] [-0.394][-.787] [#<da>] [0]
o<drill> call [-2.990][+1.480] [#<zt>][#<zb>]
o<drill> call [-1.769][+1.480] [#<zt>][#<zb>]
o<drill> call [-1.769][-1.480] [#<zt>][#<zb>]
o<drill> call [-2.990][-1.480] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [-2.990][+1.480]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [-1.769][+1.480]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [-1.769][-1.480]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [-2.990][-1.480]
o<frame_rect> call [-2.854][+1.417] [-1.870][-1.417] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<frame_rect> call [0] [-2.854][+1.417] [-1.870][-1.417]
M2 ; end program

View File

@@ -1,6 +1,6 @@
#<_z_clearance> = 12
#<_rampang> = 10
#<_td> = 8
;#<_stepover> = 0.1
@@ -19,17 +19,35 @@ G21 ; G21 mm / G20 inch
G54 ; absolute coordinates
F170 ; inch or mm/min (300 mm/min = about 1 ft/min)
;o<pocket_circ> call [15][35] [21] [1][-8]
;o<pocket_circ> call [40][15] [21] [1][-8]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [15][35] [21]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [40][15] [21]
;o<pocket_circ> call [ 70][13] [16] [1][-8]
;o<pocket_circ> call [ 95][13] [16] [1][-8]
;o<pocket_circ> call [120][13] [16] [1][-8]
;o<pocket_circ> call [115][37] [16] [1][-8]
;o<pocket_circ> call [ 90][37] [16] [1][-8]
;o<pocket_circ> call [ 65][37] [16] [1][-8]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [ 70][13] [16]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [ 95][13] [16]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [120][13] [16]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [115][37] [16]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [ 90][37] [16]
;#<_z_top> = 1
;#<_z_bot> = -8
;o<pocket_circ> call [0] [ 65][37] [16]
o<pocket_circ> call [150][29] [29] [1][-8]
#<_z_top> = 1
#<_z_bot> = -8
o<pocket_circ> call [0] [150][29] [29]
M2 ; end program

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = .5
#<_rampang> = 10
#<_td> = 0.25
; mode refernce
; +1: Conventional milling
@@ -18,14 +17,26 @@ F10
;o<end_round> call [180] [-5.513][-.50] [0.52] [#<zt>][#<zb>]
o<pocket_circ> call [-5.513][-.50] [0.51] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-5.513][-.50] [0.51]
o<pocket_circ> call [-2.028][-.315] [.323] [#<zt>][#<zb>]
o<pocket_circ> call [-0.494][-.669] [.323] [#<zt>][#<zb>]
o<pocket_circ> call [+0.494][-.669] [.323] [#<zt>][#<zb>]
o<pocket_circ> call [+2.028][-.315] [.323] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-2.028][-.315] [.323]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-0.494][-.669] [.323]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [+0.494][-.669] [.323]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [+2.028][-.315] [.323]
o<pocket_circ> call [+5.513][-.50] [0.51] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [+5.513][-.50] [0.51]
o<end_round> call [0] [+5.513][-.50] [0.52] [#<zt>][#<zb>]

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 10
#<_rampang> = 20
#<_td> = [3/16*25.4]
; mode refernce
; +1: Conventional milling
@@ -29,14 +28,30 @@ F150 ; inch or mm/min (300 mm/min = about 1 ft/min)
;#<d> = 12.1
;o<pocket_circ> call [68][-11] [#<d>] [1][-5] [.1]
;o<pocket_circ> call [68][-11] [#<d>] [-4][-10] [.1]
;o<pocket_circ> call [68][-25] [#<d>] [1][-5] [.1]
;o<pocket_circ> call [68][-25] [#<d>] [-4][-10] [.1]
;o<pocket_circ> call [68][-75+11] [#<d>] [1][-5] [.1]
;o<pocket_circ> call [68][-75+11] [#<d>] [-4][-10] [.1]
;o<pocket_circ> call [68][-75+25] [#<d>] [1][-5] [.1]
;o<pocket_circ> call [68][-75+25] [#<d>] [-4][-10] [.1]
;#<_z_top> = 1
;#<_z_bot> = -5
;o<pocket_circ> call [0] [68][-11] [#<d>] [.1]
;#<_z_top> = -4
;#<_z_bot> = -10
;o<pocket_circ> call [0] [68][-11] [#<d>] [.1]
;#<_z_top> = 1
;#<_z_bot> = -5
;o<pocket_circ> call [0] [68][-25] [#<d>] [.1]
;#<_z_top> = -4
;#<_z_bot> = -10
;o<pocket_circ> call [0] [68][-25] [#<d>] [.1]
;#<_z_top> = 1
;#<_z_bot> = -5
;o<pocket_circ> call [0] [68][-75+11] [#<d>] [.1]
;#<_z_top> = -4
;#<_z_bot> = -10
;o<pocket_circ> call [0] [68][-75+11] [#<d>] [.1]
;#<_z_top> = 1
;#<_z_bot> = -5
;o<pocket_circ> call [0] [68][-75+25] [#<d>] [.1]
;#<_z_top> = -4
;#<_z_bot> = -10
;o<pocket_circ> call [0] [68][-75+25] [#<d>] [.1]
o<drill_man> call [5][-5]
o<drill_man> call [5][-15]

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 10
#<_rampang> = 20
#<_td> = [3/16*25.4]
; mode refernce
; +1: Conventional milling
@@ -52,13 +51,17 @@ o10 elseif [#<operation> EQ 2]
o<slot_chop> call [+#<xo>+41][-50] [#<xo>+41][-58] [5.1] [#<zt>][#<zb>]
o<slot_chop> call [+#<xo>+105][-10] [#<xo>+105][-18] [5.1] [#<zt>][#<zb>]
o<slot_chop> call [+#<xo>+105][-50] [#<xo>+105][-58] [5.1] [#<zt>][#<zb>]
o<pocket_circ> call [+#<xo>+138][-8.0] [6.2] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [+#<xo>+138][-8.0] [6.2]
o<slot_chop> call [-#<xo>-41][-10] [-#<xo>-41][-18] [5.1] [#<zt>][#<zb>]
o<slot_chop> call [-#<xo>-41][-50] [-#<xo>-41][-58] [5.1] [#<zt>][#<zb>]
o<slot_chop> call [-#<xo>-105][-10] [-#<xo>-105][-18] [5.1] [#<zt>][#<zb>]
o<slot_chop> call [-#<xo>-105][-50] [-#<xo>-105][-58] [5.1] [#<zt>][#<zb>]
o<pocket_circ> call [-#<xo>-138][-8.0] [6.2] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-#<xo>-138][-8.0] [6.2]
o10 endif
M2 ; end program

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 6
#<_rampang> = 20
#<_td> = [9/16*25.4]
; mode refernce
; +1: Conventional milling
@@ -19,20 +18,34 @@ F250 ; inch or mm/min (300 mm/min = about 1 ft/min)
#<y> = -12.5
#<d> = 14.0
;o<frame_circ> call [0][0] [13.0] [+1][-5] [0] [+4+8]
;o<frame_circ> call [0][0] [13.0] [-4][-10] [0] [+4+8]
o<frame_circ> call [0][0] [15.0] [+1][-14] [0] [+4+8]
o<frame_circ> call [0][0] [11.5] [+1][-14] [0] [+4+8]
o<frame_circ> call [0][0] [7.95] [+1][-14] [0] [+4+8]
;#<_z_top> = +1
;#<_z_bot> = -5
;o<frame_circ> call [+4+8] [0][0] [13.0] [0]
;#<_z_top> = -4
;#<_z_bot> = -10
;o<frame_circ> call [+4+8] [0][0] [13.0] [0]
#<_z_top> = +1
#<_z_bot> = -14
o<frame_circ> call [+4+8] [0][0] [15.0] [0]
#<_z_top> = +1
#<_z_bot> = -14
o<frame_circ> call [+4+8] [0][0] [11.5] [0]
#<_z_top> = +1
#<_z_bot> = -14
o<frame_circ> call [+4+8] [0][0] [7.95] [0]
;o<frame_circ> call [0][0] [17] [-13][-18] [3] [+4+8]
o<frame_circ> call [0][0] [17] [-13][-23] [3] [+4+8]
;#<_z_top> = -13
;#<_z_bot> = -18
;o<frame_circ> call [+4+8] [0][0] [17] [3]
#<_z_top> = -13
#<_z_bot> = -23
o<frame_circ> call [+4+8] [0][0] [17] [3]
;M02
#<w> = 13
#<n> = 6
#<r> = [[#<w>+#<_td>]/2/COS[360/2/#<n>]]
#<r> = [[#<w>+#5410]/2/COS[360/2/#<n>]]
G0 Z#<_z_clearance>
G0 X#<r> Y0

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 10
#<_rampang> = 7
#<_td> = 6.35
; mode refernce
; +1: Conventional milling
@@ -23,10 +22,16 @@ F250 ; inch or mm/min (300 mm/min = about 1 ft/min)
;o<drill_man> call [5+45][0]
;o<drill_man> call [5+68][0]
o<pocket_circ> call [-5-68][0] [12] [1][-6]
o<pocket_circ> call [-5-68][0] [12] [-4][-12]
#<_z_top> = 1
#<_z_bot> = -6
o<pocket_circ> call [0] [-5-68][0] [12]
#<_z_top> = -4
#<_z_bot> = -12
o<pocket_circ> call [0] [-5-68][0] [12]
F100
o<pocket_circ> call [-5-68][0] [12.1] [-10][-11.9] [0] [+4]
#<_z_top> = -10
#<_z_bot> = -11.9
o<pocket_circ> call [+4] [-5-68][0] [12.1] [0]
;G0 X-50

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 10
#<_rampang> = 20
#<_td> = [3/16*25.4]
; mode refernce
; +1: Conventional milling
@@ -25,7 +24,9 @@ F150 ; inch or mm/min (300 mm/min = about 1 ft/min)
o<slot_chop> call [#<xo>-7][#<y>] [#<xo>-17][#<y>] [5.1] [#<zt>][#<zb>]
o<slot_chop> call [#<xo>-47][#<y>] [#<xo>-57][#<y>] [5.1] [#<zt>][#<zb>]
o<pocket_circ> call [#<xo>-75][#<y>] [#<d>] [#<zt>][#<zb>] [0.1]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [#<xo>-75][#<y>] [#<d>] [0.1]
#<_stepover> = 1.5
o<end_round> call [180] [#<xo>-75][#<y>] [13] [#<zt>][#<zb>]

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = .5
#<_rampang> = 10
#<_td> = [1/4]
; mode refernce
; +1: Conventional milling
@@ -16,7 +15,9 @@ G54 ; absolute coordinates
F10
o<pocket_circ> call [-.5-.394-1][-.5] [.33] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-.5-.394-1][-.5] [.33]
o<end_round> call [180] [-.5-.394-1][-.5] [.52] [#<zt>][#<zb>]

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = .5
#<_rampang> = 10
#<_td> = [1/4]
; mode refernce
; +1: Conventional milling
@@ -16,11 +15,21 @@ G54 ; absolute coordinates
F10
;o<pocket_circ> call [-0.375][-.5] [.240] [#<zt>][#<zb>]
;o<pocket_circ> call [-2.375][-.5] [.323] [#<zt>][#<zb>]
o<pocket_circ> call [-3.375][-.5] [.715] [#<zt>][#<zb>]
o<pocket_circ> call [-3.875][-.5] [.715] [#<zt>][#<zb>]
o<pocket_circ> call [-4.375][-.5] [.715] [#<zt>][#<zb>]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [-0.375][-.5] [.240]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [-2.375][-.5] [.323]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-3.375][-.5] [.715]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-3.875][-.5] [.715]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [-4.375][-.5] [.715]
o<end_round> call [180] [-4.375][-.5] [.52] [#<zt>][#<zb>]

View File

@@ -1,6 +1,5 @@
#<_z_clearance> = 5
#<_rampang> = 10
#<_td> = [3/16*25.4]
; mode refernce
; +1: Conventional milling
@@ -15,15 +14,29 @@ F150
#<zt> = 0.2
#<zb> = -4
o<pocket_circ> call [0][-17] [18.7] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<pocket_circ> call [0] [0][-17] [18.7]
;o<pocket_circ> call [10][ -7] [5.2] [#<zt>][#<zb>]
;o<pocket_circ> call [10][-27] [5.2] [#<zt>][#<zb>]
;o<pocket_circ> call [35][-17] [18.7] [#<zt>][#<zb>]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [10][ -7] [5.2]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [10][-27] [5.2]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [35][-17] [18.7]
;o<pocket_circ> call [54+10][ -7] [5.2] [#<zt>][#<zb>]
;o<pocket_circ> call [54+10][-27] [5.2] [#<zt>][#<zb>]
;o<pocket_circ> call [54+35][-17] [18.7] [#<zt>][#<zb>]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [54+10][ -7] [5.2]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [54+10][-27] [5.2]
;#<_z_top> = #<zt>
;#<_z_bot> = #<zb>
;o<pocket_circ> call [0] [54+35][-17] [18.7]
M2 ; end program

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 6
#<_rampang> = 20
#<_td> = 6.35
; mode refernce
; +1: Conventional milling
@@ -13,9 +12,15 @@ G54 ; absolute coordinates
F150 ; inch or mm/min (300 mm/min = about 1 ft/min)
o<pocket_circ> call [-20][-10.0] [8.2] [2][-9]
o<pocket_circ> call [-20][-40.6] [8.2] [2][-9]
o<pocket_circ> call [+30][-25.3] [8.2] [2][-9]
#<_z_top> = 2
#<_z_bot> = -9
o<pocket_circ> call [0] [-20][-10.0] [8.2]
#<_z_top> = 2
#<_z_bot> = -9
o<pocket_circ> call [0] [-20][-40.6] [8.2]
#<_z_top> = 2
#<_z_bot> = -9
o<pocket_circ> call [0] [+30][-25.3] [8.2]
o<end_round> call [0][+30][-25.3] [26] [2][-9] [0.5]

View File

@@ -16,19 +16,33 @@ G54 ; absolute coordinates
#<phase> = 2
o10 if [#<phase> EQ 1]
#<_td> = .26
F5
o<drill> call [0.500][-.50] [#<zt>][#<zb>]
o<drill> call [0.500][-3.0] [#<zt>][#<zb>]
o<drill> call [5.125][-3.0] [#<zt>][#<zb>]
o<drill> call [5.125][-.50] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [0.500][-.50]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [0.500][-3.0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [5.125][-3.0]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [5.125][-.50]
o<drill> call [7.375][-0.500] [#<zt>][#<zb>]
o<drill> call [9.625][-0.500] [#<zt>][#<zb>]
o<drill> call [9.625][-2.156] [#<zt>][#<zb>]
o<drill> call [7.375][-2.156] [#<zt>][#<zb>]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [7.375][-0.500]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [9.625][-0.500]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [9.625][-2.156]
#<_z_top> = #<zt>
#<_z_bot> = #<zb>
o<drill> call [7.375][-2.156]
o10 elseif [#<phase> EQ 2]
#<_td> = .375
F8
o<end_angle> call [2] [10] [0][-3.5] [0] [#<zt>][#<zb>]

View File

@@ -12,14 +12,24 @@ F8.0 ; feedrate
#<w> = 5.75
#<h> = 7.875
o<frame_rect> call [-#<w>/2] [-#<h>/2] [#<w>/2] [#<h>/2] [0.05] [-0.28] [3] [0.1]
#<_z_top> = 0.05
#<_z_bot> = -0.28
o<frame_rect> call [3] [-#<w>/2] [-#<h>/2] [#<w>/2] [#<h>/2] [0.1]
;o<pocket_circ> call [0] [+0.75] [12.1/25.4] [0.1] [0.3] [-0.15] [.005] [0]
;o<pocket_circ> call [0] [-0.75] [12.1/25.4] [0.1] [0.05] [-0.15] [.005] [0]
;o<pocket_circ> call [-0.75] [0] [12.1/25.4] [0.1] [0.05] [-0.15] [.005] [0]
;o<pocket_circ> call [+0.75] [0] [12.1/25.4] [0.1] [0.05] [-0.15] [.005] [0]
;#<_z_top> = 0.1
;#<_z_bot> = 0.3
;o<pocket_circ> call [0] [0] [+0.75] [12.1/25.4] [-0.15] [.005]
;#<_z_top> = 0.1
;#<_z_bot> = 0.05
;o<pocket_circ> call [0] [0] [-0.75] [12.1/25.4] [-0.15] [.005]
;#<_z_top> = 0.1
;#<_z_bot> = 0.05
;o<pocket_circ> call [0] [-0.75] [0] [12.1/25.4] [-0.15] [.005]
;#<_z_top> = 0.1
;#<_z_bot> = 0.05
;o<pocket_circ> call [0] [+0.75] [0] [12.1/25.4] [-0.15] [.005]

View File

@@ -5,8 +5,12 @@ M06
M101
G54
o<bore> call [0.00] [0.00] [10.5/25.4] [-0.6] [-0.65] [0.5]
o<bore> call [0.00] [0.00] [12.0/25.4] [-0.6] [-0.65] [0.5]
#<_z_top> = -0.6
#<_z_bot> = -0.65
o<bore> call [0.00] [0.00] [10.5/25.4] [0.5]
#<_z_top> = -0.6
#<_z_bot> = -0.65
o<bore> call [0.00] [0.00] [12.0/25.4] [0.5]

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 6
#<_rampang> = 20
#<_td> = 6.35
; mode refernce
; +1: Conventional milling

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 0.5
#<_rampang> = 20
#<_td> = [1/4]
; mode refernce
; +1: Conventional milling

View File

@@ -24,10 +24,18 @@ o104 call [240 + 6.5]
o104 call [300 - 6.5]
;o<bore> call [0.00] [0.00] [1.] [-0.65] [-0.65] [0.5]
;o<bore> call [0.00] [0.00] [1.50] [-0.65] [-0.65] [0.5]
;o<bore> call [0.00] [0.00] [1.75] [-0.65] [-0.65] [0.5]
;o<bore> call [0.00] [0.00] [2.02] [-0.65] [-0.65] [0.5]
;#<_z_top> = -0.65
;#<_z_bot> = -0.65
;o<bore> call [0.00] [0.00] [1.] [0.5]
;#<_z_top> = -0.65
;#<_z_bot> = -0.65
;o<bore> call [0.00] [0.00] [1.50] [0.5]
;#<_z_top> = -0.65
;#<_z_bot> = -0.65
;o<bore> call [0.00] [0.00] [1.75] [0.5]
;#<_z_top> = -0.65
;#<_z_bot> = -0.65
;o<bore> call [0.00] [0.00] [2.02] [0.5]

View File

@@ -5,10 +5,18 @@ M06
M101
G54
;o<bore> call [0.00] [0.00] [1.50] [-0.74] [-0.75] [0.5]
;o<bore> call [0.00] [0.00] [1.75] [-0.74] [-0.75] [0.5]
;o<bore> call [0.00] [0.00] [2.00] [-0.74] [-0.75] [0.5]
o<bore> call [0.00] [0.00] [2.28] [-0.74] [-0.75] [0.5]
;#<_z_top> = -0.74
;#<_z_bot> = -0.75
;o<bore> call [0.00] [0.00] [1.50] [0.5]
;#<_z_top> = -0.74
;#<_z_bot> = -0.75
;o<bore> call [0.00] [0.00] [1.75] [0.5]
;#<_z_top> = -0.74
;#<_z_bot> = -0.75
;o<bore> call [0.00] [0.00] [2.00] [0.5]
#<_z_top> = -0.74
#<_z_bot> = -0.75
o<bore> call [0.00] [0.00] [2.28] [0.5]

View File

@@ -3,7 +3,6 @@ G54 ; absolute coordinates
#<_z_clearance> = 6
#<_rampang> = 20
#<_td> = 6.35
; mode refernce
; +1: Conventional milling
@@ -14,10 +13,18 @@ G54 ; absolute coordinates
F250 ; inch or mm/min (300 mm/min = about 1 ft/min)
o10 sub
o<pocket_circ> call [#1][-00] [10] [1][-6] [0.5] [+4]
o<drill> call [#1][-0] [-5][-16]
o<pocket_circ> call [#1][-20] [10] [1][-6] [0.5] [+4]
o<drill> call [#1][-20] [-5][-16]
#<_z_top> = 1
#<_z_bot> = -6
o<pocket_circ> call [+4] [#1][-00] [10] [0.5]
#<_z_top> = -5
#<_z_bot> = -16
o<drill> call [#1][-0]
#<_z_top> = 1
#<_z_bot> = -6
o<pocket_circ> call [+4] [#1][-20] [10] [0.5]
#<_z_top> = -5
#<_z_bot> = -16
o<drill> call [#1][-20]
o10 endsub
o10 call [-15]
@@ -25,7 +32,11 @@ o10 call [-20]
o10 call [-25]
o10 call [-30]
o<drill> call [-100][-0] [-5][-16]
o<drill> call [-100][-20] [-5][-16]
#<_z_top> = -5
#<_z_bot> = -16
o<drill> call [-100][-0]
#<_z_top> = -5
#<_z_bot> = -16
o<drill> call [-100][-20]
M2 ; end program

View File

@@ -12,7 +12,9 @@ M101
;G82 X2 Y2 Z-1.5 R-0.5 P0.5
;G83 X3 Y1 Z-1.5 R-0.5 Q0.1
o<bore> call [0.03] [0.03] [1.05] [0.05] [-0.85] [0.1]
#<_z_top> = 0.05
#<_z_bot> = -0.85
o<bore> call [0.03] [0.03] [1.05] [0.1]

Some files were not shown because too many files have changed in this diff Show More