Merge 57e7618b31 into f3e0dfd481
This commit is contained in:
commit
173c13ea30
|
|
@ -221,7 +221,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
uint16_t final_adv_steps = 0;
|
uint16_t final_adv_steps = 0;
|
||||||
uint16_t max_adv_steps = 0;
|
uint16_t max_adv_steps = 0;
|
||||||
if (block->use_advance_lead) {
|
if (block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD) {
|
||||||
final_adv_steps = final_rate * block->adv_comp;
|
final_adv_steps = final_rate * block->adv_comp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -232,7 +232,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
|
||||||
if (accel_decel_steps < block->step_event_count.wide) {
|
if (accel_decel_steps < block->step_event_count.wide) {
|
||||||
plateau_steps = block->step_event_count.wide - accel_decel_steps;
|
plateau_steps = block->step_event_count.wide - accel_decel_steps;
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (block->use_advance_lead)
|
if (block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD)
|
||||||
max_adv_steps = block->nominal_rate * block->adv_comp;
|
max_adv_steps = block->nominal_rate * block->adv_comp;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -269,7 +269,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (block->use_advance_lead) {
|
if (block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD) {
|
||||||
if(!accelerate_steps || !decelerate_steps) {
|
if(!accelerate_steps || !decelerate_steps) {
|
||||||
// accelerate_steps=0: deceleration-only ramp, max_rate is effectively unused
|
// accelerate_steps=0: deceleration-only ramp, max_rate is effectively unused
|
||||||
// decelerate_steps=0: acceleration-only ramp, max_rate _is_ final_rate
|
// decelerate_steps=0: acceleration-only ramp, max_rate _is_ final_rate
|
||||||
|
|
@ -287,7 +287,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
|
||||||
// which corresponds to a maximum repeat frequency of 228.57 kHz.
|
// which corresponds to a maximum repeat frequency of 228.57 kHz.
|
||||||
// This blocking is safe in the context of a 10kHz stepper driver interrupt
|
// This blocking is safe in the context of a 10kHz stepper driver interrupt
|
||||||
// or a 115200 Bd serial line receive interrupt, which will not trigger faster than 12kHz.
|
// or a 115200 Bd serial line receive interrupt, which will not trigger faster than 12kHz.
|
||||||
if (! block->busy) { // Don't update variables if block is busy.
|
if (!(block->flag & BLOCK_FLAG_BUSY)) { // Don't update variables if block is busy.
|
||||||
block->accelerate_until = accelerate_steps;
|
block->accelerate_until = accelerate_steps;
|
||||||
block->decelerate_after = accelerate_steps+plateau_steps;
|
block->decelerate_after = accelerate_steps+plateau_steps;
|
||||||
block->initial_rate = initial_rate;
|
block->initial_rate = initial_rate;
|
||||||
|
|
@ -718,7 +718,8 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||||
block_t *block = &block_buffer[block_buffer_head];
|
block_t *block = &block_buffer[block_buffer_head];
|
||||||
|
|
||||||
// Mark block as not busy (Not executed by the stepper interrupt, could be still tinkered with.)
|
// Mark block as not busy (Not executed by the stepper interrupt, could be still tinkered with.)
|
||||||
block->busy = false;
|
// Also reset the block flag.
|
||||||
|
block->flag = 0;
|
||||||
|
|
||||||
// Set sdlen for calculating sd position
|
// Set sdlen for calculating sd position
|
||||||
block->sdlen = 0;
|
block->sdlen = 0;
|
||||||
|
|
@ -956,7 +957,7 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||||
{
|
{
|
||||||
accel = ceil(cs.retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
accel = ceil(cs.retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
block->use_advance_lead = false;
|
block->flag &= ~BLOCK_FLAG_USE_ADVANCE_LEAD;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -971,10 +972,10 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||||
* delta_mm[E_AXIS] >= 0 : Extruding or traveling, but _not_ retracting.
|
* delta_mm[E_AXIS] >= 0 : Extruding or traveling, but _not_ retracting.
|
||||||
* |delta_mm[Z_AXIS]| < 0.5 : Z is only moved for leveling (_not_ for priming)
|
* |delta_mm[Z_AXIS]| < 0.5 : Z is only moved for leveling (_not_ for priming)
|
||||||
*/
|
*/
|
||||||
block->use_advance_lead = extruder_advance_K > 0
|
if (extruder_advance_K > 0
|
||||||
&& delta_mm[E_AXIS] >= 0
|
&& delta_mm[E_AXIS] >= 0
|
||||||
&& fabs(delta_mm[Z_AXIS]) < 0.5;
|
&& fabs(delta_mm[Z_AXIS]) < 0.5) {
|
||||||
if (block->use_advance_lead) {
|
block->flag |= BLOCK_FLAG_USE_ADVANCE_LEAD;
|
||||||
#ifdef LA_FLOWADJ
|
#ifdef LA_FLOWADJ
|
||||||
// M221/FLOW should change uniformly the extrusion thickness
|
// M221/FLOW should change uniformly the extrusion thickness
|
||||||
float delta_e = (e - position_float[E_AXIS]) / extruder_multiplier[extruder];
|
float delta_e = (e - position_float[E_AXIS]) / extruder_multiplier[extruder];
|
||||||
|
|
@ -995,7 +996,7 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||||
// no one will use a retract length of 0mm < retr_length < ~0.2mm and no one will print
|
// no one will use a retract length of 0mm < retr_length < ~0.2mm and no one will print
|
||||||
// 100mm wide lines using 3mm filament or 35mm wide lines using 1.75mm filament.
|
// 100mm wide lines using 3mm filament or 35mm wide lines using 1.75mm filament.
|
||||||
if (e_D_ratio > 3.0)
|
if (e_D_ratio > 3.0)
|
||||||
block->use_advance_lead = false;
|
block->flag &= ~BLOCK_FLAG_USE_ADVANCE_LEAD;
|
||||||
else if (e_D_ratio > 0) {
|
else if (e_D_ratio > 0) {
|
||||||
const uint32_t max_accel_steps_per_s2 = ceil(cs.max_jerk[E_AXIS] / (extruder_advance_K * e_D_ratio) * steps_per_mm);
|
const uint32_t max_accel_steps_per_s2 = ceil(cs.max_jerk[E_AXIS] / (extruder_advance_K * e_D_ratio) * steps_per_mm);
|
||||||
if (accel > max_accel_steps_per_s2) {
|
if (accel > max_accel_steps_per_s2) {
|
||||||
|
|
@ -1048,9 +1049,6 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the block flag.
|
|
||||||
block->flag = 0;
|
|
||||||
|
|
||||||
if (plan_reset_next_e_sched)
|
if (plan_reset_next_e_sched)
|
||||||
{
|
{
|
||||||
// finally propagate a pending reset
|
// finally propagate a pending reset
|
||||||
|
|
@ -1150,7 +1148,7 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||||
block->speed_factor = block->nominal_rate / block->nominal_speed;
|
block->speed_factor = block->nominal_rate / block->nominal_speed;
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (block->use_advance_lead) {
|
if (block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD) {
|
||||||
// calculate the compression ratio for the segment (the required advance steps are computed
|
// calculate the compression ratio for the segment (the required advance steps are computed
|
||||||
// during trapezoid planning)
|
// during trapezoid planning)
|
||||||
float adv_comp = extruder_advance_K * e_D_ratio * cs.axis_steps_per_mm[E_AXIS]; // (step/(mm/s))
|
float adv_comp = extruder_advance_K * e_D_ratio * cs.axis_steps_per_mm[E_AXIS]; // (step/(mm/s))
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,10 @@ enum BlockFlag {
|
||||||
BLOCK_FLAG_DDA_LOWRES = 8,
|
BLOCK_FLAG_DDA_LOWRES = 8,
|
||||||
// Block starts with Zeroed E counter
|
// Block starts with Zeroed E counter
|
||||||
BLOCK_FLAG_E_RESET = 16,
|
BLOCK_FLAG_E_RESET = 16,
|
||||||
|
// Block is being executed by the stepper ISR
|
||||||
|
BLOCK_FLAG_BUSY = 32,
|
||||||
|
// Whether the block uses LA
|
||||||
|
BLOCK_FLAG_USE_ADVANCE_LEAD = 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
union dda_isteps_t
|
union dda_isteps_t
|
||||||
|
|
@ -100,14 +104,12 @@ typedef struct {
|
||||||
uint32_t final_rate; // The minimal rate at exit
|
uint32_t final_rate; // The minimal rate at exit
|
||||||
uint32_t acceleration_steps_per_s2; // acceleration steps/sec^2
|
uint32_t acceleration_steps_per_s2; // acceleration steps/sec^2
|
||||||
uint8_t fan_speed; // Print fan speed, ranges from 0 to 255
|
uint8_t fan_speed; // Print fan speed, ranges from 0 to 255
|
||||||
volatile char busy;
|
|
||||||
|
|
||||||
|
|
||||||
// Pre-calculated division for the calculate_trapezoid_for_block() routine to run faster.
|
// Pre-calculated division for the calculate_trapezoid_for_block() routine to run faster.
|
||||||
float speed_factor;
|
float speed_factor;
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
bool use_advance_lead; // Whether the current block uses LA
|
|
||||||
uint16_t advance_rate, // Step-rate for extruder speed
|
uint16_t advance_rate, // Step-rate for extruder speed
|
||||||
max_adv_steps, // max. advance steps to get cruising speed pressure (not always nominal_speed!)
|
max_adv_steps, // max. advance steps to get cruising speed pressure (not always nominal_speed!)
|
||||||
final_adv_steps; // advance steps due to exit speed
|
final_adv_steps; // advance steps due to exit speed
|
||||||
|
|
@ -208,7 +210,7 @@ FORCE_INLINE block_t *plan_get_current_block()
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
block_t *block = &block_buffer[block_buffer_tail];
|
block_t *block = &block_buffer[block_buffer_tail];
|
||||||
block->busy = true;
|
block->flag |= BLOCK_FLAG_BUSY;
|
||||||
return(block);
|
return(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ FORCE_INLINE void stepper_next_block()
|
||||||
acceleration_time = calc_timer(acc_step_rate, step_loops);
|
acceleration_time = calc_timer(acc_step_rate, step_loops);
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (current_block->use_advance_lead) {
|
if (current_block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD) {
|
||||||
target_adv_steps = current_block->max_adv_steps;
|
target_adv_steps = current_block->max_adv_steps;
|
||||||
}
|
}
|
||||||
e_steps = 0;
|
e_steps = 0;
|
||||||
|
|
@ -832,7 +832,7 @@ FORCE_INLINE void isr() {
|
||||||
_NEXT_ISR(timer);
|
_NEXT_ISR(timer);
|
||||||
acceleration_time += timer;
|
acceleration_time += timer;
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (current_block->use_advance_lead) {
|
if (current_block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD) {
|
||||||
if (step_events_completed.wide <= (unsigned long int)step_loops) {
|
if (step_events_completed.wide <= (unsigned long int)step_loops) {
|
||||||
la_state = ADV_INIT | ADV_ACC_VARY;
|
la_state = ADV_INIT | ADV_ACC_VARY;
|
||||||
if (e_extruding && current_adv_steps > target_adv_steps)
|
if (e_extruding && current_adv_steps > target_adv_steps)
|
||||||
|
|
@ -861,7 +861,7 @@ FORCE_INLINE void isr() {
|
||||||
deceleration_time += timer;
|
deceleration_time += timer;
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if (current_block->use_advance_lead) {
|
if (current_block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD) {
|
||||||
if (step_events_completed.wide <= current_block->decelerate_after + step_loops) {
|
if (step_events_completed.wide <= current_block->decelerate_after + step_loops) {
|
||||||
target_adv_steps = current_block->final_adv_steps;
|
target_adv_steps = current_block->final_adv_steps;
|
||||||
la_state = ADV_INIT | ADV_ACC_VARY;
|
la_state = ADV_INIT | ADV_ACC_VARY;
|
||||||
|
|
@ -879,7 +879,7 @@ FORCE_INLINE void isr() {
|
||||||
step_loops_nominal = step_loops;
|
step_loops_nominal = step_loops;
|
||||||
|
|
||||||
#ifdef LIN_ADVANCE
|
#ifdef LIN_ADVANCE
|
||||||
if(current_block->use_advance_lead) {
|
if(current_block->flag & BLOCK_FLAG_USE_ADVANCE_LEAD) {
|
||||||
// Due to E-jerk, there can be discontinuities in pressure state where an
|
// Due to E-jerk, there can be discontinuities in pressure state where an
|
||||||
// acceleration or deceleration can be skipped or joined with the previous block.
|
// acceleration or deceleration can be skipped or joined with the previous block.
|
||||||
// If LA was not previously active, re-check the pressure level
|
// If LA was not previously active, re-check the pressure level
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue