The servo belt drive for the spindle has proven to be a great upgrade. Milling 7050 aluminum with this 20 mm roughing end mill is like cutting butter.
However my already noisy spindle bearings didn't like the extra torque and rpm for very long so after partially machining the part below I had to pause and replace the bearings...
While I had the machine apart I decided to install a pneumatic tool release cylinder.
In order to safely trigger the tool release I used the toggle, and, not components to create a HAL logic which only enabled to tool release button if the spindle is not enabled. And while the tool release is in progress it inhibits machine and spindle motion.
The HAL code for this was pretty straight forward.
Code:
#Pneumatic tool release
loadrt toggle names=tool-change-toggle
loadrt and2 names=and-tool-change
loadrt not names=spindle-not-enabled
addf tool-change-toggle servo-thread
setp tool-change-toggle.debounce 5
addf spindle-not-enabled servo-thread
addf and-tool-change servo-thread
net tool-change-button <= hm2_7i96s.0.7i84.0.0.input-14
net spindle-enable-soft-stop => spindle-not-enabled.in
net spindle-disabled <= spindle-not-enabled.out
net tool-change-button => and-tool-change.in0
net spindle-disabled => and-tool-change.in1
net trigger-tool-change <= and-tool-change.out
net trigger-tool-change => tool-change-toggle.in
net tool-change-toggled <= tool-change-toggle.out
net tool-change-toggled => hm2_7i96s.0.7i84.0.0.output-04
net tool-change-toggled => spindle.0.inhibit
net tool-change-toggled => motion.feed-inhibit
However I banged my head against component conflicts for quite some time. First I tried the HAL TWOPASS setting which to my great surprise didn't work. Upon reading the documentation a bit more closely I realized that the TWOPASS option doesn't work for postgui HAL files which is exactly what I was dealing with here.
The conflict ended up being caused by the stock probe_basic_postgui.hal file which loads some components before chain loading my custom.hal file. My custom.hal in turn chain loads a separate run_pause.hal file (the excellent run/step/resume code from BigJohnT). I had to consolidate all these files as it made not sense to have the code spread out if they ended up being dependent on each other any way.
After sorting that out the tool release logic works great. Thought this could be useful information for other rookies who come across this problem.