
2 changed files with 88 additions and 0 deletions
@ -0,0 +1,42 @@
|
||||
#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; |
||||
|
||||
#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; |
||||
|
||||
|
||||
/* static const unsigned int microstepping_div = 16; */ |
||||
/* static const unsigned int nr_steps = 200 * microstepping_div; */ |
||||
|
||||
/* static const double stepper_gear_rad_per_step = (2*PI) / nr_steps; */ |
||||
|
||||
|
||||
// this needs to be reset
|
||||
/* static struct rot_state_t { */ |
||||
/* unsigned long elapsed_time_millis; */ |
||||
/* 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); |
||||
|
||||
return r; |
||||
} |
||||
|
||||
|
||||
int main(int argc, char **argv) { |
||||
unsigned long millis_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)); |
||||
|
||||
} |
||||
return 0; |
||||
} |
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
import sys |
||||
import numpy |
||||
|
||||
BOLT_THREAD = 1.25 |
||||
NR_TEETH_BIG=53 |
||||
NR_TEETH_SMALL=11 |
||||
|
||||
EARTH_SIDERAL_DAY = 1440 |
||||
HINGE_ROD_LEN = 200 |
||||
|
||||
def rodlen_to_angle(rod_len): |
||||
return numpy.arctan(rod_len / HINGE_ROD_LEN) |
||||
|
||||
def drivegear_angle_to_rodlen(angle): |
||||
return BOLT_THREAD*angle/(2*numpy.pi) |
||||
|
||||
def steppergear_angle_to_drivegear_angle(sangle): |
||||
return sangle * NR_TEETH_SMALL/NR_TEETH_BIG |
||||
|
||||
|
||||
def debug_from_step_angle(sangle): |
||||
step_angle = float(sangle) |
||||
|
||||
print("Step angle {}rad".format(step_angle)) |
||||
|
||||
drivegear_angle = steppergear_angle_to_drivegear_angle(step_angle) |
||||
|
||||
print("Drive gear angle {}rad".format(drivegear_angle)) |
||||
|
||||
rodlen = drivegear_angle_to_rodlen(drivegear_angle) |
||||
|
||||
print("Rod length {}mm".format(rodlen)) |
||||
|
||||
final_angle = rodlen_to_angle(rodlen) |
||||
|
||||
print("Final angle {}rad".format(final_angle)) |
||||
|
||||
def get_step_angle_from_time(time_in_sec): |
||||
final_angle = time_in_sec * 2 * numpy.pi / (1440*60) |
||||
sangle = numpy.tan(final_angle) * HINGE_ROD_LEN * 2 * numpy.pi * NR_TEETH_BIG / (BOLT_THREAD * NR_TEETH_SMALL) |
||||
print("For {} sec, final angle is {} rad => step angle is {}".format(time_in_sec, final_angle, sangle)) |
||||
verif_final = debug_from_step_angle(sangle) |
||||
|
||||
get_step_angle_from_time(int(sys.argv[1])) |
Loading…
Reference in new issue