Compare commits

..

11 Commits

Author SHA1 Message Date
Thaddeus Hughes
487f47b023 Update WIRING.md 2026-05-26 12:37:12 -05:00
Thaddeus Hughes
e90aef454c Update WIRING.md 2026-05-26 10:07:16 -05:00
Thaddeus Hughes
93f4041600 some warnings 2026-05-26 10:02:28 -05:00
Thaddeus Hughes
72436a7bf8 fix link structure 2026-05-26 09:55:49 -05:00
Thaddeus Hughes
7792c39cd6 Update WIRING.md 2026-05-26 09:40:17 -05:00
Thaddeus Hughes
4719b68648 docs 2026-05-26 09:22:40 -05:00
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
17 changed files with 272 additions and 13 deletions

View File

@@ -13,7 +13,8 @@
"WebFetch(domain:github.com)", "WebFetch(domain:github.com)",
"WebFetch(domain:raw.githubusercontent.com)", "WebFetch(domain:raw.githubusercontent.com)",
"WebFetch(domain:forum.linuxcnc.org)", "WebFetch(domain:forum.linuxcnc.org)",
"WebFetch(domain:www.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

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

View File

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

View File

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

191
docs/WIRING.md Normal file
View File

@@ -0,0 +1,191 @@
# HEPHAESTUS Wiring
This is how I have my LinuxCNC machine wired. I put a linuxCNC box in place of a Southwestern Industries TRAK CNC II control box. I am reusing the TRAK drives, motors, and encoders. Eventually, I switched to using linear encoders instead of the TRAK encoders.
| Mesa card | Role |
| --------- | ------------------------------- |
| 6i24-16 | FPGA card (PCIe host interface) |
| 7i52S | Servo interface daughter card |
| 7i37TA | Isolated I/O daughter card |
![](pc_front.jpg)
![](cbox_back.jpg)
![](cbox_inside.jpg)
# Encoders
## TRAK Encoder Pinout
The encoders for both motors and the standard TRAK encoders use the same Amphenol CPC connector.
The encoders are differential 5V output. They might have an index pulse but I wasn't using it. The Z axis has the same pinout. Peak-peak voltage is 2.7V.
| Pin | Signal | Color (in PC) |
| --- | -------- | ------------- |
| 1 | B- | White |
| 2 | 5V | Red |
| 3 | B+ | Blue |
| 4 | N/C | |
| 5 | N/C | |
| 6 | N/C | |
| 7 | N/C | |
| 8 | N/C | |
| 9 | GND/SHLD | Black |
| 10 | GND/SHLD | Black |
| 11 | GND/SHLD | Black |
| 12 | A- | Yellow |
| 13 | GND | Black |
| 14 | A+ | Green |
![](ampconns.jpg)
## Linear Encoder Pinout (DB9)
I switched to some linear encoders that have a D-sub connector. They are also 5V differential output, and nearly the same resolution, resulting in very easy switchover.
| Pin | Signal | Color (in PC) |
| --- | ------ | ------------- |
| 1 | A- | Yellow |
| 2 | GND | Black |
| 3 | B- | White |
| 4 | N/C | N/C |
| 5 | Z- | Tan |
| 6 | A+ | Green |
| 7 | 5V | Red |
| 8 | B+ | Blue |
| 9 | Z+ | Maroon |
## DB37 Pinout
The DB37 cable contains drive signals and motor encoder signals and connects to the TRAK drive box.
*This pinout was determined by probing. I'm not sure what some of the pins do; some of the ??? pins might actually be an index pulse or something.*
| Pin | Signal | Notes |
| ----- | ---------- | --------- |
| 1-5 | ??? (N/C?) | |
| 6 | YB- | Y Encoder |
| 7 | YB+ | Y Encoder |
| 8 | YA+ | Y Encoder |
| 9 | YA- | Y Encoder |
| 10 | XB+ | X Encoder |
| 11 | XB- | X Encoder |
| 12 | XA+ | X Encoder |
| 13 | XA- | X Encoder |
| 14 | XENW | X Enable |
| 15 | XENR | X Enable |
| 16 | YENW | Y Enable |
| 17 | YENR | Y Enable |
| 18 | ZENW | Z Enable |
| 19 | ZENR | Z Enable |
| 20 | ??? (N/C?) | |
| 21 | 5V | |
| 22 | 5V | |
| 23 | GND | |
| 24 | GND | |
| 25 | 5V | |
| 26 | 5V | |
| 27 | GND | |
| 28 | GND | |
| 29 | 5V | |
| 30 | 5V | |
| 31-37 | GND | |
# MESA Cards
![](mesa_cards.jpg)
## 7i37TA
Three enables are used - one for the X and Y axes, one for the z axis, and one for the spindle. This allows the z axis to be disabled independently for manual drilling operations.
Each works by connecting a pair of wires. Made = enabled.
The spindle only has enable; direction and speed is manually controlled.
A custom `M101` and `M102` g code enables/disables the z-axis.
| Enable | 7i37TA Pin | 6i24-16 Pin | Wire Color |
| ------- | ---------- | ----------- | ---------------------- |
| XY | OUT6+ | 46 | White & Green to black |
| Z | OUT4+ | 44 | Red to black |
| Spindle | OUT3+ | 41 | White to Green |
## 7i52S
#### Encoder connector
(This is for connector 0; carries over to channels 0-4 as well)
*Five encoder inputs are used - x, y, and z each use one without index pulse, and x and y have a secondary linear encoder that does use the index pulse*
*Sometimes the A-channels and B-channels are flipped, at least color-wise.*
| Pin | Signal | Function | Wire Color |
| --- | ------ | -------- | ---------- |
| 1 | QA0 | A+ | Green |
| 2 | /QA0 | A- | Yellow |
| 3 | GND | GND | Black |
| 4 | QB0 | B+ | Blue |
| 5 | /QB0 | B- | White |
| 6 | +5V | 5V | Red |
| 7 | IDX0 | I+ | Maroon |
| 8 | /IDX0 | I- | Tan |
#### Differential Output Connector
*Three differential outputs are used - one for each x, y, and z*
| Pin | Signal | Function | Color |
| --- | ------ | -------- | ----- |
| 1 | GND | | N/C |
| 2 | GND | | N/C |
| 3 | TX0A | TXA+ | White |
| 4 | /TX0A | TXA- | Green |
| 5 | TX0B | | N/C |
| 6 | /TX0B | | N/C |
| 7 | +5V | | N/C |
| 8 | +5V | | N/C |
#### HAL Channel assignments
| Axis | Encoder ch | PWM ch | Notes |
| -------- | ------------ | ----------- | ------------------------- |
| X linear | `encoder.00` | — | Joint position feedback |
| Y linear | `encoder.01` | — | Joint position feedback |
| Z linear | `encoder.02` | — | Joint position feedback |
| X motor | `encoder.03` | — | Velocity/damping feedback |
| Y motor | `encoder.04` | — | Velocity/damping feedback |
| Z motor | (none) | — | No dual loop on Z |
| X drive | — | `pwmgen.00` | Differential PWM out |
| Y drive | — | `pwmgen.02` | Differential PWM out |
| Z drive | — | `pwmgen.04` | Differential PWM out |
## Servo Drive Config
### PWM
- Carrier: **15.5 kHz** (`hm2_5i24.0.pwmgen.pwm_frequency 15500`)
- `output-type 1` (PWM + Direction pins)
- `offset-mode 1` → locked anti-phase / bipolar single-signal: duty cycle directly encodes signed command
- `scale = OUTPUT_SCALE`: X = +1, Y = -1, Z = -1 (sign flips drive polarity to match wiring)
- peak-peak voltage of 3.3V from the TRAK CNC II control
When the enable line is deasserted the pwmgen output is forced off (not 50%), so the amp sees a distinct disabled state vs. "commanded zero". You can hear the drives hum/whine at the 50% state.
My notes say that setting duty cycle to 0 or 100% cause the drive to disable. I'm not sure if this is the case or not. I don't know exactly what the functional band of the PWM is.
### Enable
Enable lines are switched by 7i37TA isolated MOSFET outputs (`OBITn+`/`OBITn-`). Per the 7i37 manual, a **low** FPGA pin turns the MOSFET **on**. HAL sets `invert_output true` on the enable GPIOs, so HAL `enable=TRUE` → FPGA-low → MOSFET on → contact **closed**.
| HAL enable | FPGA pin | MOSFET | Contact | Drive |
| ---------- | -------- | ------ | ------- | -------- |
| TRUE | LOW | ON | made | enabled |
| FALSE | HIGH | OFF | broken | disabled |
Fail-safe: cable cut, 5 V loss, or hm2 unconfigured all leave the MOSFET off → contact open → drive disabled.
![](cbox_bottom.jpg)

BIN
docs/ampconns.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

BIN
docs/cbox_back.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

BIN
docs/cbox_bottom.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

BIN
docs/cbox_inside.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
docs/mesa_cards.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

BIN
docs/pc_front.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

BIN
docs/pc_overview.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

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

@@ -4,8 +4,8 @@
; Requires tool loaded (uses #5410 for diameter) ; Requires tool loaded (uses #5410 for diameter)
; Optional global: #<_z_clearance> ; Optional global: #<_z_clearance>
o<frame_circ> sub o<frame_circ> sub
; o<frame_circ> call [mode] [x][y] [diameter] [fincut] (o<frame_circ> call [mode] [x][y] [diameter] [fincut])
; #1=mode #2=x #3=y #4=diameter #5=fincut (#1=mode #2=x #3=y #4=diameter #5=fincut)
#<M_CONVENTIONAL> = [FIX[#1/1] MOD 2 EQ 1] #<M_CONVENTIONAL> = [FIX[#1/1] MOD 2 EQ 1]
#<M_OUTSIDE> = [FIX[#1/8] MOD 2 EQ 1] #<M_OUTSIDE> = [FIX[#1/8] MOD 2 EQ 1]

View File

@@ -4,8 +4,8 @@
; Requires tool loaded (uses #5410 for diameter) ; Requires tool loaded (uses #5410 for diameter)
; Optional global: #<_z_clearance> ; Optional global: #<_z_clearance>
o<frame_rect> sub o<frame_rect> sub
; o<frame_rect> call [mode] [x1][y1] [x2][y2] [radius] (o<frame_rect> call [mode] [x1][y1] [x2][y2] [radius])
; #1=mode #2=x1 #3=y1 #4=x2 #5=y2 #6=radius (#1=mode #2=x1 #3=y1 #4=x2 #5=y2 #6=radius)
#<M_CONVENTIONAL> = [FIX[#1/1] MOD 2 EQ 1] #<M_CONVENTIONAL> = [FIX[#1/1] MOD 2 EQ 1]
#<M_OUTSIDE> = [FIX[#1/8] MOD 2 EQ 1] #<M_OUTSIDE> = [FIX[#1/8] MOD 2 EQ 1]

View File

@@ -1,5 +1,7 @@
# Lagun Mill - LinuxCNC # Lagun Mill - LinuxCNC
For wiring - see [docs/WIRING.md](docs/WIRING.md).
## Docs ## Docs
- [nc_files/MACROS.md](nc_files/MACROS.md) — macro subroutine reference (drill, pocket, frame, slot, bore, polygon) - [nc_files/MACROS.md](nc_files/MACROS.md) — macro subroutine reference (drill, pocket, frame, slot, bore, polygon)