moved acceleration factor to plan_block_t structure, moved lookup function to plan_data_init, renamed lookup fuction and adjusted the acceleration limit functions to new structure

This commit is contained in:
Dietz0r
2024-12-10 22:15:25 +01:00
committed by GitHub
parent 075d5cec57
commit e504964dae
5 changed files with 18 additions and 10 deletions

View File

@@ -362,7 +362,7 @@ void gc_init (bool stop)
ngc_modal_state_invalidate();
#endif
#if ENABLE_ACCELERATION_PROFILES
gc_state.modal.activeaccelprofile = 1.0f; // Initialize machine with 100% Profile
gc_state.modal.acceleration_profile = 1.0f; // Initialize machine with 100% Profile
#endif
// if(settings.flags.lathe_mode)

View File

@@ -349,7 +349,7 @@ static inline float limit_acceleration_by_axis_maximum (float *unit_vec)
limit_value = min(limit_value, fabsf(settings.axis[idx].acceleration / unit_vec[idx]));
} while(idx);
#if ENABLE_ACCELERATION_PROFILES
limit_value *= lookupprofile(gc_state.modal.activeaccelprofile);
limit_value *= block->acceleration_factor;
#endif
return limit_value;
}
@@ -365,7 +365,7 @@ static inline float limit_jerk_by_axis_maximum (float *unit_vec)
limit_value = min(limit_value, fabsf(settings.axis[idx].jerk / unit_vec[idx]));
} while(idx);
#if ENABLE_ACCELERATION_PROFILES
limit_value *= lookupprofile(gc_state.modal.activeaccelprofile);
limit_value *= block->acceleration_factor;
#endif
return limit_value;
}
@@ -531,6 +531,9 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data)
#ifdef KINEMATICS_API
block->rate_multiplier = pl_data->rate_multiplier;
#endif
#ifdef ENABLE_ACCELERATION_PROFILES
block->acceleration_factor = pl_data->acceleration_factor;
#endif
// Store programmed rate.
if (block->condition.rapid_motion)
@@ -735,4 +738,7 @@ void plan_data_init (plan_line_data_t *plan_data)
#ifdef KINEMATICS_API
plan_data->rate_multiplier = 1.0f;
#endif
#ifdef ENABLE_ACCELERATION_PROFILES
plan_data->acceleration_factor = lookupfactor(gc_state.modal.acceleration_profile);
#endif
}

View File

@@ -77,6 +77,9 @@ typedef struct plan_block {
float programmed_rate; // Programmed rate of this block (mm/min).
#ifdef KINEMATICS_API
float rate_multiplier; // Rate multiplier of this block.
#endif
#ifdef ENABLE_ACCELERATION_PROFILES
float current_accel_profile; // Stores the currently used acceleration profile .
#endif
// Stored spindle speed data used by spindle overrides and resuming methods.
spindle_t spindle; // Block spindle parameters. Copied from pl_line_data.
@@ -93,6 +96,9 @@ typedef struct {
#ifdef KINEMATICS_API
float rate_multiplier; // Feed rate multiplier.
#endif
#ifdef ENABLE_ACCELERATION_PROFILES
float current_accel_profile; // Stores the currently used acceleration profile .
#endif
#if ENABLE_PATH_BLENDING
float path_tolerance; //!< Path blending tolerance.
float cam_tolerance; //!< Naive CAM tolerance.

View File

@@ -507,7 +507,7 @@ bool settings_override_acceleration (uint8_t axis, float acceleration)
#if ENABLE_ACCELERATION_PROFILES
//Acceleration Profiles for G187 P[x] in percent of maximum machine acceleration.
float lookupprofile(uint8_t profile) {
float lookupfactor(uint8_t profile) {
static const float lookup[5] = {
1.0f, // 100% - Roughing - Max Acceleration Default
0.8f, // 80% - Semi Roughing

View File

@@ -535,11 +535,7 @@ typedef enum {
Setting_AxisExtended5 = Setting_AxisSettingsBase2 + 5 * AXIS_SETTINGS_INCREMENT,
Setting_AxisExtended6 = Setting_AxisSettingsBase2 + 6 * AXIS_SETTINGS_INCREMENT,
Setting_AxisExtended7 = Setting_AxisSettingsBase2 + 7 * AXIS_SETTINGS_INCREMENT,
#if ENABLE_JERK_ACCELERATION
Setting_AxisJerk = Setting_AxisSettingsBase2 + 8 * AXIS_SETTINGS_INCREMENT,
#else
Setting_AxisExtended8 = Setting_AxisSettingsBase2 + 8 * AXIS_SETTINGS_INCREMENT,
#endif
Setting_AxisExtended8 = Setting_AxisSettingsBase2 + 8 * AXIS_SETTINGS_INCREMENT,s
Setting_AxisExtended9 = Setting_AxisSettingsBase2 + 9 * AXIS_SETTINGS_INCREMENT,
// Calculated base values for encoder settings
@@ -1089,7 +1085,7 @@ bool settings_read_coord_data(coord_system_id_t id, float (*coord_data)[N_AXIS])
bool settings_override_acceleration (uint8_t axis, float acceleration);
#if ENABLE_ACCELERATION_PROFILES
float lookupprofile (uint8_t profile);
float lookupfactor (uint8_t profile);
#endif
void settings_register (setting_details_t *details);