|
satnogs-rotator-firmware
|
#include <Arduino.h>#include <AccelStepper.h>#include <Wire.h>#include "../libraries/globals.h"#include "../libraries/easycomm.h"#include "../libraries/rotator_pins.h"#include "../libraries/rs485.h"#include "../libraries/endstop.h"#include "../libraries/watchdog.h"
Go to the source code of this file.
Macros | |
| #define | SAMPLE_TIME 0.1 |
| Control loop in s. | |
| #define | RATIO 54 |
| Gear ratio of rotator gear box. | |
| #define | MICROSTEP 8 |
| Set Microstep. | |
| #define | MIN_PULSE_WIDTH 20 |
| In microsecond for AccelStepper. | |
| #define | MAX_SPEED 3200 |
| In steps/s, consider the microstep. | |
| #define | MAX_ACCELERATION 1600 |
| In steps/s^2, consider the microstep. | |
| #define | SPR 1600L |
| Step Per Revolution, consider the microstep. | |
| #define | MIN_M1_ANGLE 0 |
| Minimum angle of azimuth. | |
| #define | MAX_M1_ANGLE 360 |
| Maximum angle of azimuth. | |
| #define | MIN_M2_ANGLE 0 |
| Minimum angle of elevation. | |
| #define | MAX_M2_ANGLE 180 |
| Maximum angle of elevation. | |
| #define | DEFAULT_HOME_STATE HIGH |
| Change to LOW according to Home sensor. | |
| #define | HOME_DELAY 12000 |
| Time for homing Deceleration in millisecond. | |
Functions | |
| AccelStepper | stepper_az (1, M1IN1, M1IN2) |
| AccelStepper | stepper_el (1, M2IN1, M2IN2) |
| enum _rotator_error | homing (int32_t seek_az, int32_t seek_el) |
| Move both axis with one direction in order to find home position, end-stop switches. | |
| int32_t | deg2step (float deg) |
| Convert degrees to steps according to step/revolution, rotator gear box ratio and microstep. | |
| float | step2deg (int32_t step) |
| Convert steps to degrees according to step/revolution, rotator gear box ratio and microstep. | |
| void | setup () |
| void | loop () |
Variables | |
| uint32_t | t_run = 0 |
| easycomm | comm |
| endstop | switch_az (SW1, DEFAULT_HOME_STATE) |
| endstop | switch_el (SW2, DEFAULT_HOME_STATE) |
| wdt_timer | wdt |
This is the documentation for satnogs rotator controller firmware for stepper motors configuration. The board (PCB) is placed in satnogs-rotator-controller and is for releases: v2.0 v2.1 v2.2 wiki page
This firmware depends on AccelStepper library being present on your system. Please make sure you have installed the latest version before using this firmware.
Licensed under the GPLv3.
Definition in file stepper_motor_controller.ino.
| #define DEFAULT_HOME_STATE HIGH |
Change to LOW according to Home sensor.
Definition at line 36 of file stepper_motor_controller.ino.
| #define HOME_DELAY 12000 |
Time for homing Deceleration in millisecond.
Definition at line 37 of file stepper_motor_controller.ino.
Referenced by homing().
| #define MAX_ACCELERATION 1600 |
In steps/s^2, consider the microstep.
Definition at line 30 of file stepper_motor_controller.ino.
Referenced by setup().
| #define MAX_M1_ANGLE 360 |
Maximum angle of azimuth.
Definition at line 33 of file stepper_motor_controller.ino.
Referenced by loop().
| #define MAX_M2_ANGLE 180 |
Maximum angle of elevation.
Definition at line 35 of file stepper_motor_controller.ino.
Referenced by loop().
| #define MAX_SPEED 3200 |
In steps/s, consider the microstep.
Definition at line 29 of file stepper_motor_controller.ino.
Referenced by setup().
| #define MICROSTEP 8 |
Set Microstep.
Definition at line 27 of file stepper_motor_controller.ino.
| #define MIN_M1_ANGLE 0 |
Minimum angle of azimuth.
Definition at line 32 of file stepper_motor_controller.ino.
| #define MIN_M2_ANGLE 0 |
Minimum angle of elevation.
Definition at line 34 of file stepper_motor_controller.ino.
| #define MIN_PULSE_WIDTH 20 |
In microsecond for AccelStepper.
Definition at line 28 of file stepper_motor_controller.ino.
Referenced by setup().
| #define RATIO 54 |
Gear ratio of rotator gear box.
Definition at line 26 of file stepper_motor_controller.ino.
Referenced by deg2step(), and step2deg().
| #define SAMPLE_TIME 0.1 |
Control loop in s.
Definition at line 25 of file stepper_motor_controller.ino.
| #define SPR 1600L |
Step Per Revolution, consider the microstep.
Definition at line 31 of file stepper_motor_controller.ino.
Referenced by deg2step(), and step2deg().
| int32_t deg2step | ( | float | deg | ) |
Convert degrees to steps according to step/revolution, rotator gear box ratio and microstep.
| deg | Degrees in float format |
Definition at line 212 of file stepper_motor_controller.ino.
Referenced by loop().
| enum _rotator_error homing | ( | int32_t | seek_az, |
| int32_t | seek_el ) |
Move both axis with one direction in order to find home position, end-stop switches.
| seek_az | Steps to find home position for azimuth axis |
| seek_el | Steps to find home position for elevation axis |
Definition at line 155 of file stepper_motor_controller.ino.
References control_az, control_el, endstop::get_state(), HOME_DELAY, homing_error, no_error, _control::setpoint, stepper_az(), stepper_el(), switch_az, switch_el, wdt_timer::watchdog_reset(), and wdt.

| void loop | ( | ) |
Definition at line 85 of file stepper_motor_controller.ino.
References comm, control_az, control_el, _rotator::control_mode, deg2step(), easycomm::easycomm_proc(), endstop::get_state(), homing(), homing_error, _rotator::homing_flag, idle, _control::input, MAX_M1_ANGLE, MAX_M2_ANGLE, no_error, pointing, position, r_error, rotator, _rotator::rotator_error, _rotator::rotator_status, _control::setpoint, step2deg(), stepper_az(), stepper_el(), _rotator::switch_az, switch_az, _rotator::switch_el, switch_el, wdt_timer::watchdog_reset(), and wdt.

| void setup | ( | ) |
Definition at line 60 of file stepper_motor_controller.ino.
References comm, easycomm::easycomm_init(), endstop::init(), MAX_ACCELERATION, MAX_SPEED, MIN_PULSE_WIDTH, MOTOR_EN, stepper_az(), stepper_el(), switch_az, switch_el, wdt_timer::watchdog_init(), and wdt.

| float step2deg | ( | int32_t | step | ) |
Convert steps to degrees according to step/revolution, rotator gear box ratio and microstep.
| step | Steps in int32_t format |
Definition at line 225 of file stepper_motor_controller.ino.
Referenced by loop().
| easycomm comm |
Definition at line 50 of file stepper_motor_controller.ino.
| endstop switch_az(SW1, DEFAULT_HOME_STATE) | ( | SW1 | , |
| DEFAULT_HOME_STATE | ) |
| endstop switch_el(SW2, DEFAULT_HOME_STATE) | ( | SW2 | , |
| DEFAULT_HOME_STATE | ) |
| uint32_t t_run = 0 |
Definition at line 49 of file stepper_motor_controller.ino.