25 #define SAMPLE_TIME 0.1 29 #define POSITION_DEADZONE 0.2 30 #define PCA9540_ID 0x70 31 #define PCA9540_CH0 0x04 32 #define PCA9540_CH1 0x05 36 #define MIN_M1_ANGLE 0 37 #define MAX_M1_ANGLE 360 38 #define MIN_M2_ANGLE 0 39 #define MAX_M2_ANGLE 180 40 #define DEFAULT_HOME_STATE HIGH 41 #define HOME_SPEED 100 45 #include "../libraries/globals.h" 46 #include "../libraries/easycomm.h" 47 #include "../libraries/rotator_pins.h" 48 #include "../libraries/endstop.h" 49 #include "../libraries/watchdog.h" 50 #include "../libraries/i2c_mux.h" 51 #include "../libraries/tc74.h" 52 #include "../libraries/motor.h" 53 #include "../libraries/as5601.h" 96 pid_az.SetMode(AUTOMATIC);
99 pid_el.SetMode(AUTOMATIC);
215 bool isHome_az =
false;
216 bool isHome_el =
false;
229 while (isHome_az ==
false || isHome_el ==
false) {
#define ENC_RATIO
Encoder AS5601 gear ratio.
#define SW1
Digital input, to read the status of end-stop for motor 1.
#define M1FB
Motor 1 analog input, current/load feedback.
#define HOME_SPEED
Set speed to find home, duty cycle of 8-bit timer.
#define M2IN1
Motor 2 PWM pin.
#define M2IN2
Motor 2 PWM pin.
void set_gear_ratio(uint8_t enc_ratio)
Set the gear ratio between encoder and measure axis.
Class that functions for interacting with a watchdog timer.
void enable()
Enable motor driver.
int8_t sleep()
Sleep device request to the sensor on the specified address.
void set_channel(uint8_t ch)
Change the channel.
motor motor_el(M2IN1, M2IN2, M2FB, MOTOR_EN, M2SF, MAX_PWM, MIN_PWM)
void easycomm_proc()
Get the commands from RS485 and response to the client.
#define MOTOR_EN
Digital output, to enable the motors.
#define PCA9540_CH0
I2C Multiplexer CHO.
#define PCA9540_ID
I2C Multiplexer ID.
i2c_mux pca9540(PCA9540_ID, PCA9540_CH0, PCA9540_CH1)
Class that functions for interacting with I2C 1-of-2 multiplexer.
void init()
Initialize the Input pin for end-stop.
endstop switch_el(SW2, DEFAULT_HOME_STATE)
#define PCA9540_CH1
I2C Multiplexer CH1.
tc74 temp_sensor(TC74_ID)
Class that functions for interacting with end-stop.
enum _rotator_status rotator_status
Rotator status.
enum _rotator_error rotator_error
Rotator error.
bool switch_el
End-stop vales.
#define MAX_M1_ANGLE
Maximum angle of azimuth.
uint8_t set_zero()
Set zero by setting offset angle.
Class that functions for interacting with a TC74 Temperature sensor.
#define SAMPLE_TIME
Control loop in s.
int8_t wake_up()
Wake up request to the sensor on the specified address.
#define OVER_TEMP
Over temperature limit.
#define M2SF
Motor 2 digital input, status flag.
Class that functions for interacting with AS5601 magnetic rotary position sensor. ...
int8_t get_temp()
Reads the int8_t in temperature measurement register.
int8_t inside_temperature
Inside Temperature.
#define M1IN1
Motor 1 PWM pin.
#define M1SF
Motor 1 digital input, status flag.
void watchdog_reset()
Reset the watchdog timer.
void stop()
Stop moving the DC motor.
void init_timer(uint8_t timer, uint16_t divisor)
Set timer frequency, for timers 0, 1, 2.
void easycomm_init()
Initialize the RS485 bus.
void init_pin()
Initialize pins of DC motor driver.
#define M1IN2
Motor 1 PWM pin.
uint8_t get_pos(double *new_pos)
Calculate an unwrap the position.
enum _rotator_error homing()
Move both axis with one direction in order to find home position, end-stop switches.
#define TC74_ID
Temperature Sensor ID.
void init()
Initialize the I2C bus.
void disenable()
Disable motor driver.
bool homing_flag
Homing flag.
#define MAX_M2_ANGLE
Maximum angle of elevation.
uint8_t fault_el
Motor drivers fault flag.
Class that functions for interacting with a Motor Driver Carrier.
void watchdog_init()
Initialize watchdog timer to 2sec time out and to set up interrupt routine.
#define M2FB
Motor 2 analog input, current/load feedback.
enum _control_mode control_mode
Control mode.
uint8_t get_fault()
Get the status flag of motor driver.
#define MIN_PWM
Set min Speed.
motor motor_az(M1IN1, M1IN2, M1FB, MOTOR_EN, M1SF, MAX_PWM, MIN_PWM)
#define SW2
Digital input, to read the status of end-stop for motor 2.
Class that functions for easycomm 3 implementation.
#define MAX_PWM
Set max Speed.
void move(int16_t speed)
Move the DC motor with constant voltage (~speed)
#define POSITION_DEADZONE
Control dead zone.
endstop switch_az(SW1, DEFAULT_HOME_STATE)
#define DEFAULT_HOME_STATE
Change to LOW according to Home sensor.
void init_zero()
Reset zero position set the offset to zero.
bool get_state()
Get the state of end-stop.