Hi
Regarding to your component i have try to add something similar.
Attached is the revision with the spindle home after machine homing included.
HAL patrs need to add a or2 component for pid enable.
Code:
#####################################################################
# Spindle orient mode
#####################################################################
loadrt orientv4 names=orient.orient-spindle
loadrt pid names=pid.orient-spindle
loadrt or2 names=or2.orient-spindle-pid-ena
addf orient.orient-spindle servo-thread
addf pid.orient-spindle.do-pid-calcs servo-thread
addf or2.orient-spindle-pid-ena servo-thread
# setup Orient Spindle PID
setp pid.orient-spindle.Pgain [ORIENT]P
setp pid.orient-spindle.Igain [ORIENT]I
setp pid.orient-spindle.Dgain [ORIENT]D
setp pid.orient-spindle.FF0 [ORIENT]FF0
setp pid.orient-spindle.FF1 [ORIENT]FF1
setp pid.orient-spindle.FF2 [ORIENT]FF2
setp pid.orient-spindle.bias [ORIENT]BIAS
setp pid.orient-spindle.deadband [ORIENT]DEADBAND
setp pid.orient-spindle.maxerror [ORIENT]MAX_ERROR
setp pid.orient-spindle.maxerrorI [ORIENT]MAX_ERROR_I
setp pid.orient-spindle.maxoutput [ORIENT]MAX_OUTPUT
setp orient.orient-spindle.vel-speed [ORIENT]VEL_SPEED
setp orient.orient-spindle.tolerance [ORIENT]AT_ANGLE_TOL
# Set asked mode from M19 P0/1/2
net spindle-orient-mode <= motion.spindle-orient-mode
net spindle-orient-mode => orient.orient-spindle.mode
# pid output mux with regular spindle modul
net DAC-ctrl-out-orient <= pid.orient-spindle.output
net DAC-ctrl-out-orient => orient.orient-spindle.cmd-orient
net DAC-ctrl-out-velocity => orient.orient-spindle.cmd-velocity
net DAC-computed-ctrl-out <= orient.orient-spindle.cmd-out
net DAC-computed-ctrl-out => hpg.pwmgen.00.out.00.value
# enable out for controler from regular spindle or orient mode
net spindle-enable => orient.orient-spindle.ena-velocity
net spindle-orient-enable-out <= orient.orient-spindle.ena-out
net spindle-orient-enable-out => fur.do-6 # enable output for VFD muxed with regular spindle modul
# encoder connections index + feedback
net spindle-index-enable => pid.orient-spindle.index-enable # need investigation
net spindle-pos => orient.orient-spindle.position
net spindle-pos-deg <= orient.orient-spindle.scaled-angle-out
# Spindle orient control signals
net spindle-orient-enable <= motion.spindle-orient
net spindle-orient-enable => orient.orient-spindle.enable
net spindle-orient-enable => or2.orient-spindle-pid-ena.in0
net spindle-orient-home-enable <= orient.orient-spindle.homing
net spindle-orient-home-enable => or2.orient-spindle-pid-ena.in1
net spindle-orient-or2home-ena <= or2.orient-spindle-pid-ena.out
net spindle-orient-or2home-ena => pid.orient-spindle.enable
net spindle-index-enable <=> orient.orient-spindle.index-enable
net machinehomed <= axis.0.homed
net machinehomed => orient.orient-spindle.machine-is-homed
# Is oriented near signal + link position asked to component
net spindle-orient-degree-cmd <= motion.spindle-orient-angle
net spindle-orient-degree-cmd => orient.orient-spindle.angle
net spindle-is-oriented <= orient.orient-spindle.is-oriented
net spindle-is-oriented => motion.spindle-is-oriented
## Command to pid from component by velocity and velocity feedback
net spindle-orient-vel <= orient.orient-spindle.command
net spindle-orient-vel => pid.orient-spindle.command
net spindle-vel-fb-rps => pid.orient-spindle.feedback
In my opinion this is not the cleanest way for homing the spindle because motion or halui do no know what append.
I think is better to think about adding this feature in motion and or halui.
Edit : homing does not work correctly