diff --git a/arduino/startracker.ino b/arduino/startracker.ino index 3549cb7..c7b8297 100644 --- a/arduino/startracker.ino +++ b/arduino/startracker.ino @@ -89,8 +89,8 @@ static struct rot_state_t { } while(0) static void debug_long(rot_state_t *s){ - const unsigned long ellapsed_in_sec = s->elapsed_time_millis/1000; - DUMP(ellapsed_in_sec); + const unsigned long ellapsed_in_msec = s->elapsed_time_millis; + DUMP(ellapsed_in_msec); DUMP(earth_rot_speed_rad_msec); DUMP(axis_hinge_dist_mm); DUMP(nr_teeth_big); @@ -100,8 +100,11 @@ static void debug_long(rot_state_t *s){ } static float get_expected_stepper_rot(rot_state_t *s) { - const unsigned long ellapsed_in_sec = s->elapsed_time_millis/1000; - const float r = tan(earth_rot_speed_rad_msec * s->elapsed_time_millis /* ellapsed_in_sec */) * axis_hinge_dist_mm * 2 * PI * nr_teeth_big / (bolt_thread_mm * nr_teeth_small); + const float r = tan(earth_rot_speed_rad_msec * s->elapsed_time_millis /* ellapsed_in_sec */) + * axis_hinge_dist_mm + * 2 * PI + * nr_teeth_big + / (bolt_thread_mm * nr_teeth_small); #if DEBUG debug_long(s); @@ -117,6 +120,8 @@ static unsigned int get_step_number(rot_state_t *s, float expected_rotation) { const int steps = floor(fsteps); #if DEBUG + Serial.print("current rot:"); + Serial.println(s->stepper_gear_rot_rad, 6); Serial.print("diff :"); Serial.print(angle_diff, 6); Serial.print(" needed steps : "); @@ -163,11 +168,7 @@ static struct { unsigned int expired; } active_timer; -static unsigned long global_period = 50; - -// BIT functions -// #define CLR(x,y) (x&=(~(1< RUN"); - start_timer(global_period); + start_timer(global_period_msec); } break; }