satnogs-rotator-firmware
Loading...
Searching...
No Matches
stepper_motor_controller.ino File Reference
#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"
Include dependency graph for stepper_motor_controller.ino:

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
 

Detailed Description

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

Dependencies

This firmware depends on AccelStepper 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 stepper_motor_controller.ino.

Macro Definition Documentation

◆ DEFAULT_HOME_STATE

#define DEFAULT_HOME_STATE   HIGH

Change to LOW according to Home sensor.

Definition at line 36 of file stepper_motor_controller.ino.

◆ HOME_DELAY

#define HOME_DELAY   12000

Time for homing Deceleration in millisecond.

Definition at line 37 of file stepper_motor_controller.ino.

Referenced by homing().

◆ MAX_ACCELERATION

#define MAX_ACCELERATION   1600

In steps/s^2, consider the microstep.

Definition at line 30 of file stepper_motor_controller.ino.

Referenced by setup().

◆ MAX_M1_ANGLE

#define MAX_M1_ANGLE   360

Maximum angle of azimuth.

Definition at line 33 of file stepper_motor_controller.ino.

Referenced by loop().

◆ MAX_M2_ANGLE

#define MAX_M2_ANGLE   180

Maximum angle of elevation.

Definition at line 35 of file stepper_motor_controller.ino.

Referenced by loop().

◆ MAX_SPEED

#define MAX_SPEED   3200

In steps/s, consider the microstep.

Definition at line 29 of file stepper_motor_controller.ino.

Referenced by setup().

◆ MICROSTEP

#define MICROSTEP   8

Set Microstep.

Definition at line 27 of file stepper_motor_controller.ino.

◆ MIN_M1_ANGLE

#define MIN_M1_ANGLE   0

Minimum angle of azimuth.

Definition at line 32 of file stepper_motor_controller.ino.

◆ MIN_M2_ANGLE

#define MIN_M2_ANGLE   0

Minimum angle of elevation.

Definition at line 34 of file stepper_motor_controller.ino.

◆ MIN_PULSE_WIDTH

#define MIN_PULSE_WIDTH   20

In microsecond for AccelStepper.

Definition at line 28 of file stepper_motor_controller.ino.

Referenced by setup().

◆ RATIO

#define RATIO   54

Gear ratio of rotator gear box.

Definition at line 26 of file stepper_motor_controller.ino.

Referenced by deg2step(), and step2deg().

◆ SAMPLE_TIME

#define SAMPLE_TIME   0.1

Control loop in s.

Definition at line 25 of file stepper_motor_controller.ino.

◆ SPR

#define SPR   1600L

Step Per Revolution, consider the microstep.

Definition at line 31 of file stepper_motor_controller.ino.

Referenced by deg2step(), and step2deg().

Function Documentation

◆ deg2step()

int32_t deg2step ( float deg)

Convert degrees to steps according to step/revolution, rotator gear box ratio and microstep.

Parameters
degDegrees in float format
Returns
Steps for stepper motor driver, int32_t

Definition at line 212 of file stepper_motor_controller.ino.

References RATIO, and SPR.

Referenced by loop().

◆ homing()

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.

Parameters
seek_azSteps to find home position for azimuth axis
seek_elSteps to find home position for elevation axis
Returns
_rotator_error

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.

Here is the call graph for this function:

◆ loop()

◆ setup()

void setup ( )

◆ step2deg()

float step2deg ( int32_t step)

Convert steps to degrees according to step/revolution, rotator gear box ratio and microstep.

Parameters
stepSteps in int32_t format
Returns
Degrees in float format

Definition at line 225 of file stepper_motor_controller.ino.

References RATIO, and SPR.

Referenced by loop().

◆ stepper_az()

AccelStepper stepper_az ( 1 ,
M1IN1 ,
M1IN2  )

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

◆ stepper_el()

AccelStepper stepper_el ( 1 ,
M2IN1 ,
M2IN2  )

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

Variable Documentation

◆ comm

easycomm comm

Definition at line 50 of file stepper_motor_controller.ino.

Referenced by 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 49 of file stepper_motor_controller.ino.

◆ wdt

wdt_timer wdt

Definition at line 54 of file stepper_motor_controller.ino.

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