# Astronomical Device Control with INDI

&kstars; provides an interface to configure and control astronomical instruments via the INDI protocol.

The INDI protocol supports a variety of astronomical instruments such as CCD cameras and focusers. For an up to date list of supported devices, please visit INDI supported devices page.

## INDI Setup

&kstars; can control local and remote devices seamlessly via the INDI server/client architecture. INDI devices may be run in three different modes:

1. Local: The local mode is the most common and is used to control local device (&ie; a device attached to your machine).

2. Server: The server mode establishes an INDI server for a particular device and waits for connections from remote clients. You cannot operate server devices, you can only start and shut them down.

3. Client: The client mode is used to connect to remote INDI servers running INDI devices. You can control remote devices seamlessly like local devices.

You can run local device, establish INDI servers, and connect to remote clients from the Tools Devices Device Manager... menu item.

Here is a screenshot of the Device Manager window:

Running device drivers Start device drivers

You can run devices by browsing the device tree, selecting a specific device, and then clicking on the Run Service button. You can select the operation mode, either local or server as defined above. The port number is randomly generated between the range from 7624 to 10,000. To specify a port, click on the port column next to the desired driver. &kstars; allows multiple drivers to run under one INDI server, and hence one port. Select multiple drivers then press Run Service button.

To control remote devices, refer to the remote device control section.

## Telescope Setup

Most telescopes are equipped with RS232 interface for remote control. Connect the RS232 jack in your telescope to your computer's Serial/USB port. Traditionally, the RS232 connects to the serial port of your computer, but since many new laptops abandoned the serial port in favor of USB/FireWire ports, you might need to obtain a Serial to USB adaptor to use with new laptops.

After connecting your telescope to the Serial/USB port, turn your telescope on. It is highly recommended that you download and install the latest firmware for your telescope controller.

The telescope needs to be aligned before it can be used properly. Align your telescope (one or two stars alignment) as illustrated in your telescope manual.

&kstars; needs to verify time and location settings before connecting to the telescope. This insures proper tracking and synchronization between the telescope and &kstars;. The following steps will enable you to connect to a device that is connected to your computer. To connect and control remote devices, please refer to remote device control section.

You can use the Telescope Setup Wizard and it will verify all the required information in the process. It can automatically scan ports for attached telescopes. You can run the wizard by selecting the Devices Telescope Wizard menu item.

Alternatively, you can connect to a local telescope by performing the following steps:

1. Set your geographical location. Open the Set Geographic Location window by selecting the Settings Geographic... menu item, or by pressing the Globe icon in the toolbar, or by pressing &Ctrl;G.

2. Set your local time and date. You can change to any time or date by selecting Time Set Time... menu item, or by pressing the Time icon in the toolbar. The Set Time window uses a standard &kde; Date Picker widget. If you ever need to reset the clock back to the current time, just select the Time Set Time to Now menu item.

3. Click on the Tools Devices Device Manager... menu item.

4. Under the Device column, select your telescope model.

5. Click on the Run Service button.

6. Click Close to leave the Device Manager Dialog.

### Frequent Settings

You do not need to set the geographic location and time every time you connect to a telescope. Only adjust the settings as needed.

You are now ready to use the device features, &kstars; conveniently provides two interchangeable &GUI; interfaces for controlling telescopes:

## Controlling your telescope

1. Sky map Control: For each device you run in the Device Manager, a corresponding entry will show up in popup menu that allows you to control the properties of the device. You can issue commands like `Slew`, `Sync`, and `Track` directly from the sky map.

   Here is a screenshot of the popup menu with an active LX200 Classic device:

   Controlling devices from sky map

2. INDI Control Panel: The panel offers the user with all the features supported by a device.

   The panel is divided into three main sections:

   - Device tabs: Each additional active device occupies a tab in the INDI panel. Multiple devices can run simultaneously without affecting the operation of other devices.

   - Property views on the Main Control and Options tabs: Properties are the key element in INDI architecture. Each device defines a set of properties to communicate with the client. The current position of the telescope is an example of a property. Semantically similar properties are usually contained in logical blocks or groupings.

   - Log viewer: Devices report their status and acknowledge commands by sending INDI messages. Each device has its own log view. A device usually sends messages to its device driver only, but a device is permitted to send a generic message when appropriate.

   INDI Control Panel

You are not restricted on using one interface over another as they can be both used simultaneously. Actions from the Sky map are automatically reflected in the INDI Control Panel and vice versa.

To connect to your telescope, you can either select Connect from your device popup menu or alternatively, you can press Connect under your device tab in the INDI Control Panel.

By default, &kstars; will try to connect to the `/dev/ttyS0` port. To change the connection port, select the Tools Devices INDI Control Panel... menu item and change the port under your device tab.

&kstars; automatically updates the telescope's longitude, latitude, and time based on current settings in &kstars;. You can enable/disable these using the INDI page from the Settings Configure &kstars;... menu item. Using the INDI page you can configure &kstars; to display or not INDI status messages in the status bar. By default INDI server port numbers have values between the range from 7624 to 9000, but you can easily change the range using the From: and To: text boxes from the Server Port section.

If &kstars; communicates successfully with the telescope, it will retrieve the current RA and DEC from the telescope and will display a crosshair on the sky map indicating the telescope position. You can hide the crosshair that marks telescope position using INDI page from the Settings Configure &kstars;... menu item.

### Synchronizing your telescope

If you aligned your telescope and the last alignment star was, for example, Vega, then the crosshair should be centered around Vega. If the crosshair was off target, then you can right-click Vega from the sky map and select `Sync` from your telescope menu. This action will instruct the telescope to synchronize its internal coordinates to match those of Vega, and the telescope's crosshair should now be centered around Vega.

This is it: your telescope is ready to explore the heavens!

### WARNING

Never use the telescope to look at the sun. Looking at the sun might cause irreversible damage to your eyes and your equipment.

## CCD and Video-Capture Setup

You can run CCD and Video Capture devices from the Tools Devices Device Manager... menu item. Like all INDI devices, some of the device controls will be accessible from the skymap. The device can be controlled fully from the INDI Control Panel... item.

The standard format for image capture is FITS. Once an image is captured and downloaded, it will be automatically displayed in the &kstars; FITS Viewer.

## Configure INDI

The INDI page allows you to modify Client side INDI specific options. To access it, select the INDI page from Settings Configure &kstars;... menu item. The window is divided into several main categories: General, Device Updates, Display and Server Port:

- General

  - INDI server: Specify the binary of installed INDI server in your system. By default, &kstars; uses /usr/bin/indiserver binary.

  - INDI drivers XML directory: Specify the &XML; directory where INDI drivers are located in your system. By default, &kstars; uses /usr/share/indi directory.

  - Default FITS directory: Specify the directory where all captured FITS images will be saved to. If no directory is specified, images will be stored in `$HOME`.

- Time & Location Updates

  - KStars updates all devices: KStars is the master source for time and location settings. All INDI devices time and locations settings are synchronized to KStars settings.

  - Mount updates KStars: Mount handset is the master source of time and location settings. KStars time and location settings are synchronized with controller settings.

  - GPS updates KStars: GPS driver is the master source of time and location settings. KStars time and location settings are synchronized with GPS settings.

  - Time: Synchronize KStars date and time automatically from the update source.

  - Location: Synchronize KStars location settings from the update source.

- Display

  - Telescope crosshair: When checked, &kstars; displays the telescope's target crosshair on the sky map. The crosshair is displayed upon a successful connection to the telescope and its location is updated periodically. The telescope's name is displayed next to the crosshair. &kstars; displays one crosshair per each connected telescope. To change the color of the telescope's crosshair, open the Configure - &kstars; window. Select the Colors page, and then change the color of the Target Indicator item to the desired color.

  - Independent window: Make FITS Viewer window independent.

  - Message notifications: Show INDI messages as desktop notifications instead of dialogs.

- Server Port

  - Specify range of ports that INDI Server will bind to when starting new drivers.

## INDI Concepts

The main key concept in INDI is that devices have the ability to describe themselves. This is accomplished by using &XML; to describe a generic hierarchy that can represent both canonical and non-canonical devices. In INDI, all devices may contain one or more properties. Any property may contain one or more elements. There are four types of INDI properties:

- Text property.

- Number property.

- Switch property (Represented in &GUI; by buttons and checkboxes).

- Light property (Represented in &GUI; by colored LEDs).

For example, all INDI devices share the CONNECTION standard switch property. The CONNECTION property has two elements: CONNECT and DISCONNECT switches. &kstars; parses the generic &XML; description of properties and builds a &GUI; representation suitable for direct human interaction.

The INDI control panel offers many device properties not accessible from the sky map. The properties offered differ from one device to another. Nevertheless, all properties share common features that constrains how they are displayed and used:

- Permission: All properties can either be read-only, write-only, or read and write enabled. An example of a read-write property is the telescope's Right Ascension. You can enter a new Right Ascension and the telescope, based on current settings, will either slew or sync to the new input. Furthermore, when the telescope slews, its Right Ascension gets updated and sent back to the client.

- State: Prefixed to each property is a state indicator (round LED). Each property has a state and an associated color code:

  ## INDI State color code

  State | Color | Description
  Idle | Gray | Device is performing no action with respect to this property
  Ok | Green | Last operation performed on this property was successful and active
  Busy | Yellow | The property is performing an action
  Alert | Red | The property is in critical condition and needs immediate attention

  The device driver updates the property state in real-time when necessary. For example, if the telescope is in the process of slewing to a target, then the RA/DEC properties will be signaled as Busy. When the slew process is completed successfully, the properties will be signaled as Ok.

- Context: Numerical properties can accept and process numbers in two formats: decimal and sexagesimal. The sexagesimal format is convenient when expressing time or equatorial/geographical coordinates. You can use any format at your convenience. For example, all the following numbers are equal:

  - -156.40

  - -156:24:00

  - -156:24

- Time: The standard time for all INDI-related communications is Universal Time UTC specified as YYYY-MM-DDTHH:MM:SS in accord with ISO 8601. &kstars; communicates the correct UTC time with device drivers automatically. You can enable/disable automatic time updates from the INDI page in the settings dialog.

## Remote Device Control

&kstars; provides a simple yet powerful layer for remote device control. A detailed description of the layer is described in the INDI white paper.

You need to configure both the server and client machines for remote control:

1. Server: To prepare a device for remote control, follow the same steps in the local/server setup. When you start a device service in the Device Manager, a port number is displayed under the Port column. In addition to the port number, you also need the hostname or IP address of your server.

2. Client: Select the Tools Devices Device Manager... menu item and you can add, modify, or delete hosts into Client tab. Add a host by clicking on the Add button. Enter the hostname/IP address of the server in the Host: field, and enter the port number obtained from the server machine in step 1.

INDI Client

After you add a host, right click on the host to Connect or Disconnect. If a connection is established, you can control the telescope from the Sky map or INDI Control Panel exactly as described in the local/server section. It is as easy at that.

### Running an INDI server from the command line

While &kstars; allows you to easily deploy an INDI server; you can launch an INDI server from the command line.

Since INDI is an independent backend component, you can run an INDI server on a host without &kstars;. INDI can be compiled separately to run on remote hosts. Furthermore, device drivers log messages to `stderr` and that can be helpful in a debugging situation. The syntax for INDI server is as following:

$ `indiserver` [options] driver [`driver` ...]

    Options:
     -l d     : Log driver messages to <d>/YYYY-MM-DD.islog
     -m m     : Kill client if gets more than this many MB behind, default 128.
     -d m     : Drop streaming blobs if client gets more than this many MB behind, default 5. 0 to disable.
     -p p     : Alternate IP port, default 7624.
     -r r     : Maximum driver restarts on error, default 10.
     -f path  : Path to fifo for dynamic startup and shutdown of drivers.
     -v       : Show key events, no traffic.
     -vv      : -v + key message content.
     -vvv     : -vv + complete xml.
     driver   : Executable or [device]@host[:port]

For example, if you want to start an INDI server running an LX200 GPS driver and listening to connections on port 8000, you would run the following command:

$ `indiserver` -p 8000 `lx200gps`

### Secure Remote Operation

Suppose we want to run an indiserver with INDI drivers on a remote host, `remote_host`, and connect them to &kstars; running on the local machine.

From the local machine log onto the remote host, `remote_host`, by typing:

$ `ssh` -L `local_port`:`remote_host`:`remote_port`

This binds the `local_port` on the local machine to the `remote_port` on the `remote_host`. After logging in, run indiserver on the remote host:

$ `indiserver` -p `remote_port` [`driver`...]

Back on the local machine, start &kstars; then open the Device Manager and add a host under the Client tab. The host should be the local host (usually 127.0.0.1) and the port number should be the `local_port` used in the steps above. Right-click on the host and select Connect from the popup menu. &kstars; will connect to the remote INDI server securely. The host information will be saved for future sessions.

## INDI Frequently Asked Questions

What is INDI?

INDI is the Instrument-Neutral-Distributed-Interface control protocol developed by Elwood C. Downey of ClearSky Institute. &kstars; employs device drivers that are compatible with the INDI protocol. INDI has many advantages including loose coupling between hardware devices and software drivers. Clients that use the device drivers (like &kstars;) are completely unaware of the device capabilities. In run time, &kstars; communicates with the device drivers and builds a completely dynamical &GUI; based on services provided by the device. Therefore, new device drivers can be written or updated and &kstars; can take full advantage of them without any changes on the client side.

Do you plan to support more devices?

Yes. We plan to support major CCD cameras and focusers and extend support for more telescopes. If you would like INDI to support a particular device, please send an email to indi-devel@lists.sourceforge.net

What operations does &kstars; provide to control the telescope?

It depends on the particular telescope you're running, but the minimum three operations are `Slew`, `Track`, and `Sync`, which you can issue directly from the sky map. Your telescope must be aligned for those operations to perform correctly. Some telescopes offer you more operations like site management, slew modes, focusing, parking, and more. You can access the telescopes extended features from the Tools Devices INDI Control Panel... menu item.

What's the difference between `Slew`, `Track`, and `Sync` exactly?

The command `Slew` orders the telescope to move to a particular target, and once the telescope reaches its target, the telescope keeps tracking that target at a sidereal rate (&ie;, the rate at which stars move across the sky). This works well for stars, Messier objects, and about everything outside our solar system. But solar system objects travel differently across the sky and so the telescope must `Track` the objects as they move.

Therefore, you need to issue a track command if you want to track an object with non-sidereal motion. On the other hand, `Sync` is used to synchronize the telescope's internal coordinates with that of an object you select.

Can I control my telescope remotely?

Yes. You can start an INDI server on the machine connected to your telescope and the server will listen to requests from &kstars; clients. Once you're connected, you can control your telescope directly from the sky map. This procedure is described in detail in the Remote device control section.

When I try to Connect, &kstars; reports that the telescope is not connected to the serial/USB port. What can I do?

This message is triggered when &kstars; cannot communicate with the telescope. Here are few things you can do:

1. Check that you have both reading and writing permission for the port you are trying to connect to.

2. Check the connection cable, make sure it is in good condition and test it with other applications.

3. Check your telescope power, make sure the power is on and that the telescope is getting enough power.

4. Select the Tools Devices INDI Control Panel... menu item and set the correct port in the INDI Control Panel dialog. The default device is `/dev/ttyS0`

5. Restart &kstars; and retry again.

&kstars; reports that the telescope is online and ready, but I cannot find the telescope's crosshair, where is it?

&kstars; retrieves the telescopes RA and DEC coordinates upon connection. If your alignment was performed correctly, then you should see the crosshair around your target in the Sky Map. However, the RA and DEC coordinates provided by the telescope may be incorrect (even below the horizon) and you need to Sync your telescope to your current target. You can use the right-click menu to center and track the telescope crosshair in the sky map.

The telescope is moving erratically or not moving at all. What can I do?

This behavior is mostly due to incorrect settings, please verify the following check list:

1. Is the telescope aligned?

2. Is the telescope alignment mode correct? Use INDI Control Panel to check and change these settings (`Alt/Az,Polar, Land`).

3. Are the telescope's time and date settings correct?

4. Are the telescope's longitude and latitude settings correct?

5. Is the telescope's UTC offset correct?

6. Are the telescope's RA and DEC axis locked firmly?

7. Is the telescope's N/S switch (when applicable) setup correctly for your hemisphere?

8. Is the cable between the telescope and computer in good condition?

If you think all settings are correct but the telescope still moves erratically or not at all, then please send a report to indi-devel@lists.sourceforge.net.