mirror of
https://github.com/grblHAL/core.git
synced 2026-08-18 00:47:25 +08:00
Updated AccelerationProfile implementation to not alter settingsvalues
This commit is contained in:
@@ -2251,11 +2251,7 @@ status_code_t gc_execute_block (char *block)
|
||||
FAIL(Status_NegativeValue);}
|
||||
else if (gc_block.values.p > 5.0f){
|
||||
FAIL(Status_GcodeValueOutOfRange);}
|
||||
uint8_t idx = N_AXIS;
|
||||
do {
|
||||
idx--;
|
||||
settings_override_acceleration(idx, ((settings.axis[idx].acceleration / (60.0f * 60.0f)) * AccelerationProfile(gc_block.values.p)), ((settings.axis[idx].jerk / (60.0f * 60.0f * 60.0f)) * AccelerationProfile(gc_block.values.p)));
|
||||
} while(idx);
|
||||
ActiveAccelProfile = gc_block.values.p;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
||||
@@ -351,9 +351,12 @@ static inline float limit_acceleration_by_axis_maximum (float *unit_vec)
|
||||
if (unit_vec[--idx] != 0.0f) // Avoid divide by zero.
|
||||
limit_value = min(limit_value, fabsf(settings.axis[idx].acceleration / unit_vec[idx]));
|
||||
} while(idx);
|
||||
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
limit_value *= AccelerationProfile(ActiveAccelProfile);
|
||||
#endif
|
||||
return limit_value;
|
||||
}
|
||||
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
static inline float limit_jerk_by_axis_maximum (float *unit_vec)
|
||||
{
|
||||
@@ -364,10 +367,13 @@ static inline float limit_jerk_by_axis_maximum (float *unit_vec)
|
||||
if (unit_vec[--idx] != 0.0f) // Avoid divide by zero.
|
||||
limit_value = min(limit_value, fabsf(settings.axis[idx].jerk / unit_vec[idx]));
|
||||
} while(idx);
|
||||
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
limit_value *= AccelerationProfile(ActiveAccelProfile);
|
||||
#endif
|
||||
return limit_value;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline float limit_max_rate_by_axis_maximum (float *unit_vec)
|
||||
{
|
||||
uint_fast8_t idx = N_AXIS;
|
||||
@@ -516,7 +522,7 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data)
|
||||
#endif
|
||||
|
||||
block->millimeters = convert_delta_vector_to_unit_vector(unit_vec);
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
block->max_acceleration = limit_acceleration_by_axis_maximum(unit_vec);
|
||||
block->jerk = limit_jerk_by_axis_maximum(unit_vec);
|
||||
#else
|
||||
@@ -535,7 +541,7 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data)
|
||||
if (block->condition.inverse_time)
|
||||
block->programmed_rate *= block->millimeters;
|
||||
}
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
// Calculate effective acceleration over block. Since jerk acceleration takes longer to execute due to ramp up and
|
||||
// ramp down of the acceleration at the start and end of a ramp we need to adjust the acceleration value the planner
|
||||
// uses so it still calculates reasonable entry and exit speeds. We do this by adding 2x the time it takes to reach
|
||||
|
||||
+1
-15
@@ -886,11 +886,7 @@ static void restore_override_backup (void)
|
||||
|
||||
// Temporarily override acceleration, if 0 restore to setting value.
|
||||
// Note: only allowed when current state is idle.
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
bool settings_override_acceleration (uint8_t axis, float acceleration, float jerk)
|
||||
#else
|
||||
bool settings_override_acceleration (uint8_t axis, float acceleration)
|
||||
#endif
|
||||
{
|
||||
sys_state_t state = state_get();
|
||||
|
||||
@@ -905,22 +901,12 @@ bool settings_override_acceleration (uint8_t axis, float acceleration)
|
||||
save_override_backup();
|
||||
settings.axis[axis].acceleration = (override_backup.acceleration[axis] >= (acceleration * 60.0f * 60.0f)) ? (acceleration * 60.0f * 60.0f) : override_backup.acceleration[axis]; // Limited to max setting value
|
||||
}
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
if(jerk <= 0.0f) {
|
||||
if(override_backup.valid)
|
||||
settings.axis[axis].jerk = override_backup.jerk[axis];
|
||||
} else {
|
||||
if(!override_backup.valid)
|
||||
save_override_backup();
|
||||
settings.axis[axis].jerk = (override_backup.jerk[axis] >= (jerk * 60.0f * 60.0f * 60.0f)) ? (jerk * 60.0f * 60.0f * 60.0f) : override_backup.jerk[axis]; // Limited to max setting value
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
//Acceleration Profiles for G187 P[x] in percent of maximum machine acceleration.
|
||||
float AccelerationProfile(uint8_t Profile) {
|
||||
float LookupProfile(uint8_t Profile) {
|
||||
static const float lookup[5] = {
|
||||
1.0f, // 100% - Roughing - Max Acceleration Default
|
||||
0.8f, // 80% - Semi Roughing
|
||||
|
||||
+2
-5
@@ -964,14 +964,11 @@ void settings_write_coord_data(coord_system_id_t id, float (*coord_data)[N_AXIS]
|
||||
bool settings_read_coord_data(coord_system_id_t id, float (*coord_data)[N_AXIS]);
|
||||
|
||||
// Temporarily override acceleration, if 0 restore to configured setting value
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
bool settings_override_acceleration (uint8_t axis, float acceleration, float jerk);
|
||||
#else
|
||||
bool settings_override_acceleration (uint8_t axis, float acceleration);
|
||||
#endif
|
||||
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
float AccelerationProfile(uint8_t Profile);
|
||||
extern uint8_t ActiveAccelProfile = 1;
|
||||
float AccelerationProfile (uint8_t Profile);
|
||||
#endif
|
||||
|
||||
void settings_register (setting_details_t *details);
|
||||
|
||||
Reference in New Issue
Block a user