acceleration_ticks_per_second 1000 # Number of times per second the speed is updated
junction_deviation 0.05 # Similar to the old "max_jerk", in millimeters, see : https://github.com/grbl/grbl/blob/master/planner.c#L409
# and https://github.com/grbl/grbl/wiki/Configuring-Grbl-v0.8 . Lower values mean being more careful, higher values means being faster and have more jerk
+#minimum_planner_speed 0.0 # sets the minimum planner speed in mm/sec
# Stepper module configuration
microseconds_per_step_pulse 1 # Duration of step pulses to stepper drivers, in microseconds
void Block::debug()
{
- THEKERNEL->streams->printf("%p: steps:%4d|%4d|%4d(max:%4d) nominal:r%10d/s%6.1f mm:%9.6f rdelta:%8f acc:%5d dec:%5d rates:%10d>%10d entry: %10.4f taken:%d ready:%d \r\n", this, this->steps[0], this->steps[1], this->steps[2], this->steps_event_count, this->nominal_rate, this->nominal_speed, this->millimeters, this->rate_delta, this->accelerate_until, this->decelerate_after, this->initial_rate, this->final_rate, this->entry_speed, this->times_taken, this->is_ready );
+ THEKERNEL->streams->printf("%p: steps:%4d|%4d|%4d(max:%4d) nominal:r%10d/s%6.1f mm:%9.6f rdelta:%8f acc:%5d dec:%5d rates:%10d>%10d entry/max: %10.4f/%10.4f taken:%d ready:%d \r\n", this, this->steps[0], this->steps[1], this->steps[2], this->steps_event_count, this->nominal_rate, this->nominal_speed, this->millimeters, this->rate_delta, this->accelerate_until, this->decelerate_after, this->initial_rate, this->final_rate, this->entry_speed, this->max_entry_speed, this->times_taken, this->is_ready );
}
// Delete blocks here, because they can't be deleted in interrupt context ( see Block.cpp:release )
void Conveyor::on_idle(void* argument){
- if (flush_blocks){
+ while (flush_blocks > 0){
// Cleanly delete block
Block* block = queue.get_tail_ref();
block->gcodes.clear();
#include "Planner.h"
#include "Conveyor.h"
+#define acceleration_checksum CHECKSUM("acceleration")
+#define max_jerk_checksum CHECKSUM("max_jerk")
+#define junction_deviation_checksum CHECKSUM("junction_deviation")
+#define minimum_planner_speed_checksum CHECKSUM("minimum_planner_speed")
+
// The Planner does the acceleration math for the queue of Blocks ( movements ).
// It makes sure the speed stays within the configured constraints ( acceleration, junction_deviation, etc )
// It goes over the list in both direction, every time a block is added, re-doing the math to make sure everything is optimal
void Planner::on_config_reload(void* argument){
this->acceleration = THEKERNEL->config->value(acceleration_checksum )->by_default(100 )->as_number() * 60 * 60; // Acceleration is in mm/minute^2, see https://github.com/grbl/grbl/commit/9141ad282540eaa50a41283685f901f29c24ddbd#planner.c
this->junction_deviation = THEKERNEL->config->value(junction_deviation_checksum )->by_default(0.05f)->as_number();
+ this->minimum_planner_speed = THEKERNEL->config->value(minimum_planner_speed_checksum )->by_default(0.0f)->as_number();
}
// path width or max_jerk in the previous grbl version. This approach does not actually deviate
// from path, but used as a robust way to compute cornering speeds, as it takes into account the
// nonlinearities of both the junction angle and junction velocity.
- float vmax_junction = MINIMUM_PLANNER_SPEED; // Set default max junction speed
+ float vmax_junction = minimum_planner_speed; // Set default max junction speed
if (THEKERNEL->conveyor->queue.size() > 1 && (this->previous_nominal_speed > 0.0F)) {
// Compute cosine of angle between previous and current path. (prev_unit_vec is negative)
}
block->max_entry_speed = vmax_junction;
- // Initialize block entry speed. Compute based on deceleration to user-defined MINIMUM_PLANNER_SPEED.
- float v_allowable = this->max_allowable_speed(-this->acceleration,0.0F,block->millimeters); //TODO: Get from config
+ // Initialize block entry speed. Compute based on deceleration to user-defined minimum_planner_speed.
+ float v_allowable = this->max_allowable_speed(-this->acceleration,minimum_planner_speed,block->millimeters); //TODO: Get from config
block->entry_speed = min(vmax_junction, v_allowable);
// Initialize planner efficiency flags
// The block can now be used
block->ready();
-
}
current = &queue->buffer[block_index];
}
- // Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
- current->calculate_trapezoid( current->entry_speed/current->nominal_speed, MINIMUM_PLANNER_SPEED/current->nominal_speed );
+ // Last/newest block in buffer. Exit speed is set with minimum_planner_speed. Always recalculated.
+ current->calculate_trapezoid( current->entry_speed/current->nominal_speed, minimum_planner_speed/current->nominal_speed );
current->recalculate_flag = false;
}
// Debug function
void Planner::dump_queue(){
for( int index = 0; index <= THEKERNEL->conveyor->queue.size()-1; index++ ){
- if( index > 10 && index < THEKERNEL->conveyor->queue.size()-10 ){ continue; }
+ //if( index > 10 && index < THEKERNEL->conveyor->queue.size()-10 ){ continue; }
THEKERNEL->streams->printf("block %03d > ", index);
THEKERNEL->conveyor->queue.get_ref(index)->debug();
}
#include "../communication/utils/Gcode.h"
#include "Block.h"
-#define acceleration_checksum CHECKSUM("acceleration")
-#define max_jerk_checksum CHECKSUM("max_jerk")
-#define junction_deviation_checksum CHECKSUM("junction_deviation")
-
-// TODO: Get from config
-#define MINIMUM_PLANNER_SPEED 0.0F
using namespace std;
-
class Planner : public Module {
public:
Planner();
float acceleration; // Setting
float junction_deviation; // Setting
-
+ float minimum_planner_speed; // Setting
};
}
break;
- case 205: // M205 Xnnn - set junction deviation
+ case 205: // M205 Xnnn - set junction deviation Snnn - Set minimum planner speed
gcode->mark_as_taken();
if (gcode->has_letter('X'))
{
float jd= gcode->get_value('X');
// enforce minimum
- if (jd < 0.0)
- jd = 0.0;
+ if (jd < 0.0F)
+ jd = 0.0F;
THEKERNEL->planner->junction_deviation= jd;
}
+ if (gcode->has_letter('S'))
+ {
+ float mps= gcode->get_value('S');
+ // enforce minimum
+ if (mps < 0.0F)
+ mps = 0.0F;
+ THEKERNEL->planner->minimum_planner_speed= mps;
+ }
break;
case 220: // M220 - speed override percentage
this->arm_solution->get_steps_per_millimeter(steps);
gcode->stream->printf(";Steps per unit:\nM92 X%1.5f Y%1.5f Z%1.5f\n", steps[0], steps[1], steps[2]);
gcode->stream->printf(";Acceleration mm/sec^2:\nM204 S%1.5f\n", THEKERNEL->planner->acceleration/3600);
- gcode->stream->printf(";Junction Deviation:\nM205 X%1.5f\n", THEKERNEL->planner->junction_deviation);
+ gcode->stream->printf(";X- Junction Deviation, S - Minimum Planner speed:\nM205 X%1.5f S%1.5f\n", THEKERNEL->planner->junction_deviation, THEKERNEL->planner->minimum_planner_speed);
gcode->mark_as_taken();
break;