|
satnogs-rotator-firmware
|
#include <Arduino.h>#include <PID_v1.h>#include <Wire.h>#include "../libraries/globals.h"#include "../libraries/easycomm.h"#include "../libraries/rotator_pins.h"#include "../libraries/endstop.h"#include "../libraries/watchdog.h"#include "../libraries/i2c_mux.h"#include "../libraries/tc74.h"#include "../libraries/motor.h"#include "../libraries/as5601.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 | MAX_PWM 180 |
| Set max Speed. | |
| #define | MIN_PWM 5 |
| Set min Speed. | |
| #define | POSITION_DEADZONE 0.2 |
| Control dead zone. | |
| #define | PCA9540_ID 0x70 |
| I2C Multiplexer ID. | |
| #define | PCA9540_CH0 0x04 |
| I2C Multiplexer CHO. | |
| #define | PCA9540_CH1 0x05 |
| I2C Multiplexer CH1. | |
| #define | TC74_ID 0x48 |
| Temperature Sensor ID. | |
| #define | OVER_TEMP 60 |
| Over temperature limit. | |
| #define | ENC_RATIO 2 |
| Encoder AS5601 gear ratio. | |
| #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_SPEED 100 |
| Set speed to find home, duty cycle of 8-bit timer. | |
Functions | |
| enum _rotator_error | homing () |
| Move both axis with one direction in order to find home position, end-stop switches. | |
| void | setup () |
| void | loop () |
Variables | |
| uint32_t | t_run = 0 |
| easycomm | comm |
| motor | motor_az (M1IN1, M1IN2, M1FB, MOTOR_EN, M1SF, MAX_PWM, MIN_PWM) |
| motor | motor_el (M2IN1, M2IN2, M2FB, MOTOR_EN, M2SF, MAX_PWM, MIN_PWM) |
| PID pid_az & | control_az |
| PID pid_el & | control_el |
| endstop | switch_az (SW1, DEFAULT_HOME_STATE) |
| endstop | switch_el (SW2, DEFAULT_HOME_STATE) |
| i2c_mux | pca9540 (PCA9540_ID, PCA9540_CH0, PCA9540_CH1) |
| tc74 | temp_sensor (TC74_ID) |
| AS5601 | encoder_az |
| AS5601 | encoder_el |
| wdt_timer | wdt |
This is the documentation for satnogs rotator controller firmware for dc 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 Arduino-PID-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 dc_motor_controller.ino.
| #define DEFAULT_HOME_STATE HIGH |
Change to LOW according to Home sensor.
Definition at line 40 of file dc_motor_controller.ino.
| #define ENC_RATIO 2 |
Encoder AS5601 gear ratio.
Definition at line 35 of file dc_motor_controller.ino.
Referenced by setup().
| #define HOME_SPEED 100 |
Set speed to find home, duty cycle of 8-bit timer.
Definition at line 41 of file dc_motor_controller.ino.
Referenced by homing().
| #define MAX_M1_ANGLE 360 |
Maximum angle of azimuth.
Definition at line 37 of file dc_motor_controller.ino.
Referenced by homing().
| #define MAX_M2_ANGLE 180 |
Maximum angle of elevation.
Definition at line 39 of file dc_motor_controller.ino.
Referenced by homing().
| #define MAX_PWM 180 |
| #define MIN_M1_ANGLE 0 |
Minimum angle of azimuth.
Definition at line 36 of file dc_motor_controller.ino.
| #define MIN_M2_ANGLE 0 |
Minimum angle of elevation.
Definition at line 38 of file dc_motor_controller.ino.
| #define MIN_PWM 5 |
Set min Speed.
Definition at line 28 of file dc_motor_controller.ino.
| #define OVER_TEMP 60 |
Over temperature limit.
Definition at line 34 of file dc_motor_controller.ino.
Referenced by loop().
| #define PCA9540_CH0 0x04 |
I2C Multiplexer CHO.
Definition at line 31 of file dc_motor_controller.ino.
| #define PCA9540_CH1 0x05 |
I2C Multiplexer CH1.
Definition at line 32 of file dc_motor_controller.ino.
| #define PCA9540_ID 0x70 |
I2C Multiplexer ID.
Definition at line 30 of file dc_motor_controller.ino.
| #define POSITION_DEADZONE 0.2 |
| #define RATIO 54 |
Gear ratio of rotator gear box.
Definition at line 26 of file dc_motor_controller.ino.
| #define SAMPLE_TIME 0.1 |
Control loop in s.
Definition at line 25 of file dc_motor_controller.ino.
| #define TC74_ID 0x48 |
Temperature Sensor ID.
Definition at line 33 of file dc_motor_controller.ino.
| enum _rotator_error homing | ( | ) |
Move both axis with one direction in order to find home position, end-stop switches.
Definition at line 215 of file dc_motor_controller.ino.
References control_az, control_el, encoder_az, encoder_el, AS5601::get_pos(), endstop::get_state(), HOME_SPEED, homing_error, AS5601::init_zero(), MAX_M1_ANGLE, MAX_M2_ANGLE, motor_az, motor_el, motor::move(), no_error, pca9540, PCA9540_CH0, PCA9540_CH1, i2c_mux::set_channel(), AS5601::set_zero(), motor::stop(), switch_az, switch_el, wdt_timer::watchdog_reset(), and wdt.
Referenced by loop().

| void loop | ( | ) |
Definition at line 106 of file dc_motor_controller.ino.
References comm, control_az, control_el, _rotator::control_mode, motor::disenable(), easycomm::easycomm_proc(), encoder_az, encoder_el, _rotator::fault_az, _rotator::fault_el, motor::get_fault(), AS5601::get_pos(), endstop::get_state(), tc74::get_temp(), homing(), homing_error, _rotator::homing_flag, idle, _rotator::inside_temperature, motor_az, motor_el, motor_error, motor::move(), moving, no_error, OVER_TEMP, over_temperature, pca9540, PCA9540_CH0, PCA9540_CH1, pointing, position, POSITION_DEADZONE, r_error, rotator, _rotator::rotator_error, _rotator::rotator_status, SAMPLE_TIME, i2c_mux::set_channel(), tc74::sleep(), speed, motor::stop(), _rotator::switch_az, switch_az, _rotator::switch_el, switch_el, t_run, temp_sensor, tc74::wake_up(), wdt_timer::watchdog_reset(), and wdt.

| void setup | ( | ) |
Definition at line 72 of file dc_motor_controller.ino.
References comm, easycomm::easycomm_init(), motor::enable(), ENC_RATIO, encoder_az, encoder_el, endstop::init(), i2c_mux::init(), motor::init_pin(), motor::init_timer(), MAX_PWM, motor_az, motor_el, pca9540, SAMPLE_TIME, AS5601::set_gear_ratio(), switch_az, switch_el, wdt_timer::watchdog_init(), and wdt.

| easycomm comm |
Definition at line 57 of file dc_motor_controller.ino.
| PID pid_az& control_az |
Definition at line 60 of file dc_motor_controller.ino.
| PID pid_el& control_el |
Definition at line 62 of file dc_motor_controller.ino.
| AS5601 encoder_az |
Definition at line 67 of file dc_motor_controller.ino.
| AS5601 encoder_el |
Definition at line 67 of file dc_motor_controller.ino.
| i2c_mux pca9540(PCA9540_ID, PCA9540_CH0, PCA9540_CH1) | ( | PCA9540_ID | , |
| PCA9540_CH0 | , | ||
| PCA9540_CH1 | ) |
| 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 56 of file dc_motor_controller.ino.
Referenced by loop().