[Home]Combining Two Feedback Devices On One Axis

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

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

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]

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited October 26, 2017 9:00 pm by KimK (diff)
Published under a Creative Commons License