satnogs-rotator-firmware
Macros | Functions | Variables
dc_motor_controller.ino File Reference
#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"
Include dependency graph for dc_motor_controller.ino:

Go to the source code of this file.

Macros

#define SAMPLE_TIME   0.1
 Control loop in s. More...
 
#define RATIO   54
 Gear ratio of rotator gear box. More...
 
#define MAX_PWM   180
 Set max Speed. More...
 
#define MIN_PWM   5
 Set min Speed. More...
 
#define POSITION_DEADZONE   0.2
 Control dead zone. More...
 
#define PCA9540_ID   0x70
 I2C Multiplexer ID. More...
 
#define PCA9540_CH0   0x04
 I2C Multiplexer CHO. More...
 
#define PCA9540_CH1   0x05
 I2C Multiplexer CH1. More...
 
#define TC74_ID   0x48
 Temperature Sensor ID. More...
 
#define OVER_TEMP   60
 Over temperature limit. More...
 
#define ENC_RATIO   2
 Encoder AS5601 gear ratio. More...
 
#define MIN_M1_ANGLE   0
 Minimum angle of azimuth. More...
 
#define MAX_M1_ANGLE   360
 Maximum angle of azimuth. More...
 
#define MIN_M2_ANGLE   0
 Minimum angle of elevation. More...
 
#define MAX_M2_ANGLE   180
 Maximum angle of elevation. More...
 
#define DEFAULT_HOME_STATE   HIGH
 Change to LOW according to Home sensor. More...
 
#define HOME_SPEED   100
 Set speed to find home, duty cycle of 8-bit timer. More...
 

Functions

enum _rotator_error homing ()
 Move both axis with one direction in order to find home position, end-stop switches. More...
 
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
 

Detailed Description

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

Dependencies

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.

License

Licensed under the GPLv3.

Definition in file dc_motor_controller.ino.

Macro Definition Documentation

◆ DEFAULT_HOME_STATE

#define DEFAULT_HOME_STATE   HIGH

Change to LOW according to Home sensor.

Definition at line 40 of file dc_motor_controller.ino.

◆ ENC_RATIO

#define ENC_RATIO   2

Encoder AS5601 gear ratio.

Definition at line 35 of file dc_motor_controller.ino.

Referenced by setup().

◆ HOME_SPEED

#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().

◆ MAX_M1_ANGLE

#define MAX_M1_ANGLE   360

Maximum angle of azimuth.

Definition at line 37 of file dc_motor_controller.ino.

Referenced by homing().

◆ MAX_M2_ANGLE

#define MAX_M2_ANGLE   180

Maximum angle of elevation.

Definition at line 39 of file dc_motor_controller.ino.

Referenced by homing().

◆ MAX_PWM

#define MAX_PWM   180

Set max Speed.

Definition at line 27 of file dc_motor_controller.ino.

Referenced by setup().

◆ MIN_M1_ANGLE

#define MIN_M1_ANGLE   0

Minimum angle of azimuth.

Definition at line 36 of file dc_motor_controller.ino.

◆ MIN_M2_ANGLE

#define MIN_M2_ANGLE   0

Minimum angle of elevation.

Definition at line 38 of file dc_motor_controller.ino.

◆ MIN_PWM

#define MIN_PWM   5

Set min Speed.

Definition at line 28 of file dc_motor_controller.ino.

◆ OVER_TEMP

#define OVER_TEMP   60

Over temperature limit.

Definition at line 34 of file dc_motor_controller.ino.

Referenced by loop().

◆ PCA9540_CH0

#define PCA9540_CH0   0x04

I2C Multiplexer CHO.

Definition at line 31 of file dc_motor_controller.ino.

Referenced by homing(), and loop().

◆ PCA9540_CH1

#define PCA9540_CH1   0x05

I2C Multiplexer CH1.

Definition at line 32 of file dc_motor_controller.ino.

Referenced by homing(), and loop().

◆ PCA9540_ID

#define PCA9540_ID   0x70

I2C Multiplexer ID.

Definition at line 30 of file dc_motor_controller.ino.

◆ POSITION_DEADZONE

#define POSITION_DEADZONE   0.2

Control dead zone.

Definition at line 29 of file dc_motor_controller.ino.

Referenced by loop().

◆ RATIO

#define RATIO   54

Gear ratio of rotator gear box.

Definition at line 26 of file dc_motor_controller.ino.

◆ SAMPLE_TIME

#define SAMPLE_TIME   0.1

Control loop in s.

Definition at line 25 of file dc_motor_controller.ino.

Referenced by loop(), and setup().

◆ TC74_ID

#define TC74_ID   0x48

Temperature Sensor ID.

Definition at line 33 of file dc_motor_controller.ino.

Function Documentation

◆ homing()

enum _rotator_error homing ( )

Move both axis with one direction in order to find home position, end-stop switches.

Returns
_rotator_error

Definition at line 214 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().

Here is the call graph for this function:

◆ loop()

void loop ( )

◆ setup()

void setup ( )

Variable Documentation

◆ comm

easycomm comm

Definition at line 56 of file dc_motor_controller.ino.

Referenced by loop(), and setup().

◆ control_az

PID pid_az& control_az

Definition at line 59 of file dc_motor_controller.ino.

Referenced by homing(), and loop().

◆ control_el

PID pid_el& control_el

Definition at line 61 of file dc_motor_controller.ino.

Referenced by homing(), and loop().

◆ encoder_az

AS5601 encoder_az

Definition at line 66 of file dc_motor_controller.ino.

Referenced by homing(), loop(), and setup().

◆ encoder_el

AS5601 encoder_el

Definition at line 66 of file dc_motor_controller.ino.

Referenced by homing(), loop(), and setup().

◆ motor_az

Referenced by homing(), loop(), and setup().

◆ motor_el

Referenced by homing(), loop(), and setup().

◆ pca9540

Referenced by homing(), loop(), and setup().

◆ switch_az

Referenced by homing(), loop(), and setup().

◆ switch_el

Referenced by homing(), loop(), and setup().

◆ t_run

uint32_t t_run = 0

Definition at line 55 of file dc_motor_controller.ino.

Referenced by loop().

◆ temp_sensor

tc74 temp_sensor(TC74_ID)

Referenced by loop().

◆ wdt

wdt_timer wdt

Definition at line 67 of file dc_motor_controller.ino.

Referenced by homing(), loop(), and setup().