Homing and feed hold bug fixes.

WARNING: Bugs may still exist. This branch is a work in progress and
will be pushed to the edge branch when at beta stability. Use at your
own risk.

- Homing freezing issue fixed. Had to do with the cycle stop flag being
set incorrectly after the homing cycles and before the pull-off
maneuver. Now resets the stepper motors before this can happen.

- Fixed an issue with a rare feed hold failure. Had to do with feed
hold ending exactly at the end of a block. The runtime protocol now
sets the QUEUED and IDLE states appropriately when this occurs. Still
need to clean this code up however, as it’s patched rather than written
well.

- Updated version build via $I command.

- Forgot to comment on a new feature for the last commit. Since steps
are integers and millimeters traveled are floats, the old step segment
generator ignored the step fraction differences in generating the
segment velocities. Didn’t see like it would be much of a big deal, but
there were instances that this would be a problem, especially for very
slow feed rates. The stepper algorithm now micro-adjusts the segment
velocities based on the step fractions not executed from the previous
segment. This ensures that Grbl generates the velocity profiles EXACTLY
and noticeably improves overall acceleration performance.
This commit is contained in:
Sonny Jeon
2014-02-15 13:13:46 -07:00
parent 50fbc6e297
commit 3df61e0ec5
5 changed files with 33 additions and 34 deletions

View File

@ -620,24 +620,6 @@ void st_prep_buffer()
// Set new segment to point to the current segment data block.
prep_segment->st_block_index = prep.st_block_index;
float mm_remaining = pl_block->millimeters;
float minimum_mm = pl_block->millimeters-prep.req_mm_increment;
if (minimum_mm < 0.0) { minimum_mm = 0.0; }
if (sys.state == STATE_HOLD) {
if (minimum_mm < prep.mm_complete) { // NOTE: Exit condition
// Less than one step to decelerate to zero speed, but already very close. AMASS
// requires full steps to execute. So, just bail.
prep.current_speed = 0.0;
prep.dt_remainder = 0.0;
prep.steps_remaining = ceil(pl_block->millimeters * prep.step_per_mm);
pl_block->millimeters = prep.steps_remaining/prep.step_per_mm; // Update with full steps.
plan_cycle_reinitialize();
sys.state = STATE_QUEUED;
return; // Segment not generated, but current step data still retained.
}
}
/*------------------------------------------------------------------------------------
Compute the average velocity of this new segment by determining the total distance
traveled over the segment time DT_SEGMENT. The following code first attempts to create
@ -656,7 +638,11 @@ void st_prep_buffer()
float dt = 0.0; // Initialize segment time
float time_var = dt_max; // Time worker variable
float mm_var; // mm-Distance worker variable
float speed_var; // Speed worker variable
float speed_var; // Speed worker variable
float mm_remaining = pl_block->millimeters;
float minimum_mm = pl_block->millimeters-prep.req_mm_increment;
if (minimum_mm < 0.0) { minimum_mm = 0.0; }
do {
switch (prep.ramp_type) {
case RAMP_ACCEL:
@ -728,6 +714,21 @@ void st_prep_buffer()
float n_steps_remaining = ceil(steps_remaining); // Round-up current steps remaining
float last_n_steps_remaining = ceil(prep.steps_remaining); // Round-up last steps remaining
prep_segment->n_step = last_n_steps_remaining-n_steps_remaining; // Compute number of steps to execute.
// Bail if we are at the end of a feed hold and don't have a step to execute.
if (sys.state == STATE_HOLD) {
if (prep_segment->n_step == 0) {
// Less than one step to decelerate to zero speed, but already very close. AMASS
// requires full steps to execute. So, just bail.
prep.current_speed = 0.0;
prep.dt_remainder = 0.0;
prep.steps_remaining = n_steps_remaining;
pl_block->millimeters = prep.steps_remaining/prep.step_per_mm; // Update with full steps.
plan_cycle_reinitialize();
sys.state = STATE_QUEUED;
return; // Segment not generated, but current step data still retained.
}
}
// Compute segment step rate. Since steps are integers and mm distances traveled are not,
// the end of every segment can have a partial step of varying magnitudes that are not