mirror of
https://github.com/synthetos/g2.git
synced 2026-02-06 02:51:54 +08:00
Fix for inaccuracies that are caught by encoder corrections
This commit is contained in:
@@ -158,7 +158,7 @@ void stepper_reset()
|
||||
for (uint8_t motor=0; motor<MOTORS; motor++) {
|
||||
st_pre.mot[motor].prev_direction = STEP_INITIAL_DIRECTION;
|
||||
st_pre.mot[motor].direction = STEP_INITIAL_DIRECTION;
|
||||
st_run.mot[motor].substep_accumulator = 0; // will become max negative during per-motor setup;
|
||||
st_run.mot[motor].substep_accumulator = -DDA_SUBSTEPS;
|
||||
st_pre.mot[motor].corrected_steps = 0; // diagnostic only - no action effect
|
||||
}
|
||||
mp_set_steps_to_runtime_position(); // reset encoder to agree with the above
|
||||
@@ -822,7 +822,7 @@ stat_t st_prep_line(float start_velocity, float end_velocity, float travel_steps
|
||||
// setup motor parameters
|
||||
#if defined(NEW_FWD_DIFF) && (NEW_FWD_DIFF==1)
|
||||
// this is explained later
|
||||
float t_v0_v1 = (float)st_pre.dda_ticks * (start_velocity + end_velocity);
|
||||
double t_v0_v1 = (double)st_pre.dda_ticks * (start_velocity + end_velocity);
|
||||
#endif
|
||||
|
||||
float correction_steps;
|
||||
@@ -922,19 +922,19 @@ stat_t st_prep_line(float start_velocity, float end_velocity, float travel_steps
|
||||
// option 2:
|
||||
// d = (b (v_1 - v_0))/((t-1) a)
|
||||
|
||||
float s_double = fabs(travel_steps[motor] * 2.0);
|
||||
double s_double = fabs(travel_steps[motor] * 2.0);
|
||||
|
||||
// 1/m_0 = (2 s v_0)/(t (v_0 + v_1))
|
||||
st_pre.mot[motor].substep_increment = round(((s_double * start_velocity)/(t_v0_v1)) * (float)DDA_SUBSTEPS);
|
||||
st_pre.mot[motor].substep_increment = round(((s_double * start_velocity)/(t_v0_v1)) * (double)DDA_SUBSTEPS);
|
||||
// option 1:
|
||||
// d = ((b v_1)/a - c)/(t-1)
|
||||
// option 2:
|
||||
// d = (b (v_1 - v_0))/((t-1) a)
|
||||
st_pre.mot[motor].substep_increment_increment = round(((s_double*(end_velocity-start_velocity))/(((float)st_pre.dda_ticks-1.0)*t_v0_v1)) * (float)DDA_SUBSTEPS);
|
||||
st_pre.mot[motor].substep_increment_increment = round(((s_double*(end_velocity-start_velocity))/(((double)st_pre.dda_ticks-1.0)*t_v0_v1)) * (double)DDA_SUBSTEPS);
|
||||
#warning Using new increment style!
|
||||
#endif
|
||||
#else
|
||||
st_pre.mot[motor].substep_increment = round(fabs(travel_steps[motor] * DDA_SUBSTEPS));
|
||||
st_pre.mot[motor].substep_increment = round(fabs(travel_steps[motor] * (double)DDA_SUBSTEPS));
|
||||
#endif
|
||||
}
|
||||
st_pre.block_type = BLOCK_TYPE_ALINE;
|
||||
|
||||
@@ -314,7 +314,7 @@ typedef enum {
|
||||
* Decreasing the nominal segment time increases the number precision.
|
||||
*/
|
||||
#if NEW_DDA == 1
|
||||
#define DDA_SUBSTEPS (2147483600L)
|
||||
#define DDA_SUBSTEPS (INT64_MAX-100)
|
||||
#else
|
||||
#define DDA_SUBSTEPS ((MAX_LONG * 0.90) / (FREQUENCY_DDA * (NOM_SEGMENT_TIME * 60)))
|
||||
#endif
|
||||
@@ -372,9 +372,9 @@ typedef struct stConfig { // stepper configs
|
||||
// Motor runtime structure. Used exclusively by step generation ISR (HI)
|
||||
|
||||
typedef struct stRunMotor { // one per controlled motor
|
||||
uint32_t substep_increment; // partial steps to increment substep_accumulator per tick
|
||||
uint32_t substep_increment_increment; // partial steps to increment substep_increment per tick
|
||||
int32_t substep_accumulator; // DDA phase angle accumulator
|
||||
int64_t substep_increment; // partial steps to increment substep_accumulator per tick
|
||||
int64_t substep_increment_increment; // partial steps to increment substep_increment per tick
|
||||
int64_t substep_accumulator; // DDA phase angle accumulator
|
||||
bool motor_flag; // true if motor is participating in this move
|
||||
uint32_t power_systick; // sys_tick for next motor power state transition
|
||||
float power_level_dynamic; // power level for this segment of idle
|
||||
@@ -385,7 +385,6 @@ typedef struct stRunSingleton { // Stepper static values and axis pa
|
||||
uint32_t dda_ticks_downcount; // dda tick down-counter (unscaled)
|
||||
uint32_t dwell_ticks_downcount; // dwell tick down-counter (unscaled)
|
||||
#if NEW_DDA == 1
|
||||
uint32_t dda_steps_tick_X_substeps; // DDA substps per tick scaled by substep factor
|
||||
#else
|
||||
uint32_t dda_ticks_X_substeps; // ticks multiplied by scaling factor
|
||||
#endif
|
||||
@@ -397,8 +396,8 @@ typedef struct stRunSingleton { // Stepper static values and axis pa
|
||||
// Must be careful about volatiles in this one
|
||||
|
||||
typedef struct stPrepMotor {
|
||||
uint32_t substep_increment; // partial steps to increment substep_accumulator per tick
|
||||
uint32_t substep_increment_increment; // partial steps to increment substep_increment per tick
|
||||
int64_t substep_increment; // partial steps to increment substep_accumulator per tick
|
||||
int64_t substep_increment_increment; // partial steps to increment substep_increment per tick
|
||||
bool motor_flag; // true if motor is participating in this move
|
||||
|
||||
// direction and direction change
|
||||
|
||||
Reference in New Issue
Block a user