# PEP-II LLRF Tuner Inputs &Constants Panel

## Overview

This panel contains the various constants necessary to define the operation of the tuner loop, including phase offsets, gains, tuner polynomial coefficients, deadband and forgetting factor.

This panel is accessed using the "Inp&Consts" button about half down the Tuners panel in the column associated with the cavity of interest.

On the upper right of the panel, the equation for calculating the loading angle error is listed:

Since the phase length of the RF cables from the forward coupler and the cavity probe are unknowns, an offset must be determined for each to null both phases when the cavity is tuned to 476 MHz.  Both offsets are determined during tuner configuration which is part of station configuration.

A loading angle offset is added to the phase difference to allow the "Loading Angle Offset" loop (enabled on the Feedback panel or Tuners panel) or a fixed constant offset to be added to the loading angle error calculation.  Note that if the station phase were changed, both the forward phase and the probe phase would change but the difference would remain constant and the tuner loop still operates properly.

• Ld Angle Err Limit (Deg) - Sets the magnitude where the loading angle error value saturates. A load angle error above 5 degrees will flash the field yellow, tuner loop status will be red and display an error message.  The load angle offset (discussed below) will freeze until the error goes below the limit. Nominal value = 0.5 degrees.

• Probe Phase Offset (Deg) - Amount of offset added to the raw probe phase to form the probe phase.  Determined during tuner configuration. Can range from -180 to +180 degrees.

• Frwd Phase Offset (Deg) - Amount of offset added to the raw cavity forward phase to form the forward phase.  Determined during tuner configuration.  Can range from -180 to +180 degrees.

## Park Frequency Error Calculation

Below the loading angle error calculation is the park frequency error calculation:

PARK Freq Error = (90/(4*476e3)) * Ql * (Park Freq - Freq Offset)

This calculation is a linear approximation of the phase slope through a resonator's 3 dB points.  The difference between the "Desired Park Frequency (kHz)" and the current "Freq Offset (kHz)" along with the loaded Q allows the calculation of the "Freq Error (Deg)" which is used to replace the normal loading angle error in the tuner movement calculation (described below).  Note that even if the Ql is not correct the tuner will continue to move until the tuner polynomial reaches the "Desired Park Frequency".

• Desired Park Frequency (kHz) - Offset in kHz from 476 MHz where the cavity will move to in the PARK state.  For each station, half the cavities will be parked at +340 kHz and the other half parked at -340 kHz.  This prevents parked cavities from strongly driving low order coupled bunch modes.

• Loaded Cav Q (Ql) - Loaded cavity Q.  Does not need to be exact since the Park frequency is in feedback using the tuner polynomials to report the present resonant frequency.  Nominal value = 7000.

Below the Park frequency error calculation is the loading angle offset calculation:

This loop creates a loading angle offset based on the measured cavity strength (in percent) compared to the setpoint (also in percent).  Cavity strength is simply the fraction of the station total gap voltage (in percent) produced by the one cavity.  This is an integrating loop which uses the previous value of the offset to calculate the new value.  When the beam current goes below the limit on the Tuners panel, the RF IOC is unable to connect to the BIC IOC for beam current status, or the calculation is turned off on the Tuners panel, the stored offset value is cleared and must regenerate as beam is injected.

A forgetting factor prevents runaway by pulling the offsets for all the cavities toward zero.  This loop allows running one or more cavities at different voltages and has proven very useful.

• Fixed Offs (Deg) - Allows user to place a constant phase offset into the tuner loop for a single cavity.  Intended to be used as a diagnostic but not currently used.  Should be set to zero.

• K (Deg/%) - Gain term for the loading angle offset loop.  Nominal value = 0.5.

• Forgetting Factor (F) - On each iteration a small faction of the loading angle offset is "forgotten".  This prevents a potential (once observed) runaway condition where all tuners get offset in the same direction.  The addition of this term has solved this issue.  Nominal value = 0.9995.

• Max Offs (Deg) - Limits the maximum loading angle offset the loop can produce.  Should not need to be greater than 10 degrees but is presently set higher.  Nominal value = 75 degrees.

• Setpoint (%) - Setpoint for the loading angle offset loop.  Determines the percent of the total station gap voltage a single cavity will contribute (once the "Min Beam Curr" limit has been reached).  For example in a 4-cavity station, each cavity will normally be set to 25%.  If one cavity is prone to RF breakdown its set point can be reduced to 22% and the remaining three raised to 26%.  Important note:  The sum of all the station cavity set points must equal 100%.

• Deadband (%) - Prevents calculation of new loading angle offset if the strength error is below this value.  Prevents constant tuner motion and decreases mechanical wear.  Nominal value = 0.05.

## Delta Position Calculation

Near the bottom right of the panel is the tuner motor delta position calculation:

Delta Position = Loop Gain * Conv * Error

Based on the error term (which can be either the "Load Angle Error" or the "PARK Freq Error"), the tuner position movement in mm is calculated.

• Error Deadband (Deg) - No tuner movement will be requested if the magnitude of the error is smaller than the "Deadband" value.  This is designed to prevent unnecessary tuner movements to reduce mechanical wear.  Nominal value = 0.25 degrees.

• Max Delta Posn (mm) - Maximum tuner movement allowed for each loop iteration.  Prevents rapid tuner movements.  Nominal value = 1.00 mm.

• Conv (mm/Deg) - Scale factor which converts tuner loop phase error to desired movement in mm.  This factor is determined during tuner configuration. Nominal range = 0.020 to 0.030.

• Loop Gain - Loop gain term which allows changing gain without affecting the measured "Conv" term.  Since tuner movement is completed before the next loop iteration, this term should not exceed unity.  We have always run with unity tuner loop gain.  Nominal value = 1.00.

## Frequency Offset (Tuner Polynomial) Calculation

On the left of the panel is the frequency offset calculation:

Freq Offset (kHz) = polynomial(Tuner Posn - ON Home Posn) + (t1*(Cav Volt**2))  where

polynomial(x) = p0 + p1*(x) + p2*(x**2) + p3*(x**3)

The polynomial coefficients are generated using the "make_polynomials.m" Matlab script which is called by the "Make Polys" button in the invasive list on the MoreMATLAB EPICS panel. Remember to turn off the direct and comb RF feedback loops before generating the polynomial coefficients. A properly generated polynomial should be accurate to 10 kHz.

The philosophy that the polynomial is based on the TUNE/ON home position allows reusing the old polynomial coefficients even after changing a tuner assembly or position potentiometer, as long as tuner configuration is done to relocate the "TUNE/ON Home" position.  Since the invention of the "Fast Turnon" option, we have realized that the "TUNE/ON Home" position is set when the cavities are at a medium range gap voltage and is not optimum for banging the station on to full gap voltage.  If one adjusts the "TUNE/ON Home" position, then the polynomial is no longer valid.  The proper solution would be to either change tuner configuration to set the "TUNE/ON Home" position at a very low gap voltage or rewrite the polynomial related EPICS and Matlab code to base the polynomial on actual position (not relative to "TUNE/ON Home").  I prefer the first option.

The t1*(Cav Volt**2) term is a simple attempt to correct for cavity heating effects since thermal power is proportional to the voltage squared.

• p0 - Constant term for the tuner polynomial. Nominal range = 10 to 20.

• p1 - First order term for the tuner polynomial. Nominal range = 20 to 30.

• p2 - Second order term for the tuner polynomial. Nominal range = 0.4 to 0.6.

• p3 - Third order term for the tuner polynomial. Nominal range = -0.01 to +0.01.

• t1 - Thermal term for the frequency offset calculation. Nominal value = -.00010.

• Smoothing Factor (S) - Filters the calculated "Freq Offset (kHz)" value. Nominal value = 0.5. Smoothing equation:

new value = (1-S)*(input data)+S*(previous value)