Browse Source

minor change in 'native' checker

use correct gears sizes.
master
Marc Poulhiès 4 years ago
parent
commit
8fc86f8951
  1. 30
      native/native.C
  2. 6
      native/native.py

30
native/native.C

@ -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;

6
native/native.py

@ -4,8 +4,8 @@ import sys
import numpy
BOLT_THREAD = 1.25
NR_TEETH_BIG=53
NR_TEETH_SMALL=11
NR_TEETH_BIG=51
NR_TEETH_SMALL=13
EARTH_SIDERAL_DAY = 1440
HINGE_ROD_LEN = 200
@ -40,7 +40,7 @@ def debug_from_step_angle(sangle):
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))
print("For {} sec, final angle is {} rad ({} deg) => step angle is {}".format(time_in_sec, final_angle, final_angle * 360 /(2*numpy.pi), sangle))
verif_final = debug_from_step_angle(sangle)
get_step_angle_from_time(int(sys.argv[1]))
Loading…
Cancel
Save