The first problem that emerges in the design of the mount is the conversion between the equatorial coordinate system (Right Ascension – declination system) and the horizontal coordinate system (altitude – azimuth).
The reason why this is important is essentially the following:
The circular path of stars is a result of the rotation of the earth. But due to the inclination angle of the rotational axis of the earth, there is a small angle between the earth’s north pole and the celestial sphere’s north pole. In the equatorial coordinate system (same as the horizontal coordinate system, but for the celestial sphere instead of the earth), keeping track of the stars would be easy: we only need to rotate one axis (the Right Ascension), because the positions of the stars on the celestial sphere is fixed, and we only need to rotate around the axis of the celestial sphere at the same speed (namely 24 hour/rotation, the rate of the earth’s rotation) to catch up with the celestial sphere and hence the stars on it.
This is how most traditional equatorial mounts work — to have the two axels inclined such that one of them is aligned with the celestial polar axis. This is also why in the previous design I had, I tilted the frame on which the telescope was set up.
However, in this design, I would like to simplify the mount structurally as much as possible. Plus I am going to motorize both axels anyways, it’s possible to calculate the equivalent motions in altitude and azimuth in the horizontal coordinate system, and keep track of the stars this way. To do this, we first need to be able to convert between the two systems (maybe only in one way: from equatorial to horizontal, but just in case).
There are two major methods to do this. The first one is to do some trigonometrical operations on what is called the Astronomical Triangle (the indices of which being the zenith, the celestial north pole, and the star being observed) (see here for more details), and the second one is to perform some transformations using matrices (see here for more details). After reading both articles, I decided to use the first one. The specific algorithm is pretty clearly explained in that article so… Here goes the code (If you don’t see the code below, click here):