Fix initial safe_speed in jerk code (#11417)
This commit is contained in:
parent
2cc950d67e
commit
b826bf4194
@ -1348,7 +1348,7 @@ void Planner::check_axes_activity() {
|
|||||||
|
|
||||||
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = parser.volumetric_enabled
|
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = parser.volumetric_enabled
|
||||||
? ratio_2 / CIRCLE_AREA(filament_width_nominal * 0.5f) // Volumetric uses a true volumetric multiplier
|
? ratio_2 / CIRCLE_AREA(filament_width_nominal * 0.5f) // Volumetric uses a true volumetric multiplier
|
||||||
: ratio_2; // Linear squares the ratio, which scales the volume
|
: ratio_2; // Linear squares the ratio, which scales the volume
|
||||||
|
|
||||||
refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
|
refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
|
||||||
}
|
}
|
||||||
@ -1947,7 +1947,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||||||
else
|
else
|
||||||
block->millimeters = millimeters;
|
block->millimeters = millimeters;
|
||||||
|
|
||||||
const float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides
|
const float inverse_millimeters = 1.0f / block->millimeters; // Inverse millimeters to remove multiple divides
|
||||||
|
|
||||||
// Calculate inverse time for this move. No divide by zero due to previous checks.
|
// Calculate inverse time for this move. No divide by zero due to previous checks.
|
||||||
// Example: At 120mm/s a 60mm move takes 0.5s. So this will give 2.0.
|
// Example: At 120mm/s a 60mm move takes 0.5s. So this will give 2.0.
|
||||||
@ -2298,27 +2298,27 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
|||||||
/**
|
/**
|
||||||
* Adapted from Průša MKS firmware
|
* Adapted from Průša MKS firmware
|
||||||
* https://github.com/prusa3d/Prusa-Firmware
|
* https://github.com/prusa3d/Prusa-Firmware
|
||||||
*
|
|
||||||
* Start with a safe speed (from which the machine may halt to stop immediately).
|
|
||||||
*/
|
*/
|
||||||
|
const float nominal_speed = SQRT(block->nominal_speed_sqr);
|
||||||
|
|
||||||
// Exit speed limited by a jerk to full halt of a previous last segment
|
// Exit speed limited by a jerk to full halt of a previous last segment
|
||||||
static float previous_safe_speed;
|
static float previous_safe_speed;
|
||||||
|
|
||||||
const float nominal_speed = SQRT(block->nominal_speed_sqr);
|
// Start with a safe speed (from which the machine may halt to stop immediately).
|
||||||
float safe_speed = nominal_speed;
|
float safe_speed = nominal_speed;
|
||||||
|
|
||||||
uint8_t limited = 0;
|
uint8_t limited = 0;
|
||||||
LOOP_XYZE(i) {
|
LOOP_XYZE(i) {
|
||||||
const float jerk = ABS(current_speed[i]), maxj = max_jerk[i];
|
const float jerk = ABS(current_speed[i]), // cs : Starting from zero, change in speed for this axis
|
||||||
if (jerk > maxj) {
|
maxj = max_jerk[i]; // mj : The max jerk setting for this axis
|
||||||
if (limited) {
|
if (jerk > maxj) { // cs > mj : New current speed too fast?
|
||||||
const float mjerk = maxj * nominal_speed;
|
if (limited) { // limited already?
|
||||||
if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk;
|
const float mjerk = nominal_speed * maxj; // ns*mj
|
||||||
|
if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk; // ns*mj/cs
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++limited;
|
safe_speed *= maxj / jerk; // Initial limit: ns*mj/cs
|
||||||
safe_speed = maxj;
|
++limited; // Initially limited
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2620,7 +2620,7 @@ void Planner::reset_acceleration_rates() {
|
|||||||
|
|
||||||
// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
|
// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
|
||||||
void Planner::refresh_positioning() {
|
void Planner::refresh_positioning() {
|
||||||
LOOP_XYZE_N(i) steps_to_mm[i] = 1.0 / axis_steps_per_mm[i];
|
LOOP_XYZE_N(i) steps_to_mm[i] = 1.0f / axis_steps_per_mm[i];
|
||||||
set_position_mm_kinematic(current_position);
|
set_position_mm_kinematic(current_position);
|
||||||
reset_acceleration_rates();
|
reset_acceleration_rates();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user