Digital Setting Circles: a different experience in visual observation

The GOTO systems of the scope mounts allow us to go automatically to any object in the sky. The fact is that without knowing how to align with the polar and without knowing where the stars, clusters, galaxies or nebulae are, we can easily find and see them thanks to a motorized mount that is able to compensate our pour alignment and moves automatically to the object we want. Is this an advantage or on the contrary a functionality that limits our knowledge of the sky and the enjoyment of visual observation? 

 

This is the question I asked myself in view of the 2020 summer vacations, and I concluded that possibly yes, the GOTO system makes everything too easy and takes some of the interest out of the observation process, while making learning more diffcult. The alternative to GOTO is the hopping star technique, that is, use brilliant stars to locate us in the sky and from their location to move to the objects that we want to visualize, for example, helped by the setting circles of an equatorial mount. This way of operating requires you to have a better knowledge of the sky and to learn how to use the circles.

 

Being consistent with this idea, I made the decision to travel with a non-motorized equatorial mount, a lightweight scope and a sky guidebook. Maybe it was a romantic moment, missing the way things were done before the facilities that technology offers us, but I started to try the experience.

 

The manual mount has some obvious advantages for traveling: it is light, economical and does not require a power supply. But at the same time, it poses a challenge if we want to see beyond the Moon, the brightest planets or stars: you need a superior knowledge of the sky and learn to use the setting circles. For example, to locate a faint double star, the data we have is the zone in which it is and its coordinates, right ascension and declination. The technique in this case is to explore the sky by zones, moving from one object to another using the coordinates. And so, I started my adventure with an EQ3 mount, a red lantern and the book.

 

 

And the result was both extraordinary and frustrating. Extraordinary because when you are able to see in the eyepiece what you are looking for and compare your visual experience with of other observers, you really enjoy it. But at the same time, it's frustrating because it's not at all easy, at least if you don't have enough experience. Setting circles have little resolution: in the case of EQ3, in declination each line represents 2º and in right ascension 10 minutes. The arrow on the mount that points to the circles is not easy to associate with a precise value. Besides, the right ascension must be rectified continuously, the Earth moves, and we must compensate the movement by adjusting the scope mount as it does not have a motor. In addition to these complications, you are in the dark, and you do not see the setting circles if you do not illuminate them, but also you have to do an exercise of contortion of the neck to see them, each one at a different position in the mount. All this is not to discourage the idea, in fact, I think I have never learned as much as this summer thanks to this experience of manual use of an equatorial mount. But as everything can be improved, I started to think how to enhance the good things about the experience, while avoiding the inconveniences by improving higher accuracy, resolution and usability of the setting circles. 

 

The solution was clearly to convert the analog into digital, the destiny of modern times. As you might expect, you can find commercial products of DSC (Digital Setting Circles), that are expensive and although they can be used in different types of mounts, they are more focused on their use in Dobson-type ones and in communication with a PC or tablet software, either with USB or Bluetooth. But my idea was to make something simpler, cheaper and autonomous, which I have called sDSC (Simple Digital Setting Circles).

sDSC: Simple Digital Setting Circles

The sDSC is a simple electronic device that basically has to read two encoders (one for RA and another for DEC) and incorporate a display that will show us the coordinates and a keyboard to be able to interact with the equipment. Then we will see the components that have been selected to give a simple and economic solution.

 

The idea is to operate with a manual equatorial mount according to the following sequence: 

 

  • Align the telescope with the Polar. For visual observation it is not necessary to do it perfectly, but as we are going to use alignment with only one star (as explained below) we have to get a minimum decent alignment, which in my case works simply with a good leveling of the tripod and centering the Polar in the eyepiece, while the circles are in RA=0 and DEC=90.

  • In the initial position we turn on the sDSC that initially will indicate RA=0 and DEC=90.

  • We choose the area where we are going to observe and move the telescope with the controls towards a bright star. 

  • The sDSC will show us a new RA and DEC that it has calculated from the encoder readings. But this data is not useful, at least for the RA, and we need to synchronize with the star. The sDSC allows us to select from a list the star (I have chosen about 50 bright ones with declination>-25) and we already have on screen the correct RA and DEC. The RA will be automatically updated with the Earth rotation if we do not act on the RA control.

  • To go to the object we want, even if it is weak and we can't see it in the finder, we only have to move the RA and DEC controls until we have in the sDSC display the coordinates of the object. If everything has worked well, we will have the object visible in our eyepiece, or in any case visible with very small adjustments of the controls, depending on the magnification power of the eyepiece.

 

NOTE: For simplicity, the development has been made with observers from the northern hemisphere in mind, but I understand that it will be easy to adapt to the south.

This operation solves all the limitations of analogical circles: it is more precise, has more resolution, and is much more comfortable. In the following sections we go into more detail about how it works and how it can be built.

Of course the question arises, and isn't it easier to simply automate the mount with the corresponding GOTO kit? For me the answer is that possibly it is simpler, but it is more expensive and precisely the idea is to dispense with the GOTO and enjoy this additional complication to learn and have a different experience during visual observation. On the other hand, there are possibly many manual equatorial mounts in the storage room that can be given a second life with this system, much simpler and cheaper than motorize them.

Selection of sDSC components

As mentioned above, one of the criteria for the projects is that the solution be economical. Commercial DSC are more expensive than the manual mount itself, some exceeding for instance three times the price of an EQ3. However, we are going to build a solution with a cost of about 30 euros, including everything except the DIY that has to be done for the box.

 

Obviously, an electronic board is needed to incorporate the logic and control of the system. Currently there are solutions on the market based on known hardware platforms, perhaps the most relevant are Raspberry Pi and Arduino. Raspberry Pi is based on Linux operating system, and is a very powerful solution, but possibly excessive for the simple application we want to do. Arduino is a simpler platform that, without being supported by an operating system, allows us to implement applications that interact with sensors and handle a display and keyboard, perfect for the application we want. And the most amazing thing, we can get an Arduino board for 8.99€! (prices given in this section are those found in Amazon). 

With the Arduino architecture chosen, we need a display and a keyboard. The selected solution is a LCD of two lines of 16 characters, with an integrated 6-key keypad. This display is connected directly to the Arduino board with a strip of pins and leaves us with the digital inputs we need for the encoders. And we keep on budget, because the cost of the display with keyboard is 6.99€

Finally, we need the encoders. This element is the one that will depend more on how we attach it to the mount. The aim is to have enough resolution, so that the number of pulses obtained for a full turn of the RA axis (24 hours) or the DEC axis (360º) is sufficient. For example, if we want a 30" resolution in RA, we will need 24*3600/30=2880 pulses. But this factor will depend on how we couple the encoder to the mount, because it can turn at the same time as the corresponding axis of the mount or through a mechanical multiplication. In the case of EQ3, since the RA and DEC controls allow to couple an encoder directly, with a encoder that generates a few tens of pulses per turn is more than enough, since that value must be multiplied by the number of turns given by the control to generate a full turn of the axis of the mount. In particular for the EQ3, with a 40-pulse encoder coupled to the RA control we get 5120 pulses per full turn of the Right Ascension axis (resolution of about 17 seconds) and 2580 pulses per full turn of the Declination axis (resolution of about 8 minutes). These values are sufficient for our visual observation objective.

 

I have referred to an encoder of 40 pulses per turn because there is a very cheap and easy to get device in the market, the KY-040, a quadrature type optical encoder (it allows us to know the direction of rotation) and infinite (you can turn without limit) and we can get each one for 2.23€

En el caso de la montura EQ3, el eje para realizar el acoplamiento es de 6mm, igual que el del KY-040, por lo que necesitaremos un acoplamiento flexible de 6mm a 6mm. Una opción puede ser la que se indica a continuación, por un precio de 2.39€:

We already have all the components for about 30 euros and only the specific hardware to fit the encoders to the mount is missing. In the case of EQ3, making the coupling is very easy and you only need to make a simple clamping part (one for each axis), for example, by bending a metal plate, to achieve something similar to the following:

The encoder is glued to the board taking care that it only touches the PCB part without tracks or pins. Once the encoders are attached to the frame, the base is fixed with a double-sided tape and the result will be as shown below:

Description of operation

The sDSC offers three types of screens: 

 

  • Current Right Ascension and Declination:

 

 

 

  • Selection of the star to synchronize:

 

 

 

 

 

 

  • Current encoder values:

 

 

 

 

 

 

Actually, we will only use the first two screens, the third one will be only for the adjustment and startup of the system the first time.

When the equipment is started, the screen shown is the RA and DEC screen, with values of AR=0 and DEC=90, since the equipment must be started with the telescope at the initial position (pointing to Polar). You can always return to this screen by pressing the RST (reset) key. You will see that the RA value increases, one second for each second elapsed: the equipment automatically update the RA, since there is no motor to compensate the Earth's movement.

 

During the first 3s after the start, the software allows to change the intensity of the backlighting with the UP and DOWN keys. After 3s, as we will see later, these keys have another function.

 

Also, during the initial 3s, pressing the SELECT key changes the display to show the encoder values. This option is interesting during the start-up process or for the calibration of the number of pulses per turn on each axis, which as we will see later, is a value that has to be entered in the Arduino board source code.

 

Once we are on the RA and DEC screen, we can move the telescope with the controls and the RA and DEC values in the display will reflect the changes read by the encoders. But if we haven't done any synchronization, the RA value won't have any real meaning. Not so with the DEC value which will reflect a valid data. The synchronization should be done with the following steps:

  • Choose a bright star in the area where we want to make the observations.

  • Move the controls until the star is centered on the eyepiece, helped by the telescope's finder.

  • Press the SELECT key to access the reference star list screen. Search the star with UP and DOWN (they are ordered alphabetically according to the common name of the star). Once the star is found, press SELECT.

  • The RA and DEC data on the screen will have been updated to the star. If we do not touch the RA control, the RA value will be increased and to have the star centered again we can act on the control until recovering its RA value. But actually this is not necessary and the telescope will remain synchronized even if in a while the star we have used is no longer centered.

  • We can go to the object we want simply by moving the control until we see on the screen the RA and DEC that reflect the desired coordinates.

Here it is important to consider one aspect. The coordinates that have been entered in the equipment are J2000, so there may be small deviations in the current date of observation (JNOW). In visual observation this is usually not relevant. However, an option has been included in the keyboard handling to make small corrections to the current RA and DEC value. The display will indicate with ">" if RA or DEC is selected, and it can be changed with the LEFT key. Once what we want to adjust is selected, we can use the UP and DOWN keys to make small adjustments, for example, to set the JNOW value we read from an application on the smart phone.

 

And this is the simple way of operating the sDSC, a device designed to make digital setting circles that help us to handle our manual mount for a totally affordable cost.

Overview of keypad operation

UP y DOWN: 

 

  • Only during the initial 3s are used to adjust the intensity of the backlight

  • If we are on the RA and DEC display screen, it is used to increase or decrease the RA or DEC value indicated on the screen. To switch between RA and DEC for this setting, use LEFT.

  • If you are in the sync star selection screen, it allows you to scroll through the list until you select the one you want.

 

SELECT:

 

  • Only during the initial 3s it is used to select the display of the encoder value (sum of accumulated pulses). The accumulated pulses are set to 0 each time a synchronization is made.

  • Its normal use is to go to the star selection screen to synchronize.

 

LEFT:

 

  • In the current RA and DEC display screen, it is used to switch RA and DEC (the ">" sign will be shown indicating the selected coordinate in each case) for the purpose of adjusting their value with UP and DOWN.

 

RIGHT:

 

  • Not used.

 

RST:

 

  • Reset the equipment by setting encoders to 0, RA to 0 and DEC to 90.

Summary of operation of the controls

The indications given below may seem a little complicated at first, but in reality, they are very intuitive and done a couple of times creates an easy and agile dynamic to locate any object in the sky.

 

  • Synchronization:

    • If we are in the initial position, we must move the DEC control clockwise if the star we are going to use for synchronization is in the east and counterclockwise if it is in the west. Once this initial movement has been made, continue moving the control until the declination of the star to be used for synchronization is shown on the display.

    • Move the RA control to reach the star with the help of the finder, not take into account the display RA value.

    • Move the RA and DEC controls to center the star, with the help of the finder, not take into account for this last adjustment the display RA and DEC values.

    • Once the star is centered, select the synchronization star with the keyboard. Before giving to synchronize make a last adjustment of the RA control (clockwise) because the star will have moved a little during its search by the movement of the Earth.

    • If you want to be more precise, you can reset RA and DEC on the display to the JNOW values that we get from the corresponding application of the phone or Tablet.

 

  • Go to the desired sky object once the synchronization is done:

    • Simply turn the RA and DEC controls until you have the object's values.

    • The object should be inside the eyepiece or if the eyepiece has too much magnification, small adjustments will be necessary with the RA and DEC controls.

 

  • Observation of the located celestial object:

    • With small RA control movements we can keep the object centered by compensating the movement of the Earth.

    • If we have let some time pass, the RA adjustment can be done simply by turning the knob clockwise until the RA value of the object is recovered in the display.

 

  • Go to the next object:

    • If the next object is in the area and on the same side of the meridian, no new synchronization is needed. However, before moving to it, we can center the object we have just seen and make the small correction that is necessary in the RA and DEC values of the display to have the JNOW value.

To be taken into account in the synchronization

To move to the star that we will use for synchronization we have commented that we must do it with the slow motion controls. But is it possible to loosen the axis locks and move the mount axes without the controls? The answer is yes but bearing in mind an aspect that we will explain below.

 

If we do not use the controls, as the encoders have coupled to them, we will not generate the pulses, but as we are going to synchronize RA and DEC with the star data it could seem that this operation can be done without problems. With the right ascension there is no problem, however, we have to take into account that with the declination it is somewhat more complicated, since a turn of the declination control implies increasing or decreasing the declination depending on which side of the meridian we are. 

 

Since, once the synchronization is done, we will use the declination control for the movement to our object, the sDSC must know if in which side of the meridian we are to apply the correct sign to the change in declination, increasing or decreasing depending on the direction of the turn. If we have done the movement with slow motion control, the sDSC already knows if we have gone to one side or the other of the meridian, but if we have gone without the controls it will not know. 

 

To solve this, we must take into account these simple rules if we want to use the fast movements of the axes:

 

  • If we are in the initial position, with DEC=90, simply turn the DEC control a little towards the side of the meridian where the star we are going to is. From there, we can make quick movements.

 

  • If we are not in the initial position, we can move without the controls as long as we remain on the same side of the meridian. Otherwise, we will have to go through the DEC=0 position and use the previous rule.

How to connect the different elements

The first step is to place the display, simply by anchoring it to the Arduino board (see the instructions provided by the supplier of the device, but it has no complications).

 

Regarding the encoders, the first thing to consider where the digital inputs/outputs of the Arduino's microcontroller are accessible once we have connected the display and keyboard board. The following digital signals are available in the upper right-hand connector: (see photo)

 

D13 D12 D11 D3 D2 D1 D0

 

The photo shows that a 7-pin strip has been soldered to make the digital signals accessible, although we will actually only use the 4 pins on the right.

 

 

 

A 2-pin strip has also been soldered to make +5V and GND accessible (see bottom of photo).

 

Each encoder requires 2 signals: CLK and DT, plus the 5V power supply.

 

We will use D1 and D0 for the RA encoder, and D2 and D3 for the DEC encoder.

 

 

The connections will be:

 

Right ascension:

D0: CLK of KY-040

D1: DT of KY-040 

 

Declination:

D2: CLS of KY-040

D3: DT of KY-040 

For the connections we must make a 4-wire cable (CLK, DT, +5V and GND) long enough to connect each encoder to the display board.

 

NOTE: the SW pin of the encoders is not used.

 

The photo shows the way to connect using standard cables for connections on prototype boards. It is the way I have used to make a prototype, but it is not the right way to have a final product. From the explanations in this document, the recommended would be to place the assembly in a box and make the connections soldered, not with pin connection cables. On the other hand, possibly it's a good idea in the final mechanical enclosure to place a red transparent sheet over the display so that the light doesn't bother during the observation, because, although the backlight is adjustable, the blue color of the background and the white of the characters doesn't seem to be the most suitable.

Source code

The following provides the source code of the application. It is a version 1.0 and logically it is possible to include errors in situations that have not been foreseen, that's programming! The following versions will be the result of the experience of more time of observation, which will allow to detect failures and ideas of improvement will arise. The only aspect to take into account is that the Arduino system used has little memory and this limits the extension and complexity of the application, but in return it is so economical! Any suggestion and communication of detected errors will be welcome.

 

Regarding the customization for another mount or encoders, the only changes to be made in the application are the initialization of the variables ra_ratio, dec_ratio, ra_rotation and dec_rotation. 

 

In the case of EQ3, and according to my calculations the correct values of the ratios are:

 

5120 pulses for a complete turn of 24 hours in AR:

 int ra_ratio=5120;

 

2580 pulses per full 360 hour turn in DEC:

int dec_ratio=2580; 

 

You must also define how the direction of rotation of the encoders operates, which will depend on how the coupling has been made.

 

In my case, with the mechanical solution that I have given, when the right ascension is increased, the encoder turns counterclockwise:

 

int ra_rotation = -1; 

 

And in my case, for the declination, when turning clockwise we go east:

 

int dec_rotation = 1;

 

if in your implementation, it is the contrary, you only have to change the sign.

 

Only these four variables can vary from one installation to another.

 

The source code is included below:

// RA ENCODER

double ra;

int RA_pinA = 0; // Connected to CLK on KY-040 

int RA_pinB = 1; // Connected to DT on KY-040 

int RA_pinALast;

int RA_aVal; 

int ra_encoder = 0;

int ra_rotation = -1;

int ra_ratio=5120; // number of pulses for a complete 24-hour turn in RA (each turn of the hand is 40 pulses)

 

// DEC ENCODER

double dec;

int DEC_pinA = 2; // Connected to CLK on KY-040 

int DEC_pinB = 3; // Connected to DT on KY-040 

int DEC_pinALast;

int DEC_aVal; 

int dec_encoder = 0;

int dec_rotation = 1;

int dec_ratio=2580; // number of pulses for a complete 360 hour turn in DEC (each turn of the hand is 40 pulses)

 

char tmp[100];

unsigned long time;

int screen_type=1;

int adjust_pos=1;

int time_count=0;

int backlight=50; // initial value in the range of 0 to 255

 

 

// Star database for SYNC

// Stars with magnitude <2.25 and declination >-25 (J2000)

double ra_stars[]={4.60,10.33,3.13,6.63,12.90,13.80,2.07,5.60,5.68,9.47,15.58,0.13,19.85,14.27,5.42,5.92,5.28,7.58,0.95,20.68,11.82,0.73,11.07,5.43,17.95,2.12,14.85,6.00,1.17,3.40,6.38,13.40,2.53,7.75,7.65,17.58,10.13,5.25,20.37,5.80,0.68,6.75,13.42,18.62};

double dec_stars[]={16.5,19.8,41,16.4,56,49.3,42.3,-1.2,-1.9,-8.7,26.7,29.1,8.9,19.2,6.3,7.4,46,31.9,60.7,45.3,14.6,-18,61.8,28.6,51.5,23.5,74.2,44.9,35.6,49.9,-18,54.9,89.3,28,5.2,12.6,12,-8.2,40.3,-9.7,56.5,-16.7,-11.2,38.8};

const char *name_stars[] ={"Aldebaran","Algieba","Algol","Alhena","Alioth","Alkaid","Almach","Alnilam","Alnitak","Alphard","Alphecca","Alpheratz","Altair","Arcturus","Bellatrix","Betelgeuse","Capella","Castor","Cih","Deneb","Denebola","Diphda","Dubhe","Elnath","Eltanin","Hamal","Kochab","Menkalinan","Mirach","Mirfak","Mirzam","Mizar","Polaris","Pollux","Procyon","Rasalhague","Regulus","Rigel","Sadr","Saiph","Schedar","Sirius","Spica","Vega"};

int tot_stars=44;

int idx=-1;

 

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

 

//***********************************************************************

// Initializations at startup

//***********************************************************************

void setup() {

  pinMode (RA_pinA,INPUT);

  pinMode (RA_pinB,INPUT);

  RA_pinALast = digitalRead(RA_pinA);

  

  pinMode (DEC_pinA,INPUT);

  pinMode (DEC_pinB,INPUT);

  DEC_pinALast = digitalRead(DEC_pinA);

  

  lcd.begin(16, 2);         // LCD init

  lcd.setCursor(0,0);       // column, row

  lcd.print("DSC 1.0");     // print start message

 

  delay(300);

  lcd.clear();

 

  time = millis();

  ra=0;

  dec=90;

 

  analogWrite(10, backlight);  

  

}

 

//***********************************************************************

// Converts declination into degrees and minutes

//***********************************************************************

void ConvertDEC(double t, int *g, int *m) { 

 

    int grad;

    int minute;

    int sign;

 

    if (t<0) sign=-1; else sign=1;

    t=t*sign;

    grad=t;

 

    minute = (t-grad) * 60 ; 

 

    *g=grad*sign;

    *m=minute;

      

 

 

//***********************************************************************

// Converts RA into degrees, minutes and seconds

//***********************************************************************

void ConvertRA(double t, int *h, int *m, int *s) { 

 

    int hour=t;

    int minute = (t-hour) * 60 ; 

    int second = ((t-hour)*60-minute)*60;

 

    *h=hour;

    *m=minute;

    *s=second;

      

 

//***********************************************************************

// Print current star for syncing

//***********************************************************************

void Print_Star(void){

 

  int h, m_ra, g, m_dec, s;

   

   sprintf(tmp,"%s", name_stars[idx]);

   lcd.clear();

   lcd.print(tmp);

   lcd.setCursor(0,1);

   ConvertRA(ra_stars[idx], &h, &m_ra, &s);

   ConvertDEC(dec_stars[idx], &g, &m_dec);

   sprintf(tmp, "R:%02d %02d D:%02d %02d", h, m_ra, g, m_dec);

   lcd.print(tmp);

   

}

 

//***********************************************************************

// Main loop

//***********************************************************************

void loop() {

  

  RA_aVal = digitalRead(RA_pinA);

  DEC_aVal = digitalRead(DEC_pinA);

  int x, mod;

  int g, h, m, s;

 

  // ******************** keypad control *******************************

  x = analogRead (0);

  if (x > 900) {

    // no key

  } else {

    if (x < 50) { // right

    } else if (x < 250) { // up

      if (time_count<6) { // during first 3s

        if (backlight<255){

          backlight=backlight+5; 

          analogWrite(10, backlight);

          time_count=0;

        }

      } else if (idx==-1){

        if (adjust_pos==1) ra=ra+1.0/60; else dec=dec+0.1;  // increment 1 minute in RA or 6 minutes in DEC

        if (ra>24) ra=23.9;

        if (dec>90) dec=90;

      } else {

        if (idx>0) idx--; else idx=tot_stars-1;

        Print_Star();

      }

    } else if (x < 450){ // down

      if (time_count<6) { // during first 3s

        if (backlight>0){

          backlight=backlight-5; 

          analogWrite(10, backlight);

          time_count=0;

        }

      } else if (idx==-1) {

        if (adjust_pos==1) ra=ra-2.0/60; else dec=dec-0.1; // decrement 1 minute in RA or 6 minutes in DEC

        if (ra<0) ra=0;

      } else {

        if (idx<(tot_stars-1)) idx++; else idx=0;

        Print_Star();

      }  

    } else if (x < 650){ // left

      if (adjust_pos==2) adjust_pos=1; else adjust_pos=2;

    } else if (x < 850){ // select

      if (idx>=0 && idx<tot_stars) { // if we are selecting a star for sync

        ra=ra_stars[idx];

        dec=dec_stars[idx];

        ra_encoder=0;

        dec_encoder=0;

        idx=-1;

        lcd.clear();

      } else if (time_count<6) { // during first 3s

        screen_type=2; 

        lcd.clear();

      } else {

        idx=0;

        Print_Star();

      }

    }

    delay(200);

  }

 

  // ************ pulses in  RA ***********************************

  if (RA_aVal != RA_pinALast){ // encoder rotating

    if (digitalRead(RA_pinB) != RA_aVal) { // pin A change first: clockwise

      ra_encoder ++;

      ra=ra+ra_rotation*24.0/ra_ratio;

    } else {

      ra_encoder--; 

      ra=ra-ra_rotation*24.0/ra_ratio;

    }

    if (ra<0) ra=ra+24.0; else if (ra>24.0) ra=ra-24.0;

  } 

  RA_pinALast = RA_aVal; 

 

  

  // ************ pulses in DEC ***********************************

  if (DEC_aVal != DEC_pinALast){ // encoder rotating

    if (digitalRead(DEC_pinB) != DEC_aVal) { // pin A change first: clockwise

      dec_encoder ++;

      dec=dec+dec_rotation*360.0/dec_ratio;

    } else {

      dec_encoder--; 

      dec=dec-dec_rotation*360.0/dec_ratio;

    }

    if (dec>90.0) { // detection of passage through the northern meridian

      dec_rotation=dec_rotation*-1; 

      dec=180.0-dec;

    }

  } 

  DEC_pinALast = DEC_aVal; 

 

 

  // ************* display *********************************

  if ((millis()-time)>500 && idx==-1){  // every 0.5s and if we are not selecting a star

 

    if (time_count<100) time_count++;

    ra=ra+((millis()-time)/1000.0)/3600;

    time=millis();

 

    if (screen_type==1){

      ConvertRA(ra, &h, &m, &s);

      if (adjust_pos==1) mod='>'; else mod=' ';

      sprintf(tmp,"%cRA:%02dh %02dm %02ds", mod, h, m, s);

      lcd.setCursor(0,0);

      lcd.print(tmp);

  

      ConvertDEC(dec, &g, &m);

      if (adjust_pos==2) mod='>'; else mod=' ';

      sprintf(tmp, "%cDEC:%02d%c %02d'", mod, g, 223, m);

      lcd.setCursor(0,1);

      lcd.print(tmp);

      

    } else {

 

      sprintf(tmp, "RA enc:%04d %c", ra_encoder, mod);

      lcd.setCursor(0,0);

      lcd.print(tmp);

 

      sprintf(tmp, "DEC enc:%04d", dec_encoder, mod);

      lcd.setCursor(0,1);

      lcd.print(tmp);

      

    }

    

  } 

    

 

}