Tuning the IRTF TCS3 Servo System

1. Type of motion 

   For Slewing/MP, uses J=STEP to perform a point-to-point move.

   For Tracking, adjust velocity using 'Ixx22=vel J+' to keep pmac 
   position close to tcs3 vtcs position. 

2. Tuning Goals 

   For tracking we wanted to keep the motor following error inside a 0.2
   arcsecond band 95% of the time, And inside 0.1, 70% of the time.

   We also wish to keep the velocity stable: not varying by more that 1.4 arcsecond/sec.

   During tracking, we used 30 arcseond offset as the standard value to tune
   to. Our setting time goal is 2 seconds.

   Based on TCS1 servo performance was measured in hist/0710/11oct_tcs1_data/.
      tcs1 following error <= 2.0 arcseconds.
      tcs1 velocity is within 1.4 arcseconds/sec (80% of data).

   The TCS1 offset deadtime is 2.0 seconds.  

3. HA tracking (track & MV mode) 

   Auto PID values are 100000 3000 10000

   P can be as low as 75000 up to 100000. 100000 give stiffer responds.
   Beyond a 100,000 the servo will overshoot too much during offsets.
   The lower the P, the longer it will take to setting into 'good' tracking.

   High D is need to dampen when offseting. Going over 10000 provides better
   damping, but the motor start to fighting with each other more. 
   So 10,000 is a good high limit.

   Lots of I is good to settle the motor after an offset. Look like
   2500-3000 is needed since tracking East need lots of I to setting.
   Going beyond 3000 is dangerous since higher I can make the servo unstable.

   The TCS set Ix34=1 (turning off the integrator) when rtcs_ferr is > 0.2
   arcsec; This effectly turns off I during an offset. Without this the I-term 
   would need to be lower: > 2500.

   Need to modifiy the default Jog/Home S-Curve Time (Ix21) of 50 for
   tracking. 50ms will cause a ~50ms latency when an offset occures.
   For immediate response to offset, Ix21=1 is used.

   Adjusting Ix63, Motor XX integration Limit, doesn't help performance.
   The system is unstable at high I-terms . A value of Ix63=2000 is 
   a value with doen't affect performance during tracking+offset. 
   A suggest value of 4000 is used for safety.

   The deadband feature isn't very helpful during offsets. The
   motor_following_error cross back and forth zero during offset.
   Using deadband make it offshoot more.

   Ix35 (accel FeedForward) default is 0. Setting higher doesn't seem to help
   tracking or offsetting much. At values above 7000, it make offset worse
   (axis goes to fast, and starts overshooting). Maybe a value of 1000 is OK.

   Acceleration controlled using Ixx19. Track allow for 800 as/s^2.

   The PC will limit the PMAC velocity to 400 as/s.

4. HA Slewing (slew & MP mode)

   PID values are 80000 500 150.

   acceleration is controlled using Ix21 (Jog/Home S-curve time)
      if( vel < 400 as/s)
         ix21 = 2000 (2 seconds)
      else
         ix21 = 4000 (4 seconds)

   At speeds above 400 as/s the pmac is unable to maintain a stable
   velocity. Use are using the S-Curve to provide a very relaxed acceleration
   curve for the telescope.

   The PC will limit the PMAC velocity to 1600 as/s.

5. Dec tracking

   PID values are 80000 2000 100.

   The PC will limit the PMAC velocity to 400 as/s.

6. Dec Slewing

   PID values are 50000 2000 100.

   acceleration is controlled using Ix21 (Jog/Home S-curve time)
   Ix21 = 1000 (1 seconds).

   The PC will limit the PMAC velocity to 1600 as/s.

1. Summary of PMAC tuning Ixx Variables

Maximum Jog/Home Accel     Ixx19  default=0.15625 count/m^2; *Set at begining of track/slew.
Jog/Home Accel time        Ixx20  default=0 (ixx21 is in control). (NOT USED BY TCS3)
Jog/Home S-curve time      Ixx21  default=50 *rtcs commands in realtime.        

PID Proportional Gain       Ixx30 * rtcs commands in realtime (if autopid is ON)
PID Integral Gain           Ixx33 * rtcs commands in realtime (if autopid is ON)
PID Integral Mode           Ixx34 * default=1; change to 0 in setup. 0 means On all the time.
PID Derivative Gain         Ixx31 * rtcs commands in realtime (if autopid is ON)

PID Velocity FF Gain        Ixx32 
PID Accel FF Gain           Ixx35 * suggested value 1000. default is 0.

PID Notch Filter Coe N1     Ixx36
PID Notch Filter Coe N2     Ixx37
PID Notch Filter Coe D1     Ixx38
PID Notch Filter Coe D2     Ixx39



Max Jog/Home Acceleration   Ixx19 *  rtcs commands in realtime (track, slew, mv,mp)
Max Jog/Home Accel Time     Ixx20 
Max Jog/Home S-Curve Time   Ixx21 *  rtcs commands in realtime (track, slew, mv, mp)
Max Jog Speed               Ixx22 *  rtcs commands in realtime (Track, Slew, MV, MP) 

Abort Deceleration Rate     Ixx15

Net Desired Pos Filter Gain Ixx40
Desired Positin Limit Band  Ixx41

Motor Integration Limit     Ixx63    default=4,194,304. For safety set to 4000.
                                     (about 2000 is used during tracking).

Deadband Gain Factor        Ixx64    default=0
Deadband Size               Ixx65    default=0

Position Error Limit        Ixx67    default=4,194,304 (=262,144 counts)

Motor Friction Feedforward  Ixx68    default=0

Output Command Limit        Ixx69 *  13106 -> we limit the DAC output to 4v..