Skip to content

Tarbal/TelescopeMount

Repository files navigation

TelescopeMount

1/24/21: apt-get has been acting funny lately, so wherever I indicate using that command, use aptitude instead. Due to this reason, undocumented kernel updates to 18.04, and cpu performance management settings on 18.04, this repository has become more trouble than it is worth to maintain, and this is the final update. Work on the proprietary version for N-Dimensional Technologies (https://n-dtech.com) will continue as planned. That being said, this version compiles and runs fine as of today on Ubuntu 18.04 Raspberry Pi 4.

1/23/21: Clarification of copyright on the updated PID algorithm is now added. The license on the file pid.pseudo is to be considered separate from the rest of this repository, as is indicated in comments at the top of the file. It is purely provided for demonstrative purposes.

Second Update of 1/19/21: A good starting point for PID settings, assuming you use the updated algorithm, would be P = 20000, I = 1000, and D = 26. These are the parameters I use currently. Ultimately, however, the optimal values for these parameters will depend on a number of factors, including motor torque, power output, mount resistance to applied torque, and damping. I suggest reading up on the subject and mathematics of PID, before even attempting such an endeavor. When I said "I cannot stress how important this is," I meant it. Furthermore, a good reference for choosing the appropriate DC motor (as well as everything else related to mount design and construction)is the following:

Trueblood, M. and Genet, R.M., Telescope Control (Second English Edition), Willmann-Bell, Inc. (Richmond, 1997).

If you are taking the project seriously, I would recommend another book as well:

Smart, W.M., Textbook on Spherical Astronomy (Sixth Edition, reprinted), Cambridge University Press (Cambridge, 1979).

At some point, you'll need to account for geometric errors, which are covered in the Trueblood/Genet book. Good luck.

Update 1/19/21: I cleaned up the updated PID algorithm, even though I said 8 months ago that I would never update this repository ever again. You have to stay one step ahead of your critics...

Update 1/18/21: It has come to my attention that the PID algorithm was never updated in this version. Uploaded as optional files, the updated PID algorithm is the much improved version I have been using for the past 7 months.

Here is some telescope mount control software which can be used with any mount using DC gear motors and incremental encoders, all controlled by a Raspberry Pi 3b+ (untested on other versions). This software does not include geometric corrections for mechanical imperfections. If it does not point accurately, then you have some mechanical problems -- most likely backlash. RA and Dec should be entered in terms of epoch 2000 after calibrating/aligning with polaris (If you are in the southern hemisphere, set the polaris RA and DEC in globalvars.cpp to a convenient star which you wish to use to calibrate).

The GUI is very simple, and you may want to build on this code. This is the last this repository will be updated. A future version may or may not be public, but it will have it's own repository. This code is
GNU General Public License (GNU GPL), copyright John Emil Petersen III, 2019-2021.

You simply need to change the global variables in globalvars.cpp, such as gearRatio and quadratureStates to what is appropriate for your mount. You may want to measure environmental variables such as temperature with instrumentation, rather than updating every time and compiling.

Set the variable quadrature states to the number of pulses per revolution on your encoder times 4. So, if your encoders are 10,000 ppr, you set quadratureStates = 40000.

The variables pinRotateA, pinRotateB, PinInclineA, and PinInclineB correspond to the gpio pins attached to your motor drivers' PWM connection. The same goes for the encoderRotate and encoderIncline variables.

In order to compile on a Raspberry Pi 3b+, you will need to link the appropriate libraries. I suggest you compile within QTCreator after you have downloaded and installed the boost, pigpio, and sofa libraries. Then, you need to run pigpiod. If you want it to run automatically at startup, as well as sync the time after a 30 second wait, and set the cpu to performance mode, add the following

#!/bin/sh -e

pigpiod;

echo 'GOVERNOR="performance"' | tee /etc/default/cpufrequtils;

systemctl disable ondemand;

sleep 30;

service ntp stop;

ntpdate time.nist.gov;

service ntp start;

exit 0;

to your /etc/rc.local file. If it does not exist, then create it. Don't forget to make it executable by typing

sudo chmod a+x /etc/rc.local

All of this has been tested on Ubuntu 18.04 only. Good luck. The reason for 18.04 is due to the way GPIOs are controlled with this distribution. At some point, cpu performance was changed to an "on demand" setting, which causes problems, so now... you need to add cpufrequtility and set it to stay running at 1.5 GHz...

Once you have followed every step, You still need to tune the PID parameters in the main function. I cannot stress how important this is.

About

Basic controls for an Alt-Az Mount

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published