Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new planner options #279

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
modified planner modes and added new mode
Paciente8159 committed Oct 5, 2022
commit 5dbd9358d4cd55aff4bccf4bec0ac1b04c333bb0
13 changes: 10 additions & 3 deletions uCNC/cnc_config.h
Original file line number Diff line number Diff line change
@@ -290,16 +290,23 @@ extern "C"
* This will make the planner not perform the forward pass to adjust entry speeds.
* The adjustment of the next planner block is made on the fly when the block is loaded.
* */
// #define ENABLE_PLANNER_SPEED_OVERSHOOT
// #define ENABLE_PLANNER_SPEED_OVERSHOOT

/**
* By enabling this option the planner will junction speed based on accel only if need
* meaning that the junction speed will only be the maximum value between current and exit speed
* This will eliminate ramp up and down completly and over-simplify calculations
* */
// #define ENABLE_PLANNER_ACCEL_NONOPTIMAL

/**
* By enabling this option the planner will only perform acceleration if the exit speed is higher
* then the current speed and the distance travelled is lower then a give threshold
* then the current speed and the distance travelled is lower then a give threshold (in steps)
* This will prevent sucessive ramp up and down speed profiles a produce more continuous speed motions
* */
// #define ENABLE_PLANNER_NOACCEL_ON_SLOWER_EXIT
#ifdef ENABLE_PLANNER_NOACCEL_ON_SLOWER_EXIT
#define ENABLE_PLANNER_NOACCEL_MAX_SETP_DISTANCE 5
#define ENABLE_PLANNER_NOACCEL_MAX_STEP_DISTANCE 200
#endif

/**
6 changes: 5 additions & 1 deletion uCNC/src/core/interpolator.c
Original file line number Diff line number Diff line change
@@ -741,6 +741,9 @@ void itp_run(void)
float accel_dist = ABS(junction_speed_sqr - itp_cur_plan_block->entry_feed_sqr) / itp_cur_plan_block->acceleration;
accel_dist = fast_flt_div2(accel_dist);
accel_until -= floorf(accel_dist);
#ifdef ENABLE_PLANNER_ACCEL_NONOPTIMAL
accel_until = MIN(accel_until, remaining_steps);
#endif
initial_accel_negative = (junction_speed_sqr < itp_cur_plan_block->entry_feed_sqr);
}

@@ -899,11 +902,12 @@ void itp_run(void)
}
#endif
remaining_steps -= segm_steps;

#ifndef ENABLE_PLANNER_ACCEL_NONOPTIMAL
if (remaining_steps == accel_until) // resets float additions error
{
itp_cur_plan_block->entry_feed_sqr = junction_speed_sqr;
}
#endif

itp_cur_plan_block->total_steps = remaining_steps;

18 changes: 17 additions & 1 deletion uCNC/src/core/planner.c
Original file line number Diff line number Diff line change
@@ -426,6 +426,21 @@ float planner_get_block_top_speed(float exit_speed_sqr)

// calculates the difference between the entry speed and the exit speed
uint8_t index = planner_data_read;

#ifdef ENABLE_PLANNER_ACCEL_NONOPTIMAL
// just computes half way accel
float junction_speed_sqr = planner_data[index].acceleration * (float)(planner_data[index].total_steps);
if (planner_data[index].entry_feed_sqr > exit_speed_sqr)
{
junction_speed_sqr += exit_speed_sqr;
}
else
{
junction_speed_sqr += planner_data[index].entry_feed_sqr;
junction_speed_sqr = MAX(junction_speed_sqr, exit_speed_sqr);
}
#else

float speed_delta = exit_speed_sqr - planner_data[index].entry_feed_sqr;

#ifdef ENABLE_PLANNER_NOACCEL_ON_SLOWER_EXIT
@@ -434,7 +449,7 @@ float planner_get_block_top_speed(float exit_speed_sqr)
{
uint8_t i = planner_data[index].main_stepper;
// is short distance?
if (planner_data[index].total_steps < (planner_data[index].steps[i] * g_settings.step_per_mm[i]))
if (ENABLE_PLANNER_NOACCEL_MAX_STEP_DISTANCE > planner_data[index].steps[i])
{
// keep speed (avoid accel on short motion that will have to deaccel after)
return planner_data[index].entry_feed_sqr;
@@ -461,6 +476,7 @@ float planner_get_block_top_speed(float exit_speed_sqr)
// will overshoot the desired exit speed even deaccelerating all the way
junction_speed_sqr = planner_data[index].entry_feed_sqr;
}
#endif

float rapid_feed_sqr = planner_data[index].rapid_feed_sqr;
float target_speed_sqr = planner_data[index].feed_sqr;