diff --git a/config.gen3.h b/config.gen3.h index cf1b9a5..15a192b 100644 --- a/config.gen3.h +++ b/config.gen3.h @@ -129,10 +129,9 @@ */ #define ACCELERATION_RAMPING -/// how fast to accelerate when using ACCELERATION_RAMPING -/// smaller values give quicker acceleration -/// valid range = 1 to 8,000,000; 500,000 is a good starting point -#define ACCELERATION_STEEPNESS 500000 +/// how fast to accelerate when using ACCELERATION_RAMPING, given in mm/s^2 +/// decimal allowed, useful range 1. to 10'000, typical range 10. to 100. +#define ACCELERATION 10. /** \def ACCELERATION_TEMPORAL temporal step algorithm diff --git a/config.gen6.h b/config.gen6.h index 0d8a9ba..f344b5e 100644 --- a/config.gen6.h +++ b/config.gen6.h @@ -128,10 +128,9 @@ */ #define ACCELERATION_RAMPING -/// how fast to accelerate when using ACCELERATION_RAMPING -/// smaller values give quicker acceleration -/// valid range = 1 to 8,000,000; 500,000 is a good starting point -#define ACCELERATION_STEEPNESS 500000 +/// how fast to accelerate when using ACCELERATION_RAMPING, given in mm/s^2 +/// decimal allowed, useful range 1. to 10'000, typical range 10. to 100. +#define ACCELERATION 10. /** \def ACCELERATION_TEMPORAL temporal step algorithm diff --git a/config.h.dist b/config.h.dist index 1ce136a..2a6cf15 100644 --- a/config.h.dist +++ b/config.h.dist @@ -126,10 +126,9 @@ */ #define ACCELERATION_RAMPING -/// how fast to accelerate when using ACCELERATION_RAMPING -/// smaller values give quicker acceleration -/// valid range = 1 to 8,000,000; 500,000 is a good starting point -#define ACCELERATION_STEEPNESS 500000 +/// how fast to accelerate when using ACCELERATION_RAMPING, given in mm/s^2 +/// decimal allowed, useful range 1. to 10'000, typical range 10. to 100. +#define ACCELERATION 10. /** \def ACCELERATION_TEMPORAL temporal step algorithm diff --git a/config.ramps.h b/config.ramps.h index 2d68b9a..781ae93 100644 --- a/config.ramps.h +++ b/config.ramps.h @@ -133,10 +133,9 @@ */ #define ACCELERATION_RAMPING -/// how fast to accelerate when using ACCELERATION_RAMPING -/// smaller values give quicker acceleration -/// valid range = 1 to 8,000,000; 500,000 is a good starting point -#define ACCELERATION_STEEPNESS 500000 +/// how fast to accelerate when using ACCELERATION_RAMPING, given in mm/s^2 +/// decimal allowed, useful range 1. to 10'000, typical range 10. to 100. +#define ACCELERATION 10. /** \def ACCELERATION_TEMPORAL temporal step algorithm diff --git a/dda.c b/dda.c index 4f68d33..e776ad5 100644 --- a/dda.c +++ b/dda.c @@ -6,6 +6,7 @@ #include #include +#include #include #include "timer.h" @@ -335,8 +336,13 @@ void dda_create(DDA *dda, TARGET *target) { // add the last bit of dda->total_steps to always round up dda->ramp_steps = dda->total_steps / 2 + (dda->total_steps & 1); dda->step_no = 0; - // c is initial step time in IOclk ticks - dda->c = ACCELERATION_STEEPNESS << 8; +// remove this when people have swallowed the new config item +#ifdef ACCELERATION_STEEPNESS +#error ACCELERATION_STEEPNESS is gone, review your config.h and use ACCELERATION +#endif + // c is initial step time in IOclk ticks (currently, IOclk ticks = F_CPU) + // yes, this assumes always the x axis as the critical one regarding acceleration. If we want to implement per-axis acceleration, things get tricky ... + dda->c = ((uint32_t)((double)F_CPU / sqrt((double)(STEPS_PER_MM_X * ACCELERATION)))) << 8; dda->c_min = (move_duration / target->F) << 8; if (dda->c_min < c_limit) dda->c_min = c_limit;