Due to the open-loop response of my servo motors I found I need 'inverse-deadband' on the PID output to achieve a 'tight' PID loop.
The idea is that since the motors don't respond to DAC outputs between around -0.2 to +0.2 it's not a good idea to use this interval of the DAC. I'm mapping the -10 to +10 output of the PID loop to two ranges, -10 to -0.2 and +0.2 to +10, thus avoiding the [-0.2 , +0.2] interval where the amps/motors don't respond.
Comp is a fantastic tool for writing quick custom HAL components. As usual I received knowledgeable help on IRC and was able to test my 16-line idb-component within minutes.
component idb "Inverse Deadband"; pin in float in "Input"; pin out float out "Output"; param rw float amount; function _ ; license "GPL"; ;; FUNCTION(_) { if (in==0.0) out=in; else if (in<0.0) out=in-amount; else if (in>0.0) out=in+amount; }
Note that this code will produce a maximum output of 10+amount or -10-amount when the input is +/- 10. Be careful if your drives cannot handle this!
This component is also on the EMC2 wiki:
http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?ContributedComponents#idb_Inverse_Deadband