Add Bézier Jerk Control option

This commit is contained in:
Scott Lahteine
2018-05-08 03:42:45 -05:00
parent bb352f9836
commit 7ee1ab4fd3
7 changed files with 1486 additions and 113 deletions

View File

@@ -90,9 +90,24 @@ typedef struct {
uint32_t mix_event_count[MIXING_STEPPERS]; // Scaled step_event_count for the mixing steppers
#endif
// Settings for the trapezoid generator
int32_t accelerate_until, // The index of the step event on which to stop acceleration
decelerate_after, // The index of the step event on which to start decelerating
acceleration_rate; // The acceleration rate used for acceleration calculation
decelerate_after; // The index of the step event on which to start decelerating
uint32_t nominal_rate, // The nominal step rate for this block in step_events/sec
initial_rate, // The jerk-adjusted step rate at start of block
final_rate, // The minimal rate at exit
acceleration_steps_per_s2; // acceleration steps/sec^2
#if ENABLED(BEZIER_JERK_CONTROL)
uint32_t cruise_rate; // The actual cruise rate to use, between end of the acceleration phase and start of deceleration phase
uint32_t acceleration_time, // Acceleration time and deceleration time in STEP timer counts
deceleration_time;
uint32_t acceleration_time_inverse, // Inverse of acceleration and deceleration periods, expressed as integer. Scale depends on CPU being used
deceleration_time_inverse;
#else
int32_t acceleration_rate; // The acceleration rate used for acceleration calculation
#endif
uint8_t direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
@@ -112,12 +127,6 @@ typedef struct {
millimeters, // The total travel of this block in mm
acceleration; // acceleration mm/sec^2
// Settings for the trapezoid generator
uint32_t nominal_rate, // The nominal step rate for this block in step_events/sec
initial_rate, // The jerk-adjusted step rate at start of block
final_rate, // The minimal rate at exit
acceleration_steps_per_s2; // acceleration steps/sec^2
#if FAN_COUNT > 0
uint16_t fan_speed[FAN_COUNT];
#endif
@@ -661,6 +670,15 @@ class Planner {
return SQRT(sq(target_velocity) - 2 * accel * distance);
}
#if ENABLED(BEZIER_JERK_CONTROL)
/**
* Calculate the speed reached given initial speed, acceleration and distance
*/
static float final_speed(const float &initial_velocity, const float &accel, const float &distance) {
return SQRT(sq(initial_velocity) + 2 * accel * distance);
}
#endif
static void calculate_trapezoid_for_block(block_t* const block, const float &entry_factor, const float &exit_factor);
static void reverse_pass_kernel(block_t* const current, const block_t * const next);