From c7d5e7881fe3e557024ce6d497928afb9f9ca7da Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Mon, 27 Mar 2017 23:50:58 -0700 Subject: [PATCH] text --- avr/BezierMath.md | 3 ++- avr/MoveLifecycleCalls.md | 2 +- avr/src/motor.c | 6 ++++-- avr/src/plan/runtime.c | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/avr/BezierMath.md b/avr/BezierMath.md index f8f4e5a..f9da75a 100644 --- a/avr/BezierMath.md +++ b/avr/BezierMath.md @@ -52,4 +52,5 @@ B = 1 e = 0 - x^4 (x^2 - 3x + 5/2) + f(x) = 6x^5 -15x^4 + 10x^3 + int f(x) dx = x^6 - 3x^5 + 5/2x^4 + C diff --git a/avr/MoveLifecycleCalls.md b/avr/MoveLifecycleCalls.md index 5a9923b..8c8feb9 100644 --- a/avr/MoveLifecycleCalls.md +++ b/avr/MoveLifecycleCalls.md @@ -30,7 +30,7 @@ * mp_init_forward_dif() || mp_next_forward_dif() * _exec_aline_segment() * mp_runtime_move_to_target() - * mp_kinematics() - Converts target in mm to steps + * mp_kinematics() - Converts target mm to steps and maps motors * st_prep_line() * motor_prep_move() diff --git a/avr/src/motor.c b/avr/src/motor.c index 145e640..d43a769 100644 --- a/avr/src/motor.c +++ b/avr/src/motor.c @@ -444,7 +444,7 @@ stat_t motor_prep_move(int motor, int32_t clocks, float target, int32_t error, if (isinf(target)) return ALARM(STAT_MOVE_TARGET_INFINITE); if (isnan(target)) return ALARM(STAT_MOVE_TARGET_NAN); - // Compute motor timer clock and period. Rounding is performed to eliminate + // Compute motor timer clock and period. Rounding is performed to eliminate // a negative bias in the uint32_t conversion that results in long-term // negative drift. int32_t travel = round(target) - m->position + error; @@ -454,9 +454,11 @@ stat_t motor_prep_move(int motor, int32_t clocks, float target, int32_t error, m->negative = travel < 0; if (m->negative ^ m->reverse) m->direction = DIRECTION_CCW; else m->direction = DIRECTION_CW; + + // Use positive travel from here on if (m->negative) travel = -travel; - // Find the clock rate that will fit the required number of steps + // Find the fastest clock rate that will fit the required number of steps uint32_t ticks_per_step = travel ? clocks / 2 / travel : 0; if (ticks_per_step <= 0xffff) m->timer_clock = TC_CLKSEL_DIV1_gc; else if (ticks_per_step <= 0x1ffff) m->timer_clock = TC_CLKSEL_DIV2_gc; diff --git a/avr/src/plan/runtime.c b/avr/src/plan/runtime.c index 6907d76..cf848a7 100644 --- a/avr/src/plan/runtime.c +++ b/avr/src/plan/runtime.c @@ -152,8 +152,7 @@ void mp_runtime_set_work_offsets(float offset[]) { } -static void _step_correction(const float steps[], float time, - int32_t error[]) { +static void _step_correction(const float steps[], float time, int32_t error[]) { #ifdef STEP_CORRECTION float travel[MOTORS]; float new_length_sqr = 0; -- 2.27.0