Fixed AD595 define
This commit is contained in:
parent
d3002ef741
commit
b67dacdc8f
3 changed files with 264 additions and 216 deletions
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */
|
/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()
|
di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()
|
||||||
|
|
||||||
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
|
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Marlin.h"
|
#include "Marlin.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
|
@ -83,10 +83,10 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm
|
||||||
extern volatile int extrudemultiply; // Sets extrude multiply factor (in percent)
|
extern volatile int extrudemultiply; // Sets extrude multiply factor (in percent)
|
||||||
|
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
float autotemp_max=250;
|
float autotemp_max=250;
|
||||||
float autotemp_min=210;
|
float autotemp_min=210;
|
||||||
float autotemp_factor=0.1;
|
float autotemp_factor=0.1;
|
||||||
bool autotemp_enabled=false;
|
bool autotemp_enabled=false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -100,27 +100,33 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro
|
||||||
//=============================private variables ============================
|
//=============================private variables ============================
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||||
bool allow_cold_extrude=false;
|
bool allow_cold_extrude=false;
|
||||||
#endif
|
#endif
|
||||||
#ifdef XY_FREQUENCY_LIMIT
|
#ifdef XY_FREQUENCY_LIMIT
|
||||||
// Used for the frequency limit
|
// Used for the frequency limit
|
||||||
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
||||||
static long x_segment_time[3]={0,0,0}; // Segment times (in us). Used for speed calculations
|
static long x_segment_time[3]={
|
||||||
static long y_segment_time[3]={0,0,0};
|
0,0,0}; // Segment times (in us). Used for speed calculations
|
||||||
|
static long y_segment_time[3]={
|
||||||
|
0,0,0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Returns the index of the next block in the ring buffer
|
// Returns the index of the next block in the ring buffer
|
||||||
// NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication.
|
// NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication.
|
||||||
static int8_t next_block_index(int8_t block_index) {
|
static int8_t next_block_index(int8_t block_index) {
|
||||||
block_index++;
|
block_index++;
|
||||||
if (block_index == BLOCK_BUFFER_SIZE) { block_index = 0; }
|
if (block_index == BLOCK_BUFFER_SIZE) {
|
||||||
|
block_index = 0;
|
||||||
|
}
|
||||||
return(block_index);
|
return(block_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns the index of the previous block in the ring buffer
|
// Returns the index of the previous block in the ring buffer
|
||||||
static int8_t prev_block_index(int8_t block_index) {
|
static int8_t prev_block_index(int8_t block_index) {
|
||||||
if (block_index == 0) { block_index = BLOCK_BUFFER_SIZE; }
|
if (block_index == 0) {
|
||||||
|
block_index = BLOCK_BUFFER_SIZE;
|
||||||
|
}
|
||||||
block_index--;
|
block_index--;
|
||||||
return(block_index);
|
return(block_index);
|
||||||
}
|
}
|
||||||
|
@ -165,8 +171,12 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
||||||
unsigned long final_rate = ceil(block->nominal_rate*exit_factor); // (step/min)
|
unsigned long final_rate = ceil(block->nominal_rate*exit_factor); // (step/min)
|
||||||
|
|
||||||
// Limit minimal step rate (Otherwise the timer will overflow.)
|
// Limit minimal step rate (Otherwise the timer will overflow.)
|
||||||
if(initial_rate <120) {initial_rate=120; }
|
if(initial_rate <120) {
|
||||||
if(final_rate < 120) {final_rate=120; }
|
initial_rate=120;
|
||||||
|
}
|
||||||
|
if(final_rate < 120) {
|
||||||
|
final_rate=120;
|
||||||
|
}
|
||||||
|
|
||||||
long acceleration = block->acceleration_st;
|
long acceleration = block->acceleration_st;
|
||||||
int32_t accelerate_steps =
|
int32_t accelerate_steps =
|
||||||
|
@ -188,10 +198,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
||||||
plateau_steps = 0;
|
plateau_steps = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ADVANCE
|
#ifdef ADVANCE
|
||||||
volatile long initial_advance = block->advance*entry_factor*entry_factor;
|
volatile long initial_advance = block->advance*entry_factor*entry_factor;
|
||||||
volatile long final_advance = block->advance*exit_factor*exit_factor;
|
volatile long final_advance = block->advance*exit_factor*exit_factor;
|
||||||
#endif // ADVANCE
|
#endif // ADVANCE
|
||||||
|
|
||||||
// block->accelerate_until = accelerate_steps;
|
// block->accelerate_until = accelerate_steps;
|
||||||
// block->decelerate_after = accelerate_steps+plateau_steps;
|
// block->decelerate_after = accelerate_steps+plateau_steps;
|
||||||
|
@ -201,10 +211,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
||||||
block->decelerate_after = accelerate_steps+plateau_steps;
|
block->decelerate_after = accelerate_steps+plateau_steps;
|
||||||
block->initial_rate = initial_rate;
|
block->initial_rate = initial_rate;
|
||||||
block->final_rate = final_rate;
|
block->final_rate = final_rate;
|
||||||
#ifdef ADVANCE
|
#ifdef ADVANCE
|
||||||
block->initial_advance = initial_advance;
|
block->initial_advance = initial_advance;
|
||||||
block->final_advance = final_advance;
|
block->final_advance = final_advance;
|
||||||
#endif //ADVANCE
|
#endif //ADVANCE
|
||||||
}
|
}
|
||||||
CRITICAL_SECTION_END;
|
CRITICAL_SECTION_END;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +236,9 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity
|
||||||
|
|
||||||
// The kernel called by planner_recalculate() when scanning the plan from last to first entry.
|
// The kernel called by planner_recalculate() when scanning the plan from last to first entry.
|
||||||
void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) {
|
void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) {
|
||||||
if(!current) { return; }
|
if(!current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (next) {
|
if (next) {
|
||||||
// If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising.
|
// If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising.
|
||||||
|
@ -239,7 +251,8 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||||
if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) {
|
if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) {
|
||||||
current->entry_speed = min( current->max_entry_speed,
|
current->entry_speed = min( current->max_entry_speed,
|
||||||
max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters));
|
max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
current->entry_speed = current->max_entry_speed;
|
current->entry_speed = current->max_entry_speed;
|
||||||
}
|
}
|
||||||
current->recalculate_flag = true;
|
current->recalculate_flag = true;
|
||||||
|
@ -252,10 +265,17 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||||
// implements the reverse pass.
|
// implements the reverse pass.
|
||||||
void planner_reverse_pass() {
|
void planner_reverse_pass() {
|
||||||
uint8_t block_index = block_buffer_head;
|
uint8_t block_index = block_buffer_head;
|
||||||
if(((block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
|
|
||||||
|
//Make a local copy of block_buffer_tail, because the interrupt can alter it
|
||||||
|
CRITICAL_SECTION_START;
|
||||||
|
unsigned char tail = block_buffer_tail;
|
||||||
|
CRITICAL_SECTION_END
|
||||||
|
|
||||||
|
if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
|
||||||
block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1);
|
block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1);
|
||||||
block_t *block[3] = { NULL, NULL, NULL };
|
block_t *block[3] = {
|
||||||
while(block_index != block_buffer_tail) {
|
NULL, NULL, NULL };
|
||||||
|
while(block_index != tail) {
|
||||||
block_index = prev_block_index(block_index);
|
block_index = prev_block_index(block_index);
|
||||||
block[2]= block[1];
|
block[2]= block[1];
|
||||||
block[1]= block[0];
|
block[1]= block[0];
|
||||||
|
@ -267,7 +287,9 @@ void planner_reverse_pass() {
|
||||||
|
|
||||||
// The kernel called by planner_recalculate() when scanning the plan from first to last entry.
|
// The kernel called by planner_recalculate() when scanning the plan from first to last entry.
|
||||||
void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) {
|
void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) {
|
||||||
if(!previous) { return; }
|
if(!previous) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the previous block is an acceleration block, but it is not long enough to complete the
|
// If the previous block is an acceleration block, but it is not long enough to complete the
|
||||||
// full speed change within the block, we need to adjust the entry speed accordingly. Entry
|
// full speed change within the block, we need to adjust the entry speed accordingly. Entry
|
||||||
|
@ -291,7 +313,8 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||||
// implements the forward pass.
|
// implements the forward pass.
|
||||||
void planner_forward_pass() {
|
void planner_forward_pass() {
|
||||||
uint8_t block_index = block_buffer_tail;
|
uint8_t block_index = block_buffer_tail;
|
||||||
block_t *block[3] = { NULL, NULL, NULL };
|
block_t *block[3] = {
|
||||||
|
NULL, NULL, NULL };
|
||||||
|
|
||||||
while(block_index != block_buffer_head) {
|
while(block_index != block_buffer_head) {
|
||||||
block[0] = block[1];
|
block[0] = block[1];
|
||||||
|
@ -436,17 +459,21 @@ void check_axes_activity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if FAN_PIN > -1
|
#if FAN_PIN > -1
|
||||||
if (FanSpeed != 0){
|
if (FanSpeed != 0){
|
||||||
analogWrite(FAN_PIN,FanSpeed); // If buffer is empty use current fan speed
|
analogWrite(FAN_PIN,FanSpeed); // If buffer is empty use current fan speed
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if((DISABLE_X) && (x_active == 0)) disable_x();
|
if((DISABLE_X) && (x_active == 0)) disable_x();
|
||||||
if((DISABLE_Y) && (y_active == 0)) disable_y();
|
if((DISABLE_Y) && (y_active == 0)) disable_y();
|
||||||
if((DISABLE_Z) && (z_active == 0)) disable_z();
|
if((DISABLE_Z) && (z_active == 0)) disable_z();
|
||||||
if((DISABLE_E) && (e_active == 0)) { disable_e0();disable_e1();disable_e2(); }
|
if((DISABLE_E) && (e_active == 0)) {
|
||||||
#if FAN_PIN > -1
|
disable_e0();
|
||||||
|
disable_e1();
|
||||||
|
disable_e2();
|
||||||
|
}
|
||||||
|
#if FAN_PIN > -1
|
||||||
if((FanSpeed == 0) && (fan_speed ==0)) {
|
if((FanSpeed == 0) && (fan_speed ==0)) {
|
||||||
analogWrite(FAN_PIN, 0);
|
analogWrite(FAN_PIN, 0);
|
||||||
}
|
}
|
||||||
|
@ -454,10 +481,10 @@ void check_axes_activity() {
|
||||||
if (FanSpeed != 0 && tail_fan_speed !=0) {
|
if (FanSpeed != 0 && tail_fan_speed !=0) {
|
||||||
analogWrite(FAN_PIN,tail_fan_speed);
|
analogWrite(FAN_PIN,tail_fan_speed);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
getHighESpeed();
|
getHighESpeed();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -487,7 +514,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||||
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
||||||
|
|
||||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||||
if(target[E_AXIS]!=position[E_AXIS])
|
if(target[E_AXIS]!=position[E_AXIS])
|
||||||
if(degHotend(active_extruder)<EXTRUDE_MINTEMP && !allow_cold_extrude)
|
if(degHotend(active_extruder)<EXTRUDE_MINTEMP && !allow_cold_extrude)
|
||||||
{
|
{
|
||||||
|
@ -495,15 +522,15 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
||||||
}
|
}
|
||||||
#ifdef PREVENT_LENGTHY_EXTRUDE
|
#ifdef PREVENT_LENGTHY_EXTRUDE
|
||||||
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
|
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
|
||||||
{
|
{
|
||||||
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
|
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Prepare to set up new block
|
// Prepare to set up new block
|
||||||
block_t *block = &block_buffer[block_buffer_head];
|
block_t *block = &block_buffer[block_buffer_head];
|
||||||
|
@ -521,28 +548,42 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
|
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
|
||||||
|
|
||||||
// Bail if this is a zero-length block
|
// Bail if this is a zero-length block
|
||||||
if (block->step_event_count <= dropsegments) { return; };
|
if (block->step_event_count <= dropsegments) {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
block->fan_speed = FanSpeed;
|
block->fan_speed = FanSpeed;
|
||||||
|
|
||||||
// Compute direction bits for this block
|
// Compute direction bits for this block
|
||||||
block->direction_bits = 0;
|
block->direction_bits = 0;
|
||||||
if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<<X_AXIS); }
|
if (target[X_AXIS] < position[X_AXIS]) {
|
||||||
if (target[Y_AXIS] < position[Y_AXIS]) { block->direction_bits |= (1<<Y_AXIS); }
|
block->direction_bits |= (1<<X_AXIS);
|
||||||
if (target[Z_AXIS] < position[Z_AXIS]) { block->direction_bits |= (1<<Z_AXIS); }
|
}
|
||||||
if (target[E_AXIS] < position[E_AXIS]) { block->direction_bits |= (1<<E_AXIS); }
|
if (target[Y_AXIS] < position[Y_AXIS]) {
|
||||||
|
block->direction_bits |= (1<<Y_AXIS);
|
||||||
|
}
|
||||||
|
if (target[Z_AXIS] < position[Z_AXIS]) {
|
||||||
|
block->direction_bits |= (1<<Z_AXIS);
|
||||||
|
}
|
||||||
|
if (target[E_AXIS] < position[E_AXIS]) {
|
||||||
|
block->direction_bits |= (1<<E_AXIS);
|
||||||
|
}
|
||||||
|
|
||||||
block->active_extruder = extruder;
|
block->active_extruder = extruder;
|
||||||
|
|
||||||
//enable active axes
|
//enable active axes
|
||||||
if(block->steps_x != 0) enable_x();
|
if(block->steps_x != 0) enable_x();
|
||||||
if(block->steps_y != 0) enable_y();
|
if(block->steps_y != 0) enable_y();
|
||||||
#ifndef Z_LATE_ENABLE
|
#ifndef Z_LATE_ENABLE
|
||||||
if(block->steps_z != 0) enable_z();
|
if(block->steps_z != 0) enable_z();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable all
|
// Enable all
|
||||||
if(block->steps_e != 0) { enable_e0();enable_e1();enable_e2(); }
|
if(block->steps_e != 0) {
|
||||||
|
enable_e0();
|
||||||
|
enable_e1();
|
||||||
|
enable_e2();
|
||||||
|
}
|
||||||
|
|
||||||
if (block->steps_e == 0) {
|
if (block->steps_e == 0) {
|
||||||
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
||||||
|
@ -558,7 +599,8 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0;
|
delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0;
|
||||||
if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) {
|
if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) {
|
||||||
block->millimeters = fabs(delta_mm[E_AXIS]);
|
block->millimeters = fabs(delta_mm[E_AXIS]);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
|
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
|
||||||
}
|
}
|
||||||
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
|
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
|
||||||
|
@ -569,11 +611,11 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||||
|
|
||||||
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
||||||
#ifdef OLD_SLOWDOWN
|
#ifdef OLD_SLOWDOWN
|
||||||
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
|
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SLOWDOWN
|
#ifdef SLOWDOWN
|
||||||
// segment time im micro seconds
|
// segment time im micro seconds
|
||||||
unsigned long segment_time = lround(1000000.0/inverse_second);
|
unsigned long segment_time = lround(1000000.0/inverse_second);
|
||||||
if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
|
if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
|
||||||
|
@ -581,7 +623,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
|
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// END OF SLOW DOWN SECTION
|
// END OF SLOW DOWN SECTION
|
||||||
|
|
||||||
|
|
||||||
|
@ -597,7 +639,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
|
speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max segement time in us.
|
// Max segement time in us.
|
||||||
#ifdef XY_FREQUENCY_LIMIT
|
#ifdef XY_FREQUENCY_LIMIT
|
||||||
#define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
|
#define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
|
||||||
|
|
||||||
|
@ -698,26 +740,29 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
#endif
|
#endif
|
||||||
// Start with a safe speed
|
// Start with a safe speed
|
||||||
float vmax_junction = max_xy_jerk/2;
|
float vmax_junction = max_xy_jerk/2;
|
||||||
|
float vmax_junction_factor = 1.0;
|
||||||
if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2)
|
if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2)
|
||||||
vmax_junction = max_z_jerk/2;
|
vmax_junction = min(vmax_junction, max_z_jerk/2);
|
||||||
vmax_junction = min(vmax_junction, block->nominal_speed);
|
|
||||||
if(fabs(current_speed[E_AXIS]) > max_e_jerk/2)
|
if(fabs(current_speed[E_AXIS]) > max_e_jerk/2)
|
||||||
vmax_junction = min(vmax_junction, max_e_jerk/2);
|
vmax_junction = min(vmax_junction, max_e_jerk/2);
|
||||||
|
vmax_junction = min(vmax_junction, block->nominal_speed);
|
||||||
|
float safe_speed = vmax_junction;
|
||||||
|
|
||||||
if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) {
|
if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) {
|
||||||
float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));
|
float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));
|
||||||
if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) {
|
// if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) {
|
||||||
vmax_junction = block->nominal_speed;
|
vmax_junction = block->nominal_speed;
|
||||||
}
|
// }
|
||||||
if (jerk > max_xy_jerk) {
|
if (jerk > max_xy_jerk) {
|
||||||
vmax_junction *= (max_xy_jerk/jerk);
|
vmax_junction_factor = (max_xy_jerk/jerk);
|
||||||
}
|
}
|
||||||
if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
|
if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
|
||||||
vmax_junction *= (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
|
vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS])));
|
||||||
}
|
}
|
||||||
if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
|
if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
|
||||||
vmax_junction *= (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]));
|
vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS])));
|
||||||
}
|
}
|
||||||
|
vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed
|
||||||
}
|
}
|
||||||
block->max_entry_speed = vmax_junction;
|
block->max_entry_speed = vmax_junction;
|
||||||
|
|
||||||
|
@ -733,8 +778,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
// block nominal speed limits both the current and next maximum junction speeds. Hence, in both
|
// block nominal speed limits both the current and next maximum junction speeds. Hence, in both
|
||||||
// the reverse and forward planners, the corresponding block junction speed will always be at the
|
// the reverse and forward planners, the corresponding block junction speed will always be at the
|
||||||
// the maximum junction speed and may always be ignored for any speed reduction checks.
|
// the maximum junction speed and may always be ignored for any speed reduction checks.
|
||||||
if (block->nominal_speed <= v_allowable) { block->nominal_length_flag = true; }
|
if (block->nominal_speed <= v_allowable) {
|
||||||
else { block->nominal_length_flag = false; }
|
block->nominal_length_flag = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
block->nominal_length_flag = false;
|
||||||
|
}
|
||||||
block->recalculate_flag = true; // Always calculate trapezoid for new block
|
block->recalculate_flag = true; // Always calculate trapezoid for new block
|
||||||
|
|
||||||
// Update previous path unit_vector and nominal speed
|
// Update previous path unit_vector and nominal speed
|
||||||
|
@ -742,7 +791,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
previous_nominal_speed = block->nominal_speed;
|
previous_nominal_speed = block->nominal_speed;
|
||||||
|
|
||||||
|
|
||||||
#ifdef ADVANCE
|
#ifdef ADVANCE
|
||||||
// Calculate advance rate
|
// Calculate advance rate
|
||||||
if((block->steps_e == 0) || (block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0)) {
|
if((block->steps_e == 0) || (block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0)) {
|
||||||
block->advance_rate = 0;
|
block->advance_rate = 0;
|
||||||
|
@ -767,10 +816,10 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||||
SERIAL_ECHOPGM("advance rate :");
|
SERIAL_ECHOPGM("advance rate :");
|
||||||
SERIAL_ECHOLN(block->advance_rate/256.0);
|
SERIAL_ECHOLN(block->advance_rate/256.0);
|
||||||
*/
|
*/
|
||||||
#endif // ADVANCE
|
#endif // ADVANCE
|
||||||
|
|
||||||
calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
|
calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
|
||||||
MINIMUM_PLANNER_SPEED/block->nominal_speed);
|
safe_speed/block->nominal_speed);
|
||||||
|
|
||||||
// Move buffer head
|
// Move buffer head
|
||||||
block_buffer_head = next_buffer_head;
|
block_buffer_head = next_buffer_head;
|
||||||
|
@ -810,7 +859,8 @@ uint8_t movesplanned()
|
||||||
|
|
||||||
void allow_cold_extrudes(bool allow)
|
void allow_cold_extrudes(bool allow)
|
||||||
{
|
{
|
||||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||||
allow_cold_extrude=allow;
|
allow_cold_extrude=allow;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,12 +261,10 @@ FORCE_INLINE void trapezoid_generator_reset() {
|
||||||
#endif
|
#endif
|
||||||
deceleration_time = 0;
|
deceleration_time = 0;
|
||||||
// step_rate to timer interval
|
// step_rate to timer interval
|
||||||
|
OCR1A_nominal = calc_timer(current_block->nominal_rate);
|
||||||
acc_step_rate = current_block->initial_rate;
|
acc_step_rate = current_block->initial_rate;
|
||||||
acceleration_time = calc_timer(acc_step_rate);
|
acceleration_time = calc_timer(acc_step_rate);
|
||||||
OCR1A = acceleration_time;
|
OCR1A = acceleration_time;
|
||||||
OCR1A_nominal = calc_timer(current_block->nominal_rate);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SERIAL_ECHO_START;
|
// SERIAL_ECHO_START;
|
||||||
// SERIAL_ECHOPGM("advance :");
|
// SERIAL_ECHOPGM("advance :");
|
||||||
|
|
|
@ -957,7 +957,7 @@ enum {
|
||||||
#if EXTRUDERS > 2
|
#if EXTRUDERS > 2
|
||||||
ItemCT_nozzle2,
|
ItemCT_nozzle2,
|
||||||
#endif
|
#endif
|
||||||
#if defined BED_USES_THERMISTOR || BED_USES_AD595
|
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
|
||||||
ItemCT_bed,
|
ItemCT_bed,
|
||||||
#endif
|
#endif
|
||||||
ItemCT_fan,
|
ItemCT_fan,
|
||||||
|
@ -1212,7 +1212,7 @@ void MainMenu::showControlTemp()
|
||||||
|
|
||||||
}break;
|
}break;
|
||||||
#endif //autotemp
|
#endif //autotemp
|
||||||
#if defined BED_USES_THERMISTOR || BED_USES_AD595
|
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
|
||||||
case ItemCT_bed:
|
case ItemCT_bed:
|
||||||
{
|
{
|
||||||
if(force_lcd_update)
|
if(force_lcd_update)
|
||||||
|
|
Reference in a new issue