25#define SAMPLE_TIME 0.1
28#define MIN_PULSE_WIDTH 20
30#define MAX_ACCELERATION 1600
33#define MAX_M1_ANGLE 360
35#define MAX_M2_ANGLE 180
36#define DEFAULT_HOME_STATE HIGH
37#define HOME_DELAY 12000
40#include <AccelStepper.h>
70 stepper_az.setPinsInverted(
false,
false,
true);
75 stepper_el.setPinsInverted(
false,
false,
true);
156 bool isHome_az =
false;
157 bool isHome_el =
false;
164 while (isHome_az ==
false || isHome_el ==
false) {
179 if ((
stepper_az.distanceToGo() == 0 && !isHome_az) ||
180 (
stepper_el.distanceToGo() == 0 && !isHome_el)){
188 uint32_t time = millis();
226 return (360.00 * step / (
SPR *
RATIO));
Class that functions for easycomm 3 implementation.
void easycomm_proc()
Get the commands from RS485 and response to the client.
void easycomm_init()
Initialize the RS485 bus.
Class that functions for interacting with end-stop.
bool get_state()
Get the state of end-stop.
void init()
Initialize the Input pin for end-stop.
Class that functions for interacting with a watchdog timer.
void watchdog_reset()
Reset the watchdog timer.
void watchdog_init()
Initialize watchdog timer to 2sec time out and to set up interrupt routine.
enum _rotator_error homing()
Move both axis with one direction in order to find home position, end-stop switches.
#define M1IN2
Motor 1 PWM pin.
#define M2IN2
Motor 2 PWM pin.
#define SW2
Digital input, to read the status of end-stop for motor 2.
#define MOTOR_EN
Digital output, to enable the motors.
#define M1IN1
Motor 1 PWM pin.
#define M2IN1
Motor 2 PWM pin.
#define SW1
Digital input, to read the status of end-stop for motor 1.
endstop switch_el(SW2, DEFAULT_HOME_STATE)
endstop switch_az(SW1, DEFAULT_HOME_STATE)
#define MAX_ACCELERATION
In steps/s^2, consider the microstep.
#define RATIO
Gear ratio of rotator gear box.
float step2deg(int32_t step)
Convert steps to degrees according to step/revolution, rotator gear box ratio and microstep.
int32_t deg2step(float deg)
Convert degrees to steps according to step/revolution, rotator gear box ratio and microstep.
#define DEFAULT_HOME_STATE
Change to LOW according to Home sensor.
#define SPR
Step Per Revolution, consider the microstep.
#define MAX_SPEED
In steps/s, consider the microstep.
#define MAX_M1_ANGLE
Maximum angle of azimuth.
AccelStepper stepper_az(1, M1IN1, M1IN2)
#define MAX_M2_ANGLE
Maximum angle of elevation.
#define HOME_DELAY
Time for homing Deceleration in millisecond.
#define MIN_PULSE_WIDTH
In microsecond for AccelStepper.
AccelStepper stepper_el(1, M2IN1, M2IN2)
double setpoint
Position set point in deg.
double input
Motor Position feedback in deg.
enum _rotator_error rotator_error
Rotator error.
enum _control_mode control_mode
Control mode.
bool switch_el
End-stop vales.
enum _rotator_status rotator_status
Rotator status.
bool homing_flag
Homing flag.