I think that this is what you need for simple PID control.
I haven't checked this, (at all) so be careful.
Code:
#*******************
# SPINDLE S
#*******************
# ---PWM Generator signals/setup---
setp hm2_5i20.0.pwmgen.03.output-type 1
setp hm2_5i20.0.pwmgen.03.scale [SPINDLE_9]OUTPUT_SCALE
# ---Encoder feedback signals/setup---
setp hm2_5i20.0.encoder.03.counter-mode 0
setp hm2_5i20.0.encoder.03.filter 1
setp hm2_5i20.0.encoder.03.index-invert 0
setp hm2_5i20.0.encoder.03.index-mask 0
setp hm2_5i20.0.encoder.03.index-mask-invert 0
setp hm2_5i20.0.encoder.03.scale [SPINDLE_9]ENCODER_SCALE
net spindle-revs <= hm2_5i20.0.encoder.03.position motion.spindle-revs
net spindle-index-enable <=> hm2_5i20.0.encoder.03.index-enable <=>motion.spindle-index-enable
net spindle-vel-fb-rps hm2_5i20.0.encoder.03.velocity => motion.spindle-speed-in
#PID for spindle
#Need to add FF0, PGAIN, IGAIN to your [SPINDLE_9] section
#Set [SPINDLE_9]OUTPUT_SCALE to 1. That job is now done by the PID FF0
#Set FF0 to give the closest speed-match at mid-speed
#then adjust P and I to suit.
loadrt pid names=spindle_pid
# using names= means that 2-pass HAL can work.
# alternatively increment the count in the HAL file.
addf spindle_pid servo-thread
setp spindle_pid.Pgain [SPINDLE_9]PGAIN
setp spindle_pid.Igain [SPINDLE_9]IGAIN
setp spindle_pid.FF0 [SPINDLE_9]FF0
# ---setup spindle control signals---
loadrt abs count=1
addf abs.0 servo-thread # analog output
net spindle-brake <= motion.spindle-brake
net spindle-at-speed => motion.spindle-at-speed
net spindle-vel-cmd-rps => motion.spindle-speed-out-rps => spindle_pid.command
net spindle-vel-fb-rps spindle_pid.feedback
net spindle-fwd abs.0.is-positive => hm2_5i20.0.gpio.046.out
net spindle-rev abs.0.is-negative => hm2_5i20.0.gpio.047.out
net spindle-on motion.spindle-on hm2_5i20.0.pwmgen.03.enable spindle_pid.enable
net pid-out spindle_pid.output => abs.0.in
net pid-abs abs.0.out => hm2_5i20.0.pwmgen.03.value
# ---Setup spindle at speed signals---
loadrt near
addf near.0 servo-thread
net spindle-vel-cmd-rps => near.0.in1 # commanded
net spindle-vel-fb => near.0.in2 # real
net spindle-at-speed motion.spindle-at-speed <= near.0.out
setp near.0.scale 1.2