Skip to content
Fran Hrženjak edited this page Oct 3, 2020 · 5 revisions

Telescope Control Server

This is a Raspberry Pi (currently model 3 B plus) which performs these functions:

  • constantly reading telescope position via encoders, via EIB 741 device
  • give commands to Axor motor drivers via Modbus / serial connection
  • run HTTP API service for ASCOM drivers to connect to
  • run control loop for telescope positioning

Setup - Software

  1. Base image: Official Raspbian / Raspberry Pi OS

sudo apt update && sudo apt full-upgrade

  1. Install PowerBlock driver

https://github.com/petrockblog/PowerBlock#powerblock-driver

  1. Rename user pi to "dagor" and change the password

sudo passwd root # enable root login

logout # cannot rename while logged in

Log in as root.

usermod -l dagor pi

usermod -m -d /home/dagor dagor

Log in as dagor

passwd

sudo raspi-config

  • set auto-login in Boot Options.
  • add en.UTF-8 locale (choose ANSI-C as default when prompted)
  1. Install pyenv

https://github.com/pyenv/pyenv-installer

`curl https://pyenv.run | bash``

cat <<'EOF' >> ~/.bashrc

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
EOF

Logout, login.

  1. Install latest Python version

Version 3.8.5 at the time or writing

Install requirements for Python (see https://github.com/pyenv/pyenv/wiki/Common-build-problems for latest)

sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git

List available versions: pyenv install -l | grep 3\.8

Install Python:

pyenv install 3.8.5

TODO, we are actually still using 2.7 😊

  1. Clone the code

Clone the repo

git clone https://github.com/astrohr/dagor_tca

TODO there is a bunch of other stuff in this repo, need to split it up, see Issue #114

  1. Create virtual env

cd dagor_tca 
pyenv virtualenv 3.8.5 tca
pyenv local tca
  1. Install project dependencies

sudo apt install libgeos-dev
pip install -r requirements.txt
  1. Set up dagor user

sudo useradd dagor
sudo usermod -a -G dialout dagor

sudo su dagor

cd /home/dagor

curl https://pyenv.run | bash

cat <<'EOF' >> ~/.bashrc

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
EOF

exit

# as pi again

cd /home/dagor/.pyenv/versions/
sudo ls -s /home/pi/.pyenv/versions/tca

sudo su dagor
pynev local tca
exit

Copy files from existing server:

  • /etc/ssh/ssh_host_dsa_key
  • /etc/ssh/ssh_host_dsa_key.pub
  • /etc/ssh/ssh_host_rsa_key
  • /etc/ssh/ssh_host_rsa_key.pub
  • /home/dagor/.ssh/authorized_keys

This is optional, to prevent ssh warnings about different server hashes.

TODO:

  • Run API as a service
  • Run positioning loop as a service