Added slowdown

master
Erik van der Zalm 13 years ago
parent 331e82dcd3
commit 95126c09c0

@ -18,6 +18,9 @@
// if unwanted behavior is observed on a user's machine when running at very slow speeds. // if unwanted behavior is observed on a user's machine when running at very slow speeds.
#define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec) #define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec)
// If defined the movements slow down when the look ahead buffer is only half full
#define SLOWDOWN
// BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration // BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration
//// The following define selects which electronics board you have. Please choose the one that matches your setup //// The following define selects which electronics board you have. Please choose the one that matches your setup
@ -210,7 +213,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
#define DEFAULT_MINTRAVELFEEDRATE 0 #define DEFAULT_MINTRAVELFEEDRATE 0
// minimum time in microseconds that a movement needs to take if the buffer is emptied. Increase this number if you see blobs while printing high speed & high detail. It will slowdown on the detailed stuff. // minimum time in microseconds that a movement needs to take if the buffer is emptied. Increase this number if you see blobs while printing high speed & high detail. It will slowdown on the detailed stuff.
#define DEFAULT_MINSEGMENTTIME 20000 #define DEFAULT_MINSEGMENTTIME 20000 // Obsolete delete this
#define DEFAULT_XYJERK 30.0 // (mm/sec) #define DEFAULT_XYJERK 30.0 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec) #define DEFAULT_ZJERK 0.4 // (mm/sec)
@ -269,7 +272,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
#define ULTIPANEL #define ULTIPANEL
#ifdef ULTIPANEL #ifdef ULTIPANEL
#define NEWPANEL //enable this if you have a click-encoder panel // #define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT #define SDSUPPORT
#define ULTRA_LCD #define ULTRA_LCD
#define LCD_WIDTH 20 #define LCD_WIDTH 20

@ -499,8 +499,10 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0 block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
// unsigned long microseconds; // segment time im micro seconds
#if 0 long segment_time = lround(1000000.0/inverse_second);
if (block->steps_e == 0) { if (block->steps_e == 0) {
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate; if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
} }
@ -508,22 +510,26 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate; if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
} }
microseconds = lround((block->millimeters/feed_rate)*1000000); #ifdef SLOWDOWN
// 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
// reduces/removes corner blobs as the machine won't come to a full stop. int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
int blockcount=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5)) feed_rate = feed_rate / ((BLOCK_BUFFER_SIZE * 0.5)/moves_queued);
#endif
/*
if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) { if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
if (microseconds<minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more. if (segment_time<minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
microseconds=microseconds+lround(2*(minsegmenttime-microseconds)/blockcount); segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
} }
} }
else { else {
if (microseconds<minsegmenttime) microseconds=minsegmenttime; if (segment_time<minsegmenttime) segment_time=minsegmenttime;
} }
// END OF SLOW DOWN SECTION // END OF SLOW DOWN SECTION
#endif */
// Calculate speed in mm/sec for each axis // Calculate speed in mm/sec for each axis
float current_speed[4]; float current_speed[4];
@ -546,7 +552,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// Check and limit the xy direction change frequency // Check and limit the xy direction change frequency
unsigned char direction_change = block->direction_bits ^ old_direction_bits; unsigned char direction_change = block->direction_bits ^ old_direction_bits;
old_direction_bits = block->direction_bits; old_direction_bits = block->direction_bits;
long segment_time = lround(1000000.0/inverse_second);
if((direction_change & (1<<X_AXIS)) == 0) { if((direction_change & (1<<X_AXIS)) == 0) {
x_segment_time[0] += segment_time; x_segment_time[0] += segment_time;
} }

Loading…
Cancel
Save