GRAVITY is a second-generation instrument of the Very Large Telescope Interferometer (VLTI) that will combine the light of four telescopes in the near-infrared, resulting in images with a resolution of about 2 milli-arcseconds. Additionally it is designed to provide astrometry with a precision of 10 micro-arcseconds to detect motions close to the event horizon of the Galactic Center and study the kinematics of the Broad Line Region of Active Galactic Nuclei. Here we present the software controlling the hardware related functions, while  in these proceedings will present the higherlevel aspects of the software.
The Instrument Control Software (ICS) has been designed to comply with the common VLT Software Environment standards. It consists of several subsystems. The most straightforward is the basic Instrument Control, which commands 32 motorized functions, 12 shutters, 20 lamps (or equivalent laser devices), 14 devices monitoring environment (e.g. temperature, pressure), and 32 analog outputs. More specialized devices controlled by RS232 serial link are the metrology laser, a piezo actuator motor controller, and an optical fiber switch board. In total, the system consists of more than 100 devices. Communication between the instrument workstation and the ICS devices is performed via an online database.
Several high-speed control loops are implemented using the ESO standard Tools for Advanced Control (TAC) framework. TAC is based on function blocks, which allow to efficiently define a control algorithm. It runs on a standard VME bus machine and, in GRAVITY, is used at a frequency of up to 4kHz. We are employing this technique for the metrology control, the fringe tracker, and the tip-tilt and piston controller. Communication between TAC CPUs is performed using a reflective memory ring based on optical fibers, which also allows recording of selected data points in order to generate part of the final data product of a science exposure (as FITS file extension).
The science detectors of GRAVITY consist of three detector subsystems based on ESO’s New General detector Controller (NGC) and corresponding PC’s (LLCU): The fringe tracker as a SELEX detector is triggered by the fringe tracker TAC CPU by means of a timing TTL signal. The other two detectors are the acquisition camera and the science spectrometer, which are synchronized by means of another TTL timing signal, triggered by an ICS device. The detector subsystem is described by  in these proceedings.
In summary, the instrument has more than 100 ICS devices and runs on five workstations and seven vxWorks LCU’s.
BASIC INSTRUMENT CONTROL SOFTWARE (ICS)
As usual for any instrument built for the VLT, the basic functionalities in GRAVITY instrument control software are provided by the VLT base ICS. The software framework provides a number of commonly used functions (both hardware and software) as standard devices which can readily be used in any instrument. Within GRAVITY, we use the following standard ICS functionalities:
• DC- and Stepper Motors
• Cabinet Cooling Controllers
• Lakeshore 332 and 340 Temperature Controllers
• TIM Device for Detector Synchronization
In Base ICS, hardware device control consists of two steps: On the instrument workstation, a server process receives commands for any device. These are processed and sent (via Ethernet) to an LCU which does the actual communication with the hardware. The LCUs are VME bus computers running vxWorks as operating system. The electrical connection between the LCU and the hardware consists of either serial link (Cabinet Cooling Controllers and Lakeshores), CAN bus (Motor Controllers), or using digital I/O TTL signals (Shutters and Lamps).
Additionally, GRAVITY uses several Field Bus Devices (i.e. standard ICS devices which are connected directly via ethernet instead of an LCU), so there are only workstation processes necessary for device communication:
Of course, the standard devices are not able to support more specialized functions that GRAVITY requires. Mostly, these are serial link controlled custom made hardware, and piezo amplifier boards controlled by analog out boards. The interface software for those so-called “special devices” ensures proper integration to the higher level software including database access and device commanding. Still, the special devices are connected to LCUs. Within GRAVITY, we needed to implement the driver software for a total of 9 special device types:
• Lakeshore 340 Temperature controller (as above, but with an extension card)
• Menlo near-infrared laser for metrology
• Calibration laser
• Vacuum pressure gauge
• SmarAct piezo driven linear stage
• 2- and 3-axis piezo stages
• Optical Fiber Switch
• Calibration Lamp with 2 selectable output voltages
As part of any special device, and also as part of the special device code implementation, there is a graphical user interface which represents all ICS devices in a standardized way in the Engineering GUI (Figures 1 and 2). This GUI allows for monitoring of the monitored values of the hardware as well as sending commands to the hardware (e.g. opening and closing a shutter).
REAL TIME TASKS
The basic instrument control software is neither capable nor designed to run tasks at high frequency. In GRAVITY, we have the need for several control loops implemented in software that need to run at frequencies between 1kHz and 4kHz. For this purpose, ESO provides the “Tools for Advanced Control” (TAC). These allow to define function blocks that take several inputs and outputs and interconnect them. The resulting application runs at a defined frequency on standard LCU CPU’s under the vxWorks operating system.
Data between different TAC applications are exchanged using several methods:
While the analog I/O, digital I/O, and RMN can run at the same speed as the TAC application, the Online Database is limited to update rates of roughly 1 Hz, therefore we only use it to propagate status updates and information up to the instrument workstation. Within GRAVITY, we have a total of five TAC LCU’s running (Figure 3):
The Metrology system, the Fringe Tracker, and the Differential Delay Line are described in several papers in these proceedings, therefore we will only describe the Tip/Tilt Piston controller here.
The Tip/Tilt Piston (TTP) Controller has been implemented to replace an analog controller in order to be more flexible with respect to control algorithm and signal filtering (Figure 4).
• The main input for the fast control loop are the four voltages of a Position Sensitive Device (PSD) which records the position of a laser beam which measures the optical disturbance in the delay line tunnels of the VLT.
• The first algorithm calculates from those voltages the corresponding X and Y position and the total flux of the laser spot.
• If the flux is below a user defined threshold, the PID controller loop does nothing, else it will act as a setpoint controller. The setpoint is defined by the acquisition camera which monitors a star on the sky, measures its position and keeps it (in a separate control loop running on the instrument workstation) on the fixed position on the detector by modifying the setpoint in the TTP PID controller.
• The atmospheric perturbance simulator takes the output of the PID controller and the piston term provided by the fringe tracker (via RMN) and optionally applies a user defined disturbance to the values for performance measurement purposes.
• The last algorithm takes the tip/tilt and piston values and calculates output voltages for a piezo stage which consists of a mirror mounted on 3 piezos which are arranged in a regular triangle.
The complete TAC application runs at a frequency of 1 kHz and exists four times (for the 4 delay lines of the 4 input beams of GRAVITY). It is running on one LCU CPU board.
CURRENT STATUS AND OUTLOOK
At the time of writing, the Instrument Control Software of GRAVITY is in its consolidation phase. The integration with software modules developed by consortium partners is almost finished. Some improvements still need to be implemented on the TAC real time algorithms, which are closely connected to the behavior of the hardware system. Most software work still coming up is concerned with creating high level software (technical, calibration, and observing templates).