## 4 PAU-RAD Design, Development and Integration
### PAU-RAD Software Description  
The software written for PAU-RAD accomplishes the following functions:  
* Implements the PAU-RAD finite state machine and the calibration algorithms. This part is running on the CU over a NIOS2 microprocessor, embedded in the FPGA. This software is written in ANSI C language;
* there is a user-friendly control interface on the remote PC side, from where the instrument is operated and the acquired data is stored. This part is written in C# language; and
* the communications channel between the CU and the PC consists of a bidirectional serial communication protocol using a universal asynchronous receiver/transmitter (UART). Over this serial protocol, there is a self-designed application layer, which ensures the communications. The CU is a finite state machine that changes the system status according to some internal variables (Figure 13). The most important state variables are the integration time for each radiometric sample, and the inter-calibration time between hardware calibrations. The states of the CU can be classified in two sequences: The main sequence that perform the radiometric normal operation, and the validation sequences used for testing. The main sequence states are:  
* Init: This is the initialization mode and awaits the PC remote control connection. Figure 13: CU finite states machine diagram and interactions. * Calibration: The CU sets the ALU to measure the complex cross-correlations between the reference receiver and, sequentially, the other ones, when the _CNS_ is connected to receivers' inputs. The input temperature value is selected from the three possible values by the CU with two control bits. The measured amplitude and phase at different time instants are then filtered using a Kalman filter to reduce the noise variance (Section 3.2). Finally, the CU updates _RUT_'s look-up table following Equation (8) and modifying the NCO amplitude and phase values accordingly. At this time, the relative calibration has been performed and the DBF is ready to operate. * Correlated Internal Reference: The CU sets the ALU to compute the Stokes parameters from the signals obtained after the DBF, when the _CNS_ is connected to receiver's inputs. This mode is used to perform the internal radiometric calibration, maximizing the period between external calibrations and is performed for each synthesized beam. * Uncorrelated Internal Reference: The CU sets the ALU to compute the Stokes parameters from the signal obtained after the DBF, when the matched loads are connected to receivers' inputs. This mode is used to compute the offsets of the Stokes parameters and it is performed for each synthesized beam. * Normal mode: The CU sets the ALU to compute the Stokes parameters (radiometric observables) from the signals obtained after the DBF, when the antennas are connected to the receiver's inputs. The system stays in this mode since the receiver phase and gain drifts degrade the beam. This loop is shown in Figure 12 labeled as _if calibration not needed_. This period is established empirically and depends on the required performance and application. Moreover, it determines the tradeoff between calibration and measurement time. The validation sequences states are:  
* Phase Sweep: The CU sets the ALU to measure the complex cross-correlations between the reference receiver and a _RUT_. The goal of this sequence is to sweep the phase of each NCO from 0 to 2\(\pi\). As described in [28] this test helps to determine amplitude unbalances between I and Q branches, quadrature and phase errors, and offset errors. In PAU-RAD, since signals are sampled at IF and I/Q demodulation and low-pass filtering is performed digitally, there are only offset errors; therefore only information related to the _RUT_'s complex offset is obtained. * Open Loop: Same as previous, but with all _RUT_s and keeping the NCO constant to evaluate _RUT_s' temporal drifts. * Closed Loop: same as previous, but updating the _RUT_s' NCO to track calibration errors. The control interface has the total control of the instrument.