Skip to content

Commit 965e337

Browse files
committed
Parking motion bug fix.
- Parking motion would intermittently complete the queued tool path upon resuming in certain scenarios. Now fixed.
1 parent 9575199 commit 965e337

5 files changed

Lines changed: 86 additions & 73 deletions

File tree

doc/log/commit_log_v0.9i.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
----------------
2+
Date: 2015-08-29
3+
Author: Sonny Jeon
4+
Subject: Optional line number reporting bug fix.
5+
6+
- Fixed a bug where it would not compile when USE_LINE_NUMBERS was
7+
enabled.
8+
9+
110
----------------
211
Date: 2015-08-27
312
Author: Sonny Jeon

grbl/gcode.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,37 +1034,37 @@ uint8_t gc_execute_line(char *line)
10341034
// refill and can only be resumed by the cycle start run-time command.
10351035
gc_state.modal.program_flow = gc_block.modal.program_flow;
10361036
if (gc_state.modal.program_flow) {
1037-
protocol_buffer_synchronize(); // Sync and finish all remaining buffered motions before moving on.
1038-
if (gc_state.modal.program_flow == PROGRAM_FLOW_PAUSED) {
1039-
if (sys.state != STATE_CHECK_MODE) {
1040-
bit_true_atomic(sys.rt_exec_state, EXEC_FEED_HOLD); // Use feed hold for program pause.
1041-
protocol_execute_realtime(); // Execute suspend.
1042-
}
1043-
} else { // == PROGRAM_FLOW_COMPLETED
1044-
// Upon program complete, only a subset of g-codes reset to certain defaults, according to
1045-
// LinuxCNC's program end descriptions and testing. Only modal groups [G-code 1,2,3,5,7,12]
1046-
// and [M-code 7,8,9] reset to [G1,G17,G90,G94,G40,G54,M5,M9,M48]. The remaining modal groups
1047-
// [G-code 4,6,8,10,13,14,15] and [M-code 4,5,6] and the modal words [F,S,T,H] do not reset.
1048-
gc_state.modal.motion = MOTION_MODE_LINEAR;
1049-
gc_state.modal.plane_select = PLANE_SELECT_XY;
1050-
gc_state.modal.distance = DISTANCE_MODE_ABSOLUTE;
1051-
gc_state.modal.feed_rate = FEED_RATE_MODE_UNITS_PER_MIN;
1052-
// gc_state.modal.cutter_comp = CUTTER_COMP_DISABLE; // Not supported.
1053-
gc_state.modal.coord_select = 0; // G54
1054-
gc_state.modal.spindle = SPINDLE_DISABLE;
1055-
gc_state.modal.coolant = COOLANT_DISABLE;
1056-
// gc_state.modal.override = OVERRIDE_DISABLE; // Not supported.
1057-
1058-
// Execute coordinate change and spindle/coolant stop.
1059-
if (sys.state != STATE_CHECK_MODE) {
1060-
if (!(settings_read_coord_data(gc_state.modal.coord_select,coordinate_data))) { FAIL(STATUS_SETTING_READ_FAIL); }
1061-
memcpy(gc_state.coord_system,coordinate_data,sizeof(coordinate_data));
1062-
spindle_stop();
1063-
coolant_stop();
1064-
}
1065-
1066-
report_feedback_message(MESSAGE_PROGRAM_END);
1067-
}
1037+
protocol_buffer_synchronize(); // Sync and finish all remaining buffered motions before moving on.
1038+
if (gc_state.modal.program_flow == PROGRAM_FLOW_PAUSED) {
1039+
if (sys.state != STATE_CHECK_MODE) {
1040+
bit_true_atomic(sys.rt_exec_state, EXEC_FEED_HOLD); // Use feed hold for program pause.
1041+
protocol_execute_realtime(); // Execute suspend.
1042+
}
1043+
} else { // == PROGRAM_FLOW_COMPLETED
1044+
// Upon program complete, only a subset of g-codes reset to certain defaults, according to
1045+
// LinuxCNC's program end descriptions and testing. Only modal groups [G-code 1,2,3,5,7,12]
1046+
// and [M-code 7,8,9] reset to [G1,G17,G90,G94,G40,G54,M5,M9,M48]. The remaining modal groups
1047+
// [G-code 4,6,8,10,13,14,15] and [M-code 4,5,6] and the modal words [F,S,T,H] do not reset.
1048+
gc_state.modal.motion = MOTION_MODE_LINEAR;
1049+
gc_state.modal.plane_select = PLANE_SELECT_XY;
1050+
gc_state.modal.distance = DISTANCE_MODE_ABSOLUTE;
1051+
gc_state.modal.feed_rate = FEED_RATE_MODE_UNITS_PER_MIN;
1052+
// gc_state.modal.cutter_comp = CUTTER_COMP_DISABLE; // Not supported.
1053+
gc_state.modal.coord_select = 0; // G54
1054+
gc_state.modal.spindle = SPINDLE_DISABLE;
1055+
gc_state.modal.coolant = COOLANT_DISABLE;
1056+
// gc_state.modal.override = OVERRIDE_DISABLE; // Not supported.
1057+
1058+
// Execute coordinate change and spindle/coolant stop.
1059+
if (sys.state != STATE_CHECK_MODE) {
1060+
if (!(settings_read_coord_data(gc_state.modal.coord_select,coordinate_data))) { FAIL(STATUS_SETTING_READ_FAIL); }
1061+
memcpy(gc_state.coord_system,coordinate_data,sizeof(coordinate_data));
1062+
spindle_stop();
1063+
coolant_stop();
1064+
}
1065+
1066+
report_feedback_message(MESSAGE_PROGRAM_END);
1067+
}
10681068
gc_state.modal.program_flow = PROGRAM_FLOW_RUNNING; // Reset program flow.
10691069
}
10701070

grbl/grbl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
// Grbl versioning system
2525
#define GRBL_VERSION "1.0b"
26-
#define GRBL_VERSION_BUILD "20150829"
26+
#define GRBL_VERSION_BUILD "20150902"
2727

2828
// Define standard libraries used by Grbl.
2929
#include <avr/io.h>

grbl/limits.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ uint8_t limits_get_state()
7272
uint8_t pin = (LIMIT_PIN & LIMIT_MASK);
7373
if (bit_isfalse(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { pin ^= LIMIT_MASK; }
7474
if (pin) {
75-
uint8_t idx;
76-
for (idx=0; idx<N_AXIS; idx++) {
77-
if (pin & get_limit_pin_mask(idx)) { limit_state |= (1 << idx); }
78-
}
75+
uint8_t idx;
76+
for (idx=0; idx<N_AXIS; idx++) {
77+
if (pin & get_limit_pin_mask(idx)) { limit_state |= (1 << idx); }
78+
}
7979
}
8080
return(limit_state);
8181
}
@@ -210,37 +210,37 @@ void limits_go_home(uint8_t cycle_mask)
210210

211211
st_prep_buffer(); // Prep and fill segment buffer from newly planned block.
212212
st_wake_up(); // Initiate motion
213-
do {
214-
if (approach) {
215-
// Check limit state. Lock out cycle axes when they change.
216-
limit_state = limits_get_state();
217-
for (idx=0; idx<N_AXIS; idx++) {
218-
if (axislock & step_pin[idx]) {
219-
if (limit_state & (1 << idx)) { axislock &= ~(step_pin[idx]); }
220-
}
221-
}
222-
sys.homing_axis_lock = axislock;
223-
}
224-
225-
st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us.
226-
227-
// Exit routines: No time to run protocol_execute_realtime() in this loop.
228-
if (sys.rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET | EXEC_CYCLE_STOP)) {
229-
// Homing failure: Limit switches are still engaged after pull-off motion
230-
if ( (sys.rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET)) || // Safety door or reset issued
231-
(!approach && (limits_get_state() & cycle_mask)) || // Limit switch still engaged after pull-off motion
232-
( approach && (sys.rt_exec_state & EXEC_CYCLE_STOP)) ) { // Limit switch not found during approach.
233-
mc_reset(); // Stop motors, if they are running.
234-
protocol_execute_realtime();
235-
return;
236-
} else {
237-
// Pull-off motion complete. Disable CYCLE_STOP from executing.
213+
do {
214+
if (approach) {
215+
// Check limit state. Lock out cycle axes when they change.
216+
limit_state = limits_get_state();
217+
for (idx=0; idx<N_AXIS; idx++) {
218+
if (axislock & step_pin[idx]) {
219+
if (limit_state & (1 << idx)) { axislock &= ~(step_pin[idx]); }
220+
}
221+
}
222+
sys.homing_axis_lock = axislock;
223+
}
224+
225+
st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us.
226+
227+
// Exit routines: No time to run protocol_execute_realtime() in this loop.
228+
if (sys.rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET | EXEC_CYCLE_STOP)) {
229+
// Homing failure: Limit switches are still engaged after pull-off motion
230+
if ( (sys.rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET)) || // Safety door or reset issued
231+
(!approach && (limits_get_state() & cycle_mask)) || // Limit switch still engaged after pull-off motion
232+
( approach && (sys.rt_exec_state & EXEC_CYCLE_STOP)) ) { // Limit switch not found during approach.
233+
mc_reset(); // Stop motors, if they are running.
234+
protocol_execute_realtime();
235+
return;
236+
} else {
237+
// Pull-off motion complete. Disable CYCLE_STOP from executing.
238238
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
239-
break;
240-
}
241-
}
239+
break;
240+
}
241+
}
242242

243-
} while (STEP_MASK & axislock);
243+
} while (STEP_MASK & axislock);
244244

245245
st_reset(); // Immediately force kill steppers and reset step segment buffer.
246246
plan_reset(); // Reset planner buffer to zero planner current position and to clear previous motions.

grbl/stepper.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ typedef struct {
135135
uint8_t last_st_block_index;
136136
float last_steps_remaining;
137137
float last_step_per_mm;
138-
float last_req_mm_increment;
139138
float last_dt_remainder;
140139
#endif
141140

@@ -551,12 +550,13 @@ static uint8_t st_next_block_index(uint8_t block_index)
551550
{
552551
// Restore step execution data and flags of partially completed block, if necessary.
553552
if (prep.recalculate_flag & PREP_FLAG_HOLD_PARTIAL_BLOCK) {
553+
st_prep_block = &st_block_buffer[prep.last_st_block_index];
554554
prep.st_block_index = prep.last_st_block_index;
555555
prep.steps_remaining = prep.last_steps_remaining;
556556
prep.dt_remainder = prep.last_dt_remainder;
557557
prep.step_per_mm = prep.last_step_per_mm;
558-
st_prep_block = &st_block_buffer[prep.st_block_index];
559558
prep.recalculate_flag = (PREP_FLAG_HOLD_PARTIAL_BLOCK | PREP_FLAG_RECALCULATE);
559+
prep.req_mm_increment = REQ_MM_INCREMENT_SCALAR/prep.step_per_mm; // Recompute this value.
560560
} else {
561561
prep.recalculate_flag = false;
562562
}
@@ -594,12 +594,15 @@ void st_prep_buffer()
594594
if (sys.step_control & STEP_CONTROL_EXECUTE_PARK) { pl_block = plan_get_parking_block(); }
595595
else { pl_block = plan_get_current_block(); }
596596
if (pl_block == NULL) { return; } // No planner blocks. Exit.
597-
597+
598598
// Check if we need to only recompute the velocity profile or load a new block.
599599
if (prep.recalculate_flag & PREP_FLAG_RECALCULATE) {
600+
600601
if (prep.recalculate_flag & PREP_FLAG_PARKING) { prep.recalculate_flag &= ~(PREP_FLAG_RECALCULATE); }
601602
else { prep.recalculate_flag = false; }
602-
603+
604+
} else {
605+
603606
#else
604607

605608
// Query planner for a queued block
@@ -608,11 +611,12 @@ void st_prep_buffer()
608611

609612
// Check if we need to only recompute the velocity profile or load a new block.
610613
if (prep.recalculate_flag & PREP_FLAG_RECALCULATE) {
614+
611615
prep.recalculate_flag = false;
616+
617+
} else {
612618

613619
#endif
614-
615-
} else {
616620

617621
// Load the Bresenham stepping data for the block.
618622
prep.st_block_index = st_next_block_index(prep.st_block_index);
@@ -639,7 +643,7 @@ void st_prep_buffer()
639643
prep.step_per_mm = prep.steps_remaining/pl_block->millimeters;
640644
prep.req_mm_increment = REQ_MM_INCREMENT_SCALAR/prep.step_per_mm;
641645
prep.dt_remainder = 0.0; // Reset for new segment block
642-
646+
643647
if (sys.step_control & STEP_CONTROL_EXECUTE_HOLD) {
644648
// New block loaded mid-hold. Override planner block entry speed to enforce deceleration.
645649
prep.current_speed = prep.exit_speed;
@@ -648,7 +652,7 @@ void st_prep_buffer()
648652
prep.current_speed = sqrt(pl_block->entry_speed_sqr);
649653
}
650654
}
651-
655+
652656
/* ---------------------------------------------------------------------------------
653657
Compute the velocity profile of a new planner block based on its entry and exit
654658
speeds, or recompute the profile of a partially-completed planner block if the

0 commit comments

Comments
 (0)