Precision feedback control of a normal conducting standing wave resonator cavity

In this paper, the system identification and feedback controller design for a normal conducting standing wave radio frequency cavity operated in pulsed mode of a free electron laser is presented. The system identification, essential to achieve high performance control, is based on a grey box model, with a priori knowledge about the physical behavior. The feedback regulation concept is separated into two basic controller parts. A radio frequency controller design, based on the identified radio frequency model, is followed by a system identification and regulation of the pulse width to overcome the limitation of the underlying temperature regulation. It will be shown by measurements at the free electron laser FLASH at DESY, Germany, that the combination of both cascaded control schemes lead to high radio frequency field performance.


I. INTRODUCTION
The European X-Ray Free Electron Laser (European XFEL) is a 3.5 km long facility starting at the Deutsches Elektronen-Synchrotron (DESY, Germany) in the northwestern direction to the town Schenefeld. It will supply laser light with a tunable wavelength in x-ray range ð10 −10 mÞ [1]. Since 2005 DESY operates the free electron laser in Hamburg (FLASH) as a user facility serving as a test bed for the European XFEL. The precision feedback control scheme presented in this paper has been extensively tested and operated at FLASH. Both facilities are driven in a pulsed mode with 10 Hz repetition rate. Each radio frequency (rf) pulse can be divided into three parts; the filling, the flattop and the decay time as shown in Fig. 1. During filling, the rf field is guided by a predefined set-point trajectory on a smooth curve until the operating gradient and phase is achieved. The rf field amplitude and phase is maintained during flattop while electron bunches are injected with maximum repetition rate of 3 MHz at FLASH and 4.5 MHz at the European XFEL. During the decay, the rf power is turned off and the rf field decays exponentially. Even though the rf systems can operate with a maximum 1.3 ms pulse length, we restrict the rf pulse length at the rf gun at full power to a maximum of 650 μs in order to increase its operational lifetime. The superconducting accelerator requires a rise time of 500 μs (FLASH) or 700 μs (European-XFEL) which reduces the usable rf pulse length for beam operation to 800 and 600 μs, respectively. The measurements shown have been performed during start-up and commissioning of the FLASH rf gun operated at about 530 μs. The electron bunches are emitted for a given bunch charge (typically 0.1-1 nC) by impinging a picosecond long laser pulse onto a photocathode mounted in the 1.5-cell normal conducting rf gun. The electron bunch leaving the rf gun is further accelerated by superconducting rf cavities to its desired target energy. In 2008, a multi-input multi-output (MIMO) field controller was implemented for the first time. The MIMO controller was set up in order to increase the rf field stability for the superconducting acceleration modules [2]. Together with an iterative learning control (ILC) algorithm the performance could be increased towards the desired amplitude and phase specification, i.e., a standard deviation of σ A ¼ ΔA=A ≤ 0.01% rms and σ ϕ ¼ Δϕ ≤ 0.01 deg rms, by using the H ∞ fixed-order optimization in discrete time [3][4][5]. Recently the rf gun signal detection was adapted to the MicroTCA.4 [6] based LLRF system opening new possibilities. This new system shows a much higher rf field precision and a low latency signal processing required for feedback controlled systems with a large bandwidth like an rf gun, here with low quality factor. Electrons are emitted and accelerated by the rf gun during flattop to almost speed of light. During flattop the rf field needs to be controlled in amplitude and phase to high precision ensuring constant acceleration from bunch to bunch within a train of bunches. Deviations as little as 0.1% or 0.1deg from the nominal operating point lead to a significant reduction in the performance of the soft x-ray radiation of the self-amplified spontaneous emission (SASE) FEL. An rf phase deviation of only 0.1 deg results in an arrival time deviation of about 85 fs at the first superconducting rf acceleration module at FLASH, leading to a change in pulse compression [7]. From experience at FLASH an amplitude stability of σ A ¼ ΔA=A ≤ 0.01% rms and a phase stability of σ ϕ ¼ Δϕ ≤ 0.01 deg rms is required in order not to compromise user experiments. In order to ensure optimal SASE conditions and stable timing of the x-ray pulses in respect to optical pump-probe lasers, it is desired to keep beam performance deviations for multibunch electrons already at the rf gun as small as possible.
The paper is organized as follows: Section II starts with an overview of the rf gun. Sections III and IV focus on the system identification and controller design for the rf field. A fast pulse-to-pulse and intrapulse estimate of the resonance frequency and hence the rf gun temperature is studied in Sec. V. Regulating the resonance frequency which is to first order proportional to the rf gun temperature using a cascaded control concept by controlling the amount of stored rf energy in the rf field is discussed in Sec. VI. Conclusions are given in the last section.

II. OVERVIEW RF GUN
The rf gun at FLASH is a 1.5 cell copper cavity accelerating the electron bunches to a momentum of 5.6 MeV=c. The 1.3 GHz rf power is fed through a coaxial waveguide coupler to the cavity. With a peak power of 5 MW the maximum accelerating field amplitude at the cathode is 53 MV=m. Since the rf gun is not equipped with field probes, a directional waveguide coupler is used, mounted close to the rf gun coupler (Fig. 2). The forward and reflected signals are combined to derive a "virtual" field probe. Due to the power losses within the copper cavity with surface resistance R, the rf gun body is temperature stabilized using a water cooling system depicted in Fig. 2. The incoming temperature T in is controlled to keep the iris temperature T IRIS at its set point. The water exits the rf gun with temperature T out . The control signal α p regulates the pump flow rate in the circuit. A heater with control signal α h keeps the water temperature constant if the rf gun is not in operation (no heat consumption due to rf). A water tank is installed between the heater and mixing valves. Possible water temperature oscillations are damped by this tank, since the tank acts as a low pass filter within the regulation loop. The water exiting the tank is mixed with cold water T cw using the control signal α cw , while α out keeps the amount of water within the circuit constant. Currently this water regulation system is controlled to its quantization level, shown in Fig. 3, via a proportional-integral (PI) controller implemented on a programmable logic controller. However, pressure and temperature variations in the quantization level still affect the rf gun temperature. The current water regulation system, even though impressively good (ΔT ≈ 0.015 K), is with its slow response time and long latency not good enough. Therefore we developed a fast temperature regulation system using the rf pulse itself which puts or removes heat into the gun much faster, discussed in Sec. VI. Within this paper, we focus mainly on the rf field signals and their regulation. Furthermore, it is shown that the rf field regulation is limited by the rf gun temperature fluctuations.
The control of rf fields is carried out within a so-called low-level rf (LLRF) system which processes the measured field signals in a digital feedback loop, shown in Fig. 4. The basic functionality is briefly outlined in the following [8]. The rf reference signal is generated by the facility master oscillator. The amplitude and phase of the rf reference signal is controlled by a vector modulator and drives a solid state preamplifier. A 10 MW klystron amplifies the signal which is connected to the rf gun by two waveguides, cirulators and a T-combiner. During operation, the forward and reflected signal of the electromagnetic wave at the waveguide to the rf gun are measured with a directional coupler. The rf signals are down-converted by an analog mixer to an intermediate frequency (IF) which is sampled by a fast analog-to-digital converter (ADC). The detected rf signals are given by the forward V forw;I þ i ·Ṽ forw;Q ¼Ã forw · e iφ forw ¼Ṽ forw ∈ C and reflected V refl;I þ i ·Ṽ refl;Q ¼Ã refl · e iφ refl ¼Ṽ refl ∈ C wave signals. These rf signals are corrected for systematic errors such as cable length, attenuation of connectors etc. The goal of the calibration is to find the complex coefficients a and b such that holds. The virtual cavity probe signal V cav , the signal to be controlled, is the summation of the calibrated forward V forw and reflected V refl signals. The complex reflection coefficient Γ is determined using the well-known relationship The reflection coefficient must follow a path on a circle with intersection point Γ ¼ −1, i.e., full reflection.
Detuning the rf gun, e.g., by increasing its temperature or changing the driving frequency, leads to a set of complex reflection factors, red dots in Fig. 5. The measurements shown were performed applying a calibration pulse, see The complex calibration coefficients a and b are fitted to the theoretical circle with known intersection point Γ ¼ −1 [9]. Constant errors, e.g., due to crosstalk between the signals are not of main interest for LLRF control [10]. The driving signalũðkÞ ∈ R ð2×1Þ with ½−131072…131071 digits for an 18 bit digital-to-analog converter (DAC) is the superposition of the feed forward signal u FF ðkÞ, the correction signal u corr ðkÞ and the MIMO controller signal uðkÞ. The set-point trajectory defines the feed forward signal. The update of the correction signal is based on an ILC algorithm minimizing repetitive errors from pulse to pulse. Intrapulse errors are compensated by the MIMO feedback and its controller signal. The system is set up by changing attenuators such that the driving signal uses about 70% of the DAC dynamic range to reserve some overhead for regulation, e.g., driving signal of about 92 000 digits for operating the rf gun at a nominal gradient of 53 MV=m.
The system to characterize, e.g., by using system identification in discrete time, is defined by the vector modulator input to the virtual probe output, denoted in discrete time bỹ uðkÞ and yðkÞ, respectively. The signals processed in the controller are represented for each field vector in terms of real (in-phase or index I) and imaginary (quadrature or index Q) parts. Therefore the system is described as a MIMO system with two inputs and two outputs which need to be controlled.

III. RF FIELD SYSTEM IDENTIFICATION
The superconducting rf modules at FLASH are approximated by a grey box model in discrete time [11,12]. The same physical approach will work for the rf gun with the exception of some microseconds during power up and power off the rf gun and its time-dependent reflection coefficient [13]. Furthermore, nonlinear effects, e.g., intrapulse thermal heating or klystron input/output behavior [14], extend the system identification process to the class of nonlinear models. Those can be approximated by linear parameter varying models with scheduling parameter, e.g., input amplitude. To simplify the identification procedure and to reduce the complexity of the digital MIMO controller, a linear time invariant small signal model is to be estimated. Optimizing the MIMO controller for high precision intrapulse feedback requires a precise system model for the flattop. Hereby, we use a model around the nominal amplitude and phase reference trajectory given by the feed forward signal. Furthermore, deviations of the system output and its reference trajectory from pulse to pulse are minimized with iterative learning control adapting the feed forward by a correction signal. Hereby, the system is forced close to its operating trajectory by combination of feed forward and its correction. Both signals lift the system to a nonzero operating point. Around this operating point a system model is estimated using small signal excitation applied at uðkÞ. The system response y ðw=Þ ðkÞ with excitationũ ðw=Þ ðkÞ ¼ u FF ðkÞ þ u corr ðkÞ þ uðkÞ is subtracted from system response y ðw=oÞ ðkÞ without an additional excitation signalũ ðw=oÞ ðkÞ ¼ u FF ðkÞ þ u corr ðkÞ. This leads to a small signal set ΔuðkÞ ¼ũ ðw=Þ ðkÞ −ũ ðw=oÞ ðkÞ ¼ uðkÞ; ΔyðkÞ ¼ y ðw=Þ ðkÞ − y ðw=oÞ ðkÞ: ð1Þ Furthermore, the input/output data is shifted with respect to the a priori identified system delay, i.e., 1.66 μs or T d ¼ z −15 for 9 MHz sampling frequency. Afterwards the model is extended by the known time delay. The main dynamics of the system show a low-pass characteristic by neglecting high frequency effects like higher order modes. Small deviations within the identification and validation process were observed using a symmetric modeling approach. Therefore, a second approach, i.e., nonsymmetric modeling is presented coping with not perfectly calibrated elements, e.g., caused by the vector modulator or nonlinear behavior of a klystron [14]. The SO(2) (based on special orthogonal group of dimension 2)-like symmetric modeling without and with disturbances of symmetry is discussed in the following.

A. SO(2)-like symmetric modeling
Let us define the transfer matrix of the given system, i.e., input to the vector modulator to cavity probe, in discrete time as with input vector ΔUðzÞ, output vector ΔYðzÞ, transfer matrixĜ 0 ðzÞ and transfer functions G 1 ðzÞ and G 2 ðzÞ. This model structure follows the mathematical equations from [8] showing a symmetric structure. It has been shown in [12] that the serial connection of vector modulator, klystron and cavity can be separated intoĜ 0 ðzÞ ¼ A G ðzÞ · Rðϕ G Þ.
The frequency dependent single-input single-output (SISO) transfer function A G ðzÞ is scaled by the system dependent phase ϕ G and captures the dynamics of the system. A static MIMO mapping matrix Rðϕ G Þ is defined as fulfilling the SO(2) symmetry as rotation matrix. Hereby the system shows an SO(2)-like symmetric structure. Further details are available in [12]. We extended this symmetric approach to a non-SO(2) symmetric modeling since the identification and validation results were not satisfactory.

B. Non-SO(2)-like symmetric modeling-Part A
In case of a nonsymmetric (hence disturbed) plant, two of the four transfer functions in transfer matrixĜ 0 ðzÞ can be extended by two additional non-negative variables ν 1 and ν 2 ; ν ∈ R ≥0 as ΔY I ðzÞ Such an approach is important if nonlinear effects from the klystron and vector modulator need to be considered, see [15]. Converting the system from a transfer matrix (3) into a state space model is in general not unique for MIMO systems. However, assuming only a low pass characteristic leads to a possible transformation [12] by with discrete time index k, half bandwidth λ, and input matrix parameters b i and ν i for i ¼ 1, 2 to be identified.
The system is excited during flattop using pseudorandom binary signals added to the feed forward signal. The response is detrended by a set of responses without and with excitation signal to the small signal model around the operating point, see (1). This approach is given in more detail in [11]. The resulting small signal input/output data set is shown in Fig. 6. Due to drifts which are mainly caused by temperature variations of the rf gun, the measured signal ΔY meas is corrected to the mean free excitation signal ΔY meas;corr . The mean free excitation signal starts and ends around zero in first-order approximation applying the correction. The plant model is shown as a bode diagram on the left side of Fig. 7. The data validation ΔY sim;A with the data set used for identification (as well as a cross validation, Fig. 8) shows good agreement. However, small deviations of ΔY I;meas;corr and ΔY I;sim;A e.g., at time 750 μs, are present. This leads to the conclusion that this grey-box model approach is disturbed by other subsystems within the plant, e.g., klystron and/or vector modulator. To mitigate this limitation, the described non-SO(2) symmetric approach is further extended.

C. Non-SO(2)-like symmetric modeling-Part B
Let us assume a non-SO(2) symmetric plant given as where the input matrix of (4) is changed to Hereby the data validation and cross validation shows a better agreement between measurement and simulation, shown in Figs. 6 and 8, respectively. The bode diagram for the identified non-SO(2) symmetric modelĜ 2 ðzÞ is shown on the right side of Fig. 7. Mapping the identified half bandwidth λ from discrete time into continuous time results in f 1=2 ¼ 53 kHz corresponding to a loaded Q factor of with driving frequency f ¼ 1.3 GHz.
In the following section we will use the non-SO(2) system modelĜ 2 ðzÞ to compute the optimal rf field controller. During our tests, we observed that the low frequency magnitude (e.g., at 1 kHz) of the system matrix Ĝ 2 ðzÞ slightly varies if the rf field phase is changed. This is caused by nonlinearities in the signal chain. This can be overcome using e.g., a parameter varying system model with scheduling parameter as operating point; more precisely, a variation in the rf field phase changes the coupling of the plant model for a given fixed amplitude set point. Therefore, we will use the non-SO(2) symmetric model G 2 ðzÞ for an optimal controller design and compare the results to a simplified controller where the cross-coupling elements (I → Q and Q → I) of the system model are neglected and only the main component, i.e., the mean of both diagonal transfer functions (I → I and Q → Q), is kept in a simplified diagonal system model.

IV. RF FIELD CONTROL
In this section the focus is on closed loop regulation performance for the plant given in Sec. III C. The implemented rf field controller C rf ðzÞ on the field-programmable gate array within the LLRF control system is given as where each controller transfer function is implemented as Currently the rf gun is operated with a feedback controller designed as SISO lag compensator (ζ < 1) in discrete time with sampling time T and a pole and zero location f c;1 ¼ 1=T c and f c;2 ¼ 1=ðζ · T c ), respectively. Selecting ζ < 1 leads to the desired PI-like compensation scheme required for reference tracking. Hereby two tuning knobs (ζ and T c ) are sufficient to update a SISO controller transfer function. Furthermore, a P-type or PD-type compensation can be designed without changing the controller structure by choosing ζ ¼ 1 or ζ > 1, respectively. A diagonal PI-like MIMO controller (C diag ðzÞ) neglecting the cross-coupling elements is optimized for reference tracking with f c ¼ 135 Hz and 1=ζ ¼ 52 leading to four transfer functions in (7) as see the left side of Fig. 9. The off-diagonal transfer functions are initially set to zero for robustness against plant variations. During our experiment, the MIMO controller was optimized as a controller for compensating cross-coupling effects. Let us assume that the system modelĜ 2 ðzÞ can be separated into a dynamic SISO transfer function G A ðzÞ and a matrix G R mapping the SISO transfer function back to MIMO transfer matrix [4]. The dynamic part of the feedback controller is optimized with respect to G A ðzÞ, while the static MIMO mapping matrix is based on the identified coupling within the MIMO system model and follows a proportional inverse controller design to cancel occurring cross-couplings in closed-loop operation (see Fig. 7). So, let us define the latter initially as optimal controller, C opt ðzÞ ¼ C A ðzÞ · C R ; wit with C A ðzÞ as dynamic controller transfer function comparable to (9) and C R as static MIMO mapping matrix. C R is computed by the inverse of frequency response at low frequency of the MIMO system model given in (5) using the final value theorem (f → 0 corresponds to z → 1). The bode diagram for the optimized MIMO controller is shown on the right side of Fig. 9. Such an optimized controller holds only for one operating point if a parameter varying plant is given. However, analyzing the system dynamics and couplings leads to a robust diagonal controller for all rf field phase settings, previously introduced as controller C diag ðzÞ. The rf field stability of both MIMO controllers in comparison is shown in Fig. 10. In addition the signals are down-sampled from 9 MHz to 100 kHz using a moving average filter to average out additional distortions from sensor noise, see Fig. 8. Minimizing ADC noise by lowpass filtering with twice the corner frequency of the half system bandwidth, i.e., for rf gun at FLASH f 1=2 ¼ 53 kHz, will not disturb the measurement since the cavity itself acts as a low-pass filter. The improvement in terms of rf field stability is mainly visible on the standard deviation of the rf field phase with a performance increase of about 6 mdeg for the down-sampled 100 kHz signal, while the performance of the rf field amplitude is approximately constant for both MIMO controllers. The desired rf field stability is not achieved by just optimizing the rf field controller. Ideally the amplitude and phase is kept within the desired range from the beginning of the flattop to the end of the flattop for multibunch operation, i.e., the entire flattop is filled with electron bunches. By this the first and last electron bunches are accelerated in the same way and only differ by its time within the flattop. It seems that the main disturbance acting on the rf gun is related to resonance frequency variations and therefore the temperature stability of the rf gun.
For temperature or resonance frequency control the estimation of detuning angle ψ is required. During the following experiments the controller C diag ðzÞ is set for long term measurements; mainly important for possible plant drifts and hence variations of plant cross-couplings.

V. DETUNING PARAMETER ESTIMATION
To a first order approximation the detuning angle ψ is in proportional to the resonance frequency offset Δf and can be computed by the calibrated forward and reflected signal, see Sec. II. Based on [8], the virtual cavity voltage V cav ¼ V cav;I þ iV cav;Q ¼ A cav · e iϕ cav is given as with unknown tuning angle ψ, unknown coupling factor β and beam loading I b .
Beam Loading Effects (I b ≠ 0).-An electron bunch passing an accelerating structure takes a certain amount of energy for acceleration, i.e., energy gain. Such beam loading, resulting in a voltage drop for on-crest acceleration with zero beam phase, is also present in an rf gun. Simulations show that the maximum voltage drop by the beam for an rf gun operated in open loop is in the order of 0.02% for comparable high bunch charge of 1 nC [16]. The LLRF system should ensure the regulation of the amplitude and phase in multibeam operation below σ A ≤ 0.01% rms and σ ϕ ≤ 0.01 deg rms. The intrapulse feedback and in addition an iterative learning control scheme (ILC) allows to assume that the effect of beam loading is neglectable even in multibeam operation. However, a beam induced voltage with beam phase of 90 deg will lead to a small phase change of the virtual voltage signal resulting in a small static offset for the LLRF based temperature estimation; this is discussed in a subsequent section. Lets assume an rf gun gradient of 55 MV=m with rf phase of 90 deg and beam loading of 0.02% for 1 nC bunch. This changes the forward phase in closed loop operation by −0.0115 deg, i.e., a temperature offset based on (24) of 0.5 mK. In case of off-crest acceleration and heavy beam loading this approach still works while an additional offset needs to be considered. This justifies to focus on no beam operation for the detuning estimation, i.e., we assume in the following I b ¼ 0 which reduces (12) to A. Detuning computation 1 Equation (13) can be separated as Using a least squares method the unknown parameter x ¼ ℜfxg þ iℑfxg ∈ C can be estimated by The remaining detuning angle ψ is computed by separation of x in x ¼ x sca · x rot using FIG. 10. Displayed are the relative amplitude and absolute phase deviations along the flattop for 6000 consecutive rf pulses as root mean square (rms) for Gaussian distribution as a comparison of diagonal and optimal rf field controller for the 9 MHz and the down-sampled 100 kHz signal using a moving average filter.
Hereby the detuning angle ψ can be computed as which is a single value for the entire rf pulse displaying the mean detuning within the rf pulse. The remaining parameter β can be estimated using (15) as It should be noticed that this least squares method leads to the mean value of the detuning angle and coupling factor during flattop. The following computation gives in addition an approximation of ψ and β along the entire flattop.

B. Detuning computation 2
The approach described in the last paragraph can be evaluated by consideration of the angles of the complex signals. Hereby the voltage phasors (13) are separated into magnitude and phase and written as The left-hand side of (21) is with zero angle, while the magnitude on the right-hand side is one. Hereby the unknown time varying detuning angle ψðkÞ on the righthand side of (21) is solved element wise by for all sampling instances k during flattop. The detuning angle ψðkÞ is proportional to the angle of cavity probe ϕ cav ðkÞ and forward signal ϕ forw ðkÞ in the no-beam case.
The remaining coupling factor βðkÞ on the left-hand side of (21) is solved element wise by Computing the mean of ψðkÞ and βðkÞ during flattop, shown in Fig. 11, gives the same result as the approach using the method of least squares in Detuning computation 1.

C. Discussion
The reflection coefficient of the rf gun changes from being time dependent during the filling to a quasisteady state coefficient during flattop. Let us consider Fig. 5 and assume a perfectly tuned rf cavity, i.e., the reflection coefficient is minimal and hence on the real axis with zero imaginary part. The temperature and hence the reflection coefficient varies over an rf pulse for an rf gun. The reflected signal is scaled by the forward signal and located on the resonant circle. Let us choose two points on the resonant circle, e.g., one at the beginning of the flattop, i.e., point (1), and the second towards the end of flattop, i.e. point (2) as indicated in Fig. 5. The clockwise phase change on the resonant circle corresponds to an rf gun temperature rise during flattop. For a perfectly tuned rf gun, the absolute value of both points on the resonant circle are equal, while the minimum is found in the middle of the rf pulse. In case of temperature variations, both points move simultaneously on this circle. The rf gun at FLASH is usually operated at a temperature slightly above the optimal tuning, visible in Fig. 12. The coupling factor β can also be computed using the minimal reflection coefficient Γ 0 crossing the real axis as with Γ 0 ≈ −0.1213 in this example. Figure 12 shows a good agreement between the first points of the timevarying βðkÞ with ψðkÞ and the resonant circle used for calibration, displayed as a blue dashed circle. The computed coupling factor βðkÞ along an rf pulse is time varying and decreasing. In the following subsection the detuning angle ψ and the coupling factor β are used to compute the frequency and therefore temperature mismatch from on-resonance operation. The focus is set to the temperature estimation in the middle of the flattop (Detuning computation 1) for later pulse-to-pulse rf-gun temperature regulation using a pulse width modulation scheme, see Sec. VI.

D. Temperature estimation
The relative temperature change is in first order proportional to the detuning angle ψ and can be approximated by with Q L and Q 0 as loaded and unloaded quality factor, respectively. The constant factor K f=T maps temperature in frequency changes Δf ¼ f 0 − f, with f 0 as rf gun resonance frequency and driving frequency f. The parameter is given for the FLASH rf gun as K f=T ¼ −21 kHz=K. Comparing the LLRF based temperature estimation with a high precision temperature sensor (24 bit resolution) at the Photo Injector Test facility at DESY-Zeuthen (PITZ) shows very good agreement, see Fig. 13. Hereby the mean temperature within the rf pulse is plotted using the average detuning value ψ of time varying parameter ψðkÞ computed by Detuning computation 2 together with a fixed Q L corresponding to the identification result in (6), i.e., assuming a constant coupling factor β. The temperature transition from the inner part of the rf gun to the temperature sensor acts as a low-pass filter and delays its response by about five seconds.

VI. FREQUENCY CONTROL
This section is separated into two parts: first the model of rf pulse width variation is examined, then the proportional feedback control scheme is presented. The main difference between rf field control and frequency control is in the sampling and correction frequency. The rf field is controlled by intratrain MIMO controller at MHz frequency with drift compensation from pulse to pulse by ILC in the sub-Hz range. The frequency controller to be designed should regulate at 10 Hz from pulse to pulse, i.e., keeping the optimal rf field frequency or temperature constant which is disturbed by the applied water regulation scheme and other effects.

A. Modeling
The static behavior for pulse width variation and the imposed temperature change shows a temperature sensitivity of about 4 mK=μs rf pulse length change. Hereby a 10 μs step in pulse width (495 to 505 μs) is applied which leads to an increase of the rf gun mean temperature of about 40 mK, shown in Fig. 14.

B. Controller design
As a first attempt, a proportional controller C L ðzÞ ¼ K P;L is used to control temperature variations using pulse width variation from pulse to pulse. Here the controller gain is set to K P;L ¼ 250 such that the loop gain is close to one, ensuring a stable closed loop operation by small gain theorem.
Applying this regulation scheme in addition to the previously mentioned control concepts leads for the diagonal and optimized MIMO controller to an improvement of the rf phase standard deviation by factor of 2 compared to only rf field control, see Figs gain of the optimized MIMO controller in comparison with the diagonal controller is almost neglectable, which justifies setting the MIMO controller for safe operation to C diag ðzÞ. The improvement in terms of rf field stability is mainly caused by disturbance rejection of rf gun temperature variations using pulse width variation resulting in reduced phase deviations from pulse to pulse. Analyzing the mean rf field phase stability within an rf pulse leads to a mean phase performance close to the desired rf field phase specification of σðϕ cav Þ ¼ 0.01 deg if the pulse width controller is active in addition to the LLRF regulation, see Table I.
An optimization of pulse width controller gain to a critically damped closed loop system, i.e., overshoot in system response is avoided, has been carried out for a long term run at FLASH and shown in Fig. 16. The optimal controller gain K P;L is found as K P;L ¼ 800 minimizing the LLRF based temperature estimation. This further improves the rf field phase stability which is explained in more detail in the following.
During the first 30 minutes only rf field control is applied. The rf field phase is controlled using the PI-like controller, see Sec. IV. Over the length of the rf pulse this lead to improvements of the standard deviation for the rf amplitude and phase from 0.015% and 50 mdeg at the beginning of the flattop (at time 700 μs) to 0.0065% and 12 mdeg towards the end of the rf pulse (1180 μs), see as example Fig. 10. Controlling in addition the pulse width (last 30 minutes) with maximum pulse width change of AE8 μs from the nominal flattop length of 530 μs-denoted by red dashed lines in the last subplot of Fig. 16-reduces at the beginning of the rf pulse the amplitude and phase standard deviation by a factor of about 2 for amplitude and 3 for phase. Furthermore, a minimal standard deviation of 0.0043% and 5.1 mdeg is achieved at the end of the flattop with applied pulse width variation. After about 30 minutes of pulse width variation the pulse width variation concept drifts towards one of the pulse width regulation limits, denoted by red dashed lines in the last subplot of Fig. 16. Hereby the regulation runs into saturation, caused by integral action of the applied water control concept, which will worsen the rf field stability again.   16. Radio frequency field stability for 9 MHz (blue line) and decimated 100 kHz (black line) readout signals without and with applied pulse width variation. During this test the rf field controller remains unchanged and the pulse width control gain is set to K P;L ¼ 800. The peak to peak and standard deviation values are given at the beginning and towards the end of the rf pulse, for time 700 and 1180 μs, respectively. The black line of each subplot displays the trend using a sliding window with 90 sampling points. The LLRF based temperature estimation and the iris temperature (see Fig. 2) are shown for completeness. Finally, the last subplot shows the flattop length (pulse width) together with the positive and negative limit for pulse width variation.
This can be overcome by proper controller connection with the water regulation concept, e.g., by feedback control of the water set-point value, shown in Fig. 17. The rf-gun temperature mismatch ΔT is estimated by (24) and subtracted from its set-point r ΔT . The corresponding pulse width correction ΔL is limited and quantized for safety reasons and fed back by the inverse controller C −1 L ðzÞ. This leads to a temperature correctionê ΔT which is the input to the controller C T;SP ðzÞ, currently a proportional feedback gain. Adding the water temperature reference r T;SP to the correction Δr T;SP defines the new water regulation set-point r T;SP for the PI controller C water ðzÞ discussed in Sec. II.

C. Long term performance
The LLRF performance for a long term run of 5 h using the previously introduced regulation concepts is shown in Fig. 18 with a pulse width feedback gain of C L ðzÞ ¼ K P;L ¼ 800 and a water set-point controller C T;SP ðzÞ ¼ K T;SP ¼ 7.
Hereby the water set-point value is frequently adjusted as well. The achieved LLRF based temperature stability is 3 mK (rms), i.e., 63 Hz (rms) resonance frequency stability for an rf gun with a nominal pulse length of 530 μs and half bandwidth of 53 kHz. The rf gun iris temperature readout (T IRIS ) shows only a few bit jumps close to the quantization level. The temperature stability has been improved from 14 mK (rms) to 3 mK (rms) using the pulse width modulation. The achieved rf field stability at the first bunch position, i.e., at time 700 μs, is σðA cav Þ ¼ 0.0026% (rms) and σðϕ cav Þ ¼ 0.016 deg (rms) for the 100 kHz bandwidth limited cavity field. The achieved rf amplitude stability is a factor 4 below specifications. The achieved rf phase stability at the first bunch position is slightly above its specification. However, during the rf pulse, the rf phase stability improves towards the end of the flattop to 5.5 mdeg (rms). Overall, the rf field can be significantly improved by controlling the rf gun temperature using a pulse width variation in addition to LLRF field control.

VII. CONCLUSION
This contribution shows a cascaded feedback control concept consisting of fast MIMO controller (MHz range), rf pulse width controller together with water set-point adaptation (10 Hz) and an ILC (sub-Hz range) for an rf gun used at FLASH. A system identification for rf fields based on the grey-box modeling approach shows a nonsymmetric model structure. A second order rf field MIMO control transfer matrix is optimized for a given operation point and compared to a diagonal MIMO controller chosen for robustness and model uncertainties which are present for different operating points, e.g., klystron nonlinearity. The achieved performance for both MIMO controllers by using only the LLRF control schemes is within the goal for relative amplitude deviation, while the rf field phase is a factor of 3 above the goal. A small deviation of the rf cavity volume, controlled by cooling water flow through the cavity, shifts the rf resonance frequency and therefore the rf field phase. Hereby one main disturbance is connected to the frequency detuning or temperature stabilization of the rf gun caused by the water regulation. It has been shown that disturbances acting on the rf gun are connected to the limited temperature resolution of the rf gun iris temperature sensor and its time delay used for rf gun water based temperature regulation. Using an adjustable pulse width reduces occurring cooling/ heating disturbances from pulse to pulse and improves the FIG. 17. Block diagram of water temperature adaptation scheme.
FIG. 18. Long term run of all cascaded feedback loops, i.e., rf field control with C diag ðzÞ, frequency control with K P;L ¼ 800 and water set-point adaptation as shown in Fig. 17. The achieved long term temperature stability is 3 mK (rms) corresponding to 63 Hz (rms) resonance frequency stability; moreover the rf field stability is σðA cav Þ ¼ 0.0026% (rms) and σðϕ cav Þ ¼ 0.016 deg (rms) for the 100 kHz half bandwidth limited cavity field A 100kHz cav and ϕ 100kHz cav at first bunch position, i.e., at 700 μs. phase stability by a factor of about 3 at the beginning of the flattop. The cascaded combination of the sophisticated control concepts ensures an operation of the rf gun close to the specifications of FLASH and needed for the European XFEL project.