RedBalloonShenanigans / antenny

Make your own base station to communicate with satellites!
https://nyan-sat.com
155 stars 37 forks source link

Antenny

Make your own base station to communicate with satellites!

We have a discord server for collaboration, questions, and show and tell off!

Setting up the hardware

Important Notice:

Jumpers

Required Antenny Jumpers

Optional Antenny Jumpers

Antenny KM7 jumper Antenny KM7 jumper

Flash Firmware button

Optional IMU Jumper

There is one optional IMU jumper. This is used to select the IMU mode. More info can be found in the BNO080 datasheet If you do not want to use the jumper, you can use pins to select the correct mode. This can also be useful for switching between modes in software.

The mode we use is the Robotic Vacuum Cleaner (RVC) mode. To enable this you can provide power to the PS0 pin using the jumper as shown below.

BNO080 Jumper

Setting up the platform

This will go over how to setup the servo gimbal, IMU and antenny board. I used hot glue to secure the hardware, but more creative approaches are welcome.

Step 1: Position the IMU

Position the IMU on the gimbal arm. The position show below will give the correct orientation. If you want a different IMU position, you can correct the elevation angle in software.

Platform Step 1

Step 2: Position the Antenny

Next we secure the Antenny to the platform. It is advised to isolate the pins from any metal contact.

Platform Step 2

Step 3: Wire the IMU Communication Lines

NOTE: From this point on, the pins you use are configurable from the antenny_config, as described in the software guide below. To verify your pins or reconfigure as you wish, it is suggested you edit the config through the antenny_manual_setup command described in the software guide.

The IMU communication lines are labeled on both the IMU PCB and the Antenny PCB, just match them up, as shown.

Platform Step 3

Step 4: Wire the IMU Reset Line

Same as step 3, it is labeled.

Platform Step 4

Step 5: Wiring the Program Select Pins (Optional):

If you did not solder the IMU jumper, you must pick two pins to use to control PS0 and PS1. If using this approach, its suggested you setup these pins using the antenny_manual_setup.

Platform Step 5

Step 6: Wiring the Servos

Next we wire the servos to the PWM controller. By default the elevation(top) servo goes to pwm index 0 and azimuth (bottom) goes to index 1, but this is, again, configurable.

Platform Step 6

Installing the Antenny software

Installing Micropython

  1. Download and install the USB driver for the CP210 USB to UART chip here

  2. Download esptool from here

  3. Put the ESP into download mode (see above) and erase your ESP32

    Example: python3 -m esptool --port /dev/tty.SLAB_USBtoUART erase_flash

  4. Download the micropython firmware from here

  5. Put the ESP into download mode (see above) and re-flash the Micropython firmware

    Example: python3 -m esptool --chip esp32 --port /dev/tty.SLAB_USBtoUART --baud 115200 write_flash -z 0x1000 ~/Downloads/esp32spiram-20210623-v1.16.bin

Installing Antenny MP Code

  1. We use MPFShell to upload the python files to the board. First you must install this on your host computer with python3 -m pip install mpfshell.

  2. To begin install, first push the reset button on the antenny board, labeled RET Button.

  3. Next, from the root directory of this repository, run the make nyansat make directive with the SERIAL argument pointing to your antenny block device.

    Example: make nyansat SERIAL=/dev/tty.SLAB_USBtoUART

  4. The Installer will give you a series of prompts.

    • Do you want to do an installation of all components and libraries?(Y/n)

      • If this is your first install, or you would like to do a fresh install of all code select Y, otherwise, if you would only like to install specific components select N.
    • If you selected Y for the previous prompt you will see:

      • Are you sure you want to erase all files on the device? (y/N)

        • This is just a confirmation, as a full install will take a bit of time.
    • If you selected N you will see:

      • Name a component you wish to install:

        • If you are developing new components or making fixes to existing ones, you can upload one component at a time by typing its name into this prompt. That name should correspond to a sub directory found in the station directory. For example selecting imu would upload all code in the imu sub directory.
      • Do you wish to install more? (y/N)

        • Use this to repeat the above step.
      • Do you want to keep the configs on the device? (Y/n).

        • If you would like to restart your antenny configs from the repository state, select N, to keep your configs on board select Y.
      • Do you want to re-install the libraries (y/N)

        • Select yes to reinstall the libraries found here
  5. You should see the installer upload the code to the antenny.

  6. You will see the installer report False upon completion, press Enter to continue.

  7. The installer will prompt you for your WiFi info. If the above steps were taken to enable WiFi, enter your info, otherwise leave blank.

Your installation is complete!

Getting Started

Entering the Python interpreter

  1. Using a terminal utility of your choice, enter the devices python interpreter.

    • Examples:

      screen <block device> 115200

      or

      minicom -D <block device> -b 115200

    • In the case of windows, Putty is suggested.

  2. Upon entering the interpreter you should be met with the python prompt >>>. If you are not try the reset button on the side of the board or revisit the Installing Micropython section of this README.

  3. To view any potential import errors, press the reset button on the board as described in the installation section.

    • In micropython, the first script run on startup will always be boot.py followed by main.py. The main.py script will import all relevant antenny code and provide access to api, an instance of AntennyAPI.

Using the Antenny API

Device Startup

Once your hardware is properly setup and you have installed the antenny station code, you can begin working with the device. To interface with the device from the python interpreter, we will use member methods of the api class.

High Level Methods

High level methods start with antenny_ are used to setup your antenny assembly, calibrate and save calibration data.

Platform Methods

Platform methods start with platform_ and are used to operate the platform, a term used in this project to describe the pwm driver, the motors it is driving, the IMU and the antenny board as a single assembly.

Servo Methods

Each individual servo can be operated manually through these methods. Without access to the IMU the servos will not know they're orientation.

IMU Methods

IMU data can be accessed directly from the API as well.

The IMU can also be manually calibrated

Other

There are plenty of other methods, most used for debugging, available to the user, as well as direct access to underlying components. For more information, reading through the antenny code is advised.

Configuring Antenny

NOTE: These configs have wrappers to properly alter the config members before saving in the API. In general only the High Level api.antenny_save(name: Optional) should be used by users.

Your hardware is described by a series of configs that can be updated through your installer or on the antenny board itself. This section will go over on baord config modification. To use the installer re-visit the above guide.

The api uses the Config class to manage configs and are exposed by the AntennyAPI. There are currently three configs used by the antenny system, but any components that require information to be stored across boots should use its own config.

Antenny API Config classes

Config Methods

The Antenny Host System

Under Development...

Cooperation between the antenny board and another system is possible through the antenny client as well as the UDP Sender. Use of the client is not suggested while developing on or debugging the system, but could be useful for more interesting applications such as beacon tracking.

The Command Invoker

The command_invoker is a 1:1 library to the antenny api class found at nyansat/host/shell/command_invoker.py. The command_invoker calls out to the board through MPFShell to exec API commands. Feedback and error handling does not work very well so work should be offloaded to the board when possible.

Antenny Client

The antenny_client, found at nyansat/host/shell/antenny_client.py should use the command invoker to implement higher level functions in conjunction with more computationally expensive libraries.

Shell

Current depricated.

The antenny client can then be integrated into the MPFShell environment through nyansat/host/shell/__main__.py. Commands of the format do_<cmd>() will be used as shell commands. See the file for examples. This shell can then be run through the command make nyanshell.

Known Issues

Requirements

NyanShell: