# 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. Currently, KStars supports the following devices:

## Supported Telescopes

Telescope | Device driver | Version
LX200 8"-12" Classic | LX200 Classic | 0.5
Autostar based telescopes | LX200 Autostar | 0.5
LX200 GPS 8"-16" | LX200 GPS | 0.5
LX200 Classic 16" | LX00 16" | 0.5
NexStar GPS, CGE, AS-GT | Celestron GPS | 0.5
New GT, NexStar 5i/8i | Celestron GPS | 0.5
Astro-Physics AP | LX200 Generic | 0.1
Astro-Electronic FS-2 | LX200 Generic | 0.1
Losmandy Gemini | LX200 Generic | 0.1
Mel Bartels Controllers | LX200 Generic | 0.1

## Supported Focusers

Focuser | Device driver | Version
Meade LX200GPS Microfocuser | LX200 GPS | 0.1
Meade 1206 Primary Mirror Focuser | LX200 Generic | 0.1
JMI NGF Series | LX200 Generic | 0.1
JMI MOTOFOCUS | LX200 Generic | 0.1

## Focuser connection

The focusers must be connected to the focuser port in the LX200 GPS, Autostar or Classic telescopes only.

## Supported CCDs

CCD | Device driver | Version
Finger Lakes Instruments CCDs | fliccd | 0.1

## Supported Webcams

Webcam | Device driver | Version
Any Video4Linux compatible device | v4ldriver | 0.1
Philips webcam | v4lphilips | 0.1

## 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 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 Device Manager in the Devices menu.

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.

To control remove 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 favour 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 synchronisation 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 Telescope Setup Wizard from the Devices menu.

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 Set Geographic Location... from the Settings menu, 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 Set Time... from the Time menu, or by pressing the time icon in the toolbar. The Set Time window uses a standard &kde; Date Picker widget, coupled with three spinboxes for setting the hours, minutes and seconds. If you ever need to reset the clock back to the current time, just select Set Time to Now from the Time menu.

3. Click on the Devices menu and select the Device Manager.

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

5. Right-click on the device and select Run Service.

6. Click Ok to close the Device Manager Dialogue.

### 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 view: 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 viewers: Devices report their status and acknowledge commands by sending INDI messages. Each device has its own log view, and all devices share one generic log viewer. 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 INDI Control Panel from the Devices menu 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 updates from Configure INDI dialogue under the Devices menu.

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.

### Synchronising your telescope

If you aligned your telescope and the last alignment star was, for example, Vega, then the crosshair should be centred 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 synchronise its internal coordinates to match those of Vega, and the telescope's crosshair should now be centred around Vega.

That 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 as well as your equipment.

## CCD and Video-Capture Setup

KStars supports Finger Lakes instruments CCDs and any Video4Linux compatible device. Philips webcam extended features are supported as well.

You can run CCD and Video Capture devices from the Device Manager in the Devices menu. 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.

The standard format for image capture is FITS. Once an image is captured and downloaded, it will be displayed in the KStars FITSViewer. To capture a sequence of images, use the Capture Image Sequence tool from the Devices menu. This tool is inactive until you establish a connection to an image device.

## INDI Concepts

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 colour code:

  ## INDI State colour code

  State | Colour | Description
  Idle | Grey | 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 signalled as Busy. When the slew process is completed successfully, the properties will be signalled 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 Configure INDI dialogue under the Devices menu.

## 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 Listening port column. In addition to the port number, you also need the hostname or IP address of your server.

2. Client: Select the Device Manager from the Device menu and click on the Client tab. You can add, modify, or delete hosts under the 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` ...]

Options:

-p p : alternate IP port, default 7624

-r n : max restart attempts, default 2

-v : more verbose to stderr

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

I do not have a serial port, how can I connect to the telescope?

Many modern laptops do not have a serial port. You will need a Serial To USB adaptor that is supported under Linux. For example, Keyspan's USA-19QW Serial to USB adaptor is well supported under Linux and had been tested with &kstars;. You need to refer to your adaptor's documentation to find which ports they provide (e.g. `/dev/ttyUSB0 .... /dev/ttyUSB9`).

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. Set the correct port in the INDI Control Panel under the Devices menu. The default port 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.

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

This behaviour 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 kstars-devel@kde.org