|
|
|
@ -1,14 +1,18 @@
|
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <math.h> |
|
|
|
|
|
|
|
|
|
static const double nr_teeth_small = 11.0; |
|
|
|
|
static const double nr_teeth_big = 53.0; |
|
|
|
|
static const double axis_hinge_dist_mm = 200; |
|
|
|
|
#include "../arduino/teeth_config.h" |
|
|
|
|
|
|
|
|
|
static const float nr_teeth_small = CONFIG_TEETH_SMALL; // 13.0
|
|
|
|
|
static const float nr_teeth_big = CONFIG_TEETH_BIG; // 51.0
|
|
|
|
|
static const float axis_hinge_dist_mm = 200; |
|
|
|
|
|
|
|
|
|
#define PI M_PI |
|
|
|
|
|
|
|
|
|
static const double earth_rot_speed_rad_sec = 2*PI / (1440*60*1000); |
|
|
|
|
static const double bolt_thread_mm = 1.25; |
|
|
|
|
// Use immediate value. Using symbolic values leads to incorrect value.
|
|
|
|
|
static const float earth_rot_speed_rad_msec = 7.272205e-8; //2*PI / (1440*60);
|
|
|
|
|
|
|
|
|
|
static const float bolt_thread_mm = 1.25; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* static const unsigned int microstepping_div = 16; */ |
|
|
|
@ -23,19 +27,25 @@ static const double bolt_thread_mm = 1.25;
|
|
|
|
|
/* double stepper_gear_rot_rad = 0; */ |
|
|
|
|
/* } rot_state; */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static double get_expected_stepper_rot(unsigned long elapsed_time_millis) { |
|
|
|
|
const double r = tan(fmod(earth_rot_speed_rad_sec * (elapsed_time_millis), PI)) * axis_hinge_dist_mm * 2 * PI * nr_teeth_big / (bolt_thread_mm * nr_teeth_small); |
|
|
|
|
const float r = tan(earth_rot_speed_rad_msec * elapsed_time_millis) |
|
|
|
|
* axis_hinge_dist_mm |
|
|
|
|
* 2 * PI |
|
|
|
|
* nr_teeth_big |
|
|
|
|
/ (bolt_thread_mm * nr_teeth_small); |
|
|
|
|
|
|
|
|
|
// const float r = tan(earth_rot_speed_rad_sec * (elapsed_time_millis)) * axis_hinge_dist_mm * 2 * PI * nr_teeth_big / (bolt_thread_mm * nr_teeth_small);
|
|
|
|
|
|
|
|
|
|
return r; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) { |
|
|
|
|
unsigned long millis_step = 0; |
|
|
|
|
unsigned long sec_step = 0; |
|
|
|
|
|
|
|
|
|
for (millis_step=0; millis_step < 1000; millis_step++) { |
|
|
|
|
printf("%d (%d sec) : %f\n", millis_step*1000, millis_step, get_expected_stepper_rot(millis_step * 1000)); |
|
|
|
|
for (sec_step=0; sec_step < 1000; sec_step++) { |
|
|
|
|
const float exp = get_expected_stepper_rot(sec_step * 1000); |
|
|
|
|
printf("%d (%d sec) : %f (%f rounds)\n", sec_step*1000, sec_step, exp, exp/(2*PI)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|