Position Control with PID Library

Hi all,

Would like some help with the PID Library.

Here is my use case: I have a high-resolution encoder that is constantly monitoring the shaft angle of a telescope's right ascension axis.

This shaft must be turning at a fixed rate of approx. 15.04" / second (that is, 15.04 arc-seconds per second). However, due to imperfections in the telescope's gear train, the actual speed varies around this figure ("periodic error").

The input variables I have are

  • the actual measured angle of the axis (call it measured_angle)
  • the desired angle of the axis (call it expected_angle)

I have two relay type outputs (to be precise ST-4 outputs). The first output doubles the speed of the RA drive, and the other output zero's the speed of the RA drive.

I have been using a dumb "on off" circuit (no PID Library at all, but I suppose it is a primitive sort of PID) and it regulates the position fairly well, but there are persistent drifts and jumps that I am hoping that true PID control can address. However I don't know how to do it. :stuck_out_tongue:

Sample code would be much appreciated.

Without a continuous speed adjustment control I fear that's the best that can be done - so long as the relays are pulsed for the smallest
unit of time that has an effect you'll reduce the size of the jumps. Adding a little hysteresis into the system may be
needed to prevent back-and-forth oscillations resulting from slop in the gear system.