Someone needs to please make up a MPG install for dummies
I got totally tripped up for a long time with the MPG HAL. OK here's what you ask for. These are the elements of note:
1. The driver code already included inside LinuxCNC. You don't touch this. It's essential and does all the magic with the port and creates HAL pins for the functions.
2. The xhc-hb04.tcl file. This actually IS a HAL file, it executes HAL commands in a sophisticated, complicated if/else system, INSTEAD of connecting the HAL. It did not work for me. You do NOT need to use it.. IMHO it is MUCH more trouble than it's worth, and I think it's probably gonna hook up something wrongly that can only be fixed by modifying the .tcl code.
3. layout20.inc, needs to be included in your HAL. Do NOT change layout20.inc
4. Inside your ini system, there can be [XHC_HB04_BUTTONS] and [XHC_HB04_CONFIG], but these ONLY get used by the xhc-hb04.tcl code, not the XHC driver itself.
So if you don't use the xhc-hb04.tcl code, you have HAL like:
# Absolute position LCD
net pos-x halui.axis.0.pos-feedback => xhc-hb04.x.pos-absolute
net originX halui.mdi-command-09 xhc-hb04.button-goto-zero-x
I got tired of people ACCIDENTALLY pressing the yellow "home all" button, so I added:
setp debounce.0.delay 1500
net homeButton xhc-hb04.button-home => debounce.0.0.in
net homeCmd debounce.0.0.out => halui.home-all
So you must hold the button for a solid 1.5 sec to start a homing cycle, not a "whoops". If I used the .tcl, this connection would have to be implemented by changing the .tcl. Or, I might make it so "home all" only has an effect from the MPG if it's never been homed, otherwise it ignores. The case for needing it is if you've stalled an axis, in which case you can go fix it from the terminal in that rare case.
The handwheel does cause vibration on high accel machines. You can create your own lowpass easy enough:
#Lowpass Filtering for mpg
addf mult2Lowpass servo-thread
setp ilowpass.0.scale 1000
setp ilowpass.0.gain 0.01
net jog-counts_in xhc-hb04.jog.counts => ilowpass.0.in
net jog-counts_out ilowpass.0.out => axis.0.jog-counts axis.1.jog-counts axis.2.jog-counts halui.feed-override.counts halui.spindle-override.counts
net jog-scale xhc-hb04.jog.scale => mult2Lowpass.in0
setp mult2Lowpass.in1 0.001
net scale_div_1000 mult2Lowpass.out => axis.0.jog-scale axis.1.jog-scale axis.2.jog-scale #axis.3.jog-scale
# Wheel for feedrate and spindle
setp halui.feed-override.scale 0.00001
net jog-feed halui.feed-override.count-enable <= xhc-hb04.jog.enable-feed-override
net jog-feed2 halui.feed-override.value => xhc-hb04.feed-override
setp halui.spindle-override.scale 0.00001
net jog-spindle halui.spindle-override.count-enable <= xhc-hb04.jog.enable-spindle-override
net jog-spindle2 halui.spindle-override.value => xhc-hb04.spindle-override