Implement BEZIER_JERK_CONTROL
Enable 6th-order jerk-controlled motion planning in real-time. Only for 32bit MCUs. (AVR simply does not have enough processing power for this!)
This commit is contained in:
@ -97,6 +97,15 @@ class Stepper {
|
||||
static long counter_X, counter_Y, counter_Z, counter_E;
|
||||
static volatile uint32_t step_events_completed; // The number of step events executed in the current block
|
||||
|
||||
#if ENABLED(BEZIER_JERK_CONTROL)
|
||||
static int32_t bezier_A, // A coefficient in Bézier speed curve
|
||||
bezier_B, // B coefficient in Bézier speed curve
|
||||
bezier_C, // C coefficient in Bézier speed curve
|
||||
bezier_F; // F coefficient in Bézier speed curve
|
||||
static uint32_t bezier_AV; // AV coefficient in Bézier speed curve
|
||||
static bool bezier_2nd_half; // If Bézier curve has been initialized or not
|
||||
#endif
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
|
||||
static uint32_t LA_decelerate_after; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
||||
@ -117,11 +126,13 @@ class Stepper {
|
||||
|
||||
#endif // !LIN_ADVANCE
|
||||
|
||||
static long acceleration_time, deceleration_time;
|
||||
static int32_t acceleration_time, deceleration_time;
|
||||
static uint8_t step_loops, step_loops_nominal;
|
||||
|
||||
static hal_timer_t OCR1A_nominal,
|
||||
acc_step_rate; // needed for deceleration start point
|
||||
static hal_timer_t OCR1A_nominal;
|
||||
#if DISABLED(BEZIER_JERK_CONTROL)
|
||||
static hal_timer_t acc_step_rate; // needed for deceleration start point
|
||||
#endif
|
||||
|
||||
static volatile long endstops_trigsteps[XYZ];
|
||||
static volatile long endstops_stepsTotal, endstops_stepsDone;
|
||||
@ -129,7 +140,7 @@ class Stepper {
|
||||
//
|
||||
// Positions of stepper motors, in step units
|
||||
//
|
||||
static volatile long count_position[NUM_AXIS];
|
||||
static volatile int32_t count_position[NUM_AXIS];
|
||||
|
||||
//
|
||||
// Current direction of stepper motors (+1 or -1)
|
||||
@ -349,43 +360,10 @@ class Stepper {
|
||||
return timer;
|
||||
}
|
||||
|
||||
// Initialize the trapezoid generator from the current block.
|
||||
// Called whenever a new block begins.
|
||||
FORCE_INLINE static void trapezoid_generator_reset() {
|
||||
|
||||
static int8_t last_extruder = -1;
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
#if E_STEPPERS > 1
|
||||
if (current_block->active_extruder != last_extruder) {
|
||||
current_adv_steps = 0; // If the now active extruder wasn't in use during the last move, its pressure is most likely gone.
|
||||
LA_active_extruder = current_block->active_extruder;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((use_advance_lead = current_block->use_advance_lead)) {
|
||||
LA_decelerate_after = current_block->decelerate_after;
|
||||
final_adv_steps = current_block->final_adv_steps;
|
||||
max_adv_steps = current_block->max_adv_steps;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (current_block->direction_bits != last_direction_bits || current_block->active_extruder != last_extruder) {
|
||||
last_direction_bits = current_block->direction_bits;
|
||||
last_extruder = current_block->active_extruder;
|
||||
set_directions();
|
||||
}
|
||||
|
||||
deceleration_time = 0;
|
||||
// step_rate to timer interval
|
||||
OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
|
||||
// make a note of the number of step loops required at nominal speed
|
||||
step_loops_nominal = step_loops;
|
||||
acc_step_rate = current_block->initial_rate;
|
||||
acceleration_time = calc_timer_interval(acc_step_rate);
|
||||
_NEXT_ISR(acceleration_time);
|
||||
|
||||
}
|
||||
#if ENABLED(BEZIER_JERK_CONTROL)
|
||||
static void _calc_bezier_curve_coeffs(const int32_t v0, const int32_t v1, const uint32_t steps);
|
||||
static int32_t _eval_bezier_curve(const uint32_t curr_step);
|
||||
#endif
|
||||
|
||||
#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
|
||||
static void digipot_init();
|
||||
|
Reference in New Issue
Block a user