using_mount_classes.rst.txt 3.08 KB
***********************************************
User guide to program with mount Python classes
***********************************************

This section show how to use Mount classes in a Python code.

1. Classes and attributes 
*************************

.. image:: doc_images/classes_mount.png

The mountastro module provides the class Mountastro
which contains almost all the methods to drive mounts.
Mountastro provides methods only for simulations
but all these methods call also an abstract method
for real mounts. The abstracts methods are concreted
in a dedicated class. For example, for AstroMECCA mounts
the class Mountastro_Astromecca inherits the Mountastro
methods and provides concrete methods.

2. Examples of Python codes to instanciate the mount
****************************************************

To include the mount classes in a python program, one must import 
the desired classes:

::

	import celme
	import mountastro_astromecca

Define the site where the telescope is installed:

::

	home = celme.Home("GPS 2.0375 E 43.6443484725 136.9")
	site = celme.Site(home)

The home geographic coordinates must be adjusted to the location of the mount.
Instanciate the class Mountastro_Astromecca:

::

	mount1 = mountastro.Mountastro_Astromecca("HADEC", name="My Mount", manufacturer="AstroMECCA", model="TM350", serial_number="beta001", site=site, CONTROLLER_BASE_ID=1, CONTROLLER_POLAR_ID=2)

HADEC stands for the fact the axes of the mount are oriented according an equatorial mount.
The protocol to communicate with the controller used for AstroMECCA mounts must be configured.
The following lines show how to get available list of serial ports and configre it:

::

	tools = mountastro.Mounttools()
	available_serial_ports = tools.get_available_serial_ports()
	print("Avaible serial ports {}".format(available_serial_ports))
	port = "/dev/ttySC0"
	mount1.set_channel_params("SERIAL", port=port, baud_rate=115200, delay_init_chan=0.1, end_of_command_to_send="\r\n".encode('utf8'), end_of_command_to_receive="\r\n".encode('utf8'), delay_put_read=0.06)

The port key must be available in the list of serial ports.

3. Examples of Python codes to drive the mount
****************************************************

Prerequisite is to have instanciated an object (mount1)
as explained in the previous section.

To get current coordinates of the mount:

::

	ra, dec, side = mount1.radec_coord()

The side is where the tube lies. Side can be 1 or -1.
If side = 1 the tube is in regular position.
If side = -1 the tube is in fliped position.

To slew the mount to a target defined by J2000 astronomical coordinates:

::

	mount1.radec_goto("3h5m56.45s","+3d51m34.1s")

The methods radec_coord and radec_goto, it is possible to
add options as equinox or output formats.

Example of options to get coordinates at the equinox of the date
and outputs in decimal degrees:

::

	ra, dec, side = mount1.radec_coord("deg", "deg", equinox="NOW")

To start a move on declination axis at the rate of 2 deg/sec:

::

	mount1.hadec_move(0, 2)

To stop a move motion:

::

	mount1.hadec_move_stop()

To stop a any motion:

::

	mount1.hadec_stop()