In effect, he is averaging the two sensors. That is not the best way, but it would work.
The more common way to take advantage of two sensors is to nest the two PIDs, where the outer loop sets the set point for the inner loop. For example, the outer loop measures position, and the inner is torque. I think(?) the setup described below would be the same as if you determined position by combining the two position sensors and then had one PID loop. The double PID is common on something like a robot arm or leg. The inner PID uses a rotational sensor on the motor, and the joint connects to the motor via a (say) 10:1 planetary gear reduction. Gears always have backlash, so there is a position sensor on the joint. The joint PID’s output is a setup that is handed to the inner PID. I’d be surprised if this is not the most common way for machine tools, too. > On Dec 31, 2025, at 2:16 PM, andrew beck <[email protected]> wrote: > > hey guys > > just looking for a config example if possible for a mesa card from someone > that has this nested PID loop setup. > > internal PID loop uses servo motor encoder and the outer Pid loop only uses > the Intergral value with the scale and then they get summed together to > drive the motor > > > I found this link here on the forum and want to try set it up > > http://wiki.linuxcnc.org/cgi-bin/wiki.pl?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 > 1. net X-linear-pos-fb 'linear position feedback' pid.4.feedback > 5. motor encoder position feedback connects to the feedback input of the > pid.0 PID > 1. net X-motor-pos-fb 'axis motor position feedback' pid.0.feedback > 6. position command signal from LinuxCNC axis connects to both PID > command inputs > 1. net Xpos-cmd axis.0.motor-pos-cmd pid.0.command pid.4.command > 7. bit signals from LinuxCNC axis connnects to enable/disable both PID > loops > 1. net Xenable axis.0.amp-enable-out pid.0.enable pid.4.enable > 8. set PID loop output limits as specified in ini file > 1. setp pid.0.maxoutput [AXIS_0]PID_MAX_VEL > 2. setp pid.4.maxoutput [AXIS_0]PID_MAX_VEL > 9. set the motor encoder PID loop gains > 10. NOTE - I gain is set to zero - it would fight the other PID > 1. setp pid.0.Pgain [AXIS_0]P > 2. setp pid.0.Igain 0 > 3. setp pid.0.Dgain [AXIS_0]D > 4. setp pid.0.bias [AXIS_0]BIAS > 5. setp pid.0.FF0 [AXIS_0]FF0 > 6. setp pid.0.FF1 [AXIS_0]FF1 > 7. setp pid.0.FF2 [AXIS_0]FF2 > 8. setp pid.0.deadband [AXIS_0]DEADBAND > 9. setp ppmc.0.DAC.00.scale [AXIS_0]OUTPUT_SCALE > 11. set the linear scale PID loop gains > 12. NOTE - it has only I gain - all other gains are set to zero > 1. setp pid.4.Pgain 0 > 2. setp pid.4.Igain [AXIS_0]I > 3. setp pid.4.Dgain 0 > 4. setp pid.4.bias 0 > 5. setp pid.4.FF0 0 > 6. setp pid.4.FF1 0 > 7. setp pid.4.FF2 0 > 8. setp pid.4.deadband [AXIS_0]DEADBAND > 13. connect both PID output signals to sum2.4 inputs > 14. sum the outputs of pid.0 and pid.4 > 15. pid.0 is using motor encoder feedback > 16. pid.4 is using linear scale feedback > 1. net Xoutput-motor pid.0.output sum2.4.in0 > 2. net Xoutput-linear pid.4.output sum2.4.in1 > 17. the summed PID output is connnected to the DAC input signal > 1. net Xoutput sum2.4.out 'DAC input' > 18. repeat as necessary for more axes > > _______________________________________________ > Emc-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/emc-users _______________________________________________ Emc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-users
