claude init

This commit is contained in:
Thaddeus Hughes
2026-04-03 21:47:22 -05:00
parent f3953d66ae
commit 9d2379205f
26 changed files with 2382 additions and 4243 deletions

View File

@@ -0,0 +1,163 @@
# Lagun Milling Machine - GMOCCAPY Configuration
LinuxCNC configuration for a Lagun 3-axis (X, Y, Z) milling machine with servo drives, controlled by a Mesa 5i24 FPGA card and the GMOCCAPY GUI. Units are imperial (inches).
Originally generated by PNCconf (July 2024), then modified for GMOCCAPY and dual-encoder feedback.
## Files
| File | Purpose |
|------|---------|
| `lagun_gmoccapy.ini` | Main config: axes, PID gains, encoder scales, limits, MDI commands |
| `lagun.hal` | Main HAL: loads drivers, wires encoders/PWM/PID/GPIO, tool change |
| `xhc-whb04b-6.hal` | Pendant HAL: jog, axis select, feed override, macro buttons |
| `gmoccapy_postgui.hal` | Post-GUI HAL: connects tool offset display to GMOCCAPY |
| `shutdown.hal` | Shutdown HAL: currently empty (placeholder) |
| `tool.tbl` | Tool table with 6 tools (T0-T5) |
## Hardware
### Controller
- **Mesa 5i24** PCI FPGA card (`hm2_pci`)
- 6 encoder channels, 6 PWM generators
- PWM frequency: 15,500 Hz
- Servo period: 1 ms (1,000,000 ns)
### Servo Drives and PWM Mapping
| Axis | PWM Channel | Output Scale |
|------|-------------|-------------|
| X | pwmgen.00 | +1 |
| Y | pwmgen.02 | -1 (inverted) |
| Z | pwmgen.04 | -1 (inverted) |
### Encoder Mapping
X and Y each have two encoders (motor + linear scale). Z has only a linear scale.
| Signal | Encoder Channel | Scale (counts/inch) | Purpose |
|--------|----------------|---------------------|---------|
| X linear | encoder.00 | 5085.5 | Position feedback (used for joint FB) |
| Y linear | encoder.01 | 5085.4 | Position feedback (used for joint FB) |
| Z linear | encoder.02 | -10075 | Position feedback (used for joint FB) |
| X motor | encoder.03 | -27939.6 | Velocity/damping feedback |
| Y motor | encoder.04 | 27453.6 | Velocity/damping feedback |
| Z motor | (none) | N/A | Not installed |
### GPIO Pin Assignments
**Relay outputs** (active low / inverted):
| GPIO | Function |
|------|----------|
| 041 | Spindle on/off relay |
| 044 | Z-axis servo enable relay |
| 046 | X-axis servo enable relay |
**Button inputs** (active low, currently unused/commented out):
| GPIO | Function |
|------|----------|
| 027 | Button (unassigned) |
| 028 | Button (unassigned) |
| 029 | ESTOP button |
| 030 | START button |
| 031 | STOP button |
The button inputs are configured as inputs but their HAL net connections are commented out because they were causing unexpected machine shutoff.
## Dual PID Feedback (X and Y Axes)
X and Y each use two PID loops running in parallel, whose outputs are summed:
1. **Motor encoder PID** (`pid.x` / `pid.y`): Uses D gain and FF1 for velocity damping. No I gain. Feedback from the motor-mounted encoder.
2. **Linear scale PID** (`pid.xl` / `pid.yl`): Uses high P and I gains for accurate position correction. Feedback from the linear scale mounted on the axis.
The outputs are summed via `sum2` components:
- `sum2.0`: X motor PID + X linear PID
- `sum2.1`: Y motor PID + Y linear PID
- `sum2.2`: Z linear PID only (no motor encoder)
The **linear scale** position is used as the joint feedback (`joint.N.motor-pos-fb`), so LinuxCNC tracks actual table position rather than motor position.
## Z-Axis Override Mechanism
The Z-axis has a special enable/disable mechanism for manual quill operation:
- A HAL `logic AND` gate combines two signals: `z-override` and `z-enable`
- The combined output `z-enable-comb` controls the Z servo PID enable and the GPIO 044 relay
- `z-override` defaults to TRUE at startup (CNC controls Z)
- M101 can set `z-override` to FALSE, disabling the Z servo so the quill can be moved manually
- M102 can set `z-override` back to TRUE to re-enable CNC Z control
**Workaround**: Because the Z servo is disabled during manual quill use, the quill position diverges from the commanded position. To prevent following-error faults, `MIN_FERROR` is set to 100 inches in the INI file (ideally it would be 0.2). An attempt to dynamically switch the ferror value via a `mux2` component exists in the HAL but is non-functional (the output signal is not connected to the joint).
## Spindle
On/off relay control only via GPIO 041. No speed control or encoder feedback. The spindle PID section in the INI exists but is effectively unused (FF0=1 with no feedback). Default spindle speed in the GUI is 500 RPM.
## Pendant (XHC WHB04B-6)
Wireless pendant loaded with `xhc-whb04b-6 -HsfB` (HAL-only, step, filtered, 6-axis model).
Connected to `joint.N.jog-*` pins (not `axis.x.jog-*`, which GMOCCAPY does not create).
### Macro Button Mapping
Macro buttons trigger MDI commands defined in the `[HALUI]` section of the INI:
| Button | MDI Index | G-code | Action |
|--------|-----------|--------|--------|
| Macro 1 | 01 | `G10 L20 P0 X[#<_x>/2.0]` | Halve X coordinate |
| Macro 2 | 02 | `G10 L20 P0 Y[#<_y>/2.0]` | Halve Y coordinate |
| Macro 3 | -- | (hardcoded) | Spindle speed increase |
| Macro 4 | -- | (hardcoded) | Spindle speed decrease |
| Macro 5 | 05 | `G10 L20 P0 X0` | Zero X |
| Macro 6 | 06 | `G10 L20 P0 Y0` | Zero Y |
| Macro 7 | 07 | `G10 L20 P0 Z0` | Zero Z |
| Macro 8 | -- | (hardcoded) | Spindle direction |
| Macro 10 | -- | (hardcoded) | Toggle ABS/REL DRO |
| Macro 15 | -- | (hardcoded) | Flood coolant toggle |
| Macro 16 | -- | (hardcoded) | Mist coolant toggle |
### Function Buttons
| Button | Action |
|--------|--------|
| M-Home | Home all axes (`halui.home-all`) |
| Safe-Z | MDI command 03 (debug/placeholder) |
| W-Home | MDI command 04 (debug/placeholder) |
| Probe-Z | MDI command 08 (debug/placeholder) |
Feed override is connected and functional via the pendant knob.
## Tool Change
Manual tool change using `hal_manualtoolchange`. A dialog pops up on screen prompting the operator to change the tool. Tool prepare requests are looped back (no automatic tool changer).
## Axis Limits and Homing
| Axis | Travel (inches) | Home Sequence |
|------|----------------|---------------|
| X | -24.0 to +24.0 | 2 |
| Y | -12.0 to +12.0 | 3 |
| Z | -4.0 to +1.0 | 1 (first) |
`NO_FORCE_HOMING = 1` is set, so the machine can be jogged and run programs without homing first.
## Startup G-code
```
G20 G40 G90 G94 G97 G64 P0.001
```
- G20: Inch mode
- G40: Cancel cutter compensation
- G90: Absolute distance mode
- G94: Feed per minute
- G97: RPM mode (constant spindle speed)
- G64 P0.001: Path blending with 0.001" tolerance
## E-Stop
The estop signal is looped back internally (`user-enable-out` -> `emc-enable-in`). There is no external hardware estop chain connected through LinuxCNC. The physical ESTOP button on GPIO 029 is configured as an input but not wired into the estop logic.

View File

@@ -2,5 +2,6 @@
# These connections are made after the GUI loads so gmoccapy pins exist
# --- Tool offset display ---
# Pass tool offset values to GMOCCAPY for DRO display
net tooloffset-x gmoccapy.tooloffset-x <= motion.tooloffset.x
net tooloffset-z gmoccapy.tooloffset-z <= motion.tooloffset.z

View File

@@ -1,20 +1,30 @@
# ============================================================================
# Lagun milling machine - Main HAL configuration
# Generated by PNCconf at Fri Jul 26 13:18:08 2024
# Using LinuxCNC version: Master (2.9)
# If you make changes to this file, they will be
# overwritten when you run PNCconf again
# ============================================================================
# --- Load realtime modules ---
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS base_thread_fp=1
loadrt hostmot2
loadrt hm2_pci config="num_encoders=6 num_pwmgens=6"
loadrt hm2_pci config="num_encoders=6 num_pwmgens=6"
# mux16: used by pendant for jog increment, feed override, max velocity override, spindle override
loadrt mux16 names=jogincr,foincr,mvoincr,soincr
# mux2: selects ferror value based on z-override state (attempted but unused)
loadrt mux2 count=1
# sum2: sums dual PID outputs for X(0), Y(1), Z(2)
loadrt sum2 count=3
# logic: 2-input AND gate for z-override mechanism
# personality 0x0102 = 1 output, 2 inputs, AND function
loadrt logic count=1 personality=0x0102
addf logic.0 servo-thread
addf mux2.0 servo-thread
# weighted_sum: for ADC reading (currently unused)
loadrt weighted_sum wsum_sizes=8 #wsum_sizes=[128,64,32,16,8,4,2,1] # default should do conversion??
addf process_wsums servo-thread
@@ -26,11 +36,19 @@ addf foincr servo-thread
addf mvoincr servo-thread
addf soincr servo-thread
# --- Mesa 5i24 global PWM/watchdog settings ---
setp hm2_5i24.0.pwmgen.pwm_frequency 15500
setp hm2_5i24.0.pwmgen.pdm_frequency 15500
setp hm2_5i24.0.watchdog.timeout_ns 5000000
# --- Load PID controllers ---
# pid.x / pid.xl = X motor encoder / linear scale (dual loop)
# pid.y / pid.yl = Y motor encoder / linear scale (dual loop)
# pid.zl = Z linear scale (single loop, no motor encoder)
# pid.s = spindle (not actively used)
loadrt pid names=pid.x,pid.y,pid.s,pid.xl,pid.yl,pid.zl
# --- Servo thread function execution order ---
addf hm2_5i24.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
@@ -42,7 +60,10 @@ addf pid.zl.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
addf hm2_5i24.0.write servo-thread
# relay outputs
# --- GPIO relay outputs (active low / inverted) ---
# GPIO 041 = spindle on/off relay
# GPIO 044 = Z-axis servo enable relay
# GPIO 046 = X-axis servo enable relay
setp hm2_5i24.0.gpio.041.is_output true
setp hm2_5i24.0.gpio.044.is_output true
setp hm2_5i24.0.gpio.046.is_output true
@@ -50,13 +71,15 @@ setp hm2_5i24.0.gpio.041.invert_output true
setp hm2_5i24.0.gpio.044.invert_output true
setp hm2_5i24.0.gpio.046.invert_output true
# some inputs
# --- GPIO button inputs (active low, not all wired into HAL logic) ---
# GPIO 029 = ESTOP, 030 = START, 031 = STOP
setp hm2_5i24.0.gpio.027.is_output false
setp hm2_5i24.0.gpio.028.is_output false
setp hm2_5i24.0.gpio.028.is_output false
setp hm2_5i24.0.gpio.029.is_output false # ESTOP
setp hm2_5i24.0.gpio.030.is_output false # START
setp hm2_5i24.0.gpio.031.is_output false # STOP
# Button wiring attempts - commented out, caused machine to shut off unexpectedly
#net machine_estop_out <= hm2_5i24.0.gpio.029.in_not
#net machine_estop_out => halui.machine.on
@@ -69,7 +92,8 @@ setp hm2_5i24.0.gpio.031.is_output false # STOP
# net btn-start hm2_5i24.0.gpio.030.in_not => halui.program.resume
# first ADC
# --- ADC inputs (commented out, unused) ---
# first ADC (GPIO 032-039)
#setp hm2_5i24.0.gpio.032.is_output false
#setp hm2_5i24.0.gpio.033.is_output false
#setp hm2_5i24.0.gpio.034.is_output false
@@ -79,7 +103,7 @@ setp hm2_5i24.0.gpio.031.is_output false # STOP
#setp hm2_5i24.0.gpio.038.is_output false
#setp hm2_5i24.0.gpio.039.is_output false
# second ADC
# second ADC (GPIO 040-047)
#setp hm2_5i24.0.gpio.040.is_output false
#setp hm2_5i24.0.gpio.041.is_output false
#setp hm2_5i24.0.gpio.042.is_output false
@@ -89,7 +113,7 @@ setp hm2_5i24.0.gpio.031.is_output false # STOP
#setp hm2_5i24.0.gpio.046.is_output false
#setp hm2_5i24.0.gpio.047.is_output false
# weighted_sum wiring for ADC (unused)
#net hm2_5i24.0.gpio.032 <= wsum.0.bit.0.in
#net hm2_5i24.0.gpio.033 <= wsum.0.bit.1.in
#net hm2_5i24.0.gpio.034 <= wsum.0.bit.2.in
@@ -99,10 +123,16 @@ setp hm2_5i24.0.gpio.031.is_output false # STOP
#net hm2_5i24.0.gpio.038 <= wsum.0.bit.6.in
#net hm2_5i24.0.gpio.039 <= wsum.0.bit.7.in
# ******************
# AXIS X JOINT 0
# ******************
# ============================================================================
# AXIS X - JOINT 0
# Dual PID: pid.x (motor encoder) + pid.xl (linear scale), summed via sum2.0
# Motor encoder: hm2 encoder 03
# Linear scale: hm2 encoder 00
# PWM output: pwmgen.00
# Enable relay: GPIO 046 (active low)
# ============================================================================
# --- X motor encoder PID (velocity/damping loop) ---
setp pid.x.Pgain [JOINT_0]P
setp pid.x.Igain 0
setp pid.x.Dgain [JOINT_0]D
@@ -118,6 +148,7 @@ net x-enable => pid.x.enable
net x-pos-mtr => pid.x.feedback
net x-output-mtr <= pid.x.output
# --- X linear scale PID (position correction loop) ---
setp pid.xl.Pgain [JOINT_0]P_LIN
setp pid.xl.Igain [JOINT_0]I_LIN
setp pid.xl.Dgain [JOINT_0]D_LIN
@@ -133,11 +164,13 @@ net x-enable => pid.xl.enable
net x-pos-lin => pid.xl.feedback
net x-output-lin <= pid.xl.output
# Sum motor + linear PID outputs for final X drive signal
net x-output-lin => sum2.0.in0
net x-output-mtr => sum2.0.in1
net x-output <= sum2.0.out
net x-pos-cmd <= joint.0.motor-pos-cmd
# Position command feeds both PID loops
net x-pos-cmd <= joint.0.motor-pos-cmd
net x-pos-cmd => pid.xl.command
net x-pos-cmd => pid.x.command
@@ -149,11 +182,13 @@ setp hm2_5i24.0.pwmgen.00.offset-mode 1
net x-output => hm2_5i24.0.pwmgen.00.value
net x-enable joint.0.amp-enable-out => hm2_5i24.0.pwmgen.00.enable
# X enable also drives GPIO 046 relay
net x-enable => hm2_5i24.0.gpio.046.out
net x-pos-rawcounts <= hm2_5i24.0.encoder.00.rawcounts
# ---Encoder feedback signals/setup---
# Motor encoder (encoder 03)
setp hm2_5i24.0.encoder.03.counter-mode 0
setp hm2_5i24.0.encoder.03.filter 1
setp hm2_5i24.0.encoder.03.index-invert 0
@@ -161,6 +196,7 @@ setp hm2_5i24.0.encoder.03.index-mask 0
setp hm2_5i24.0.encoder.03.index-mask-invert 0
setp hm2_5i24.0.encoder.03.scale [JOINT_0]ENCODER_MTR_SCALE
# Linear scale (encoder 00)
setp hm2_5i24.0.encoder.00.counter-mode 0
setp hm2_5i24.0.encoder.00.filter 1
setp hm2_5i24.0.encoder.00.index-invert 0
@@ -173,15 +209,21 @@ net x-vel-mtr <= hm2_5i24.0.encoder.03.velocity
net x-index-enable joint.0.index-enable <=> hm2_5i24.0.encoder.03.index-enable
#net x-pos-mtr => joint.0.motor-pos-fb
# Linear scale provides the actual position feedback to the joint
net x-pos-lin <= hm2_5i24.0.encoder.00.position
net x-vel-lin <= hm2_5i24.0.encoder.00.velocity
net x-index-enable joint.0.index-enable <=> hm2_5i24.0.encoder.00.index-enable
net x-pos-lin => joint.0.motor-pos-fb
# ******************
# AXIS Y JOINT 1
# ******************
# ============================================================================
# AXIS Y - JOINT 1
# Dual PID: pid.y (motor encoder) + pid.yl (linear scale), summed via sum2.1
# Motor encoder: hm2 encoder 04
# Linear scale: hm2 encoder 01
# PWM output: pwmgen.02
# ============================================================================
# --- Y motor encoder PID (velocity/damping loop) ---
setp pid.y.Pgain [JOINT_1]P
setp pid.y.Igain 0
setp pid.y.Dgain [JOINT_1]D
@@ -197,6 +239,7 @@ net y-enable => pid.y.enable
net y-pos-mtr => pid.y.feedback
net y-output-mtr <= pid.y.output
# --- Y linear scale PID (position correction loop) ---
setp pid.yl.Pgain [JOINT_1]P_LIN
setp pid.yl.Igain [JOINT_1]I_LIN
setp pid.yl.Dgain [JOINT_1]D_LIN
@@ -212,11 +255,13 @@ net y-enable => pid.yl.enable
net y-pos-lin => pid.yl.feedback
net y-output-lin <= pid.yl.output
# Sum motor + linear PID outputs for final Y drive signal
net y-output-lin => sum2.1.in0
net y-output-mtr => sum2.1.in1
net y-output <= sum2.1.out
net y-pos-cmd <= joint.1.motor-pos-cmd
# Position command feeds both PID loops
net y-pos-cmd <= joint.1.motor-pos-cmd
net y-pos-cmd => pid.yl.command
net y-pos-cmd => pid.y.command
@@ -233,6 +278,7 @@ net y-pos-rawcounts <= hm2_5i24.0.encoder.01.rawcounts
# ---Encoder feedback signals/setup---
# Motor encoder (encoder 04)
setp hm2_5i24.0.encoder.04.counter-mode 0
setp hm2_5i24.0.encoder.04.filter 1
setp hm2_5i24.0.encoder.04.index-invert 0
@@ -240,6 +286,7 @@ setp hm2_5i24.0.encoder.04.index-mask 0
setp hm2_5i24.0.encoder.04.index-mask-invert 0
setp hm2_5i24.0.encoder.04.scale [JOINT_1]ENCODER_MTR_SCALE
# Linear scale (encoder 01)
setp hm2_5i24.0.encoder.01.counter-mode 0
setp hm2_5i24.0.encoder.01.filter 1
setp hm2_5i24.0.encoder.01.index-invert 0
@@ -252,15 +299,28 @@ net y-vel-mtr <= hm2_5i24.0.encoder.04.velocity
net y-index-enable joint.1.index-enable <=> hm2_5i24.0.encoder.04.index-enable
#net y-pos-mtr => joint.1.motor-pos-fb
# Linear scale provides the actual position feedback to the joint
net y-pos-lin <= hm2_5i24.0.encoder.01.position
net y-vel-lin <= hm2_5i24.0.encoder.01.velocity
net y-index-enable joint.1.index-enable <=> hm2_5i24.0.encoder.01.index-enable
net y-pos-lin => joint.1.motor-pos-fb
#*******************
# AXIS Z JOINT 2
#*******************
# ============================================================================
# AXIS Z - JOINT 2
# Single PID: pid.zl (linear scale only), output via sum2.2
# Linear scale: hm2 encoder 02
# PWM output: pwmgen.04
# Enable relay: GPIO 044 (active low), gated by z-override AND gate
#
# Z-OVERRIDE MECHANISM:
# A HAL "logic AND" gate combines z-override (default TRUE) with z-enable.
# When z-override is set FALSE (via M101), the AND output goes low,
# disabling the Z servo and GPIO 044 relay. This allows manual quill use.
# M102 sets z-override back to TRUE to re-enable CNC Z control.
# MIN_FERROR is set to 100 in INI to prevent following errors during manual mode.
# ============================================================================
# Z motor encoder PID commented out - no motor encoder on Z axis
#setp pid.z.Pgain [JOINT_2]P
#setp pid.z.Igain 0
#setp pid.z.Dgain [JOINT_2]D
@@ -276,6 +336,7 @@ net y-pos-lin => joint.1.motor-pos-fb
#net z-pos-mtr => pid.z.feedback
#net z-output-mtr <= pid.z.output
# --- Z linear scale PID ---
setp pid.zl.Pgain [JOINT_2]P
setp pid.zl.Igain [JOINT_2]I
setp pid.zl.Dgain [JOINT_2]D
@@ -287,13 +348,17 @@ setp pid.zl.deadband [JOINT_2]DEADBAND
setp pid.zl.maxoutput [JOINT_2]MAX_OUTPUT
setp pid.zl.error-previous-target true
# Z-override AND gate: z-enable-comb = z-override AND z-enable
# When z-override is FALSE, Z servo is disabled (manual quill mode)
net z-override => logic.0.in-00
net z-enable => logic.0.in-01
net z-enable-comb <= logic.0.and
# Default: z-override is TRUE (CNC controls Z)
sets z-override TRUE
# this section about ferror doesnt work
# Attempted dynamic ferror switching (not functional - see INI workaround)
# mux2 selects between 100 (disabled) and 0.2 (enabled) based on z-enable-comb
net z-enable-comb => mux2.0.sel
setp mux2.0.in0 100
setp mux2.0.in1 0.2
@@ -304,11 +369,12 @@ net z-enable-comb => pid.zl.enable
net z-pos-lin => pid.zl.feedback
net z-output-lin <= pid.zl.output
# Z only has linear scale PID, no motor encoder sum needed
net z-output-lin => sum2.2.in0
#net z-output-mtr => sum2.2.in1
net z-output <= sum2.2.out
net z-pos-cmd <= joint.2.motor-pos-cmd
net z-pos-cmd <= joint.2.motor-pos-cmd
net z-pos-cmd => pid.zl.command
#net z-pos-cmd => pid.z.command
@@ -320,11 +386,13 @@ setp hm2_5i24.0.pwmgen.04.offset-mode 1
net z-output => hm2_5i24.0.pwmgen.04.value
net z-enable joint.2.amp-enable-out => hm2_5i24.0.pwmgen.04.enable
# Z enable relay gated through AND gate (z-override mechanism)
net z-enable-comb => hm2_5i24.0.gpio.044.out
net z-pos-rawcounts <= hm2_5i24.0.encoder.02.rawcounts
# ---Encoder feedback signals/setup---
# Motor encoder (encoder 05) - not used on Z axis
#setp hm2_5i24.0.encoder.05.counter-mode 0
#setp hm2_5i24.0.encoder.05.filter 1
#setp hm2_5i24.0.encoder.05.index-invert 0
@@ -332,6 +400,7 @@ net z-pos-rawcounts <= hm2_5i24.0.encoder.02.rawcounts
#setp hm2_5i24.0.encoder.05.index-mask-invert 0
#setp hm2_5i24.0.encoder.05.scale [JOINT_2]ENCODER_MTR_SCALE
# Linear scale (encoder 02)
setp hm2_5i24.0.encoder.02.counter-mode 0
setp hm2_5i24.0.encoder.02.filter 1
setp hm2_5i24.0.encoder.02.index-invert 0
@@ -344,19 +413,23 @@ setp hm2_5i24.0.encoder.02.scale [JOINT_2]ENCODER_LIN_SCALE
#net z-index-enable joint.2.index-enable <=> hm2_5i24.0.encoder.05.index-enable
#net z-pos-mtr => joint.2.motor-pos-fb
# Linear scale provides the actual position feedback to the joint
net z-pos-lin <= hm2_5i24.0.encoder.02.position
net z-vel-lin <= hm2_5i24.0.encoder.02.velocity
net z-index-enable joint.2.index-enable <=> hm2_5i24.0.encoder.02.index-enable
net z-pos-lin => joint.2.motor-pos-fb
#### SPINDLE ####
# ============================================================================
# SPINDLE
# On/off relay via GPIO 041 (active low). No speed control or feedback.
# ============================================================================
#net spindle.0.on spindle-enable
net spindle-enable spindle.0.on => hm2_5i24.0.gpio.041.out
#******************************
# connect miscellaneous signals
#******************************
# ============================================================================
# MISCELLANEOUS SIGNALS
# ============================================================================
# ---coolant signals---
@@ -375,7 +448,7 @@ net machine-is-enabled <= motion.motion-enabled
# ---digital in / out signals---
# ---estop signals---
# Estop loops back: user-enable-out feeds emc-enable-in (no external estop chain)
net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in
@@ -395,4 +468,3 @@ net tool-number => hal_manualtoolchange.number
# ---ignore tool prepare requests---
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared

View File

@@ -1,12 +1,21 @@
# Lagun milling machine configuration for GMOCCAPY GUI
# Based on lagun config (PNCconf Fri Jul 26 13:18:08 2024)
# Modified to use GMOCCAPY instead of AXIS
# Using LinuxCNC version: Master (2.9)
#
# Hardware: Mesa 5i24 FPGA card (hm2_pci)
# Axes: X, Y (dual encoder: motor + linear scale), Z (linear scale only)
# Pendant: XHC WHB04B-6 wireless
# Spindle: On/off relay (no speed control)
# Units: Imperial (inches)
# --- General EMC settings ---
[EMC]
MACHINE = my_LinuxCNC_machine
DEBUG = 0
VERSION = 1.1
# --- GUI configuration ---
[DISPLAY]
DISPLAY = gmoccapy
POSITION_OFFSET = RELATIVE
@@ -17,6 +26,7 @@ MIN_SPINDLE_OVERRIDE = 0.500000
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/linuxcnc/linuxcnc/nc_files
# Jog increments available in the GUI (inches)
INCREMENTS = 0.1000 0.0500 0.0100 0.0050 0.0010 0.0005 0.0001
DEFAULT_LINEAR_VELOCITY = 3.0
MAX_LINEAR_VELOCITY = 1.000000
@@ -29,6 +39,7 @@ GEOMETRY = xyz
CYCLE_TIME = 100
DEFAULT_SPINDLE_SPEED = 500
# --- File type filters for loading programs ---
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
@@ -37,23 +48,31 @@ gif = image-to-gcode
jpg = image-to-gcode
py = python3
# --- Task controller ---
[TASK]
TASK = milltask
CYCLE_TIME = 0.010
# --- G-code interpreter ---
[RS274NGC]
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
# --- Motion controller ---
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
# 1ms servo period
SERVO_PERIOD = 1000000
# --- Mesa 5i24 FPGA card ---
[HMOT]
# **** This is for info only ****
CARD0=hm2_5i24.0
# --- HAL file loading order ---
[HAL]
HALUI = halui
HALFILE = lagun.hal
@@ -61,6 +80,16 @@ HALFILE = xhc-whb04b-6.hal
POSTGUI_HALFILE = gmoccapy_postgui.hal
SHUTDOWN = shutdown.hal
# --- MDI commands for HALUI (pendant macro buttons) ---
# Index 00: (unused, debug)
# Index 01: Halve X coordinate (macro button 1)
# Index 02: Halve Y coordinate (macro button 2)
# Index 03: (unused, debug)
# Index 04: (unused, debug)
# Index 05: Zero X in current work offset (macro button 5)
# Index 06: Zero Y in current work offset (macro button 6)
# Index 07: Zero Z in current work offset (macro button 7)
# Index 08-14: (unused, debug or reserved)
[HALUI]
MDI_COMMAND=(DEBUG,<1>)
MDI_COMMAND=G10 L20 P0 X[#<_x>/2.0]
@@ -78,24 +107,34 @@ SHUTDOWN = shutdown.hal
MDI_COMMAND=(DEBUG,<13>)
MDI_COMMAND=(DEBUG,<14>)
# --- Kinematics ---
[KINS]
JOINTS = 3
KINEMATICS = trivkins coordinates=XYZ
# --- Trajectory planner ---
[TRAJ]
COORDINATES = XYZ
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 3.0
MAX_LINEAR_VELOCITY = 1.00
# Allow motion without homing first
NO_FORCE_HOMING = 1
# --- I/O controller ---
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
# Raise quill before tool change
TOOL_CHANGE_QUILL_UP = 1
#******************************************
# X AXIS - Joint 0
# Dual feedback: motor encoder (enc 03) + linear scale (enc 00)
# PWM output: pwmgen.00
# Enable relay: GPIO 046 (active low)
#******************************************
[AXIS_X]
MAX_VELOCITY = 1.0
@@ -113,8 +152,7 @@ MAX_ACCELERATION = 30.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
# Motor encoder PID gains (velocity loop)
P = 0
I = 0
D = 4
@@ -123,6 +161,7 @@ FF0 = 0
FF1 = 0.6
FF2 = 0
# Linear scale PID gains (position correction loop)
P_LIN = 300
I_LIN = 500
D_LIN = 0
@@ -131,6 +170,7 @@ BIAS = 0
DEADBAND = 0.0005
MAX_OUTPUT = 0
# Encoder scales (counts per inch)
ENCODER_LIN_SCALE = 5085.5
ENCODER_MTR_SCALE = -27939.6
# 5.4 is the ratio between linear and motor scales, roughly
@@ -149,6 +189,12 @@ HOME_SEQUENCE = 2
OUTPUT_SCALE = 1
OUTPUT_OFFSET = 0
#******************************************
# Y AXIS - Joint 1
# Dual feedback: motor encoder (enc 04) + linear scale (enc 01)
# PWM output: pwmgen.02
# Enable relay: (shares Z-axis GPIO 044 line)
#******************************************
[AXIS_Y]
MAX_VELOCITY = 1.0
MAX_ACCELERATION = 30.0
@@ -165,6 +211,7 @@ MAX_ACCELERATION = 30.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
# Motor encoder PID gains (velocity loop)
P = 0
I = 0
D = 5
@@ -173,6 +220,7 @@ FF0 = 0
FF1 = 0.6
FF2 = 0
# Linear scale PID gains (position correction loop)
P_LIN = 350
I_LIN = 500
D_LIN = 0
@@ -181,6 +229,7 @@ BIAS = 0
DEADBAND = 0
MAX_OUTPUT = 1
# Encoder scales (counts per inch)
ENCODER_LIN_SCALE = 5085.4
ENCODER_MTR_SCALE = 27453.6
# these are in nanoseconds
@@ -194,10 +243,17 @@ MAX_LIMIT = +12
HOME_OFFSET = 0.0
HOME_SEQUENCE = 3
# Negative scale inverts direction
OUTPUT_SCALE = -1
OUTPUT_OFFSET = 0
#******************************************
#******************************************
# Z AXIS - Joint 2
# Single feedback: linear scale only (enc 02), no motor encoder
# PWM output: pwmgen.04
# Enable relay: GPIO 044 (active low), gated by z-override AND logic
# z-override allows M101/M102 to disable CNC Z for manual quill use
#******************************************
[AXIS_Z]
MAX_VELOCITY = 1.0
@@ -210,6 +266,8 @@ TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
# SETTING MIN_FERROR TO 100 ALLOWS Z AXIS TO DO WHATEVER. IDEALLY ITS 0.2
# This is a workaround: when z-override disables the Z servo, the quill
# can be moved manually and would trip a normal following error limit.
MIN_FERROR = 100
MAX_VELOCITY = 1.0
MAX_ACCELERATION = 30.0
@@ -217,6 +275,7 @@ MAX_ACCELERATION = 30.0
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 1.25
STEPGEN_MAXACCEL = 37.50
# Linear scale PID gains (single loop, no motor encoder on Z)
P = 200
I = 300
D = 2
@@ -237,12 +296,15 @@ MAX_LIMIT = +1.0
HOME_OFFSET = 0.0
HOME_SEQUENCE = 1
# Negative scale inverts direction
OUTPUT_SCALE = -1
OUTPUT_OFFSET = 0
# Encoder scale (counts per inch)
ENCODER_LIN_SCALE = -10075
#******************************************
# --- Spindle PID (not actively used; relay on/off only) ---
[SPINDLE_0]
P = 0
I = 0

View File

@@ -1,2 +1,3 @@
# Include your shutdown HAL commands here
# This file will not be overwritten when you run PNCconf again
# Currently no shutdown actions are configured.

View File

@@ -1,30 +1,35 @@
# ============================================================================
# XHC WHB04B-6 wireless pendant configuration for Lagun mill
# Provides jog wheel, axis select, feed override, homing, and macro buttons
# ============================================================================
# ######################################################################
# load pendant components
# ######################################################################
# -H = HAL-only mode, -s = step mode, -f = filtered, -B = big (6-axis pendant)
loadusr -W xhc-whb04b-6 -HsfB
# ######################################################################
# pendant signal configuration
# ######################################################################
# On/Off signals
# --- Machine on/off ---
net machine.is-on halui.machine.is-on whb.halui.machine.is-on
# net pdnt.machine.on whb.halui.machine.on halui.machine.on
# net pdnt.machine.off whb.halui.machine.off halui.machine.off
# program related signals
# --- Program state feedback (read-only status to pendant) ---
net pdnt.program.is-idle whb.halui.program.is-idle halui.program.is-idle
net pdnt.program.is-paused whb.halui.program.is-paused halui.program.is-paused
net pdnt.program-is-running whb.halui.program.is-running halui.program.is-running
# Program control buttons disabled
#net pdnt.program.resume whb.halui.program.resume halui.program.resume
#net pdnt.program.pause whb.halui.program.pause halui.program.pause
#net pdnt.program.run whb.halui.program.run halui.program.run
#net pdnt.program.stop whb.halui.program.stop halui.program.stop
# machine mode related signals
# --- Machine mode (auto/manual/mdi/joint/teleop) ---
net pdnt.mode.auto whb.halui.mode.auto halui.mode.auto
net pdnt.mode.manual whb.halui.mode.manual halui.mode.manual
net pdnt.mode.mdi whb.halui.mode.mdi halui.mode.mdi
@@ -36,12 +41,12 @@ net pdnt.mode.is-mdi halui.mode.is-mdi
net pdnt.mode.is-joint halui.mode.is-joint whb.halui.mode.is-joint
net pdnt.mode.is-teleop halui.mode.is-teleop whb.halui.mode.is-teleop
# "is-homed" axis signal for allowing pendant when machine is not homed
# --- Homed status per axis (pendant needs this to allow jogging) ---
net pdnt.axis.X.is-homed halui.joint.0.is-homed whb.halui.joint.x.is-homed
net pdnt.axis.Y.is-homed halui.joint.1.is-homed whb.halui.joint.y.is-homed
net pdnt.axis.Z.is-homed halui.joint.2.is-homed whb.halui.joint.z.is-homed
# "selected axis" signals
# --- Axis select (pendant rotary switch picks active axis) ---
net pdnt.axis.X.select whb.halui.axis.x.select halui.axis.x.select
net pdnt.axis.y.select whb.halui.axis.y.select halui.axis.y.select
net pdnt.axis.Z.select whb.halui.axis.z.select halui.axis.z.select
@@ -67,18 +72,27 @@ net pdnt.axis.y.jog-vel-mode whb.axis.y.jog-vel-mode
net pdnt.axis.z.jog-vel-mode whb.axis.z.jog-vel-mode joint.2.jog-vel-mode
# macro buttons to MDI commands
# --- Macro buttons mapped to MDI commands (see [HALUI] in INI) ---
# Macro 1: halve X coord (MDI 01)
# Macro 2: halve Y coord (MDI 02)
net pdnt.macro-1 whb.button.macro-1 halui.mdi-command-01 # use MDI command from main.ini
net pdnt.macro-2 whb.button.macro-2 halui.mdi-command-02 # use MDI command from main.ini or used for Hardcoded lube on/off
# Macro 3,4: hardcoded spindle+/- inside pendant firmware
#net pdnt.reserved.for.spindle+ whb.button.macro-3 # Hardcoded for spindle+ whb.halui.spindle.increase
#net pdnt.reserved.for.spindle- whb.button.macro-4 # Hardcoded for spindle- whb.halui.spindle.decrease
# Macro 5: zero X (MDI 05)
# Macro 6: zero Y (MDI 06)
# Macro 7: zero Z (MDI 07)
net pdnt.macro-5 whb.button.macro-5 halui.mdi-command-05 # use MDI command from main.ini
net pdnt.macro-6 whb.button.macro-6 halui.mdi-command-06 # use MDI command from main.ini
net pdnt.macro-7 whb.button.macro-7 halui.mdi-command-07 # use MDI command from main.ini
# Macro 8: hardcoded spindle direction inside pendant
#net pdnt.reserved.for.spindle.dir whb.button.macro-8 # Hardcoded for spindle direction inside pendant
net pdnt.macro-9 whb.button.macro-9 halui.mdi-command-09 # use MDI command from main.ini
# Macro 10: hardcoded ABS/REL DRO toggle
net pdnt.reserved.for.ABS-REL whb.button.macro-10 # Hardcoded for swap Dro Relative/Absolue
net pdnt.macro-14 whb.button.macro-14 halui.mdi-command-14 # use MDI command from main.ini
# Macro 15,16: hardcoded flood/mist toggles
net pdnt.reserved.for.flood whb.button.macro-15 # Hardcoded for halui.flood on/off
net pdnt.reserved.for.mist whb.button.macro-16 # Hardcoded for halui.mist on/off
@@ -87,7 +101,7 @@ net pdnt.macro.12 whb.button.macro-12
net pdnt.macro.13 whb.button.macro-13 halui.mdi-command-13 # use MDI command from main.ini
# flood and mist toggle signals
# --- Flood and mist coolant toggle (pendant hardcoded buttons) ---
net pdnt.flood.is-on whb.halui.flood.is-on halui.flood.is-on #return signal is on or off
net pdnt.flood.off whb.halui.flood.off halui.flood.off #reserved whb.button.macro-15
net pdnt.flood.on whb.halui.flood.on halui.flood.on #reserved whb.button.macro-15
@@ -96,19 +110,20 @@ net pdnt.mist.is-on whb.halui.mist.is-on
net pdnt.mist.off whb.halui.mist.off halui.mist.off #reserved whb.button.macro-16
net pdnt.mist.on whb.halui.mist.on halui.mist.on #reserved whb.button.macro-16
# Lube control (unused)
#net pdnt.lube.is-on whb.halui.lube.is-on halui.lube.is-on #return signal is on or off
#net pdnt.lube.off whb.halui.lube.off halui.lube.off #reserved whb.button.macro-2
#net pdnt.lube.on whb.halui.lube.on halui.lube.on #reserved whb.button.macro-2
# default function button signals
# --- Default function buttons ---
net pdnt.button.m-home whb.button.m-home halui.home-all # Homing use built-in halui home all
net pdnt.button.safe-z whb.button.safe-z halui.mdi-command-03 # Safe-z use MDI command from main.ini
net pdnt.button.w-home whb.button.w-home halui.mdi-command-04 # Unpark use MDI command from main.ini
net pdnt.button.probe-z whb.button.probe-z halui.mdi-command-08 # Probe-Z use MDI command from main.ini
# unused, just exposes pendant internal status or as basic button
# --- Unused pendant status/button signals ---
#net pdnt.mode-lead whb.halui.feed.selected-lead
#net pdnt.mode-mpg-feed whb.halui.feed.selected-mpg-feed
#net pdnt.mode-continuous whb.halui.feed.selected-continuous
@@ -127,7 +142,7 @@ net pdnt.button.probe-z whb.button.probe-z
#net pdnt.button.feed-minus whb.button.feed-minus
# spindle related signals
# --- Spindle control (disabled - relay-only spindle, no speed feedback) ---
#net pdnt.spindle.is-on whb.halui.spindle.is-on spindle.0.on
#net pdnt.spindle.start whb.halui.spindle.start halui.spindle.0.start
#net pdnt.spindle.stop whb.halui.spindle.stop halui.spindle.0.stop
@@ -138,33 +153,31 @@ net pdnt.button.probe-z whb.button.probe-z
#net pdnt.spindle-speed-abs whb.halui.spindle-speed-cmd spindle.0.speed-out-abs # speed cmd from motion in rpm absolue
# spindle speed override signals
# --- Spindle speed override (disabled) ---
#net pdnt.spindle-override.scale whb.halui.spindle-override.scale halui.spindle.0.override.scale # needed for both spindle+/- and spindleoverride+/- button
#net pdnt.spindle.override.value halui.spindle.0.override.value whb.halui.spindle-override.value # GUI feed rate related signals
#net pdnt.spindle.override.increase whb.halui.spindle-override.increase halui.spindle.0.override.increase
#net pdnt.spindle.override.decrease whb.halui.spindle-override.decrease halui.spindle.0.override.decrease
# GUI feed rate related signals can be used when program is running moving GUI slider
# --- Feed override (pendant knob controls feed rate) ---
net pdnt.feed-override.scale whb.halui.feed-override.scale halui.feed-override.scale # needed for both FeedOverride+/- and rotary knob button
net pdnt.max-velocity.value whb.halui.max-velocity.value halui.max-velocity.value # needed for Mpg mode : button feed position% * max-velocity = Mpg feedrate
# take feed override min/max values from/to the GUI
# --- Feed override value and increment/decrement ---
net pdnt.feed-override.value halui.feed-override.value whb.halui.feed-override.value # GUI feed rate related signals
net pdnt.feed-override.increase whb.halui.feed-override.increase halui.feed-override.increase
net pdnt.feed-override.decrease whb.halui.feed-override.decrease halui.feed-override.decrease
# axis position related signals feedback
# --- Axis position feedback to pendant display ---
net pdnt.axis.x.pos-feedback halui.axis.x.pos-feedback whb.halui.axis.x.pos-feedback
net pdnt.axis.y.pos-feedback halui.axis.y.pos-feedback whb.halui.axis.y.pos-feedback
net pdnt.axis.z.pos-feedback halui.axis.z.pos-feedback whb.halui.axis.z.pos-feedback
# axis position related signals relative
# --- Axis position relative to work offset (for pendant DRO) ---
net pdnt.axis.x.pos-relative halui.axis.x.pos-relative whb.halui.axis.x.pos-relative
net pdnt.axis.y.pos-relative halui.axis.y.pos-relative whb.halui.axis.y.pos-relative
net pdnt.axis.z.pos-relative halui.axis.z.pos-relative whb.halui.axis.z.pos-relative