#ifndef FTW_CONSTANTS_H #define FTW_CONSTANTS_H /* ------------------------------------------------------------------------- Serial ------------------------------------------------------------------------- */ #define BAUD_RATE 115200 /* ------------------------------------------------------------------------- SPI The TMC5160 supports up to ~4 MHz. DIV4 on a 16 MHz Arduino = 4 MHz. ------------------------------------------------------------------------- */ #define SPI_CLOCK_DIV SPI_CLOCK_DIV4 /* ------------------------------------------------------------------------- Motor driver — shared by both axes ------------------------------------------------------------------------- */ #define ACCELERATION 20000 // counts/s² — used for A1, AMAX, DMAX, D1 (flat ramp profile) #define ENC_DEVIATION_LIMIT 1500 // max allowed |XACTUAL - XENC| before DEVIATION_WARN fires #define ENC_CONST 0x000C1F40 // encoder resolution constant (counts per electrical cycle) #define ENCMODE_DECIMAL 0x400 // encoder counting mode: decimal (as opposed to binary) /* ------------------------------------------------------------------------- Yaw axis ------------------------------------------------------------------------- */ #define YAW_STEPS_PER_ROUND 177000 // encoder counts per full mechanical revolution #define YAW_GEAR_RATIO 739.5555f #define YAW_GLOBAL_SCALER 80 // scales peak coil current (0–255); lower = less current #define YAW_DEFAULT_XACTUAL 0x0007A120 // initial value written to XACTUAL on reset #define YAW_ENDSTOP_SPEED 25000 // velocity used when driving toward a limit during homing #define YAW_DEFAULT_VMAX 50000 // normal operating speed /* ------------------------------------------------------------------------- Pitch axis ------------------------------------------------------------------------- */ #define PITCH_STEPS_PER_ROUND 500000 #define PITCH_GEAR_RATIO 739.5555f #define PITCH_GLOBAL_SCALER 50 // pitch motor runs at lower current than yaw #define PITCH_DEFAULT_XACTUAL 500000 #define PITCH_ENDSTOP_SPEED 150000 // pitch can home faster because it uses physical switches #define PITCH_DEFAULT_VMAX 250000 /* ------------------------------------------------------------------------- Homing ------------------------------------------------------------------------- */ // After homing, this many encoder counts are kept as a margin inside each limit // so normal operation never commands the axis right to the mechanical stop. #define HOMING_XENC_MARGIN 1000 // If the measured travel between endstops is less than // (steps_per_round - HOMING_MIN_ROUND_DIFF_OFFSET), homing is declared failed. // The offset accounts for the margin on each side plus mechanical tolerance. #define HOMING_MIN_ROUND_DIFF_OFFSET 6000 #define HOMING_DELAY_MS 10 // settle time after an endstop fires before reading XLATCH #define HOMING_PITCH_INITIAL_DELAY 1000 // time to back off a switch before starting the pitch sequence #define HOMING_YAW_TIMEOUT_MS 2000 // pause between yaw right-pass and left-pass (deceleration time) #define HOMING_SGT_THRESHOLD 60 // stallGuard threshold during homing (high = only triggers on hard stop) #define HOMING_YAW_SPEED 30000 // speed used during the yaw homing passes #define HOMING_PITCH_SPEED 30000 // speed used during the pitch homing passes #define HOMING_YAW_CENTER_SPEED 35000 // speed for the post-homing move to centre (yaw) #define HOMING_PITCH_CENTER_SPEED 150000 // speed for the post-homing move to centre (pitch) /* ------------------------------------------------------------------------- Thermal ------------------------------------------------------------------------- */ #define THERMAL_FAN_ON_TEMP 25 // °C threshold below which the fan stays off #define THERMAL_FAN_GAIN 20 // PWM counts per °C above threshold #define THERMAL_FAN_MAX_PWM 255 // PWM ceiling (full speed) #define THERMAL_FAN_PULSE_US 100000 // timeout for pulseIn() on the fan tachometer signal #define THERMAL_FAN_FREQ_DIV 0.004f // unused — reserved for frequency calculation #define THERMAL_LOOP_INTERVAL 250 // ms between thermal samples (DHT11 max ~1 Hz) /* ------------------------------------------------------------------------- Main loop ------------------------------------------------------------------------- */ #define INFO_PRINT_INTERVAL_MS 250 // ms between Serial status prints #endif