Combining_Two_Feedback_Devices_On_One_Axis - rmu75/linuxcnc-wiki GitHub Wiki
date: '2017-10-26T23:00:16' title: Combining Two Feedback Devices On One Axis
This page shows how to combine two position feedback devices into two PID's for the tuning and positioning of one axis.
1.This example has one high resolution linear scale on the axis table and one rotary encoder on the axis drive motor. 2.This could also be a rotary encoder on the ballscrew and a rotary encoder on the motor 3.This assumes the PID's are loaded and connected to the servo thread 4. linear scale position feedback connects to the input of the pid.4 PID 5.net X-linear-pos-fb 'linear position feedback' pid.4.feedback 6. motor encoder position feedback connects to the feedback input of the pid.0 PID 7.net X-motor-pos-fb 'axis motor position feedback' pid.0.feedback 8. position command signal from LinuxCNC axis connects to both PID command inputs 9.net Xpos-cmd axis.0.motor-pos-cmd pid.0.command pid.4.command 10. bit signals from LinuxCNC axis connnects to enable/disable both PID loops 11.net Xenable axis.0.amp-enable-out pid.0.enable pid.4.enable 12. set PID loop output limits as specified in ini file 13.setp pid.0.maxoutput [AXIS_0]PID_MAX_VEL 14.setp pid.4.maxoutput [AXIS_0]PID_MAX_VEL 15. set the motor encoder PID loop gains 16. NOTE - I gain is set to zero - it would fight the other PID 17.setp pid.0.Pgain [AXIS_0]P 18.setp pid.0.Igain 0 19.setp pid.0.Dgain [AXIS_0]D 20.setp pid.0.bias [AXIS_0]BIAS 21.setp pid.0.FF0 [AXIS_0]FF0 22.setp pid.0.FF1 [AXIS_0]FF1 23.setp pid.0.FF2 [AXIS_0]FF2 24.setp pid.0.deadband [AXIS_0]DEADBAND 25.setp ppmc.0.DAC.00.scale [AXIS_0]OUTPUT_SCALE 26.set the linear scale PID loop gains 27. NOTE - it has only I gain - all other gains are set to zero 28.setp pid.4.Pgain 0 29.setp pid.4.Igain [AXIS_0]I 30.setp pid.4.Dgain 0 31.setp pid.4.bias 0 32.setp pid.4.FF0 0 33.setp pid.4.FF1 0 34.setp pid.4.FF2 0 35.setp pid.4.deadband [AXIS_0]DEADBAND 36. connect both PID output signals to sum2.4 inputs 37. sum the outputs of pid.0 and pid.4 38. pid.0 is using motor encoder feedback 39. pid.4 is using linear scale feedback 40.net Xoutput-motor pid.0.output sum2.4.in0 41.net Xoutput-linear pid.4.output sum2.4.in1 42. the summed PID output is connnected to the DAC input signal 43.net Xoutput sum2.4.out 'DAC input' 44. repeat as necessary for more axes
It seems redundant to measure the same axis twice, with two encoders. But often that gives significantly better results than using a single encoder. Whether it is two different kinds of sensor -- gyro, accelerometer, GPS 1. Or two identical sensors in two different locations, one with accuracy but bad latency, the other with good (low) latency but bad accuracy: Bob Pease, "What's All This P-I-D Stuff, Anyhow?"2